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]
Other format: [Raw text]

Re: questions regarding m68k/ColdFire dynamic/shared code


Sorry for sending this to three mailing lists, but I think my problem
spans all three... (gcc for code generation, binutils for .PLT entry
creation by the linker, and glibc for the ld.so.1 questions).

I *think I've got my .PLT entries fixed for ColdFire, and I'm stepping
through the startup of ld.so.1 which the Linux kernel loads at 0x40000000,
with _GLOBAL_OFFSET_TABLE_ at 0x40015db4.

The code in elf/rtld.c _dl_start() first clears bootstrap_map.l_info,
and then attempts to call elf_get_dynamic_info using the GOT to get
there.

The linked code looks like:

0000309c <_dl_start>:
    309c:	4e56 fe40      	linkw %fp,#-448
    30a0:	4fef ffe4      	lea %sp@(-28),%sp
    30a4:	48d7 3c1c      	moveml %d2-%d4/%a2-%a5,%sp@
    30a8:	2a7c 0001 2d0a 	moveal #77066,%a5
    30ae:	4bfb d8fa      	lea %pc@(30aa <_dl_start+0xe>,%a5:l),%a5
    30b2:	4280           	clrl %d0
    30b4:	41ee fe72      	lea %fp@(-398),%a0
    30b8:	4298           	clrl %a0@+
    30ba:	5280           	addql #1,%d0
    30bc:	7234           	moveq #52,%d1
    30be:	b280           	cmpl %d0,%d1
    30c0:	64f6           	bccs 30b8 <_dl_start+0x1c>
    30c2:	41fa ffd8      	lea %pc@(309c <_dl_start>),%a0
    30c6:	91ed 0010      	subal %a5@(16),%a0
    30ca:	2d48 fe5a      	movel %a0,%fp@(-422)
    30ce:	d1d5           	addal %a5@,%a0
    30d0:	2d48 fe62      	movel %a0,%fp@(-414)
    30d4:	260e           	movel %fp,%d3
    30d6:	0683 ffff fe5a 	addil #-422,%d3
    30dc:	2f03           	movel %d3,%sp@-
    30de:	204e           	moveal %fp,%a0
    30e0:	203c 0000 0018 	movel #24,%d0
    30e6:	2275 0800      	moveal %a5@(00000000,%d0:l),%a1
    30ea:	4e91           	jsr %a1@

At the point that the jsr %a1@ at 0x400030ea is executed, %a1 contains
the value:

(gdb) si
0x400030ea in ?? ()
1: $pc = (void *) 0x400030ea
(gdb) p/x $a1
$5 = 0x2d9a
(gdb) p/x $a5
$6 = 0x40015db4   <- matches &_GLOBAL_OFFSET_TABLE_[]
(gdb) p/x $d0
$7 = 0x18
(gdb) x/x 0x40015db4+0x18
0x40015dcc:	0x00002d9a

which is the *offset* from the load address of 0x40000000 to the
function elf_get_dynamic_info, and not its address, so the jsr fails miserably.

The GLOBAL_OFFSET_TABLE at this point looks like:

(gdb) x/20x 0x40015db4
0x40015db4:	0x00015cfc	0x00000000	0x00000000	0x00002c08
0x40015dc4:	0x0000309c	0x00002c7c	0x00002d9a	0x00002f6c
0x40015dd4:	0x000031c2	0x000033cc	0x00004cb8	0x0000327c
0x40015de4:	0x000032b2	0x000032f2	0x00003350	0x00004678
0x40015df4:	0x00016230	0x000043d6	0x0000437a	0x00016234

And everything in there looks like an offset from the load address.
The 4rd entry is the offset to _dl_start(), the 5th is
elf_machine_rela(), the sixth is the offset to elf_get_dynamic_info(),
the 7th is the offset to elf_dynamic_do_rela().

1) Does this look right(i.e. should the GLOBAL_OFFSET_TABLE contain
   the offset for he function entry points, and not its address)?

2) If its wrong, then who should 'adjust' the entries in the
   _GLOBAL_OFFSET_TABLE_ so they hold the addresses?

3) Am I generating the correct code for the call?

4) Could anyone who has the m68k ABI supplement fax me the one/two
   pages describing the GOT/PLT? I can't find it on the web anywhere.

Any help is appreciated.

-- 
Peter Barada                                   Peter.Barada@motorola.com
Wizard                                         781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola)   781-270-0193 (fax)


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