Bug 26223 - [2.35/2.36 Regression] ld now fails to take an executable as input
Summary: [2.35/2.36 Regression] ld now fails to take an executable as input
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.35
: P2 normal
Target Milestone: 2.35
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-09 15:08 UTC by Michael Tokarev
Modified: 2020-07-10 11:00 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2020-07-09 00:00:00


Attachments
Proposed patch (1.67 KB, patch)
2020-07-10 11:00 UTC, Nick Clifton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Tokarev 2020-07-09 15:08:42 UTC
Apparently since this commit:

commit a87e1817a435dab6c6c042f9306497c9f13d4236
Author: Nick Clifton <nickc@redhat.com>
Date:   Thu May 28 17:43:21 2020 +0100

    Have the linker fail if any attempt to link in an executable is made.

            PR 26047
            * ldelf.c (ldelf_after_open): Fail if attempting to link one
            executable into another.  Ensure that the test is made for all
            forms of linking.

ld fails to build, for example, seabios, which is a bios/firmware for x86 platform and needs to have 16bit startup code. 

Current seabios source tarball available for download from
https://www.seabios.org/downloads/seabios-1.13.0.tar.gz 
(it is a relatively small self-contained project), here's
the relevant output:

seabios-1.13.0 $ make silentoldconfig
seabios-1.13.0 $ make V=1 PYTHON=python3
...
  Linking out/rom16.o
ld -T out/romlayout16.lds out/code16.o -o out/rom16.o
  Stripping out/rom16.strip.o
strip out/rom16.o -o out/rom16.strip.o
  Linking out/rom.o
ld -N -T out/romlayout32flat.lds out/rom16.strip.o out/rom32seg.strip.o out/code32flat.o -o out/rom.o
ld: cannot use executable file 'out/rom16.strip.o' as input to a link
make: *** [Makefile:187: out/rom.o] Error 1
seabios-1.13.0 $ _

Previous versions of ld accepted this file just fine
and produced valid out/bios.bin in the end.

Might be it is possible to change seabios in a way to not require linking an executable into executable, I dunno. The whole firmware build thing is always somewhat funny..

Thanks,

/mjt
Comment 1 Nick Clifton 2020-07-10 11:00:48 UTC
Created attachment 12689 [details]
Proposed patch

Hi Guys,

  I had not realized that a new PR had been opened, so I actually created this patch for PR 26047.

  Please could you give this patch a try and see if it solves the problem for you.  You will need to add the (new) "-z allowexec" option to your linker command line in order for the patch to take affect.

Cheers
  Nick