Summary: | hppa ld SIGSEGVs on invalid object files: bfd/elf32-hppa.c:468 : hppa_get_stub_entry() | ||
---|---|---|---|
Product: | binutils | Reporter: | Sergei Trofimovich <slyich> |
Component: | ld | Assignee: | Alan Modra <amodra> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 2.30 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: | 2018-05-22 00:00:00 | |
Attachments: |
bug.o
bug-2.o bug-orig.o |
Description
Sergei Trofimovich
2018-05-19 21:11:57 UTC
Minimal reproducer does not require any external objects: $ hppa2.0-unknown-linux-gnu-ld -shared -o libbug.so bug.o The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7455c018e45766ab7193cbd45f98f781e0dc7d84 commit 7455c018e45766ab7193cbd45f98f781e0dc7d84 Author: Alan Modra <amodra@gmail.com> Date: Mon May 21 21:29:25 2018 +0930 PR23207, hppa ld SIGSEGVs on invalid object files We don't create PLT call stubs for anything in non-alloc sections, so it doesn't pay to go looking for them. The problem is that non-alloc sections aren't processed by group_sections and thus don't get a link_sec set up for them. PR 23207 * elf32-hppa.c (final_link_relocate): Don't look for plt call stubs in non-alloc sections. (In reply to cvs-commit@gcc.gnu.org from comment #2) > The master branch has been updated by Alan Modra <amodra@sourceware.org>: > > https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git; > h=7455c018e45766ab7193cbd45f98f781e0dc7d84 > > commit 7455c018e45766ab7193cbd45f98f781e0dc7d84 > Author: Alan Modra <amodra@gmail.com> > Date: Mon May 21 21:29:25 2018 +0930 This seems to fix the minimal reproducer, but not original bug. ld still SIGSEGVs. Bigger minimal file that still SIGSEGVs: // $ cat bug.i a() { b(); } __asm__(".section .gnu.warning."); c() { b(); } Same steps to reproduce: $ hppa2.0-unknown-linux-gnu-gcc -fPIC -c bug.i -o bug.o $ hppa2.0-unknown-linux-gnu-gcc -shared -fPIC bug.o -o libbug.so Will attach bigger object file as well. Created attachment 11033 [details]
bug-2.o
(In reply to Sergei Trofimovich from comment #4) > Created attachment 11033 [details] > bug-2.o crash backtrace for it: $ gdb --args ~/dev/git/binutils-gdb-hppa2.0/ld/ld-new -shared -o libbug.so bug.o ... (gdb) bt #0 0x00005555555c980b in hppa_stub_name (input_section=0x0, sym_sec=0x0, hh=0x555555906b50, rela=0x55555591f8d0) at ../../binutils-gdb/bfd/elf32-hppa.c:469 #1 0x00005555555cdd61 in elf32_hppa_size_stubs (output_bfd=0x555555903f20, stub_bfd=0x555555918580, info=0x5555558ebd20 <link_info>, multi_subspace=0, group_size=1, add_stub_section=0x5555555a2b59 <hppaelf_add_stub_section>, layout_sections_again=0x5555555a2c58 <hppaelf_layout_sections_again>) at ../../binutils-gdb/bfd/elf32-hppa.c:2925 #2 0x00005555555a2e07 in gldhppalinux_after_allocation () at ehppalinux.c:354 #3 0x000055555559af2a in ldemul_after_allocation () at ../../binutils-gdb/ld/ldemul.c:76 #4 0x0000555555590259 in lang_process () at ../../binutils-gdb/ld/ldlang.c:7403 #5 0x000055555559466e in main (argc=5, argv=0x7fffffffcd98) at ../../binutils-gdb/ld/ldmain.c:438 Created attachment 11034 [details]
bug-orig.o
bug-orig.o is an object file produced by gcc on libressl-2.6.4
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=215f527155ea776fff3f2f836d5da1e300e8c370 commit 215f527155ea776fff3f2f836d5da1e300e8c370 Author: Alan Modra <amodra@gmail.com> Date: Tue May 22 18:34:18 2018 +0930 PR23207, hppa ld SIGSEGVs on invalid object files The last patch was enough to cure the testcase, but not the original object file. This patch does the same for hppa as is done for ppc64, simply test for the section belonging to a group. I've also restricted stubs to load, alloc, code sections. PR 23207 * elf32-hppa.c (hppa_get_stub_entry): Return NULL when link_sec is NULL. (elf32_hppa_size_stubs): Only create stubs for load, alloc, code sections. (final_link_relocate): Revert last change. Fixed |