[RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
Yury Gribov
y.gribov@samsung.com
Fri Feb 7 10:16:00 GMT 2014
Hi all,
Currently BFD linker generates 3-word wide .plt entries for ARM targets:
0000825c <.plt>:
...
8270: e28fc600 add ip, pc, #0, 12
8274: e28cca08 add ip, ip, #8, 20 ; 0x8000
8278: e5bcf3e8 ldr pc, [ip, #1000]! ; 0x3e8
827c: e28fc600 add ip, pc, #0, 12
8280: e28cca08 add ip, ip, #8, 20 ; 0x8000
8284: e5bcf3e0 ldr pc, [ip, #992]! ; 0x3e0
These entries are only able to initialize first 28 bits of .plt/.got
displacement. If .text and .rodata are bigger than 2 ^ 28 bytes (i.e.
256M) this may cause linker errors due to assert in
elf32_arm_populate_plt_entry (in bfd/elf32-arm.c):
BFD_ASSERT ((got_displacement & 0xf0000000) == 0);
I suggest to add an option --long-plt to allow generation of 4-word wide
.plt entries capable of handling arbitrary .plt/.got displacements:
0000825c <.plt>:
...
8270: e28fc200 add ip, pc, #0, 4
8274: e28cc600 add ip, ip, #0, 12
8278: e28cca08 add ip, ip, #8, 20 ; 0x8000
827c: e5bcf3f4 ldr pc, [ip, #1012]! ; 0x3f4
8280: e28fc200 add ip, pc, #0, 4
8284: e28cc600 add ip, ip, #0, 12
8288: e28cca08 add ip, ip, #8, 20 ; 0x8000
828c: e5bcf3e8 ldr pc, [ip, #1000]! ; 0x3e8
Users will than be able to avoid afore-mentioned link error by compiling
with -Wl,--long-plt.
I'm attaching a draft patch to illustrate my proposal. Does it make sense?
Best regards,
Yury
-------------- next part --------------
A non-text attachment was scrubbed...
Name: long_plt_1.diff
Type: text/x-diff
Size: 7211 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20140207/3975ae43/attachment.bin>
More information about the Binutils
mailing list