In an ELF file, how does the address for _start get detemined?
The _start
symbol may be defined in any object file. Normally it is generated automatically (it corresponds to main
in C). You can generate it yourself, for instance in an assembler source file:
.globl _start
_start:
// assembly here
When the linker has processed all object files it looks for the _start
symbol and puts its value in the e_entry
field of the elf header. The loader takes the address from this field and makes a call to it after it has finished loading all sections in memory and is ready to execute the file.
Under what circumstances, if any, would an executable ELF file (type == EXEC) not have section headers?
Under what circumstances would it be omitted?
Section info is not needed at execution time, and traditionally is only kept for debugging (e.g. you can get a backtrace for a crash from an executable compiled without any debugging info).
You should be able to remove them with e.g. strip --strip-all
, but that doesn't appear to work.
You could also binary-patch the the file -- e.g. zero out .e_shoff
and .e_shnum
in the ELF header.
Related answer.
How to get user defined function range (begin and end address) in elf file?
nm -S a.out
will show the symbol size (if available). Then you can get the 'end address' from the start address and size.
Related Topics
How to Read the Mouse Button State from /Dev/Input/Mice
Capture Both Exit Status and Output from a System Call in R
Getting "I Won't Open a Connection To" When Connecting to Ftp Server from Google Compute Engine
Microsecond Accurate (Or Better) Process Timing in Linux
Where Does Output of Print in Kernel Go
How to Load Jna Native Support Library Elasticsearch 6.X
"Make" Command for Windows - Possible Options
How to Change Encoding in Many Files
Paste Two Text Lists (One List a File) into One List Separated by Semicolon
How to Specify Non-Capturing Groups in Sed
What Character Sequence Should I Not Allow in a Filename
How to Set Environment Variables on Ec2 Instance via User Data
D-Bus Tutorial in C to Communicate with Wpa_Supplicant
Linux: Run Cron Job in Foreground