[Bug gold/10887] New: building memtest86 causes segfault in LD.

View: New views
8 Messages — Rating Filter:   Alert me  

[Bug gold/10887] New: building memtest86 causes segfault in LD.

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Using gold from 2.20 to build memtest86-3.4 causes a segfault in LD, back trace :

#0  gold::Output_section::add_output_section_data (this=0x0, inp=0xbfffc6dc)
    at ../../binutils-2.20/gold/output.cc:2001
#1  0x0810bfe3 in gold::Output_section::add_output_section_data (this=0x0,
    posd=0x82dac10) at ../../binutils-2.20/gold/output.cc:1959
#2  0x080cdb75 in void gold::Layout::sized_create_version_sections<32,
false>(gold::Versions const*, gold::Symbol_table const*, unsigned int,
std::vector<gold::Symbol*, std::allocator<gold::Symbol*> > const&,
gold::Output_section const*)
    ()
#3  0x080c63f5 in gold::Layout::finalize (this=0xbfffe930,
    input_objects=0xbfffed40, symtab=0xbfffead4, target=0x824a820,
    task=0x82bd868) at ../../binutils-2.20/gold/layout.cc:1555
#4  0x080c65e3 in gold::Layout_task_runner::run (this=0x82bd080,
    workqueue=0xbfffee04, task=0x82bd868)
    at ../../binutils-2.20/gold/layout.cc:140
#5  0x080b462f in gold::Task_function::run (this=0x82bd868,
    workqueue=0xbfffee04) at ../../binutils-2.20/gold/workqueue.h:178
#6  0x08192f89 in gold::Workqueue::find_and_run_task (this=0xbfffee04,
    thread_number=0) at ../../binutils-2.20/gold/workqueue.cc:314
#7  0x0819321c in gold::Workqueue::process (this=0xbfffee04, thread_number=0)
    at ../../binutils-2.20/gold/workqueue.cc:480
#8  0x0804bc64 in main (argc=65536, argv=0x10001)
    at ../../binutils-2.20/gold/main.cc:246


It appears that in the Layout::sized_create_version_sections function the first
thing is does is:

  Output_section* vsec = this->choose_output_section(NULL, ".gnu.version",
                       elfcpp::SHT_GNU_versym,
                       elfcpp::SHF_ALLOC,
                       false);

which can return NULL, then a few lines down it does:

  vsec->add_output_section_data(vdata);

which fails because vsec is NULL.

Upgrading to snapshot from 20091102 I now get the error:

internal error in address, at output.h:126

This doesn't trap in gdb, please let me know what extra information you need.

--
           Summary: building memtest86 causes segfault in LD.
           Product: binutils
           Version: 2.21 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gold
        AssignedTo: ian at airs dot com
        ReportedBy: scott dot sourceware dot 2009 at scottrix dot co dot uk
                CC: bug-binutils at gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=10887

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils

[Bug gold/10887] building memtest86 causes segfault in LD.

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From scott dot sourceware dot 2009 at scottrix dot co dot uk  2009-11-02 16:33 -------
Just set a break point on exit (which I am assuming is from the assert, the back
trace of this gives:

#0  0xb7d6e354 in exit () from /lib/libc.so.6
#1  0x080b32de in gold::gold_exit (status=false)
    at ../../binutils-2.20/gold/gold.cc:62
#2  0x080b332f in gold::do_gold_unreachable (
    filename=0x81df850 "../../binutils-2.20/gold/output.h", lineno=126,
    function=0x81f2674 "address") at ../../binutils-2.20/gold/gold.cc:93
#3  0x08121cac in void gold::Output_data_dynamic::sized_write<32,
false>(gold::Output_file*) ()
#4  0x0810ce0e in gold::Output_section::do_write (this=0x82be2c0, of=0x82ad3a0)
    at ../../binutils-2.20/gold/output.cc:2780
#5  0x080be175 in gold::Output_data::write (this=0xbfffe930, of=0x82ad3a0)
    at ../../binutils-2.20/gold/output.h:275
#6  gold::Layout::write_output_sections (this=0xbfffe930, of=0x82ad3a0)
    at ../../binutils-2.20/gold/layout.cc:3493
#7  0x08193859 in gold::Workqueue::find_and_run_task (this=0xbfffee04,
    thread_number=0) at ../../binutils-2.20/gold/workqueue.cc:314
#8  0x08193aec in gold::Workqueue::process (this=0xbfffee04, thread_number=0)
    at ../../binutils-2.20/gold/workqueue.cc:480
#9  0x0804bc64 in main (argc=1953326445, argv=0x5f747365)
    at ../../binutils-2.20/gold/main.cc:246

HTH.

--


http://sourceware.org/bugzilla/show_bug.cgi?id=10887

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils

[Bug gold/10887] building memtest86 causes segfault in LD.

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2009-11-04 16:36 -------
Subject: Bug 10887

CVSROOT: /cvs/src
Module name: src
Changes by: ian@... 2009-11-04 16:35:51

