[PATCH] D58378: [PowerPC]Leverage the addend in the TOC relocation to do the address calculation
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 2 00:16:35 PST 2020
MaskRay added a comment.
> b.c:(.text+0x8): relocation truncated to fit: R_PPC64_TOC16_HA against symbol `b' defined in COMMON section in /tmp/b-9d97be.o+7ffffff8
The r_addend is 0x7ffffff8, a value close to 2**31.
The distance between the TOC entry and the variable address cannot be too far. More accurately, `-0x80008000 <= address - .TOC. + r_addend < 0x7fff8000`
GNU ld correctly reports a relocation overflow. lld currently does not check `R_PPC64_TOC16_HA` overflow.
% powerpc64le-linux-gnu-ld -pie b.o main.o
powerpc64le-linux-gnu-ld: warning: cannot find entry symbol _start; defaulting to 0000000000000230
powerpc64le-linux-gnu-ld: b.o: in function `foo':
b.c:(.text+0x8): relocation truncated to fit: R_PPC64_TOC16_HA against symbol `b' defined in COMMON section in b.o+7ffffff8
The largest address a pair of HA/L can materialize is something like:
addis 3, 2, 32767 # adding 1 will overflow to -32768
lfd 1, 32767(3)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58378/new/
https://reviews.llvm.org/D58378
More information about the llvm-commits
mailing list