Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program headers not in the first page when trying to run on FreeBSD #38

Closed
probonopd opened this issue Sep 3, 2020 · 9 comments
Closed
Labels
block Something is preventing the fulfillement of this issue

Comments

@probonopd
Copy link

probonopd commented Sep 3, 2020

Program headers not in the first page error message when trying to run the contents of extracted AppImages on FreeBSD.

AppImage/AppImageKit#98 (comment)

Same issue with the GCompris AppImage.

Interestingly, this error does not happen e.g., with the Akira AppImage that was made with go-appimage's appimagetool -s deploy: akiraux/Akira#3 (comment)

I don't have any idea yet what may be causing this. Probably something related to the way the ingredients are compiled, or something about the systems/tools they are compiled on?

(May be useful for testing: https://www.nomadbsd.org/)

@probonopd
Copy link
Author

probonopd commented Sep 3, 2020

freebsd/freebsd-src@1cfd0bd seems to have some information on this:

@DarkHelmet433 wrote there in 1998:

Update the ELF image activator to use some of the exec resources rather
than rolling it's own. This means that it now uses the "safe"
exec_map_first_page() to get the ld.so headers rather than risking a panic
on a page fault failure (eg: NFS server goes down).
Since all the ELF tools go to a lot of trouble to make sure everything
lives in the first page for executables, this is a win. I have not seen
any ELF executable on any system where all the headers didn't fit in the
first page with lots of room to spare.

I have been running variations of this code for some time on my pure ELF
systems.

And @emaste added the Program headers not in the first page message in 2015:
freebsd/freebsd-src@41e1b13#diff-d67c2311eb3db76bf6d25a9bde8a531aR758

@probonopd
Copy link
Author

probonopd commented Sep 3, 2020

Possibly caused by
NixOS/patchelf#153

Underlying issue
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229708

@azubieta azubieta added the block Something is preventing the fulfillement of this issue label Sep 23, 2020
@azubieta
Copy link
Contributor

azubieta commented Sep 30, 2020

I'm testing using LIEF tool to change the PT_INTERP segment in ELF files. But now I'm getting an Invalid PT_INTERP error.

Edit

It seems that the ld-linux binary that comes in ubuntu is not compatible with FreeBSD. When executed manually it complains with this message:

ELF type "0" not known
Exec format error

@azubieta
Copy link
Contributor

azubieta commented Sep 30, 2020

The Akira AppImage seems to be built on Centos or Fedora. Maybe their ld-linux version is "better" that the one shipped in Ubuntu

Edit

With patchelf 0.12, brandelf -t linux squashfs-root/usr/lib64/ld-linux-x86-64.so.2 and sysctl compat.linux.osrelease=4.0.00 I was able to make a kcalc AppDir that runs on FuryBSD 🥳

@azubieta
Copy link
Contributor

I guess that I can close this issue, as it's related to patchelf. Please feel free to reopen it if required.

The solution: use patchelf >= 0.12

@probonopd
Copy link
Author

This is excellent news @azubieta - but don't the new patchelf versions cripple our binaries?

@azubieta
Copy link
Contributor

The binaries ran well on FuryBSD after being patched, also they ran on all the docker containers.

Do you remember in which systems this used to happen?

azubieta added a commit that referenced this issue Sep 30, 2020
@probonopd
Copy link
Author

I remember that it crippled Qt libs.

@azubieta
Copy link
Contributor

I'm only patching the executable (not the libraries), maybe that's why it doesn't produce any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
block Something is preventing the fulfillement of this issue
Projects
None yet
Development

No branches or pull requests

2 participants