(1) describe -relax
[deliverable/binutils-gdb.git] / ld / ldindr.c
CommitLineData
812df84b
SC
1/* ldindr.c
2 Handle indirect symbols.
3
4 BFD supplies symbols to be indirected with the BFD_INDIRECT bit
5 set. Whenever the linker gets one of these, it calls add_indirect
1af27af8
SC
6 with the symbol. We look up the symbol which this one dereferneces,
7 and stop if they are the same. If they are not the same, copy all
8 the information from the current to the dereffed symbol. Set the
9 indirect bit in the flag. From now on the ldsym_get stuff will
10 perform the indirection for us, at no charge.
812df84b
SC
11*/
12
13
14
812df84b 15#include "bfd.h"
f177a611 16#include "sysdep.h"
812df84b
SC
17#include "ld.h"
18#include "ldsym.h"
1af27af8 19#include "ldmisc.h"
812df84b 20
1af27af8
SC
21
22
23static asymbol **
24DEFUN(move_it,(a_list, b_list),
25asymbol **a_list AND
26asymbol **b_list)
812df84b 27{
1af27af8
SC
28 asymbol **head = a_list;
29 asymbol **cursor = head;
30
31 if (a_list == 0) return b_list;
32 if (b_list == 0) return a_list;
33
34 while (1) {
35 asymbol *ptr = cursor[0];
36 asymbol **next = (asymbol **)(ptr->udata);
37 if (next == 0) {
38 ptr->udata = (PTR) b_list;
39 return head;
40 }
41 cursor = next;
812df84b
SC
42 }
43}
44
812df84b 45void
1af27af8
SC
46DEFUN(add_indirect,(ptr),
47asymbol **ptr)
812df84b 48{
1af27af8
SC
49 ldsym_type *lgs = ldsym_get((*ptr)->name);
50 ldsym_type *new = ldsym_get(((asymbol *)((*ptr)->value))->name);
812df84b 51
1af27af8
SC
52 /* If the mapping has already been done, stop now */
53 if (lgs == new) return;
54 lgs->flags |= SYM_INDIRECT;
812df84b 55
1af27af8
SC
56 new->scoms_chain = move_it(new->scoms_chain, lgs->scoms_chain);
57 lgs->scoms_chain = 0;
58 new->srefs_chain = move_it(new->srefs_chain, lgs->srefs_chain);
59 lgs->srefs_chain = 0;
60 new->sdefs_chain = move_it(new->sdefs_chain, lgs->sdefs_chain);
61 lgs->sdefs_chain = 0;
812df84b 62
1af27af8
SC
63 lgs->sdefs_chain = (asymbol **)new;
64}
812df84b 65
812df84b
SC
66
67
This page took 0.038696 seconds and 4 git commands to generate.