This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: RFA: Don't canonicalize STT_SECTION syms
On Sat, Dec 11, 2004 at 03:27:51PM +1030, Alan Modra wrote:
> On Fri, Dec 10, 2004 at 11:34:26PM -0500, Daniel Jacobowitz wrote:
> > On Sat, Dec 11, 2004 at 02:50:43PM +1030, Alan Modra wrote:
> > > On Fri, Dec 10, 2004 at 10:19:29AM -0500, Daniel Jacobowitz wrote:
> > > > so I assume there is more.
> > >
> > > Yeah.
> > >
> > > bfd/ChangeLog
> > > * elfcode.h (elf_slurp_symbol_table): Use bfd_elf_sym_name so that
> > > canonical sections syms have a name.
> >
> > Could you explain why this change is necessary? It's not going back to
> > the same place we were before, and I find this...
>
> Well, you either have this change, revert your change that stopped use
> of the section symbol for relocs, or introduce some elf dependecy into
> objdump. Otherwise objdump -r won't display a name for relocs against
> section syms.
OK, now I see the problem.
> > > -0+00 l d foo 0+0
> > > +0+00 l d foo 0+0 (|foo)
> >
> > to be pretty confusing, since IIRC an undefined reference to foo
> > shouldn't be resolved to that symbol, if the ELF symbol's name is
> > empty.
>
> How is this different from other local symbols?
Like this. Output from my system tools, i.e. well before this patch.
drow@nevyn:~/qtmp% cat foo.s
.section "foo"
.word 0
drow@nevyn:~/qtmp% cat bar.s
.section "bar"
.word foo
drow@nevyn:~/qtmp% as -o foo.o foo.s
drow@nevyn:~/qtmp% as -o bar.o bar.s
drow@nevyn:~/qtmp% readelf -s foo.o bar.o
File: foo.o
Symbol table '.symtab' contains 5 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 SECTION LOCAL DEFAULT 1
2: 00000000 0 SECTION LOCAL DEFAULT 2
3: 00000000 0 SECTION LOCAL DEFAULT 3
4: 00000000 0 SECTION LOCAL DEFAULT 4
File: bar.o
Symbol table '.symtab' contains 6 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 SECTION LOCAL DEFAULT 1
2: 00000000 0 SECTION LOCAL DEFAULT 2
3: 00000000 0 SECTION LOCAL DEFAULT 3
4: 00000000 0 SECTION LOCAL DEFAULT 4
5: 00000000 0 NOTYPE GLOBAL DEFAULT UND foo
drow@nevyn:~/qtmp% ld -r -o foo foo.o bar.o
drow@nevyn:~/qtmp% readelf -s foo
Symbol table '.symtab' contains 11 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 SECTION LOCAL DEFAULT 1
2: 00000000 0 SECTION LOCAL DEFAULT 2
3: 00000000 0 SECTION LOCAL DEFAULT 3
4: 00000000 0 SECTION LOCAL DEFAULT 4
5: 00000000 0 SECTION LOCAL DEFAULT 5
6: 00000000 0 SECTION LOCAL DEFAULT 6
7: 00000000 0 SECTION LOCAL DEFAULT 7
8: 00000000 0 SECTION LOCAL DEFAULT 8
9: 00000000 0 SECTION LOCAL DEFAULT 9
10: 00000000 0 NOTYPE GLOBAL DEFAULT UND foo
drow@nevyn:~/qtmp% objdump -t foo
foo: file format elf32-i386
SYMBOL TABLE:
00000000 l d .text 00000000
00000000 l d .data 00000000
00000000 l d .bss 00000000
00000000 l d foo 00000000
00000000 l d bar 00000000
00000000 l d *ABS* 00000000
00000000 l d *ABS* 00000000
00000000 l d *ABS* 00000000
00000000 l d *ABS* 00000000
00000000 *UND* 00000000 foo
If that showed both of these:
00000000 l d foo 00000000 foo
00000000 *UND* 00000000 foo
I'd be really confused! "Why didn't 'foo' resolve to 'foo'?" the user
asks me...
--
Daniel Jacobowitz