Help with extremely basic ld linker script

Thomas Nyberg tomnyberg@gmail.com
Mon Jan 19 17:13:00 GMT 2015


I'm writing an (extremely) simple boot sector. Right now my input 
assembly file is

boot.s
---------------------------
.section .kernel
.here:
     jmp .here

.skip 512 - 2 - (. - .here)

.byte 0x55
.byte 0xaa
---------------------------

I produce my boot sector by running the following commands:

 > as boot.s -o boot.o
 > objcopy -O binary --set-section-flags .kernel=alloc 
--only-section=.kernel boot.o boot.img

My use of objcopy is a little bizarre (imo), but essentially what it 
does is simply extract the literal .kernel section in the object file 
and write it to another file. This results in a 512 byte file which is a 
valid bootsector.

Now what I would like is to do this with a linker script. I've read 
different manuals and tried quite a few things, but kept running into 
issues. Is there an easy way to produce something equivalent to what my 
first method does? Thanks so much for any help!

Cheers,
Thomas



More information about the Binutils mailing list