This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [RFC] PR ld/13621
- From: Alan Modra <amodra at gmail dot com>
- To: Mark Wielaard <mjw at redhat dot com>
- Cc: Richard Henderson <rth at redhat dot com>, binutils at sourceware dot org
- Date: Tue, 7 Feb 2012 22:27:39 +1030
- Subject: Re: [RFC] PR ld/13621
- References: <4F25EAD1.7040601@redhat.com> <20120130032626.GC8407@bubble.grove.modra.org> <20120130082840.GB16460@toonder.wildebeest.org> <20120130131722.GA12169@bubble.grove.modra.org> <1327932837.2714.54.camel@springer.wildebeest.org> <20120130231623.GB12169@bubble.grove.modra.org> <1328003863.2687.22.camel@springer.wildebeest.org>
On Tue, Jan 31, 2012 at 10:57:43AM +0100, Mark Wielaard wrote:
> On Tue, 2012-01-31 at 09:46 +1030, Alan Modra wrote:
> > As far as symbols go, the ELF spec says that st_value for (non-common)
> > symbols in relocatable object files is an offset from the beginning of
> > a section. There is nothing to say that values should be within the
> > section bounds.
>
> But it does also say "If a symbol's value refers to a specific location
> within a section, its section index member, st_shndx, holds an index
> into the section header table." and again when defining SHN_XINDEX it
> says "It indicates that the symbol refers to a specific location within
> a section...". So I would interpret that as saying the offset shouldn't
> be outside the section.
You do have a point. I'll not throw a fit and revert rth's patch
if he still wants to commit it. :)
You can of course easily create symbols outside of a sections. For
example:
.data
.global x
x:
.byte 2, 3, 5, 7, 11, 13, 17, 19, 23
.global y
y = x - '1'
But, yeah, I can't think of a really good reason why you would want to
do this.
--
Alan Modra
Australia Development Lab, IBM