I'm a simple hobbiest programmer with no formal education who recently
started working in Linux, I was screwing around on the internet the
other day and found a tutorial on creating super tiny elf
executables. I did the tutorial and would now like to write a small
program that when run can print out the following list of things.
1. Exact place in memory where the program starts and what is found
there.
2. Exact memory location of the beginning of the elf header and how
it relates to #1.
3. Exact length of ehdr and the location of the end of ehdr in memory
and what comes directly after that.
4. Exact memory location of _start.
5. Exact memory location and size of phdr.
Now I understand how to figure the size of any of the sections without
knowing exact memory addresses:
--Code--
ehdr:
.... ehdr stuff goes here ...
(at end of ehdr)
ehdrsize equ $ - ehdr
However, how would I look back into memory from within the .text
section and return the actual address of ehdr?
Is there any way of returning the actual address of the .text
section's beginning or maybe even the calling routine?
I have searched google pretty hard and I don't think I am going to
find any code examples there so I had hoped maybe one of you could
help.
Thanks for your help.