This is the mail archive of the
mailing list for the binutils project.
Re: [AArch64] Use SYMBOL_REFERENCES_LOCAL in one symbol check
On 20/06/17 23:50, Steve Ellcey wrote:
Some new information, I see that when building the dynamic
linker/loader (part of the glibc build), when using your patch I get
this error that I did not get before.
aarch64-linux-gnu-gcc -mabi=lp64 -nostdlib -nostartfiles -shared -o /home/sellcey/toolchain/obj/glibc64/elf/ld.so.new \
-Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs \
/home/sellcey/toolchain/obj/glibc64/elf/librtld.os -Wl,--version-script=/home/sellcey/toolchain/obj/glibc64/ld.map \
/home/sellcey/toolchain/install/lib/gcc/aarch64-linux-gnu/8.0.0/../../../../aarch64-linux-gnu/bin/ld: /home/sellcey/toolchain/obj/glibc64/elf/librtld.os: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_dl_argv' which may bind externally can not be used when making a shared object; recompile with -fPIC
This is because my patch actually tighten the symbol check under PIC mode.
For this particular case, it's because some hand-written assembly
adrp x3, _dl_argv \n\
str " PTR "2, [x3, #:lo12:_dl_argv] \n\
is exactly reference a normal global visibility symbol "_dl_argv" for which if
in usual userspace then might be overriden, so a warning was given here.
However that hand written assembly is a RTLD hook for which I think the symbol
can't be overridden, so use ADRP is fine there, but the assembly ought to mark
the symbol's visibility correctly, I feel hidden it make sense here.
So, I think we should fix AArch64 glibc code, to use _GI__dl_argv instead of
adrp x3, __GI__dl_argv \n\
str " PTR "2, [x3, #:lo12:__GI__dl_argv] \n\
This seems to me is the correct way, and I verified glibc build should be OK after