bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gold/22266] New: ld.gold produces invalid output when linking with


From: bgamari at gmail dot com
Subject: [Bug gold/22266] New: ld.gold produces invalid output when linking with --relocatable
Date: Thu, 05 Oct 2017 22:25:49 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=22266

            Bug ID: 22266
           Summary: ld.gold produces invalid output when linking with
                    --relocatable
           Product: binutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gold
          Assignee: ccoutant at gmail dot com
          Reporter: bgamari at gmail dot com
                CC: ian at airs dot com
  Target Milestone: ---

I recently noticed that the Glasgow Haskell Compiler would break when built
with split sections enabled. After a long process of debugging
(https://ghc.haskell.org/trac/ghc/ticket/14291), I found that the cause is that
ld.gold produces incorrect output when producing relocatable object files.

To demonstrate the issue I put together a small reproduction case fo build anr
amd64 here:  https://github.com/bgamari/T14291-repro.

The testcase consists of three object files taken from a GHCd a linker script.
When linked with `ld.bfd -r` the testcase produces the expected output.
However, when `ld.gold -r` is used the resulting object file appears to be
mangled. Specifically, the input object `Err.o` contains the symbol,

    $ objdump -D Err.o | grep -A6 '<r1Cy_closure>'
    0000000000000000 <r1Cy_closure>:
            ...
      10:   03 00                   add    (%rax),%eax
      12:   00 00                   add    %al,(%rax)
      14:   00 00                   add    %al,(%rax)
            ...

Whereas the output object produced by `ld.gold` contains,

    $ ld.gold --version
    GNU gold (GNU Binutils for Debian 2.28) 1.14
    Copyright (C) 2017 Free Software Foundation, Inc.
    This program is free software; you may redistribute it under the terms of
    the GNU General Public License version 3 or (at your option) a later
version.
    This program has absolutely no warranty.

    $ ld.gold -r -T merge_sections.ld -o out.o Concurrent.o Base.o Err.o

    $ objdump -D out.o | grep -A6 '<r1Cy_closure>'
    0000000000001548 <r1Cy_closure>:
            ...

There is no other symbol named r1Cy_closure in any of the other linked objects.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]