mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
83c325007c
__attribute__((visibility("protected"))) void *foo() { return (void *)foo; } gcc -fpic -shared -fuse-ld=bfd fails with the confusing diagnostic: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `foo' which may bind externally can not be used when making a shared object; recompile with -fPIC Call _bfd_elf_symbol_refs_local_p with local_protected==true to suppress the error. The new behavior matches gold and ld.lld. Note: if some code tries to use direct access relocations to take the address of foo (likely due to -fno-pic), the pointer equality will break, but the error should be reported on the executable link, not on the innocent shared object link. glibc 2.36 will give a warning at relocation resolving time.
12 lines
292 B
ArmAsm
12 lines
292 B
ArmAsm
.protected protected_a, protected_b, protected_c
|
|
.type protected_b, %object
|
|
.type protected_c, %function
|
|
|
|
.text
|
|
adrp x0, protected_a
|
|
add x0, x0, :lo12:protected_a
|
|
adrp x0, protected_b
|
|
add x0, x0, :lo12:protected_b
|
|
adrp x0, protected_c
|
|
add x0, x0, :lo12:protected_c
|