This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: 2.10.91: A problem with LINK_ONCE_DISCARD sections on mipsel-linux


On Tue, 3 Oct 2000, Maciej W. Rozycki wrote:

> On Tue, 3 Oct 2000, Alan Modra wrote:
> 
> > > 	.section .gnu.linkonce.d.dummy,"aw"
> > > 	.int	0x76543210
> > > 
> > > 	.data
> > > 	.int	.gnu.linkonce.d.dummy
> > 
> > FWIW, x86 doesn't bomb, but produces incorrect output.
> > 
> > Contents of section .data:
> >  8049074 7c900408 00000000 10325476
> > 
> > The zeros correspond to the section symbol being referenced by the second
> > copy.
> 
>  Hmm, maybe we could mark such symbols global?...

Well, that would lead to multiply defined symbol errors for normal
(non-linkonce) section symbols.  Actually, after following this path of
reasoning earlier, I came close to retracting my comment about incorrect
output.  Since section symbols must stay local, in some ways it's not
unreasonable for the reference to the removed section symbol to resolve to
zero.  However, it's confusing, and perhaps against the spirit of
link-once sections.  See what happens when we extend your example a
little:

cat > z.s <<EOF
        .section .gnu.linkonce.d.dummy,"aw"
	.globl foo
foo:
        .int    0x76543210
bar:
	.int	0x12345678

        .data
        .int    .gnu.linkonce.d.dummy, foo, bar, bar-foo
EOF
as -o z1.o z.s
as -o z2.o z.s
ld -o zz z1.o z2.o
objdump --full -j .data zz

zz:     file format elf32-i386

Contents of section .data:
 8049074 94900408 94900408 9c900408 04000000  ................
 8049084 00000000 94900408 08000000 04000000  ................
 8049094 10325476 78563412                    .2TvxV4.        

Notice how referencing any local symbol in the dropped section results in
silly values, and whoops, look at the value of `bar' we get for the
included section.

Alan Modra
-- 
Linuxcare.  Support for the Revolution.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]