[AArch64] Use SYMBOL_REFERENCES_LOCAL in one symbol check
Jiong Wang
jiong.wang@foss.arm.com
Wed Jun 21 10:01:00 GMT 2017
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 \
> -Wl,-soname=ld-linux-aarch64.so.1 \
> -Wl,-defsym=_begin=0
> /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
>
>
Hi Steve,
This is because my patch actually tighten the symbol check under PIC mode.
For this particular case, it's because some hand-written assembly
GLIBC/sysdep/aarch64/dl-machine.h: RTLD_START_1
...
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
_dl_argv,
...
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
this change.
More information about the Binutils
mailing list