Bug 18365 - GOLD: AArch64: produces broken dynamic executable
Summary: GOLD: AArch64: produces broken dynamic executable
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: ---
Assignee: Han Shen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-01 15:47 UTC by Nick Clifton
Modified: 2015-05-08 20:12 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Run the doit.* scripts to reproduce the bug (1.06 MB, application/force-download)
2015-05-01 15:47 UTC, Nick Clifton
Details
attachment-35797-0.html (811 bytes, text/html)
2015-05-01 20:37 UTC, Han Shen
Details
conftest.dynamic built in shenhan's environment (2.75 KB, application/octet-stream)
2015-05-05 18:52 UTC, Han Shen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clifton 2015-05-01 15:47:32 UTC
Created attachment 8294 [details]
Run the doit.* scripts to reproduce the bug

Linking dynamic aarch64 executables using gold results in unexecutable binaries.  Unfortunately I do not know how to get the loader to tell me what is wrong with the binary.

Linking using the exact same command line, but using the LD linker, results in a working binary.  Linking static executables works with both linkers.

The uploaded tarball contains a test case that demonstrates the problem.  Running the conftest.dynamic binary generates a seg-fault.  Running the conftest.static binary produces a return code of 0.
Comment 1 Cary Coutant 2015-05-01 18:32:25 UTC
Did this only recently start failing?

Han, can you take a look, please?
Comment 2 Han Shen 2015-05-01 20:37:15 UTC
Created attachment 8296 [details]
attachment-35797-0.html

Hi Cary, sure.

Han

On Fri, May 1, 2015 at 11:32 AM, ccoutant at gmail dot com <
sourceware-bugzilla@sourceware.org> wrote:

> https://sourceware.org/bugzilla/show_bug.cgi?id=18365
>
> Cary Coutant <ccoutant at gmail dot com> changed:
>
>            What    |Removed                     |Added
>
> ----------------------------------------------------------------------------
>              Status|NEW                         |ASSIGNED
>            Assignee|ccoutant at gmail dot com          |shenhan at google
> dot com
>
> --- Comment #1 from Cary Coutant <ccoutant at gmail dot com> ---
> Did this only recently start failing?
>
> Han, can you take a look, please?
>
> --
> You are receiving this mail because:
> You are the assignee for the bug.
>
Comment 3 Han Shen 2015-05-01 22:52:21 UTC
Hi Nick, I was not able to run your script - the 'libc.so' in the archive is not a binary but a linker script pointing to files under your home - "/home/nickc/work/builds/binutils/branches/2.25/aarch64-elf-gold/tests/libc.so.6 /home/nickc/work/builds/binutils/branches/2.25/aarch64-elf-gold/tests/libc_nonshared.a  AS_NEEDED ( /home/nickc/work/builds/binutils/branches/2.25/aarch64-elf-gold/tests/ld-linux-aarch64.so.1"

However I was able to dynamic gold-link conftest.o on an aarch64 box with the following similar command line, and resulted in a runnable binary which exited with 0.

shenhan@k:~/gold-bug$ cat shenhan.dynamic
GOLD=~/gold-aarch64/build/gold/ld-new

${GOLD} \
    --build-id \
    --no-add-needed \
    --eh-frame-hdr \
    --hash-style=gnu \
    -dynamic-linker /lib/ld-linux-aarch64.so.1 \
    -X \
    -EL \
    -maarch64linux \
    -fuse-ld=gold \
    -o conftest.dynamic \
    /usr/lib/gcc/aarch64-linux-gnu/4.8/../../../aarch64-linux-gnu/crt1.o \
    /usr/lib/gcc/aarch64-linux-gnu/4.8/../../../aarch64-linux-gnu/crti.o \
    /usr/lib/gcc/aarch64-linux-gnu/4.8/crtbegin.o \
    conftest.o \
    -L/usr/lib/gcc/aarch64-linux-gnu/4.8 \
    -L/usr/lib/gcc/aarch64-linux-gnu/4.8/../../../aarch64-linux-gnu \
    -L/usr/lib/gcc/aarch64-linux-gnu/4.8/../../../../lib -L/lib/aarch64-linux-gnu \
    -L/lib/../lib -L/usr/lib/aarch64-linux-gnu \
    -L/usr/lib/../lib \
    -L/usr/lib/gcc/aarch64-linux-gnu/4.8/../../.. \
    -lgcc \
    --as-needed -lgcc_s --no-as-needed \
    -lc \
    -lgcc \
    --as-needed -lgcc_s --no-as-needed \
    /usr/lib/gcc/aarch64-linux-gnu/4.8/crtend.o \
    /usr/lib/gcc/aarch64-linux-gnu/4.8/../../../aarch64-linux-gnu/crtn.o


