Generating symbol map for flat binary with LD

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
moth

Generating symbol map for flat binary with LD

Post by moth »

Anyone know how to generate a file containing addresses and symbols while linking together several objects into a flat binary using LD?  Below is the linker script I'm currently using:

OUTPUT_FORMAT(binary)
ENTRY(boot_start)
SECTIONS
{
     .text 0x00007C00: {
          *(.text)
     }
     .data : {
          *(.data)
     }
     .bss : {
          *(.bss)
     }
     .rodata : {
          *(.rodata)
     }
}

and my LD command line is something like:

ld -nostdlib -Bstatic --no-undefined -L./ -T boot.lnk -o boot.bin boot_main.o boot_fs.o

I would like to have a file containing addresses and symbol names something like:

00000000 boot_start
0000004c bootstrap
000001b9 boot_main
...

Which I could then load into bochs's debugger and get easier to fallow debugging:

<bochs:1> load-symbols global "boot.sym" 0x7c00
<bochs:2> lb 0x7c00
<bochs:3> c
(0) Breakpoint 1, 0x7c00 in ?? ()
Next at t=1221697
(0) [0x00007c00] 0000:7c00 (boot_start+0): jmp 7c4c                  ; eb4a
<bochs:4>

Any ideas?
Post Reply