arch/powerpc/kernel/vdso32/gettimeofday.S:40: Error: syntax error; found `@', expected `,'
Quoted 10 lines · Segher Boessenkool
Hi!
Quoted 6 lines · Fāng-ruì Sòng
Quoted 4 lines · Segher Boessenkool
This is the 32-bit @local relocation; its history predates binutils CVS (so older than 1999). It is the same as @local24pc (which is documented in even the oldest ABI documents). It *uses* the GOT (or PLT).
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
If you do have @local24pc, just add an alias @local for it?
R_PPC_LOCAL24PCis a legacy thing.I have no idea what you call "legacy". It is very much an active feature.
R_PPC_LOCAL24PC and R_PPC_PLTREL24 are not inherited by ppc64. That is a pretty good sign that they are "legacy" :)
Quoted 5 lines
Quoted 2 lines
GCC appears to emit it when
referencing hidden/internal/local symbols.GCC uses it for PIC (and other things).
Quoted 7 lines
Quoted 3 lines
It was invented probably
because a couple of decades ago people think having relocation types to encode symbol properties was a good idea.It *had* to be invented. The ABIs clearly say what it does, and no other mechanism provide for that. It has nothing to do with symbol properties.
They may have overloaded edge-case semantics in binutils but their general purpose use cases aren't any different from _REL24.
Quoted 21 lines
Quoted 5 lines
This is not useful
because symbol information can change when merging information from other translation units (a default visibility can become hidden). Such properties are really the symbols', and not the relocation types'. ppc64 has unified R_PPC_LOCAL24PC/R_PPC_REL24/R_PPC_PLTREL24.It is not clear to me what you are saying here.
Quoted 3 lines
When I implemented
R_PPC_LOCAL24PCfor LLD
(https://reviews.llvm.org/D62464 ) I simply treated it as an alias forR_PPC_REL24.But it very obviously is *not*. It might not matter for the one use case you wanted to support, of course.
In any case, you should implement @local as well? That is used as an alias to @local24pc for over twenty years now.
Quoted 3 lines
It is clear that LLVM integrated assembler needs to support @local24pc .... There isn't even a test case in binutils-gdb.
Quoted 8 lines
Quoted 2 lines
If there is a @local24pc use case, just change it to @local. The suffix can probably be deleted as well.
If you want to claim to support the older ABIs, you need to implement support for them.
Segher
clang ppc32 supports @local and LLD supports R_PPC_LOCAL24PC, which are sufficient. Even GNU as does not have a test for @local24pc and I cannot find usage in the wild, so clang probably does not need to support @local24pc.
Quoted 67 lines · Fāng-ruì Sòng
Quoted 10 lines · Segher Boessenkool
Hi!
Quoted 6 lines · Fāng-ruì Sòng
Quoted 4 lines · Segher Boessenkool
This is the 32-bit @local relocation; its history predates binutils CVS (so older than 1999). It is the same as @local24pc (which is documented in even the oldest ABI documents). It *uses* the GOT (or PLT).
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
If you do have @local24pc, just add an alias @local for it?
R_PPC_LOCAL24PCis a legacy thing.I have no idea what you call "legacy". It is very much an active feature.
R_PPC_LOCAL24PCandR_PPC_PLTREL24are not inherited by ppc64. That is a pretty good sign that they are "legacy" :)Quoted 5 lines
Quoted 2 lines
GCC appears to emit it when
referencing hidden/internal/local symbols.GCC uses it for PIC (and other things).
Quoted 7 lines
Quoted 3 lines
It was invented probably
because a couple of decades ago people think having relocation types to encode symbol properties was a good idea.It *had* to be invented. The ABIs clearly say what it does, and no other mechanism provide for that. It has nothing to do with symbol properties.
They may have overloaded edge-case semantics in binutils but their general purpose use cases aren't any different from
_REL24.Quoted 28 lines
Quoted 5 lines
This is not useful
because symbol information can change when merging information from other translation units (a default visibility can become hidden). Such properties are really the symbols', and not the relocation types'. ppc64 has unified R_PPC_LOCAL24PC/R_PPC_REL24/R_PPC_PLTREL24.It is not clear to me what you are saying here.
Quoted 3 lines
When I implemented
R_PPC_LOCAL24PCfor LLD
(https://reviews.llvm.org/D62464 ) I simply treated it as an alias forR_PPC_REL24.But it very obviously is *not*. It might not matter for the one use case you wanted to support, of course.
In any case, you should implement @local as well? That is used as an alias to @local24pc for over twenty years now.
Quoted 5 lines
It is clear that LLVM integrated assembler needs to support @local24pc .... There isn't even a test case in binutils-gdb.
If there is a @local24pc use case, just change it to @local. The suffix can probably be deleted as well.
If you want to claim to support the older ABIs, you need to implement support for them.
Quoted 6 lines
Quoted 1 line
Segher
clang ppc32 supports @local and LLD supports
R_PPC_LOCAL24PC, which are sufficient. Even GNU as does not have a test for @local24pc and I cannot find usage in the wild, so clang probably does not need to support @local24pc.
I just fetched the config and can reproduce via:
$ ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make CC=clang -j71 arch/powerpc/kernel/vdso32/gettimeofday.o
Adding V=1 to the above, I see:
clang -Wp,-MMD,arch/powerpc/kernel/vdso32/.gettimeofday.o.d -nostdinc -isystem /android0/llvm-project/llvm/build/lib/clang/12.0.0/include -I./arch/powerpc/include -I./arch/powerpc/include/generated -I./include -I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -I ./arch/powerpc -DHAVE_AS_ATHIGH=1 -Qunused-arguments -D__ASSEMBLY__ -fno-PIE --target=powerpc64le-linux-gnu --prefix=/usr/bin/powerpc64le-linux-gnu- --gcc-toolchain=/usr -no-integrated-as -Werror=unknown-warning-option -m64 -Wl,-a64 -Wa,-maltivec -Wa,-mpower4 -Wa,-many -mlittle-endian -Wa,-gdwarf-2
-D__VDSO32__ -s -m32 -c -oarch/powerpc/kernel/vdso32/gettimeofday.o arch/powerpc/kernel/vdso32/gettimeofday.S
(so I was wrong about -no-integrated-as)
I wonder if we need to be setting --target=powerpc-linux-gnu instead? Maybe the -m32 isn't being forwarded to the assembler? Or is there an assembler directive we can use to tell the assembler that this should be assembled in 32b mode? (looks like no:
https://sourceware.org/binutils/docs/as/PowerPC_002dPseudo.html#PowerPC_002dPseudo)
``` foo: bl bar(a)local bar: ```
assembles with powerpc-linux-gnu-as but fails with the error message we observe for powerpc64le-linux-gnu-as. (I'm pretty sure we had similar issues with the compat vdso on arm64).
ah, -a32 will put the assembler in 32b mode. I'm guessing gcc maybe adds this implicitly for -m32?
```
diff --git a/arch/powerpc/kernel/vdso32/Makefile
b/arch/powerpc/kernel/vdso32/Makefile
index 73eada6bc8cd..c29d948f45e3 100644
--- a/arch/powerpc/kernel/vdso32/Makefile
+++ b/arch/powerpc/kernel/vdso32/Makefile
@@ -26,7 +26,7 @@ UBSAN_SANITIZE := n
ccflags-y := -shared -fno-common -fno-builtin -nostdlib \
-Wl,-soname=linux-vdso32.so.1 -Wl,--hash-style=both
-asflags-y := -D__VDSO32__ -s
+asflags-y := -D__VDSO32__ -s -Wa,-a32
obj-y += vdso32_wrapper.o
targets += vdso32.lds
```
gets us a little further, but then I observe additional failures:
```
VDSO32A arch/powerpc/kernel/vdso32/gettimeofday.o
arch/powerpc/kernel/vdso32/gettimeofday.S: Assembler messages:
arch/powerpc/kernel/vdso32/gettimeofday.S:39: Error: operand out of
range (0x00000000000f4240 is not between 0xffffffffffff8000 and
0x000000000000ffff)
arch/powerpc/kernel/vdso32/gettimeofday.S:39: Error: syntax error;
found `@', expected `,'
arch/powerpc/kernel/vdso32/gettimeofday.S:39: Error: junk at end of
line: `@high'
arch/powerpc/kernel/vdso32/gettimeofday.S:83: Error: operand out of
range (0x000000003b9aca00 is not between 0xffffffffffff8000 and
0x000000000000ffff)
arch/powerpc/kernel/vdso32/gettimeofday.S:83: Error: syntax error;
found `@', expected `,'
arch/powerpc/kernel/vdso32/gettimeofday.S:83: Error: junk at end of
line: `@high'
arch/powerpc/kernel/vdso32/gettimeofday.S:203: Error: operand out of
range (0x00000000003d0900 is not between 0xffffffffffff8000 and
0x000000000000ffff)
arch/powerpc/kernel/vdso32/gettimeofday.S:203: Error: syntax error;
found `@', expected `,'
arch/powerpc/kernel/vdso32/gettimeofday.S:203: Error: junk at end of
line: `@high'
clang-12: error: assembler command failed with exit code 1 (use -v to
see invocation)
make[3]: *** [arch/powerpc/kernel/vdso32/Makefile:49:
arch/powerpc/kernel/vdso32/gettimeofday.o] Error 1
```That's preprocessed in, but looks like support for @high is missing from clang as well.
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 83 lines · Nick Desaulniers
I just fetched the config and can reproduce via:
$ ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make CC=clang -j71 arch/powerpc/kernel/vdso32/gettimeofday.oAdding
V=1to the above, I see:clang -Wp,-MMD,arch/powerpc/kernel/vdso32/.gettimeofday.o.d -nostdinc
(quoted diff) +0
-11-isystem /android0/llvm-project/llvm/build/lib/clang/12.0.0/include -I./arch/powerpc/include -I./arch/powerpc/include/generated -I./include -I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -I ./arch/powerpc -DHAVE_AS_ATHIGH=1 -Qunused-arguments -D__ASSEMBLY__ -fno-PIE --target=powerpc64le-linux-gnu --prefix=/usr/bin/powerpc64le-linux-gnu- --gcc-toolchain=/usr -no-integrated-as -Werror=unknown-warning-option -m64 -Wl,-a64 -Wa,-maltivec -Wa,-mpower4 -Wa,-many -mlittle-endian -Wa,-gdwarf-2 -D__VDSO32__ -s -m32 -c -o
arch/powerpc/kernel/vdso32/gettimeofday.oarch/powerpc/kernel/vdso32/gettimeofday.S(so I was wrong about -no-integrated-as)
I wonder if we need to be setting --target=powerpc-linux-gnu instead? Maybe the -m32 isn't being forwarded to the assembler? Or is there an assembler directive we can use to tell the assembler that this should be assembled in 32b mode? (looks like no:
https://sourceware.org/binutils/docs/as/PowerPC_002dPseudo.html#PowerPC_002dPseudo)``` foo: bl bar(a)local bar: ```assembles with powerpc-linux-gnu-as but fails with the error message we observe for powerpc64le-linux-gnu-as. (I'm pretty sure we had similar issues with the compat vdso on arm64).
ah,
-a32will put the assembler in 32b mode. I'm guessing gcc maybe adds this implicitly for-m32?```
arch/powerpc/kernel/vdso32/Makefile +1
-1@@ -26,7 +26,7 @@ UBSAN_SANITIZE := n ccflags-y := -shared -fno-common -fno-builtin -nostdlib \ -Wl,-soname=linux-vdso32.so.1 -Wl,--hash-style=both -asflags-y := -D__VDSO32__ -s +asflags-y := -D__VDSO32__ -s -Wa,-a32 obj-y += vdso32_wrapper.o targets += vdso32.lds``` gets us a little further, but then I observe additional failures: ```VDSO32A
arch/powerpc/kernel/vdso32/gettimeofday.oarch/powerpc/kernel/vdso32/gettimeofday.S: Assembler messages:arch/powerpc/kernel/vdso32/gettimeofday.S:39: Error: operand out of range (0x00000000000f4240is not between0xffffffffffff8000and0x000000000000ffff)arch/powerpc/kernel/vdso32/gettimeofday.S:39: Error: syntax error; found@', expected,'arch/powerpc/kernel/vdso32/gettimeofday.S:39: Error: junk at end of
line: `@high'arch/powerpc/kernel/vdso32/gettimeofday.S:83: Error: operand out of range (0x000000003b9aca00is not between0xffffffffffff8000and0x000000000000ffff)arch/powerpc/kernel/vdso32/gettimeofday.S:83: Error: syntax error; found@', expected,'arch/powerpc/kernel/vdso32/gettimeofday.S:83: Error: junk at end of
line: `@high'arch/powerpc/kernel/vdso32/gettimeofday.S:203: Error: operand out of range (0x00000000003d0900is not between0xffffffffffff8000and0x000000000000ffff)arch/powerpc/kernel/vdso32/gettimeofday.S:203: Error: syntax error; found@', expected,'arch/powerpc/kernel/vdso32/gettimeofday.S:203: Error: junk at end of
Quoted 8 lines
line: `@high'
clang-12: error: assembler command failed with exit code 1 (use -v to see invocation)
make[3]: *** [arch/powerpc/kernel/vdso32/Makefile:49:arch/powerpc/kernel/vdso32/gettimeofday.o] Error 1
```
That's preprocessed in, but looks like support for @high is missing from clang as well.
Hmmm...so the @high is coming from arch/powerpc/include/asm/ppc_asm.h:320
314 #if defined(__powerpc64__) && defined(HAVE_AS_ATHIGH) 315 #define __AS_ATHIGH high
316 #else
317 #define __AS_ATHIGH h
318 #endif
319
320 .macro __LOAD_REG_IMMEDIATE_32 r, x
321 .if (\x) >= 0x8000 || (\x) < -0x8000
322 lis \r, (\x)@__AS_ATHIGH
So we're #defining __powerpc64__ because of the --target=powerpc64le-linux-gnu, but then trying to assemble this in 32b mode since it's a compat vdso?
Signature · 2 lines
Thanks, ~Nick Desaulniers