If I use the --pic-executable flag then everything works fine. The loader resolves everything at execution time so there are no wrong addresses.
But, what if I wanted a pure statically linked ELF64 executable with all addresses known at link time? I am probably missing a flag for the linker or smth.
Does anyone know?
@mcoll I'm interested but this is waaaay out of my comfort zone: had to read about ELF segments to even understand what you're talking about...
So, I may have an idea, but I have literally no idea what I'm talking about.
Does gdb has a magic flag that let you trace the segfault? If so, you may be able trace both what's wrong and what libc is doing.
I'm interested in a writeup about that problem when you'll figure it out.
@mcoll Is your code publicly available somewhere?
Is this related or just to happen being the same name? http://www.science.smith.edu/dftwiki/index.php/CSC231_asm_io.asm ?
@ninjatrappeur @mcoll No need to even run through assembly process... just remove the "--dynamic-linker=/usr/lib/ld-linux-x86-64.so.2" from all statically linked programs, and the _start entrypoint will be the first thing run when the ELF image setup is complete.
The example I posted earlier (in C w/ inline asm) will build a simple program that simply returns to the (Linux) OS. However, when you build that ELF and compare it (with readelf -Wa) to crashing one, the diff will be ELF interpreter.
mastodont.cat és un servidor en català de la xarxa social Mastodon, per a la comunitat de llengua i cultura catalana d'arreu d'internet.
Mastodon és descentralitzada i de programari lliure.
Mastodon és dels humans i no dels algoritmes ni dels interessos de corporacions.
Mastodon és per a les persones. No és pas pels anunciants ni pels recol·lectors de dades.