2009-06-05 Doug Kwan <dougkwan@google.com>
authorDoug Kwan <dougkwan@google.com>
Fri, 5 Jun 2009 18:16:31 +0000 (18:16 +0000)
committerDoug Kwan <dougkwan@google.com>
Fri, 5 Jun 2009 18:16:31 +0000 (18:16 +0000)
* object.cc (Sized_relobj::Sized_relobj): Initialize
discarded_eh_frame_shndx_ to -1U.
(Sized_relobj::do_layout): Record index of a discard .eh_frame
section.
(Sized_relobj::do_count_local_symbols): Skip local symbols in
a discarded .eh_frame section.
(Sized_relobj::do_finalize_local_symbols): Ditto.
* object.h (class Sized_relobj): Declare new member
discarded_eh_frame_shndx_.
* testsuite/Makefile.am (check_PROGRAMS): Add local_labels_test.
(local_labels_test.o, local_labels_test): New rules.
* testsuite/Makefile.in: Regenerate.

gold/ChangeLog
gold/object.cc
gold/object.h
gold/testsuite/Makefile.am
gold/testsuite/Makefile.in

index a6e11d5793d8762b0b886293be0bbf5fe3238b48..d556e20fb3f7080c56134861d908f1b6577d160a 100644 (file)
@@ -1,3 +1,18 @@
+2009-06-05  Doug Kwan  <dougkwan@google.com>
+
+       * object.cc (Sized_relobj::Sized_relobj): Initialize
+       discarded_eh_frame_shndx_ to -1U.
+       (Sized_relobj::do_layout): Record index of a discard .eh_frame
+       section.
+       (Sized_relobj::do_count_local_symbols): Skip local symbols in
+       a discarded .eh_frame section.
+       (Sized_relobj::do_finalize_local_symbols): Ditto.
+       * object.h (class Sized_relobj): Declare new member
+       discarded_eh_frame_shndx_.
+       * testsuite/Makefile.am (check_PROGRAMS): Add local_labels_test.
+       (local_labels_test.o, local_labels_test): New rules.
+       * testsuite/Makefile.in: Regenerate.
+
 2009-06-04  Doug Kwan  <dougkwan@google.com>
 
        * layout.cc (Layout::section_name_mapping): Add mapping for
index 75fb67970ea7326494ce78d1d78d567249c7d53e..77ddce6e3820b3d8be279025e4d1f7de82202af8 100644 (file)
@@ -327,7 +327,8 @@ Sized_relobj<size, big_endian>::Sized_relobj(
     local_values_(),
     local_got_offsets_(),
     kept_comdat_sections_(),
-    has_eh_frame_(false)
+    has_eh_frame_(false),
+    discarded_eh_frame_shndx_(-1U)
 {
 }
 
@@ -1295,7 +1296,13 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
                                                   &offset);
       out_sections[i] = os;
       if (offset == -1)
-        out_section_offsets[i] = invalid_address;
+       {
+         // An object can contain at most one section holding exception
+         // frame information.
+         gold_assert(this->discarded_eh_frame_shndx_ == -1U);
+         this->discarded_eh_frame_shndx_ = i;
+         out_section_offsets[i] = invalid_address;
+       }
       else
         out_section_offsets[i] = convert_types<Address, off_t>(offset);
 
