2 Handle indirect symbols.
4 An indirect symbol is where a global symbol in one file say's that
5 all refs like it should be turned into refs of the symbol pointed
6 at by the value of the indirect symbol.
8 BFD supplies symbols to be indirected with the BFD_INDIRECT bit
9 set. Whenever the linker gets one of these, it calls add_indirect
10 with the symbol. We look up the symbol which this one dereferneces,
11 and stop if they are the same. If they are not the same, copy all
12 the information from the current to the dereffed symbol. Set the
13 indirect bit in the flag. From now on the ldsym_get stuff will
14 perform the indirection for us, at no charge.
28 DEFUN(move_it
,(a_list
, b_list
),
32 asymbol
**head
= a_list
;
33 asymbol
**cursor
= head
;
35 if (a_list
== 0) return b_list
;
36 if (b_list
== 0) return a_list
;
39 asymbol
*ptr
= cursor
[0];
40 asymbol
**next
= (asymbol
**)(ptr
->udata
);
42 ptr
->udata
= (PTR
) b_list
;
51 DEFUN(copy_over
,(ldsym
, bfdsym
),
57 refize(Q_enter_global_ref(list
, name
);
58 list
= (asymbol
**)((*list
)->udata
);
63 /* This call allows us to change the symbol table so that all future
64 refs to the symbol are patched to know the alias - but we still
65 have to fix all the old ones */
67 DEFUN(add_indirect
,(ptr
),
71 ldsym_type
*lgs
= ldsym_get((*ptr
)->name
);
72 ldsym_type
*new = ldsym_get(((asymbol
*)((*ptr
)->value
))->name
);
74 /* If the mapping has already been done, stop now */
75 if (lgs
== new) return;
77 lgs
->flags
|= SYM_INDIRECT
;
79 if (lgs
->sdefs_chain
&& lgs
->sdefs_chain
[0])
81 einfo("indirect symbol already has definition %s", lgs
->sdefs_chain
[0]);
83 new->scoms_chain
= move_it(new->scoms_chain
, lgs
->scoms_chain
);
85 new->srefs_chain
= move_it(new->srefs_chain
, lgs
->srefs_chain
);
87 new->sdefs_chain
= move_it(new->sdefs_chain
, lgs
->sdefs_chain
);
90 /* If the result has any commons they should be turned into refs */
92 if (new->sdefs_chain
&& new->scoms_chain
)
94 refize(new, new->scoms_chain
);
96 lgs
->sdefs_chain
= (asymbol
**)new;
This page took 0.031885 seconds and 4 git commands to generate.