This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM


On 7 February 2014 10:17, Yury Gribov <y.gribov@samsung.com> wrote:
> 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

This sounds ok in principle to me (note I am not the ARM or a global
maintainer).

I think elf32_arm_use_long_plt_entry should probably be a boolean
rather than size_t.

The comments on the PLT entries could be more verbose (i.e. point out
that one PLT can address 28 bits and the other 32).

I wonder whether the FOUR_WORD_PLT #define is now rather ambiguous,
maybe it should be removed?

The gold parts of this patch look like they are not related?

And obviously there would need to be ld testcases.

-- 
Will Newton
Toolchain Working Group, Linaro


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]