Summary: | [PATCH] when linked with gold, NetBSD ld.elf_so crashes due to missing .plt.got entry | ||
---|---|---|---|
Product: | binutils | Reporter: | Ben Gras <ben> |
Component: | gold | Assignee: | Cary Coutant <ccoutant> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | ccoutant |
Priority: | P2 | ||
Version: | 2.25 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: | ||
Attachments: | .tar file with script to reproduce the problem; .o files (as the script generates on my end); executables (as the script generates on my end); patch file with suggested solution. |
Description
Ben Gras
2014-05-04 01:59:06 UTC
Thanks for the diagnosis. You're right that the problem is that the GOT is initialized only when there is a PLT, but it shouldn't be necessary to forcibly create a PLT that would otherwise be empty. I've fixed this by changing the .got.plt section to have its own class derived from Output_section_data_build, so that its own do_write() method can write those reserved entries, but I leave the remainder of the section to be written when the PLT is written. This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "gdb and binutils". The branch, master has been updated via 57b2284c6318841612acef23c60fe7298a1ac91a (commit) from 757a636fb585824699b1cc4f8f23dbc3a6a6d914 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=57b2284c6318841612acef23c60fe7298a1ac91a commit 57b2284c6318841612acef23c60fe7298a1ac91a Author: Cary Coutant <ccoutant@google.com> Date: Tue May 6 11:40:04 2014 -0700 Fix issue where first reserved word of GOT is not initialized if there is no PLT. gold/ PR gold/16900 * i386.cc (Output_data_got_plt_i386): New class. (Output_data_plt_i386::Output_data_plt_i386): Change type of got_plt parameter. Change all callers. (Output_data_plt_i386::layout_): Remove. (Output_data_plt_i386::got_plt_): Change type. (Target_i386::got_plt_): Change type. Change all references. (Target_i386::got_section): Create instance of new class. (Output_data_got_plt_i386::do_write): New function. * x86_64.cc (Output_data_got_plt_x86_64): New class. (Output_data_plt_x86_64::Output_data_plt_x86_64): Change type of got_plt parameter. Change all callers. (Output_data_plt_x86_64::layout_): Remove. (Output_data_plt_x86_64::got_plt_): Change type. (Target_x86_64::got_plt_): Change type. Change all references. (Target_x86_64::got_section): Create instance of new class. (Output_data_got_plt_x86_64::do_write): New function. (Output_data_plt_x86_64::do_write): Don't write reserved words in GOT. (Target_x86_64<size>::init_got_plt_for_update): Create instance of new class. ----------------------------------------------------------------------- Summary of changes: gold/ChangeLog | 23 ++++++++++++ gold/i386.cc | 102 +++++++++++++++++++++++++++++++++++----------------- gold/x86_64.cc | 110 ++++++++++++++++++++++++++++++++++++++------------------ 3 files changed, 167 insertions(+), 68 deletions(-) This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "gdb and binutils". The branch, binutils-2_24-branch has been updated via 6ce193a2807a10a53c1883e573f0ea5e03fbff76 (commit) via 367f1035d2f7da6fbad69f659208bdb7da3d55dc (commit) from a9534d052d7714778fa615974c4a8115fc973420 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6ce193a2807a10a53c1883e573f0ea5e03fbff76 commit 6ce193a2807a10a53c1883e573f0ea5e03fbff76 Author: Cary Coutant <ccoutant@google.com> Date: Tue May 6 11:40:04 2014 -0700 Fix issue where first reserved word of GOT is not initialized if there is no PLT. gold/ PR gold/16900 * i386.cc (Output_data_got_plt_i386): New class. (Output_data_plt_i386::Output_data_plt_i386): Change type of got_plt parameter. Change all callers. (Output_data_plt_i386::layout_): Remove. (Output_data_plt_i386::got_plt_): Change type. (Target_i386::got_plt_): Change type. Change all references. (Target_i386::got_section): Create instance of new class. (Output_data_got_plt_i386::do_write): New function. * x86_64.cc (Output_data_got_plt_x86_64): New class. (Output_data_plt_x86_64::Output_data_plt_x86_64): Change type of got_plt parameter. Change all callers. (Output_data_plt_x86_64::layout_): Remove. (Output_data_plt_x86_64::got_plt_): Change type. (Target_x86_64::got_plt_): Change type. Change all references. (Target_x86_64::got_section): Create instance of new class. (Output_data_got_plt_x86_64::do_write): New function. (Output_data_plt_x86_64::do_write): Don't write reserved words in GOT. (Target_x86_64<size>::init_got_plt_for_update): Create instance of new class. https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=367f1035d2f7da6fbad69f659208bdb7da3d55dc commit 367f1035d2f7da6fbad69f659208bdb7da3d55dc Author: Cary Coutant <ccoutant@google.com> Date: Wed Apr 2 14:21:14 2014 -0700 Fix handling of __ehdr_start when it cannot be defined. gold/ * defstd.cc (in_segment): Define __ehdr_start here... * layout.cc (Layout::finalize): ...Instead of here. Set the output segment when known. * resolve.cc (Symbol::override_base_with_special): Remember the original binding. * symtab.cc (Symbol::set_output_segment): New function. (Symbol::set_undefined): New function. * symtab.h (Symbol::is_weak_undefined): Check original undef binding. (Symbol::is_strong_undefined): New function. (Symbol::set_output_segment): New function. (Symbol::set_undefined): New function. * target-reloc.h (is_strong_undefined): Remove. (issue_undefined_symbol_error): Call Symbol::is_weak_undefined. Check for hidden undefs. (relocate_section): Call Symbol::is_strong_undefined. * testsuite/Makefile.am (ehdr_start_test_1) (ehdr_start_test_2, ehdr_start_test_3) (ehdr_start_test_4, ehdr_start_test_5): New test cases. * testsuite/Makefile.in: Regenerate. * testsuite/ehdr_start_def.cc: New source file. * testsuite/ehdr_start_test.cc: New source file. * testsuite/ehdr_start_test.t: New linker script. * testsuite/ehdr_start_test_4.sh: New shell script. ----------------------------------------------------------------------- Summary of changes: gold/ChangeLog | 51 ++++++++ gold/defstd.cc | 14 ++ gold/i386.cc | 102 +++++++++++----- gold/layout.cc | 14 ++- gold/resolve.cc | 4 + gold/symtab.cc | 25 ++++ gold/symtab.h | 34 +++++- gold/target-reloc.h | 8 +- gold/testsuite/Makefile.am | 44 +++++++ gold/testsuite/Makefile.in | 223 +++++++++++++++++++++++++++++++---- gold/testsuite/ehdr_start_def.cc | 26 ++++ gold/testsuite/ehdr_start_test.cc | 67 +++++++++++ gold/testsuite/ehdr_start_test.t | 42 +++++++ gold/testsuite/ehdr_start_test_4.sh | 40 ++++++ gold/x86_64.cc | 110 ++++++++++++------ 15 files changed, 699 insertions(+), 105 deletions(-) create mode 100644 gold/testsuite/ehdr_start_def.cc create mode 100644 gold/testsuite/ehdr_start_test.cc create mode 100644 gold/testsuite/ehdr_start_test.t create mode 100755 gold/testsuite/ehdr_start_test_4.sh Fixed on trunk and backported to binutils-2.24 branch. |