[GOLD][PATCH] Handle section symbols of relaxed input sections.
Doug Kwan (關振德)
dougkwan@google.com
Tue Oct 20 22:17:00 GMT 2009
Hi,
This patch fixes a problem where
Sized_relobj::do_finalize_local_symbols incorrectly assumes sections
symbols of relaxation input sections to have the starting addresses of
their containing output sections.
-Doug
2009-10-20 Doug Kwan <dougkwan@google.com>
* object.cc (Sized_relobj::do_finalize_local_symbols): Handle section
symbols of relaxed input sections.
* output.h (Output_section::find_relaxed_input_section): Make
method public.
-------------- next part --------------
Index: gold/object.cc
===================================================================
RCS file: /cvs/src/src/gold/object.cc,v
retrieving revision 1.104
diff -u -p -r1.104 object.cc
--- gold/object.cc 13 Oct 2009 21:17:43 -0000 1.104
+++ gold/object.cc 20 Oct 2009 22:09:14 -0000
@@ -1711,12 +1711,18 @@ Sized_relobj<size, big_endian>::do_final
}
else if (!os->find_starting_output_address(this, shndx, &start))
{
- // This is a section symbol, but apparently not one
- // in a merged section. Just use the start of the
- // output section. This happens with relocatable
- // links when the input object has section symbols
- // for arbitrary non-merge sections.
- lv.set_output_value(os->address());
+ // This is a section symbol, but apparently not one in a
+ // merged section. First check to see if this is a relaxed
+ // input section. If so, use its address. Otherwise just
+ // use the start of the output section. This happens with
+ // relocatable links when the input object has section
+ // symbols for arbitrary non-merge sections.
+ const Output_section_data* posd =
+ os->find_relaxed_input_section(this, shndx);
+ if (posd != NULL)
+ lv.set_output_value(posd->address());
+ else
+ lv.set_output_value(os->address());
}
else
{
Index: gold/output.h
===================================================================
RCS file: /cvs/src/src/gold/output.h,v
retrieving revision 1.84
diff -u -p -r1.84 output.h
--- gold/output.h 9 Oct 2009 23:18:19 -0000 1.84
+++ gold/output.h 20 Oct 2009 22:09:14 -0000
@@ -2585,6 +2585,11 @@ class Output_section : public Output_dat
convert_input_sections_to_relaxed_sections(
const std::vector<Output_relaxed_input_section*>& sections);
+ // Find a relaxed input section to an input section in OBJECT
+ // with index SHNDX. Return NULL if none is found.
+ const Output_section_data*
+ find_relaxed_input_section(const Relobj* object, unsigned int shndx) const;
+
// Print merge statistics to stderr.
void
print_merge_stats();
@@ -3208,11 +3213,6 @@ class Output_section : public Output_dat
Output_section_data*
find_merge_section(const Relobj* object, unsigned int shndx) const;
- // Find a relaxed input section to an input section in OBJECT
- // with index SHNDX. Return NULL if none is found.
- const Output_section_data*
- find_relaxed_input_section(const Relobj* object, unsigned int shndx) const;
-
// Build a relaxation map.
void
build_relaxation_map(
More information about the Binutils
mailing list