shenhan@k:~/gold-bug$ ./shenhan.dynamic
shenhan@k:~/gold-bug$ ./conftest.dynamic 
shenhan@k:~/gold-bug$ echo $?
0
shenhan@k:~/gold-bug$
Comment 4 Nick Clifton 2015-05-05 13:21:32 UTC
Hi Han,

  Thank you for taking a look at this problem.

> I was not able to run your script - the 'libc.so' in the archive is
> not a binary but a linker script pointing to files under your home -

Doh!  Sorry about that.  I assume that you updated the file in the obvious way ?

> However I was able to dynamic gold-link conftest.o on an aarch64 box with
> the following similar command line, and resulted in a runnable binary which
> exited with 0.

Darn.

Were you able to run the conftest.dynamic executable included in the tarball on your system ?  If so then it must be a bug on the machine I am using.

Please could you upload a copy of the working conftest.dynamic binary so that I can compare it to mine, and see if it runs on my machine.

Cheers
  Nick
Comment 5 Han Shen 2015-05-05 18:51:00 UTC
(In reply to Nick Clifton from comment #4)
> Hi Han,
> 
>   Thank you for taking a look at this problem.
> 
> > I was not able to run your script - the 'libc.so' in the archive is
> > not a binary but a linker script pointing to files under your home -
> 
> Doh!  Sorry about that.  I assume that you updated the file in the obvious
> way ?

Hi Nick, no problem. Yup, I tailored the script to my env.

> 
> > However I was able to dynamic gold-link conftest.o on an aarch64 box with
> > the following similar command line, and resulted in a runnable binary which
> > exited with 0.
> 
> Darn.
> 
> Were you able to run the conftest.dynamic executable included in the tarball
> on your system ?  If so then it must be a bug on the machine I am using.

Yup, both conftest.dynamic and conftest.static from the tarball run correctly on my system.

> 
> Please could you upload a copy of the working conftest.dynamic binary so
> that I can compare it to mine, and see if it runs on my machine.

Attached.

> 
> Cheers
>   Nick
Comment 6 Han Shen 2015-05-05 18:52:33 UTC
Created attachment 8302 [details]
conftest.dynamic built in shenhan's environment

This is the binary built on my environment by command - 

shenhan@k:~/gold-bug$ cat shenhan.dynamic
GOLD=~/gold-aarch64/build/gold/ld-new

${GOLD} \
    --build-id \
    --no-add-needed \
    --eh-frame-hdr \
    --hash-style=gnu \
    -dynamic-linker /lib/ld-linux-aarch64.so.1 \
    -X \
    -EL \
    -maarch64linux \
    -fuse-ld=gold \
    -o conftest.dynamic \
    /usr/lib/gcc/aarch64-linux-gnu/4.8/../../../aarch64-linux-gnu/crt1.o \
    /usr/lib/gcc/aarch64-linux-gnu/4.8/../../../aarch64-linux-gnu/crti.o \
    /usr/lib/gcc/aarch64-linux-gnu/4.8/crtbegin.o \
    conftest.o \
    -L/usr/lib/gcc/aarch64-linux-gnu/4.8 \
    -L/usr/lib/gcc/aarch64-linux-gnu/4.8/../../../aarch64-linux-gnu \
    -L/usr/lib/gcc/aarch64-linux-gnu/4.8/../../../../lib -L/lib/aarch64-linux-gnu \
    -L/lib/../lib -L/usr/lib/aarch64-linux-gnu \
    -L/usr/lib/../lib \
    -L/usr/lib/gcc/aarch64-linux-gnu/4.8/../../.. \
    -lgcc \
    --as-needed -lgcc_s --no-as-needed \
    -lc \
    -lgcc \
    --as-needed -lgcc_s --no-as-needed \
    /usr/lib/gcc/aarch64-linux-gnu/4.8/crtend.o \
    /usr/lib/gcc/aarch64-linux-gnu/4.8/../../../aarch64-linux-gnu/crtn.o
Comment 7 Nick Clifton 2015-05-06 09:49:17 UTC
Hi Han,

> This is the binary built on my environment by command - 

Thanks.  That binary fails to run on our machine, so it must be a problem with our execution environment.  (The machine is one of the Fedora Mustang boards, running F21).  I guess that you can consider this bug report as closed, since it is not reproducible, but before you do that, please could you tell me about your execution environment ?

Cheers
  Nick
Comment 8 Han Shen 2015-05-08 20:12:42 UTC
(In reply to Nick Clifton from comment #7)
> Hi Han,
> 
> > This is the binary built on my environment by command - 
> 
> Thanks.  That binary fails to run on our machine, so it must be a problem
> with our execution environment.  (The machine is one of the Fedora Mustang
> boards, running F21).  I guess that you can consider this bug report as
> closed, since it is not reproducible, but before you do that, please could
> you tell me about your execution environment ?
> 
> Cheers
>   Nick

Hi, Nick, mine is a customized-built Ubuntu on a no-name machine (which means I should not reveal detail about it, sorry), the kernel version is 3.13. 

I'll close the bug.

Thanks,
Han