This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [patch][gold] Don't put rodata and text in the same segment.
- From: Ian Lance Taylor <iant at google dot com>
- To: Rafael Espindola <espindola at google dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Wed, 01 Sep 2010 21:12:25 -0700
- Subject: Re: [patch][gold] Don't put rodata and text in the same segment.
- References: <AANLkTikANPgKOb_Tohs7ZtTKTW=cEh9=oERuaKFj6zV7@mail.gmail.com>
Rafael Espindola <espindola@google.com> writes:
> In native client the rodata section cannot be in the same segment as
> text since the data will fail to validate. We have been using a linker
> script, but maybe others also think it is a good idea to have rodata
> in a non executable segment.
>
> The change to attach_allocated_section_to_segment is the core of the
> patch. The update to find_first_load_seg is because it would now find
> a non-executable segment that was not the first segment after the
> sorting. The change to set_segment_offsets fixes what I think is a
> hidden bug. I think it was never noticed because the executable
> segment was normally followed by a rw one.
It's definitely not a good idea to always put read-only data in a
different segment. That will introduce an additional segment to every
executable, which will force an additional mmap each time a program is
run. That is not desirable.
I think it would be OK to have an option to put read-only data in a
different segment.
Ian