Modified files:
        gold           : ChangeLog arm.cc i386.cc powerpc.cc sparc.cc
                         x86_64.cc

Log message:
        PR 10887
        * arm.cc (Target_arm::do_finalize_sections): Don't add dynamic
        tags if data is discarded by linker script.
        * i386.cc (Target_i386::do_finalize_sections): Likewise.
        * powerpc.cc (Target_powerpc::do_finalize_sections): Likewise.
        * sparc.cc (Target_sparc::do_finalize_sections): Likewise.
        * x86_64.cc (Target_x86_64::do_finalize_sections): Likewise.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.344&r2=1.345
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/arm.cc.diff?cvsroot=src&r1=1.28&r2=1.29
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/i386.cc.diff?cvsroot=src&r1=1.98&r2=1.99
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/powerpc.cc.diff?cvsroot=src&r1=1.19&r2=1.20
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/sparc.cc.diff?cvsroot=src&r1=1.23&r2=1.24
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/x86_64.cc.diff?cvsroot=src&r1=1.91&r2=1.92



--


http://sourceware.org/bugzilla/show_bug.cgi?id=10887

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils

[Bug gold/10887] building memtest86 causes segfault in LD.

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2009-11-04 16:36 -------
Subject: Bug 10887

CVSROOT: /cvs/src
Module name: src
Branch: binutils-2_20-branch
Changes by: ian@... 2009-11-04 16:36:08

Modified files:
        gold           : ChangeLog arm.cc i386.cc powerpc.cc sparc.cc
                         x86_64.cc

Log message:
        PR 10887
        * arm.cc (Target_arm::do_finalize_sections): Don't add dynamic
        tags if data is discarded by linker script.
        * i386.cc (Target_i386::do_finalize_sections): Likewise.
        * powerpc.cc (Target_powerpc::do_finalize_sections): Likewise.
        * sparc.cc (Target_sparc::do_finalize_sections): Likewise.
        * x86_64.cc (Target_x86_64::do_finalize_sections): Likewise.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_20-branch&r1=1.281.2.8&r2=1.281.2.9
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/arm.cc.diff?cvsroot=src&only_with_tag=binutils-2_20-branch&r1=1.8.2.2&r2=1.8.2.3
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/i386.cc.diff?cvsroot=src&only_with_tag=binutils-2_20-branch&r1=1.88.4.2&r2=1.88.4.3
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/powerpc.cc.diff?cvsroot=src&only_with_tag=binutils-2_20-branch&r1=1.13.4.2&r2=1.13.4.3
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/sparc.cc.diff?cvsroot=src&only_with_tag=binutils-2_20-branch&r1=1.17.4.2&r2=1.17.4.3
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gold/x86_64.cc.diff?cvsroot=src&only_with_tag=binutils-2_20-branch&r1=1.85.2.2&r2=1.85.2.3



--


http://sourceware.org/bugzilla/show_bug.cgi?id=10887

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils

[Bug gold/10887] building memtest86 causes segfault in LD.

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From ian at airs dot com  2009-11-04 16:41 -------
Thanks for the bug report.  I've patched the linker to avoid the crash.

However, the core problem is that the linker script expects that the dynamic
reloc sections will have specific names, and gold does not use those names.  
gold puts all the dynamic relocs in a section named .rel.dyn.  So while I have
fixed the crash, the effect is that the linker script will discard all the
dynamic relocs, which I think is not what is intended. I think the linker script
might be better written as something like
    .rel.dyn { *(.rel.*) }
or simply adding
    .rel.dyn { *(.rel.dyn .rel.dyn.*) }
like the other cases will also fix the problem.

--
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://sourceware.org/bugzilla/show_bug.cgi?id=10887

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils

[Bug gold/10887] building memtest86 causes segfault in LD.

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From scott dot sourceware dot 2009 at scottrix dot co dot uk  2009-11-06 09:40 -------
Applied the patches to binutils-2.20 and it makes no difference to the
segmentation fault.  I also added the line:

.rel.dyn     : { *(.rel.dyn    .rel.dyn.*) }

to the memtest86 memtest_shared.lds linker script.

--
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


http://sourceware.org/bugzilla/show_bug.cgi?id=10887

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils

[Bug gold/10887] building memtest86 causes segfault in LD.

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From ian at airs dot com  2009-11-06 14:14 -------
Try the mainline development sources.  I didn't test those patches applied to
the 2.20 branch.

--


http://sourceware.org/bugzilla/show_bug.cgi?id=10887

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils

[Bug gold/10887] building memtest86 causes segfault in LD.

by Bugzilla from sourceware-bugzilla@sourceware.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


------- Additional Comments From scott dot sourceware dot 2009 at scottrix dot co dot uk  2009-11-06 15:08 -------
The snapshot from today works.  Many thanks.

--
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED


http://sourceware.org/bugzilla/show_bug.cgi?id=10887

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@...
http://lists.gnu.org/mailman/listinfo/bug-binutils