Bug 28501 - ld arm: R_ARM_GOTOFF32 referencing a preemptible symbol should be disallowed
Summary: ld arm: R_ARM_GOTOFF32 referencing a preemptible symbol should be disallowed
Status: UNCONFIRMED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-26 20:18 UTC by Fangrui Song
Modified: 2021-10-26 20:18 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2021-10-26 20:18:48 UTC
cat >a.s <<e
.globl _dl_argv
_dl_argv:
  nop

.word _dl_argv(GOTOFF)
e
arm-linux-gnueabi-gcc -fpic -c arm.s


% arm-linux-gnueabi-ld -shared arm.o  # incorrectly allowed; should issue an error like R_X86_64_PC32/R_AARCH64_PREL32
% ld.lld -shared arm.o
ld.lld: error: relocation R_ARM_GOTOFF32 cannot be used against symbol _dl_argv; recompile with -fPIC
>>> defined in arm.o
>>> referenced by arm.o:(.text+0x4)
% ld.lld -shared -Bsymbolic arm.o     # -Bsymbolic makes defined symbols non-preemptible, so no diagnostic



As of 2021-10, glibc sysdeps/arm/dl-machine.h has such incorrect usage: https://sourceware.org/pipermail/libc-alpha/2021-October/132315.html