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

Fix nix gcc vanishing paths #578

Open
ConnorNelson opened this issue Sep 26, 2024 · 0 comments
Open

Fix nix gcc vanishing paths #578

ConnorNelson opened this issue Sep 26, 2024 · 0 comments
Labels

Comments

@ConnorNelson
Copy link
Member

We shouldn't have /nix/store/... paths in our ELFs. Our nix stores are not stable, we might garbage collect them at any point. This is largely separate from challenge authors compiling in the dojo and uploading the created files (we should find a smoother development process that sidesteps this entirely). Instead, this has to do with the idea that a user might compile a program in their home directory, and that program should continue to work in any challenge image. In this case, ld should actually be from nix, since we have no idea if the challenge image will have an ld. We still might run into issues related to ld and the libraries changing (upgrading for example), but we can be way more stable than the current /nix/store/... references.

Currently:

hacker@paths~the-root:~$ echo 'int main() { }' > test.c
hacker@paths~the-root:~$ gcc test.c -o test
hacker@paths~the-root:~$ ldd test
	linux-vdso.so.1 (0x00007ffc6f3ed000)
	libc.so.6 => /nix/store/r8qsxm85rlxzdac7988psm7gimg4dl3q-glibc-2.39-52/lib/libc.so.6 (0x00007c13a6b52000)
	/nix/store/r8qsxm85rlxzdac7988psm7gimg4dl3q-glibc-2.39-52/lib/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00007c13a6d41000)
hacker@paths~the-root:~$ readelf -a test | grep nix
      [Requesting program interpreter: /nix/store/r8qsxm85rlxzdac7988psm7gimg4dl3q-glibc-2.39-52/lib/ld-linux-x86-64.so.2]
 0x000000000000001d (RUNPATH)            Library runpath: [/nix/store/r8qsxm85rlxzdac7988psm7gimg4dl3q-glibc-2.39-52/lib:/nix/store/qksd2mz9f5iasbsh398akdb58fx9kx6d-gcc-13.2.0-lib/lib]
hacker@paths~the-root:~$ strings test | grep nix
/nix/store/r8qsxm85rlxzdac7988psm7gimg4dl3q-glibc-2.39-52/lib/ld-linux-x86-64.so.2
/nix/store/r8qsxm85rlxzdac7988psm7gimg4dl3q-glibc-2.39-52/lib:/nix/store/qksd2mz9f5iasbsh398akdb58fx9kx6d-gcc-13.2.0-lib/lib

If we need an absolute path to ld for the interpreter (probably we do, that would make sense?) it should be something like /run/dojo/lib/ld-linux-x86-64.so.2 (on ubuntu:24.04 I see /lib64/ld-linux-x86-64.so.2). We can make sure libc and friends end up in /run/dojo/lib and point RUNPATH there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant