ld: optionally emit _etext last, before .data
Fangrui Song
i@maskray.me
Sun Jul 19 00:16:47 GMT 2020
On 2020-07-17, Hans-Peter Nilsson wrote:
>On Fri, 17 Jul 2020, Hans-Peter Nilsson wrote:
>
>> So, here's my suggestion for making _init .. __etext cover .text +
>> .rodata (including things like the read-only exception tables) for
>> elf64mmix.
>
>I forgot to mention that I re-built cris-elf and diff'd the
>ldscripts to smoke test that this patch has absolutely no effect
>there or for any other target not setting
>ETEXT_LAST_IN_RODATA_SEGMENT and of course I redid the
>"original" gcc test (building for elf, objcopying to mmo,
>before/after patch) to check that it had the intended effect for
>elf64mmix. If the test-suite adjustment wasn't convincing...
>
>>
>> ld:
>> * scripttempl/elf.sc (ETEXT_LAST_IN_RODATA_SEGMENT): New variable.
>> * emulparams/elf64mmix.sh (ETEXT_LAST_IN_RODATA_SEGMENT): Define.
>> * testsuite/ld-mmix/sec-1.d: Adjust.
>
>brgds, H-P
I am in favor of this choice.
An effective way mitigating
https://sourceware.org/bugzilla/show_bug.cgi?id=24490
and
https://sourceware.org/bugzilla/show_bug.cgi?id=24491
is to move read-only sections (.rodata .eh_frame .eh_frame_hdr)
before text sections.
LLD has such a default layout and thus its _etext is after both .rodata and .text
Very few applications need to be fixed (see https://github.com/mruby/mruby/pull/4716 for an example)
More information about the Binutils
mailing list