Bug 21518 - ld.gold should ignore -pie flag for --oformat=binary mode (ld.bfd does)
Summary: ld.gold should ignore -pie flag for --oformat=binary mode (ld.bfd does)
Status: UNCONFIRMED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.27
: P2 normal
Target Milestone: ---
Assignee: Cary Coutant
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-24 21:12 UTC by Sergei Trofimovich
Modified: 2018-11-24 13:03 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich 2017-05-24 21:12:26 UTC
It came up as a build failure of dosemu on gcc-7 with --enable-default-pie:
    https://bugs.gentoo.org/show_bug.cgi?id=618366

Simple reproducer (imagine '-pie' is a default):

$ cat a.S
.text
.code16
  .globl _start16
_start16:

# this works
$ gcc -pie -fuse-ld=gold -Wl,-Ttext,100,-e,_start16,--oformat,binary -nostdlib -s -o foo.com a.S
/usr/lib/gcc/x86_64-pc-linux-gnu/7.1.0/../../../../x86_64-pc-linux-gnu/bin/ld.gold: fatal error: binary output format not compatible with -shared or -pie or -r
collect2: error: ld returned 1 exit status

# this fails
$ gcc -pie -fuse-ld=bfd -Wl,-Ttext,100,-e,_start16,--oformat,binary -nostdlib -s -o foo.com a.S

Arguably '-pie' has no role here as the output format is not really an ELF.

$ x86_64-pc-linux-gnu-ld.gold --version
GNU gold (Gentoo 2.27 p1.0 2.27) 1.12