On 11/06/2025 07.54, Sertonix wrote:
On Wed Jun 11, 2025 at 6:07 AM CEST, Michael Tokarev wrote:
On 10.06.2025 23:36, Sertonix wrote:
On Tue Jun 10, 2025 at 10:32 PM CEST, Michael Tokarev wrote:
On 10.06.2025 20:58, Sertonix wrote:
Adding -pie to LDFLAGS caused s390-ccw.img to become dynamically linked.
Why do you think -pie causes it to become dynamically linked?
/mjt
The documentation (at least for gcc) states that the -pie option produces
a *dynamically* linked position independent executable. (And I verified
that the patch changes the resulting binary from dynamically linked to
statically linked).
Ok.
Why I asked is because -pie by its own does not change "dynaminess" of
an executable.
I am uncertain what you mean with "dynaminess" but I mean the ELF file
type, whether or not an interpreter is set and some additional sections
(like .dynamic) exist.
-pie has been introduced for s390-ccw in commit d884c86dcd "s390/bios:
Make the s390-ccw.img relocatable" (9 Mar 2015). Before this commit,
s390x-ccw.img has been dynamically linked too. Now with current
master (commit bc98ffdc75), removing -Wl,-fpie from LDFLAGS does not
change the fact that the image is linked dynamically.
The prebuild binary before d884c86dcd was added in 553ce81c31e4 and shows as
statically linked: (ET_EXEC is the ELF file type of static binaries)
~/src/qemu$ scanelf pc-bios/s390-ccw.img
TYPE FILE
ET_EXEC pc-bios/s390-ccw.img
and when the binary was rebuild after d884c86dcd in 2d5eeef1c0be it shows
as dynamically linked:
~/src/qemu$ scanelf pc-bios/s390-ccw.img
TYPE FILE
ET_DYN pc-bios/s390-ccw.img
(Same results with file(1) and readelf -l)
I was initially also surprised by this (since there was no "-static" flag in
the Makefile before the change to "-pie"), but I can also reproduce these
results. I didn't find anything related to that in the documentation, but it
seems like "-nostdlib" without "-pie" causes the linker to emit a statically
linked binary, and with "-pie" it's dynamically instead?
Anyway, this patch here looks fine to me, so I'll queue it for the next time
when the s390-ccw.img needs an update (might take a while, though, so please
be patient).
Thanks,
Thomas