Help with extremely basic ld linker script

Alan Modra amodra@gmail.com
Mon Jan 19 23:42:00 GMT 2015


On Mon, Jan 19, 2015 at 06:13:38PM +0100, Thomas Nyberg wrote:
> > 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!

No.  You can't change section alloc/non-alloc, but why not get this
right in your assembly?  See gas info doc .section description.

objcopy may also be doing some other things for you, not available in
ld:  You can't drop relocations that boot.o may have had, ie. there is
no way to tell ld to not relocate a section.

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list