You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.6 KiB

36 years ago
/* ldindr.c
Handle indirect symbols.
BFD supplies symbols to be indirected with the BFD_INDIRECT bit
set. Whenever the linker gets one of these, it calls add_indirect
with the symbol. We look up the symbol which this one dereferneces,
and stop if they are the same. If they are not the same, copy all
the information from the current to the dereffed symbol. Set the
indirect bit in the flag. From now on the ldsym_get stuff will
perform the indirection for us, at no charge.
36 years ago
*/
#include "bfd.h"
#include "sysdep.h"
36 years ago
#include "ld.h"
#include "ldsym.h"
#include "ldmisc.h"
36 years ago
static asymbol **
DEFUN(move_it,(a_list, b_list),
asymbol **a_list AND
asymbol **b_list)
36 years ago
{
asymbol **head = a_list;
asymbol **cursor = head;
if (a_list == 0) return b_list;
if (b_list == 0) return a_list;
while (1) {
asymbol *ptr = cursor[0];
asymbol **next = (asymbol **)(ptr->udata);
if (next == 0) {
ptr->udata = (PTR) b_list;
return head;
}
cursor = next;
36 years ago
}
}
void
DEFUN(add_indirect,(ptr),
asymbol **ptr)
36 years ago
{
ldsym_type *lgs = ldsym_get((*ptr)->name);
ldsym_type *new = ldsym_get(((asymbol *)((*ptr)->value))->name);
36 years ago
/* If the mapping has already been done, stop now */
if (lgs == new) return;
lgs->flags |= SYM_INDIRECT;
36 years ago
new->scoms_chain = move_it(new->scoms_chain, lgs->scoms_chain);
lgs->scoms_chain = 0;
new->srefs_chain = move_it(new->srefs_chain, lgs->srefs_chain);
lgs->srefs_chain = 0;
new->sdefs_chain = move_it(new->sdefs_chain, lgs->sdefs_chain);
lgs->sdefs_chain = 0;
36 years ago
lgs->sdefs_chain = (asymbol **)new;
}
36 years ago