This is the mail archive of the gas2@sourceware.cygnus.com mailing list for the gas2 project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Hi,
Here is some info on my debugging the GNU linker with gdb as suggested.
I just took the small test program of "hello" to avoid those thousands of
assembly instructions.
As you know the output that I get is
hello
dynamic linker: ./tt: unidentifiable procedure reference (address =
0x40062cd8)
Killed
Now what is there at this location and from where is this message coming...
O.K From the assembly I could see the following...
0x40062cd8 [_exithandle+0x6c]: lw %t0,0(%s)
This message is coming from the function _binder when a call to this
function is made as ...
_binder(0x23,0x40062cd8,0x400bf2fo,0x40052fd0)
I do have access to DDE-MIPS SVR4.2 Sources here and that is how I could
locate where this message is coming from.
I am attaching the file binder.c which is part of the libc and rtld for
mipsr4000. The base for the mips-dde-sysv4.2MP port seems to have mainly
come from i386 as base.
- ---- Some clip from that (although I am attaching that file at end ) -----
unsigned long _binder( unsigned long sym_index, unsigned long pc)
{
struct rt_private_map *nlm, *first_lm, *lm;
char *symname;
- - - - - -
- - - - - -
Some line go here .....
/* Note that since the MIPS ABI doesn't provide a means for passing
* lm from the stub routines, so we must get this information
* someplace else. Here we just start with the head of the list
* which is stored in the global variable _ld_loaded. This may
* not be correct for objects which have DT_SYMBOLIC set.
* FIXME!
*/
lm = _rt_address_to_lm(_ld_loaded,pc);
if (!lm) {
_rtfprintf(2, "%s: %s: unidentifiable procedure reference
(addre
ss = 0x%x)\n",(char*) _rt_name,_proc_name,pc);
(void)_rtkill(_rtgetpid(), SIGKILL);
}
- ------------------ End of the clip .. later stuff not here
- -------------------
So here is the message that I am getting .
But how and why is it happening , I could not think.
Any pointers on this....
Could there be any problems with the start up file like crti, crt1 and crtn used. This is how the linking is done ...
--------------------------------------------------------------------------
/usr/local/mips-dde-sysv4.2MP/bin/ld /usr/lib/ld.so.1 /usr/local/mips-dde-sysv4.2MP/lib/crt1.o /usr/local/mips-dde-sysv4.2MP/lib/crti.o /usr/local/mips-dde-sysv4.2MP/lib/values-Xa.o -L/usr/local/lib/gcc-lib/mips-dde-sysv4.2MP/egcs-2.91.57 -L/usr/local/mips-dde-sysv4.2MP/lib -L/usr/local/lib /var/tmp/ccrLBNAM.o -lgcc -L/usr/lib -lc -lgcc /usr/local/mips-dde-sysv4.2MP/lib/crtn.o
GNU ld version 2.9.4 (with BFD 990118)
Supported emulations:
elf32bsmip
--------------------------------------------------------------------------
Could using the crtbegin and crtend help. Why don't the MIPS targets use them..
Thanks for any help and information in advance.
With best regards
Koundinya
Here is the file binder.c (which is a part of the native libc source )that I am attaching...
Thanks for any help in advance.
Koundinya
/* Copyright 1994, Concurrent Computer Corporation -- All rights reserved. */
#ident "@(#)mipsr4000/lib/libc/rtld/mipsr4000/binder.c 8.1.1.2 CCUR"
/* Copyright (c) 1993 UNIX System Laboratories, Inc. */
/* (a wholly-owned subsidiary of Novell, Inc.). */
/* All Rights Reserved. */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF UNIX SYSTEM */
/* LABORATORIES, INC. (A WHOLLY-OWNED SUBSIDIARY OF NOVELL, INC.). */
/* The copyright notice above does not evidence any actual or */
/* intended publication of such source code. */
#ident "@(#)rtld:mips/binder.c 1.16"
/* function binding routine - invoked on the first call
* to a function through the procedure linkage table;
* passes first through an assembly language interface
*
*
* Takes the address of the PLT entry where the call originated,
* the offset into the relocation table of the associated
* relocation entry and the address of the rt_private_map for the entry
*
* Returns the address of the function referenced
*
* On error, causes process to terminate with a SIGKILL
*/
#include <signal.h>
#include "rtinc.h"
#if defined(DEBUG) && !defined(__sgi)
static void print_list(struct rt_private_map *lm);
#elif !defined(__sgi)
static struct rt_private_map *_rt_address_to_lm();
#endif
#ifdef DEBUG
static void
print_list( struct rt_private_map *head_lm )
{
struct rt_private_map *lm;
DPRINTF(LIST,(2, " \n"));
DPRINTF(LIST,(2, "==================================================\n"));
DPRINTF(LIST,(2, " list of lm objects\n"));
DPRINTF(LIST,(2, "==================================================\n"));
for (lm = head_lm; lm; lm = (struct rt_private_map *)NEXT(lm)) {
DPRINTF(LIST,(2, "lm = 0x%x ['%s']\n",
lm,GETNAME(lm)));
DPRINTF(LIST,(2, "&lm->r_public = 0x%x\n",&(lm->r_public)));
DPRINTF(LIST,(2, "lm->r_public = 0x%x\n",lm->r_public));
DPRINTF(LIST,(2, "TEXTSTART(lm) = 0x%x\n",TEXTSTART(lm)));
DPRINTF(LIST,(2, "TEXTSIZE(lm) = 0x%x\n",TEXTSIZE(lm)));
DPRINTF(LIST,(2, "NEXT(lm) = 0x%x\n",NEXT(lm)));
DPRINTF(LIST,(2, "ADDR(lm) = 0x%x\n",ADDR(lm)));
DPRINTF(LIST,(2, "INIT(lm) = 0x%x\n",INIT(lm)));
DPRINTF(LIST,(2, "FINI(lm) = 0x%x\n",FINI(lm)));
DPRINTF(LIST,(2, "------------------ \n"));
}
}
#endif
/*
* address_to_lm - given an address, return a pointer to an
* lm struct from list.
*
*/
static struct rt_private_map *
_rt_address_to_lm( struct rt_private_map *head_lm, unsigned long address )
{
static unsigned long last_addr = 0;
static struct rt_private_map *last_lm = 0;
struct rt_private_map *lm;
/* return from list the rt_private_map struct which has address
* in its range. */
TRACE_ENTER((LIST|DRELOC),
(2,"_rt_address_to_lm(head_lm=0x%x, addr=0x%x)\n",
head_lm,address));
#ifdef DEBUG
print_list(head_lm);
#endif
for (lm = head_lm; lm; lm = (struct rt_private_map *)NEXT(lm)) {
#if 1
#ifdef DEBUG
DPRINTF(LIST,(2,"rtld: looking for addr 0x%x in object %s [0x%x,0x%x]\n",
address,GETNAME(lm),
TEXTSTART(lm), TEXTSTART(lm) + TEXTSIZE(lm)));
if (!TEXTSTART(lm) || !TEXTSIZE(lm)) {
DPRINTF(LIST,(2,"Error in object %s: zero text field\n",
GETNAME(lm)));
DPRINTF(LIST,(2," TEXTSTART=0x%x,TEXTSIZE=0x%x\n",
TEXTSTART(lm),TEXTSIZE(lm)));
}
#endif /* DEBUG */
#endif
if (address >= TEXTSTART(lm) &&
address < TEXTSTART(lm) + TEXTSIZE(lm)) {
last_addr = address;
last_lm = lm;
TRACE_LEAVE((LIST|DRELOC),
(2,"_rt_address_to_lm(returning lm=0x%x [%s])\n",
lm,GETNAME(lm)));
return(lm);
}
} /* for */
TRACE_LEAVE((LIST|DRELOC),
(2,"_rt_address_to_lm(returning lm=NULL [not found])\n"));
return ((struct rt_private_map *)0); /* not found */
} /* end _rt_address_to_lm */
unsigned long _binder( unsigned long sym_index, unsigned long pc)
{
struct rt_private_map *nlm, *first_lm, *lm;
char *symname;
int got_index;
Elf32_Sym *sym, *nsym;
unsigned long value;
unsigned long *got_addr;
TRACE_ENTER((LIST|DRELOC),(2,"_binder(sym_index=%d, pc=0x%x)\n",
sym_index,pc));
/* Note that since the MIPS ABI doesn't provide a means for passing
* lm from the stub routines, so we must get this information
* someplace else. Here we just start with the head of the list
* which is stored in the global variable _ld_loaded. This may
* not be correct for objects which have DT_SYMBOLIC set.
* FIXME!
*/
lm = _rt_address_to_lm(_ld_loaded,pc);
if (!lm) {
_rtfprintf(2, "%s: %s: unidentifiable procedure reference (address = 0x%x)\n",(char*) _rt_name,_proc_name,pc);
(void)_rtkill(_rtgetpid(), SIGKILL);
}
/* use relocation entry to get symbol table entry and symbol name */
first_lm = SYMBOLIC(lm) ? lm : 0;
sym = (Elf32_Sym *)((unsigned long)SYMTAB(lm) +
(sym_index * SYMENT(lm)));
symname = (char *)(STRTAB(lm) + sym->st_name);
STDLOCK(&_rtld_lock);
/* find definition for symbol */
if ((nsym = _lookup(symname, first_lm, _ld_loaded, lm,
&nlm, LOOKUP_NORM)) ==
(Elf32_Sym *)0) {
_rtfprintf(2, "%s: %s: symbol not found: %s\n",(char*) _rt_name,_proc_name,symname);
(void)_rtkill(_rtgetpid(), SIGKILL);
}
STDUNLOCK(&_rtld_lock);
/* get definition address and update GOT entry */
value = nsym->st_value + (NAME(nlm) ? ADDR(nlm) - BASEADDR(nlm) : 0);
DPRINTF(DRELOC,(2, "rtld: binder: nsym->st_value=%x ADDR(nlm)=%x BASEADDR(nlm)=%x value=%x\n",
nsym->st_value , ADDR(nlm), BASEADDR(nlm), value));
/* CBP :got_index = GOTSYM(lm) - sym_index; */
got_index = sym_index- GOTSYM(lm);
got_addr = PLTGOT(lm) + (LOCALGOTNO(lm) + got_index);
DPRINTF(DRELOC,(2, "rtld: relocating function %s [0x%x to 0x%x]\n",
symname, *got_addr, value));
*got_addr = value;
if (lm != nlm)
{
/* add to list of referenced objects */
if (!_rt_add_ref(lm, nlm))
{
TRACE_LEAVE(LIST,(2,"_binder(killing process)\n"));
(void)_rtkill(_rtgetpid(), SIGKILL);
}
}
TRACE_LEAVE((LIST|DRELOC),
(2, "_binder(returning value=0x%x [%s <%s>])\n",
value, symname ? symname : "0", GETNAME(nlm)));
return(value);
}