@@ -1453,7 +1460,8 @@ Sized_relobj<size, big_endian>::do_count_local_symbols(Stringpool* pool,
 
       // Decide whether this symbol should go into the output file.
 
-      if (shndx < shnum && out_sections[shndx] == NULL)
+      if ((shndx < shnum && out_sections[shndx] == NULL)
+         || (shndx == this->discarded_eh_frame_shndx_))
         {
          lv.set_no_output_symtab_entry();
           gold_assert(!lv.needs_output_dynsym_entry());
@@ -1558,7 +1566,15 @@ Sized_relobj<size, big_endian>::do_finalize_local_symbols(unsigned int index,
 
              // This is a SHF_MERGE section or one which otherwise
              // requires special handling.
-             if (!lv.is_section_symbol())
+             if (shndx == this->discarded_eh_frame_shndx_)
+               {
+                 // This local symbol belongs to a discarded .eh_frame
+                 // section.  Just treat it like the case in which
+                 // os == NULL above.
+                 gold_assert(this->has_eh_frame_);
+                 continue;
+               }
+             else if (!lv.is_section_symbol())
                {
                  // This is not a section symbol.  We can determine
                  // the final value now.
index a2836d04863f9ef4032531e3ee2bf1fffc3fa2c9..d5f111fa7182f98957c2911c48ef876110dd00c0 100644 (file)
@@ -1815,6 +1815,9 @@ class Sized_relobj : public Relobj
   Kept_comdat_section_table kept_comdat_sections_;
   // Whether this object has a GNU style .eh_frame section.
   bool has_eh_frame_;
+  // If this object has a GNU style .eh_frame section that is discarded in
+  // output, record the index here.  Otherwise it is -1U.
+  unsigned int discarded_eh_frame_shndx_;
   // The list of sections whose layout was deferred.
   std::vector<Deferred_layout> deferred_layout_;
 };
index 5208e063127aa654e0a4f7a6187f93c00af62caa..e2bf8bd2aaedf1e07aa28534b10c4fc8bb146f81 100644 (file)
@@ -1074,5 +1074,11 @@ alt/libexclude_libs_test_3.a: exclude_libs_test_3.o
        test -d alt || mkdir -p alt
        $(TEST_AR) rc $@ $^
 
+check_PROGRAMS += local_labels_test
+local_labels_test.o: ver_test_6.c
+       $(COMPILE) -g -c -Wa,-L -o $@ $<
+local_labels_test: local_labels_test.o
+       $(LINK) -Bgcctestdir/ local_labels_test.o
+
 endif GCC
 endif NATIVE_LINKER
index 53b7bf8fdb192d5929674b22f5da0f1fd507d3a0..0533e7bb8d9e504864e333b2d1537074bb5103b8 100644 (file)
@@ -318,7 +318,8 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@   plugin_test_2.err \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@   plugin_test_3.err \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@   plugin_test_4.err
-@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_24 = exclude_libs_test
+@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_24 = exclude_libs_test \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ local_labels_test
 @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_25 = exclude_libs_test.sh
 @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_26 = exclude_libs_test.syms
 @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_27 = exclude_libs_test.syms libexclude_libs_test_1.a \
@@ -429,7 +430,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@   plugin_test_3$(EXEEXT) \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@   plugin_test_4$(EXEEXT)
 @GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_17 =  \
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ exclude_libs_test$(EXEEXT)
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ exclude_libs_test$(EXEEXT) \
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ local_labels_test$(EXEEXT)
 basic_pic_test_SOURCES = basic_pic_test.c
 basic_pic_test_OBJECTS = basic_pic_test.$(OBJEXT)
 basic_pic_test_LDADD = $(LDADD)
@@ -573,6 +575,12 @@ am__justsyms_SOURCES_DIST = justsyms_1.cc
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms_1.$(OBJEXT)
 justsyms_OBJECTS = $(am_justsyms_OBJECTS)
 justsyms_LDADD = $(LDADD)
+local_labels_test_SOURCES = local_labels_test.c
+local_labels_test_OBJECTS = local_labels_test.$(OBJEXT)
+local_labels_test_LDADD = $(LDADD)
+local_labels_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
+       ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 many_sections_r_test_SOURCES = many_sections_r_test.c
 many_sections_r_test_OBJECTS = many_sections_r_test.$(OBJEXT)
 many_sections_r_test_LDADD = $(LDADD)
@@ -900,15 +908,15 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
        $(exclude_libs_test_SOURCES) \
        flagstest_compress_debug_sections.c flagstest_o_specialfile.c \
        flagstest_o_specialfile_and_compress_debug_sections.c \
-       $(initpri1_SOURCES) $(justsyms_SOURCES) many_sections_r_test.c \
-       $(many_sections_test_SOURCES) $(object_unittest_SOURCES) \
-       plugin_test_1.c plugin_test_2.c plugin_test_3.c \
-       plugin_test_4.c $(protected_1_SOURCES) $(protected_2_SOURCES) \
-       $(relro_script_test_SOURCES) $(relro_test_SOURCES) \
-       $(script_test_1_SOURCES) $(script_test_2_SOURCES) \
-       script_test_3.c $(thin_archive_test_1_SOURCES) \
-       $(thin_archive_test_2_SOURCES) $(tls_pic_test_SOURCES) \
-       $(tls_shared_gd_to_ie_test_SOURCES) \
+       $(initpri1_SOURCES) $(justsyms_SOURCES) local_labels_test.c \
+       many_sections_r_test.c $(many_sections_test_SOURCES) \
+       $(object_unittest_SOURCES) plugin_test_1.c plugin_test_2.c \
+       plugin_test_3.c plugin_test_4.c $(protected_1_SOURCES) \
+       $(protected_2_SOURCES) $(relro_script_test_SOURCES) \
+       $(relro_test_SOURCES) $(script_test_1_SOURCES) \
+       $(script_test_2_SOURCES) script_test_3.c \
+       $(thin_archive_test_1_SOURCES) $(thin_archive_test_2_SOURCES) \
+       $(tls_pic_test_SOURCES) $(tls_shared_gd_to_ie_test_SOURCES) \
        $(tls_shared_gnu2_gd_to_ie_test_SOURCES) \
        $(tls_shared_gnu2_test_SOURCES) $(tls_shared_ie_test_SOURCES) \
        $(tls_shared_nonpic_test_SOURCES) $(tls_shared_test_SOURCES) \
@@ -955,7 +963,8 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
        flagstest_compress_debug_sections.c flagstest_o_specialfile.c \
        flagstest_o_specialfile_and_compress_debug_sections.c \
        $(am__initpri1_SOURCES_DIST) $(am__justsyms_SOURCES_DIST) \
-       many_sections_r_test.c $(am__many_sections_test_SOURCES_DIST) \
+       local_labels_test.c many_sections_r_test.c \
+       $(am__many_sections_test_SOURCES_DIST) \
        $(object_unittest_SOURCES) plugin_test_1.c plugin_test_2.c \
        plugin_test_3.c plugin_test_4.c \
        $(am__protected_1_SOURCES_DIST) \
@@ -1519,6 +1528,7 @@ binary_unittest_SOURCES = binary_unittest.cc
 @GCC_TRUE@@NATIVE_LINKER_TRUE@exclude_libs_test_LDADD = -lexclude_libs_test_1 -lexclude_libs_test_2 \
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/libexclude_libs_test_3.a
 
+@GCC_TRUE@@NATIVE_LINKER_TRUE@local_labels_test_LDFLAGS = -Bgcctestdir/
 all: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) all-am
 
@@ -1659,6 +1669,12 @@ initpri1$(EXEEXT): $(initpri1_OBJECTS) $(initpri1_DEPENDENCIES)
 justsyms$(EXEEXT): $(justsyms_OBJECTS) $(justsyms_DEPENDENCIES) 
        @rm -f justsyms$(EXEEXT)
        $(CXXLINK) $(justsyms_LDFLAGS) $(justsyms_OBJECTS) $(justsyms_LDADD) $(LIBS)
+@GCC_FALSE@local_labels_test$(EXEEXT): $(local_labels_test_OBJECTS) $(local_labels_test_DEPENDENCIES) 
+@GCC_FALSE@    @rm -f local_labels_test$(EXEEXT)
+@GCC_FALSE@    $(LINK) $(local_labels_test_LDFLAGS) $(local_labels_test_OBJECTS) $(local_labels_test_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@local_labels_test$(EXEEXT): $(local_labels_test_OBJECTS) $(local_labels_test_DEPENDENCIES) 
+@NATIVE_LINKER_FALSE@  @rm -f local_labels_test$(EXEEXT)
+@NATIVE_LINKER_FALSE@  $(LINK) $(local_labels_test_LDFLAGS) $(local_labels_test_OBJECTS) $(local_labels_test_LDADD) $(LIBS)
 @GCC_FALSE@many_sections_r_test$(EXEEXT): $(many_sections_r_test_OBJECTS) $(many_sections_r_test_DEPENDENCIES) 
 @GCC_FALSE@    @rm -f many_sections_r_test$(EXEEXT)
 @GCC_FALSE@    $(LINK) $(many_sections_r_test_LDFLAGS) $(many_sections_r_test_OBJECTS) $(many_sections_r_test_LDADD) $(LIBS)
@@ -1891,6 +1907,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_o_specialfile_and_compress_debug_sections.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/initpri1.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/justsyms_1.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/local_labels_test.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/many_sections_r_test.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/many_sections_test.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object_unittest.Po@am__quote@
@@ -2613,6 +2630,10 @@ uninstall-am: uninstall-info-am
 @GCC_TRUE@@NATIVE_LINKER_TRUE@alt/libexclude_libs_test_3.a: exclude_libs_test_3.o
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ test -d alt || mkdir -p alt
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_AR) rc $@ $^
+@GCC_TRUE@@NATIVE_LINKER_TRUE@local_labels_test.o: ver_test_6.c
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -g -c -Wa,-L -o $@ $<
+@GCC_TRUE@@NATIVE_LINKER_TRUE@local_labels_test: local_labels_test.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ local_labels_test.o
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT: