I'm compiling my kernel as a flat binary file using gcc and would like to know if there is a setting to output a debug file or something where I can find out the function addresses for all my functions??
I'd like to add breakpoints in bfe2(bochs) but I need to know the function addresses etc..
Thanks
Finding out Function addresses from gcc
Re:Finding out Function addresses from gcc
I use the -Map mapfile option for ld which does what you want. I am not sure if this option will work as a gcc parameter or not. If not, you can easily seperate your build steps into a gcc -c command and a ld command.
Re:Finding out Function addresses from gcc
objdump -d a.out | grep "^[^ ]"
Every good solution is obvious once you've found it.
Re:Finding out Function addresses from gcc
I use that too, but I parse the map file to only give me things I'm interested in:I use the -Map mapfile option for ld which does what you want. I am not sure if this option will work as a gcc parameter or not. If not, you can easily seperate your build steps into a gcc -c command and a ld command.
cat kernel.*.Map | grep " 0x00000000" | sort | less
Not that sure about the grep, but it's something like this.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Finding out Function addresses from gcc
The CodePoet strikes again with Yet Another Useful Comment ...srthb wrote: gcc -g !
the '-g' flag in GCC turns on internal debugging information. It is certainly necessary if you wish 'objdump -d' to work, for instance (afaik), but it will not provide *you* the information until you have a GDB-compliant debugger ... and i doubt bochs or any other virtual PC can go that far ...
Re:Finding out Function addresses from gcc
objdump always works, even with stripped executables. -g just adds additional information (like, variable names), but all functions with external linkage are required to keep their symbol names anyway (or you couldn't link to them).Pype.Clicker wrote: The '-g' flag in GCC turns on internal debugging information. It is certainly necessary if you wish 'objdump -d' to work, for instance (afaik)...
Little to do with GDB. External linkage symbols are defined by ELF (or whatever format you use), and the rest by the debugging format you chose (e.g. DWARF). Either are well defined, and understood by several other debuggers....but it will not provide *you* the information until you have a GDB-compliant debugger...
Just to be correct. (Hi Candy! )
Every good solution is obvious once you've found it.