gold input section handling
Ian Lance Taylor
iant@google.com
Tue Apr 15 04:09:00 GMT 2008
David Miller <davem@davemloft.net> writes:
> From: Ian Lance Taylor <iant@google.com>
> Date: Mon, 14 Apr 2008 09:45:05 -0700
>
>> Because the Linux kernel is not reliable about setting section flags
>> in assembler source, gold has exceptions such that it will combine
>> sections with zero flags with sections with non-zero flags if they
>> have the same name.
>>
>> Because gcc uses an optimization for the .eh_frame section, making it
>> read-only possible and read-write when necessary, gold has an
>> exception for the .eh_frame section.
>
> I think the fact that gold needs two exceptions already, and we know
> of other cases that break, are good indications that it may not be
> tenable, in the end, to enforce this rule.
>
> There seems to be quite some precendence of using different section
> flags in different instances of a section.
I saw your later post, but this seems like a reasonable argument to
me. I changed gold so that it ignores SHF_WRITE and SHF_EXECINSTR
when merging sections. It still pays attention to SHF_ALLOC, except
for sections with zero flags.
I committed the attached patch.
Ian
2008-04-14 Ian Lance Taylor <iant@google.com>
* layout.cc (Layout::Layout): Initialize sections_are_attached_.
(Layout::get_output_section): Ignore SHF_WRITE and SHF_EXECINSTR
in the name/type/flags to section mapping. Don't call
allocate_output_section.
(Layout::choose_output_section): Change parameter from adjust_name
to is_input_section. Don't permit input sections after sections
are attached to segments. Don't call allocate_output_section.
(Layout::layout_eh_frame): Call update_flags_for_input_section,
not write_enable_output_section.
(Layout::make_output_section): Don't push to
unattached_section_list_ nor call attach_to_segment. Call
attach_section_to_segment if sections are attached.
(Layout::attach_sections_to_segments): New function.
(Layout::attach_section_to_segment): New function.
(Layout::attach_allocated_section_to_segment): Rename from
attach_to_segment. Remove flags parameter.
(Layout::allocate_output_section): Remove function.
(Layout::write_enable_output_section): Remove function.
* layout.h (class Layout): Update for above changes. Add new
field sections_are_attached_.
* output.h (Output_section::update_flags_for_input_section): New
function.
* output.cc (Output_section::add_input_section): Call
update_flags_for_input_section.
* gold.cc (queue_middle_tasks): Call attach_sections_to_segments.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-patch
Size: 13231 bytes
Desc: Merge read/write with read/only sections
URL: <https://sourceware.org/pipermail/binutils/attachments/20080415/5fe435c3/attachment.bin>
More information about the Binutils
mailing list