Search code examples
coperating-systemembeddedelfbsp

Can the value _edata be inferred by info in the ELF Header or Program Header?


Is there any information in the elf headers that show where _edata is located?

Am aware I can search the whole image for the symbol but would like to know where it is from information in the headers...


Solution

  • The virtual address (p_vaddr) of the data segment (the PT_LOAD segment that's writable) plus its size on disk (p_filesz) gives you the equivalent of _edata if you mean for it to be just past the end of initialized data and before bss. If you also want to count bss, use the full size in memory (p_memsz) instead of the size on disk.