Page 1 of 1
Question about certain GNU tools (objdump,ld,nm,strip)
Posted: Mon May 17, 2004 12:21 pm
by Faw
I have downloaded the sample operating systems from OSD (
http://my.execpc.com/~geezer/osd/) and I have some questions:
The make file for OSD3 (one of the simple demo kernels) has the following:
krnl.x: $(OBJS) $(LDSCRIPT) $(MAKEDEP)
$(LD) -o$@ $(OBJS)
objdump --source $@ >krnl.lst
nm --line-numbers $@ | sort >krnl.sym
strip $@
What the purpose if the objdump, and nm line? I guess it is to save some debug information into krnl.lst and krnl.sym, right? Could I eliminate the 'objdump','nm' and 'strip' command and call LD with the '--strip-all' argument?
Re:Question about certain GNU tools (objdump,ld,nm,strip)
Posted: Mon May 17, 2004 5:12 pm
by Tim
Yes, and yes.
Re:Question about certain GNU tools (objdump,ld,nm,strip)
Posted: Fri May 28, 2004 6:40 am
by Faw
Ok, LD can do the 'strip' command with the --strip-all flag. Is there flag (or flags) in LD that would let me do the same as the 'objdump' and 'nm' commands?
Re:Question about certain GNU tools (objdump,ld,nm,strip)
Posted: Fri May 28, 2004 7:21 am
by Solar
ld is a linker, and as such its purpose isn't to produce any debugging output. So no, you can't do objdump using ld - or there wouldn't be an objdump, right?
This makefile does two things: Create debug output (using objdump and nm) and linking the object files (using ld).
The 'strip' at the end is not strictly necessary because ld has a 'stip-all' option, and you can leave out the debug steps ('objdump' and 'nm'). Actually, if you run 'ld' with strip-all, there won't be any debug information left in the binary for objdump and/or nm to process, so calling them would be rather pointless.
Does that help?
Re:Question about certain GNU tools (objdump,ld,nm,strip)
Posted: Fri May 28, 2004 8:01 am
by Faw
Thanks, it sort of helps...
I ask because I'm trying to use Borland C++BuilderX for OS Development and I have to configure it so it uses the LD linker and NASM. Originally it comes with Borland and MingW toolsets. Since C++BuilderX Personal Edition is free (and fairly decent) I wanted to use it.
Re:Question about certain GNU tools (objdump,ld,nm,strip)
Posted: Fri May 28, 2004 8:02 am
by Pype.Clicker
Faw wrote:
Ok, LD can do the 'strip' command with the --strip-all flag. Is there flag (or flags) in LD that would let me do the same as the 'objdump' and 'nm' commands?
i dunno exactly what "nm" and "objdump" does with those arguments, but you can get the "map" of your built file using -Map <filename> flag in LD.
It will show, among other things, the "LinkerScript and Memory Map"
Code: Select all
Linker script and memory map
0x0000000000000074 . = SIZEOF_HEADERS
.text 0x0000000000000000 0x1c4e0
0x0000000000002000 . = 0x2000
*fill* 0x0000000000000000 0x100002000 00
*(.text)
.text 0x0000000000002000 0x104 bin/kernel.o
0x00000000000020fc farJmp
0x00000000000020e0 enablePaging
0x00000000000020f4 farCall
0x0000000000002000 start
*fill* 0x0000000000002104 0xc 00
.text 0x0000000000002110 0x200 bin/config.o
0x0000000000002232 _prepare
0x00000000000022eb setBreakPoints
However, do not expect line numbers or static function names here ...