Fix internal error when using --emit-relocs with plugins.
authorCary Coutant <ccoutant@gmail.com>
Sat, 14 Jul 2018 18:52:27 +0000 (11:52 -0700)
committerCary Coutant <ccoutant@gmail.com>
Sat, 14 Jul 2018 19:44:48 +0000 (12:44 -0700)
When an .eh_frame section has deferred layout because of plugins, gold
was neglecting to mark the section as deferred. When we later processed
the corresponding relocation section, we were then ignoring it, causing
the internal error later on in the link.

gold/
PR gold/23397
* object.cc (Sized_relobj_file::do_layout): Mark section as deferred.
* testsuite/Makefile.am (plugin_test_1): Add --emit-relocs option to
existing test case.
* testsuite/Makefile.in: Regenerate.

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

index 0e50f05570d436046f048740d2a57acf82be599b..ae0b8c9eb9ed95bedfe39dd720208a9860ea544d 100644 (file)
@@ -1,3 +1,11 @@
+2018-07-14  Cary Coutant  <ccoutant@gmail.com>
+
+       PR gold/23397
+       * object.cc (Sized_relobj_file::do_layout): Mark section as deferred.
+       * testsuite/Makefile.am (plugin_test_1): Add --emit-relocs option to
+       existing test case.
+       * testsuite/Makefile.in: Regenerate.
+
 2018-07-14  Cary Coutant  <ccoutant@gmail.com>
 
        PR gold/23409
index 374340fa16c0ce63ed79e7c82c9020ca46a92544..084212c790e6afdb6678f4bdb46d4d54a875a9ee 100644 (file)
@@ -1742,9 +1742,13 @@ Sized_relobj_file<size, big_endian>::do_layout(Symbol_table* symtab,
                  out_section_offsets[i] = invalid_address;
                }
              else if (this->is_deferred_layout())
-               this->deferred_layout_.push_back(
-                   Deferred_layout(i, name, sh_type, pshdrs,
-                                   reloc_shndx[i], reloc_type[i]));
+               {
+                 out_sections[i] = reinterpret_cast<Output_section*>(2);
+                 out_section_offsets[i] = invalid_address;
+                 this->deferred_layout_.push_back(
+                     Deferred_layout(i, name, sh_type, pshdrs,
+                                     reloc_shndx[i], reloc_type[i]));
+               }
              else
                eh_frame_sections.push_back(i);
              continue;
index e15788e5621862c0cbe40dee0055f1f8d7958135..c1c5539cdb070d857f63190466f2fa4eeca4404b 100644 (file)
@@ -2256,7 +2256,7 @@ check_SCRIPTS += plugin_test_1.sh
 check_DATA += plugin_test_1.err
 MOSTLYCLEANFILES += plugin_test_1.err
 plugin_test_1: two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o.syms empty.o.syms gcctestdir/ld plugin_test.so
-       $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv" two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o.syms empty.o.syms 2>plugin_test_1.err
+       $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--emit-relocs,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv" two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o.syms empty.o.syms 2>plugin_test_1.err
 plugin_test_1.err: plugin_test_1
        @touch plugin_test_1.err
 
index 7305d32db6b10e3c848fad62a52e6bda58e2fac7..08b5c07a6726f9fa48d1cbcee2cd5a7609f80fc5 100644 (file)
@@ -8922,7 +8922,7 @@ uninstall-am:
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ test -d alt || mkdir -p alt
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -o $@ $<
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_1: two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o.syms empty.o.syms gcctestdir/ld plugin_test.so
-@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@   $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv" two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o.syms empty.o.syms 2>plugin_test_1.err
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@   $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--emit-relocs,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv" two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_test_2.o.syms empty.o.syms 2>plugin_test_1.err
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_1.err: plugin_test_1
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@   @touch plugin_test_1.err
 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_2: two_file_test_main.o two_file_test_1.o.syms two_file_test_1b.o.syms two_file_shared_2.so gcctestdir/ld plugin_test.so