This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Help with extremely basic ld linker script
- From: Thomas Nyberg <tomnyberg at gmail dot com>
- To: binutils at sourceware dot org
- Date: Mon, 19 Jan 2015 18:13:38 +0100
- Subject: Help with extremely basic ld linker script
- Authentication-results: sourceware.org; auth=none
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