Questions tagged [elf]
ELF stands for Executable and Linkable Format, a file format for files containing machine code.
146 questions
2 votes
2 answers
175 views
Update mmap mapping to be readonly without overwriting existing data
I'm making a custom ELF loader to learn how the dynamic loader works behind the scenes, and one of the program headers often found in them is PT_GNU_RELRO, which tells the loader to make that segment ...
1 vote
2 answers
117 views
How to specify ELF shared objects in `LD_PRELOAD` if their path contains a space character?
Paths to ELF shared objects in LD_PRELOAD cannot contain spaces, as space is one of the two list separators, and it cannot be escaped: LD_PRELOAD A list of additional, user-specified, ELF shared ...
1 vote
0 answers
66 views
What is the difference between the ELF Visibility Values STV_INTERNAL and STV_HIDDEN?
I was trying to understand Visibility values in ELF file , and I couldn't Understand the difference between STV_HIDDEN and STV_INTERNAL . After some reseach I found that this may be related to how ...
5 votes
1 answer
487 views
Who maintains architecture IDs (and OS ABIs) for ELF format now?
The latest spec for ELF list many architectures that can be used with it, but some self-assignments are made in the wild (e.g. Chinese LoongArch). Is there anyone coordinating these assignments? ...
2 votes
1 answer
276 views
Calculate byte offset for unquashfs
I'm trying to calculate the -o value for extracting an .AppImage file using unsquashfs on foreign architectures/OSs , but using objdump instead of readelf to make the solution more compatible with OSs ...
1 vote
1 answer
218 views
Why is the stack segment not explicit in ELF files?
Everything mapped in memory is explicit in ELF files except the stack segment. The stack segment is mapped automatically. Why is the stack segment not like other segments, with explicit settings in ...
0 votes
0 answers
520 views
How to cross-compile Linux tools/perf for embedded system?
I am working on an embedded Linux system (kernel-5.19.20) on MIPS, and I want to build tools/perf for my system. I want to have libelf feature enabled when cross compile perf, so I firstly cross-...
0 votes
1 answer
282 views
Calculation of relocation address; ELF
I am learning about the relocation from the ELF reference and this blog, but I can't get my head around calculating the relocation address. Suppose we have two files A and B of type ET_REL, we want ...
9 votes
1 answer
2k views
Why can an aarch64 ELF executable be run on an x86_64 machine?
I compiled a simple "Hello World" C program on Raspberry Pi 3, which was then transferred to an AMD64 laptop. Out of curiosity, I executed it, and it runs even though I did not expect it to: ...
1 vote
0 answers
196 views
Why can't linux use $ORIGIN to find the loader (aka interpreter)
When compiling a binary on Linux there's this thing called the RPATH, which tells the dynamic loader where to look for the shared objects. What I like about the RPATH is that you can vendor a ...
1 vote
1 answer
411 views
Why the same offset of two sections in ELF?
Recently I noticed something in several ELF files which looks for me a bit suspicious under Linux. Taking for example "/bin/ls" file and running readelf on it I can see following: There are ...
1 vote
0 answers
99 views
why some android elf file has interpreter path?
I am learning the elf file format for Android, but I have found that some elf files can specify the loader through the interpreter path in the program header. However, the elf test file I wrote myself ...
-1 votes
1 answer
375 views
Why do I get different results when running a program with ld-linux.so and when changing the interpreter with patchelf?
What's the difference between running a program with ld + --library-path and with changing the loader with patchelf? To illustrate, here is a binary that wouldn't run as is, presumably because of lack ...
3 votes
0 answers
135 views
Why is my 32 bit programs load in 3GB address space mode?
I have noticed, that Manjaro Linux (kernel 6.6.8) loads 32 bit executable files with ADDR_LIMIT_3GB set. Or as: setarch -B --3g. But I have a clear memory, that earlier it was not the case and 32 bit ...
3 votes
2 answers
2k views
Why is path to the interpreter hardcoded in ELF executables?
(This is a general question and not a complaint -- there is probably a good explanation for this.) For a compiled executable, why is path to the interpreter hard-coded into the binary as opposed to ...