This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Help with extremely basic ld linker script
- From: Alan Modra <amodra at gmail dot com>
- To: Thomas Nyberg <tomnyberg at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Tue, 20 Jan 2015 10:12:13 +1030
- Subject: Re: Help with extremely basic ld linker script
- Authentication-results: sourceware.org; auth=none
- References: <54BD3B42 dot 5080809 at gmail dot com>
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