[Open64-devel] upgrading IPA linker to 2.13 binutils
Brought to you by:
ributzka,
suneeljain
From: Christophe L. <chr...@st...> - 2004-01-14 16:43:29
|
Hi, I have already asked this question some time ago, but got no reply :-( I am currently upgrading ipa_linker to GNU binutils 2.13, and I can't understand a piece of IPA-specific code. In linker.c (as found under cygnus_20000828/bfd/), at line ~1610 we can read: /* Define a symbol. */ oldtype = h->type; if (action == DEFW) { h->type = bfd_link_hash_defweak; } else { h->type = bfd_link_hash_defined; } h->u.def.section = section; #ifdef IPA_LINK /* ipa_set_def_bfd(abfd,h); */ if (is_ipa) h->u.def.section = (asection *)abfd; ^^^^^^^^^^^^^^^^^^^^^^^^^^ #endif h->u.def.value = value; What I don't understand here is the overwrite of h->u.def.section by (asection*)abfd: the only common field between section and bfd is the "name" one, and thus I don't understand the purpose of this overwriting. What I understand is that when the symbol we have just defined is later referenced, in elflink.h we do: /* OLDBFD is a BFD associated with the existing symbol. */ switch (h->root.type) { default: oldbfd = NULL; break; case bfd_link_hash_undefined: case bfd_link_hash_undefweak: oldbfd = h->root.u.undef.abfd; break; case bfd_link_hash_defined: case bfd_link_hash_defweak: oldbfd = h->root.u.def.section->owner; ^^^^^^^^^^^^^^^ break; Here, the section value has actually been replaced by 'abfd' for the file which contained the symbol definition. But how can the "owner" field be valid as we are actually referencing some memory area in a bfd structure? From what I can see in the original Open64 code, the offset of the "owner" field in "struct section" is the same as the offset of the "usrdata" field in "struct bfd", which is in turn updated in ipa_process_whirl. Unfortunately, these offsets no longer match in more recent binutils sources :-( I am surprised that ipa_link relies on this. Would anyone be kind enough to give me some light? Many thanks, Christophe. |