stlw wrote:
What is the nm command
The
nm command is a standard UNIX tool (part of the IEEE Std 1003.1-2008 (“POSIX.1”) specification) to extract symbols from object files like executables and shared libraries. (Similar to readelf -s, but it accepts not only elf, but other formats as well, and the output is easier to parse by scripts)
stlw wrote:
and how the output it produces different from one that Bochs accepts ?
I didn't understand ...
The difference is as I wrote before: nm adds an additional coloumn between the address and the symbol's name, the symbol's type. That's a one letter code, something like "t" for local text symbol, "T" for external text symbol, "d" for local data symbol etc.
For example:
Code:
0000000000000000 b .bss
0000000000000000 n .comment
0000000000000004 C const_global
0000000000000000 R const_global_init
0000000000000000 d .data
0000000000000000 r .eh_frame
000000000000000b T function_with_param
0000000000000004 C global
0000000000000000 D global_init
0000000000000027 T main
0000000000000000 a main.c
0000000000000000 n .note.GNU-stack
0000000000000000 r .rodata
0000000000000000 t static_function
0000000000000000 b static_global
0000000000000004 d static_global_init
0000000000000004 b static_local.1733
0000000000000008 d static_local_init.1732
0000000000000000 t .text
So as you can see, the only difference is that one letter type code, otherwise it's exactly the same format as bochs' symbol file. If bochs were to read nm format, it wouldn't have to care about the type code, it could simply skip it (but if you want to differentiate between data and text symbols, you could).
The
example I've provided for you in the other topic, was actually
made with nm too:
Code:
nm bootboot.elf | sort | sed 's/\ A\ /\ /g' > bootboot.sym
But that was easy because I wrote the Assembly in a way that only "A" (global address) types were defined in the elf, so I could simply remove that " A " string part from the middle with sed. Another option could be cut perhaps.
Cheers,
bzt