simple C file:
#include <stdio.h>
int main(){
printf("Hello World");
return 0;
}
after compile the code, using readelf -a a.out
, elf info is follow:
Questions:
You may have garbage in the section table or it may be missing completely. All that matters to the dynamic loader is the segment table (program headers), and even then, only the PT_LOAD segments should not overlap*. The other kinds of segments (INTERP, DYNAMIC etc) provide additional info for the loader and usually refer to some parts of the LOAD segments.
*Here's what the spec says:
PT_LOAD The array element specifies a loadable segment, described by
p_filesz
andp_memsz
. The bytes from the file are mapped to the beginning of the memory segment. If the segment's memory size (p_memsz
) is larger than the file size (p_filesz
), the "extra" bytes are defined to hold the value 0 and to follow the segment's initialized area. The file size may not be larger than the memory size. Loadable segment entries in the program header table appear in ascending order, sorted on thep_vaddr
member.
As you can see, there's no mention of overlapping, so it does not seem to be forbidden, although I don't think I've seen any files with overlapping PT_LOAD segments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With