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) > On the other hand, people sometimes confuse the result of -static-pie > as a dynamic executable, especially with older file(1) utility which > reported it as dynamically linked. Latest file(1) release: $ file --version file-5.46 magic file from /usr/share/misc/magic > So my question was badly worded: what I wanted to ask is what makes > you think that adding -pie to the link line makes the resulting > executable to be linked dynamically. > > With all the above in mind, I think the commit message is misleading > a bit. But it'd be interesting to clarify how this image, being > a dynamic executable, worked all these years, and why it has to be > changed now. As mentioned above this is only about the file metadata and doesn't affect the binary code part of the binary. So it is probably just ignored by qemu and shouldn't change the bhaviour of qemu. This is mostly to fix the intend of the commit that added -pie and exclude a libc dependant string from a binary that isn't libc dependant. > I'm definitely not opposing to the change, I just am > curious about this aspect and want a correct commit message. > > Thanks, > > /mjt