[PATCH][GOLD] Set correct linked section and entsize for EXIDX output section.
Doug Kwan (關振德)
dougkwan@google.com
Mon Feb 1 22:40:00 GMT 2010
Hi,
This patch adds code to set correct linked section and entsize in
the section header of the EXIDX output section.
-Doug
2010-02-01 Doug Kwan <dougkwan@google.com>
* arm.cc (Arm_exidx_fixup::Arm_exidx_fixup): Initialize
first_output_text_section_.
(Arm_exidx_fixup::first_output_text_section): New method definition.
(Arm_exidx_fixup::first_output_text_section_): New data member.
(Arm_exidx_fixup::process_exidx_section): Record the first text
output section seen.
(Arm_output_section::fix_exidx_coverage): Set correct linked section
and entsize in output section header.
-------------- next part --------------
Index: gold/arm.cc
===================================================================
RCS file: /cvs/src/src/gold/arm.cc,v
retrieving revision 1.72
diff -u -u -p -r1.72 arm.cc
--- gold/arm.cc 30 Jan 2010 00:11:00 -0000 1.72
+++ gold/arm.cc 1 Feb 2010 22:31:23 -0000
@@ -1210,7 +1210,7 @@ class Arm_exidx_fixup
Arm_exidx_fixup(Output_section* exidx_output_section)
: exidx_output_section_(exidx_output_section), last_unwind_type_(UT_NONE),
last_inlined_entry_(0), last_input_section_(NULL),
- section_offset_map_(NULL)
+ section_offset_map_(NULL), first_output_text_section_(NULL)
{ }
~Arm_exidx_fixup()
@@ -1231,6 +1231,12 @@ class Arm_exidx_fixup
void
add_exidx_cantunwind_as_needed();
+ // Return the output section for the text section which is linked to the
+ // first exidx input in output.
+ Output_section*
+ first_output_text_section() const
+ { return this->first_output_text_section_; }
+
private:
// Copying is not allowed.
Arm_exidx_fixup(const Arm_exidx_fixup&);
@@ -1273,6 +1279,9 @@ class Arm_exidx_fixup
const Arm_exidx_input_section* last_input_section_;
// Section offset map created in process_exidx_section.
Arm_exidx_section_offset_map* section_offset_map_;
+ // Output section for the text section which is linked to the first exidx
+ // input in output.
+ Output_section* first_output_text_section_;
};
// Arm output section class. This is defined mainly to add a number of
@@ -5159,6 +5168,17 @@ Arm_exidx_fixup::process_exidx_section(
this->section_offset_map_ = NULL;
this->last_input_section_ = exidx_input_section;
+ // Set the first output text section so that we can link the EXIDX output
+ // section to it. Ignore any EXIDX input section that is completely merged.
+ if (this->first_output_text_section_ == NULL
+ && deleted_bytes != section_size)
+ {
+ unsigned int link = exidx_input_section->link();
+ Output_section* os = relobj->output_section(link);
+ gold_assert(os != NULL);
+ this->first_output_text_section_ = os;
+ }
+
return deleted_bytes;
}
@@ -5547,6 +5567,11 @@ Arm_output_section<big_endian>::fix_exid
}
}
+ // Link exidx output section to the first seen output section and
+ // set correct entry size.
+ this->set_link_section(exidx_fixup.first_output_text_section());
+ this->set_entsize(8);
+
// Make changes permanent.
this->save_states();
this->set_section_offsets_need_adjustment();
More information about the Binutils
mailing list