This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: User defined sections
- To: Nick Clifton <nickc at cambridge dot redhat dot com>
- Subject: Re: User defined sections
- From: Daniël Mantione <daniel at deadlock dot et dot tudelft dot nl>
- Date: Thu, 11 Oct 2001 22:26:49 +0200 (CEST)
- cc: binutils at sources dot redhat dot com
Hello,
I just tried to link statically, so ld.so is not involved. That works
without problems.
Daniël
On 11 Oct 2001, Nick Clifton wrote:
> Hi Daniel,
>
> > > Thirdly - which versions of the tools are you using ? In particular
> > > which version of ld are you using ?
> >
> > Nasm 0.98
> > GNU ld 2.9.5
> > ld.so 2.1.3
>
> Ok, so you are using an old version of ld. It would probably be a
> good idea to upgrade to the most recent release (2.11.2) although
> this will not actually fix your problem :-)
>
> > Does it also crash on your system?
>
> Indeed it does. I note that if I do not use your linker script
> however, the executable runs just fine. Why are you using a custom
> linker script anyway ? The default one appears to work OK:
>
> % gcc problem.o image.o -o prob
> % readelf -S prob | grep custom
> [16] .custom PROGBITS 08049544 000544 000014 00 WAX 0 0 1
>
> Do you need the .custom section to be located at a specific address ?
>
> Anyway I tried adding your .custom modifications to the current
> default linker script and using that, and the linker complains with:
>
> ld: prob: Not enough room for program headers (allocated 6, need 7)
>
> Which is not surprising really since your new section needs a segment
> all to itself. It is possible to work around this by tweaking the
> linker script, but it still produces an executable that seg faults.
>
> The problem is that your load address of 0x0 causes the section to be
> written into protected memory, which generates the seg fault. Since
> you are running this program on a virtual memory system you are never
> going to be able to just choose an arbitrary address for your section.
> It would be much better to allow the linker to do its job, and link
> the section in at an address that it deems fit, and then set up the
> program headers appropriately.
>
> Cheers
> Nick
>
>