Closed nathanchance closed 3 years ago
hmm, I wonder if -fPIC
should be added to ccflags-y in arch/powerpc/kernel/vdso32/Makefile?
Either gcc doesn't generate R_PPC_REL16_LO relocations, or LLD is wrong about that error message. It looks like a relative relocation, so I'd think adding -fPIC
is the way to go. cc @MaskRay
It does look like space and x86 add -fpic
to the CFLAGS for their 32-bit vDSOs so maybe there is precedent there. At the same time, I wonder if there is something deeper going on in ld.lld
.
What is next-20200128
? master is good. Should I add git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git
as another remote?
edit:
git remote add linux-next git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git fetch linux-next
git checkout next-20200204
% git diff -U1
diff --git i/arch/powerpc/kernel/vdso32/Makefile w/arch/powerpc/kernel/vdso32/Makefile
index 06f54d947057..30eb22b3f36b 100644
--- i/arch/powerpc/kernel/vdso32/Makefile
+++ w/arch/powerpc/kernel/vdso32/Makefile
@@ -29,3 +29,3 @@ UBSAN_SANITIZE := n
ccflags-y := -shared -fno-common -fno-builtin -nostdlib \
- -Wl,-soname=linux-vdso32.so.1 -Wl,--hash-style=both
+ -Wl,-soname=linux-vdso32.so.1 -Wl,--hash-style=both -fuse-ld=lld
asflags-y := -D__VDSO32__ -s
% make -j30 ARCH=powerpc CC=/tmp/ReleaseA/bin/clang CROSS_COMPILE=powerpc-linux-gnu- LD=/tmp/ReleaseA/bin/ld.lld O=/tmp/out/ppc32 all
ld.lld: error: relocation R_PPC_REL16_LO cannot be used against symbol __kernel_datapage_offset; recompile with -fPIC
>>> defined in arch/powerpc/kernel/vdso32/datapage.o
>>> referenced by arch/powerpc/kernel/vdso32/gettimeofday.o:(__kernel_gettimeofday)
...
Delete arch/powerpc/kernel/vdso32/vdso32.so.dbg
, rerun make all V=1
. I get the linker command line: clang ... -shared ... -o arch/powerpc/kernel/vdso32/vdso32.so.dbg
% readelf -s /tmp/out/ppc32/arch/powerpc/kernel/vdso32/vdso32.so.dbg | grep __kernel_datapage_offset
4: 000005f4 0 NOTYPE GLOBAL DEFAULT 8 __kernel_datapage_offset@@LINUX_2.6.15
13: 000005f4 0 NOTYPE GLOBAL DEFAULT 8 __kernel_datapage_offset
The symbol is preemptible in a -shared link. + addi \ptr, \ptr, (__kernel_datapage_offset - (.-4))@l
in https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id=ec0895f08f99515194e9fcfe1338becf6f759d38 introduced an incorrect PC-relative relocation.
R_PPC_REL16_LO
is a bit special in GNU ld. GNU ld seems to allow it referencing a preemptible symbol, though it is not the case on other architectures.
I can send a patch. How should I start? :)
@MaskRay
https://www.kernel.org/doc/html/latest/process/submitting-patches.html
Create the change, test it, and commit it with your explanation and signed-off-by tag.
Run git format-patch -1
to generate the patch file.
Run ./scripts/checkpatch.pl <patch_file>
to check the patch and make sure there are no errors.
Run ./scripts/get_maintainer.pl <patch_file>
to get the maintainers of the file.
Sample output:
$ ./scripts/get_maintainer.pl arch/powerpc/kernel/vdso32/
Benjamin Herrenschmidt <benh@kernel.crashing.org> (supporter:LINUX FOR POWERPC (32-BIT AND 64-BIT))
Paul Mackerras <paulus@samba.org> (supporter:LINUX FOR POWERPC (32-BIT AND 64-BIT))
Michael Ellerman <mpe@ellerman.id.au> (supporter:LINUX FOR POWERPC (32-BIT AND 64-BIT),commit_signer:12/16=75%)
Christophe Leroy <christophe.leroy@c-s.fr> (commit_signer:11/16=69%,authored:9/16=56%)
Thomas Gleixner <tglx@linutronix.de> (commit_signer:2/16=12%,authored:2/16=12%)
Greg Kroah-Hartman <gregkh@linuxfoundation.org> (commit_signer:2/16=12%)
Allison Randal <allison@lohutok.net> (commit_signer:2/16=12%)
Arnd Bergmann <arnd@arndb.de> (authored:2/16=12%)
Nick Desaulniers <ndesaulniers@google.com> (authored:1/16=6%)
Vincenzo Frascino <vincenzo.frascino@arm.com> (authored:1/16=6%)
linuxppc-dev@lists.ozlabs.org (open list:LINUX FOR POWERPC (32-BIT AND 64-BIT))
linux-kernel@vger.kernel.org (open list)
git send-email
to send the patch. For something touching this, I would recommend something like this (maintainers, person who introduced the error with the PPC, main Linux kernel, and our mailing list on CC):$ git send-email --to="Benjamin Herrenschmidt <benh@kernel.crashing.org>" \
--to="Paul Mackerras <paulus@samba.org>" \
--to="Michael Ellerman <mpe@ellerman.id.au>" \
--to="Christophe Leroy <christophe.leroy@c-s.fr>" \
--cc="linuxppc-dev@lists.ozlabs.org" \
--cc="linux-kernel@vger.kernel.org" \
--cc="clang-built-linux@googlegroups.com" \
<patch_file>
Feel free to ask me any questions :)
Thanks! I'll try that tomorrow.
In the meantime, I filed https://sourceware.org/bugzilla/show_bug.cgi?id=25500 . This is a missing diagnostic from the powerpc32/powerpc64 ports of GNU ld.
needs to be chased
It sounds like __get_datapage
may have been removed from the kernel?
Does not look like it. Christophe's patch series that he mentioned no longer includes a patch that removes __get_datapage
so Fangrui's patch needs to be chased.
Still relevant but marking low priority for now because this cannot be reproduced without -DCLANG_DEFAULT_LINKER=lld
passed to cmake
at LLVM build time or #774 resolved.
Actually, this was resolved with https://git.kernel.org/linus/49bf59fd0371b1053a17021f27605f43071584ee so closing.
NOTE: Because of #774,
clang
needs to be configured to useld.lld
by default (-DCLANG_DEFAULT_LINKER=lld
) to see this. Otherwise, adding-fuse-ld=lld
toccflags-y
inarch/powerpc/kernel/vdso32/Makefile
should work.Caused by https://git.kernel.org/powerpc/c/ec0895f08f99515194e9fcfe1338becf6f759d38.