This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
PATCH: Improve ELF linker for non-ELF input
- From: "H. J. Lu" <hjl at lucon dot org>
- To: binutils at sources dot redhat dot com
- Date: Thu, 22 Apr 2004 13:39:34 -0700
- Subject: PATCH: Improve ELF linker for non-ELF input
The current ELF linker can link in non-ELF input if it doesn't
reference symbols in DSO. This patch improves it a little bit so
that simple function call to DSO works.
H.J.
------
2004-04-22 H.J. Lu <hongjiu.lu@intel.com>
* elflink.c (_bfd_elf_link_create_dynamic_sections): Clear
the ELF_LINK_NON_ELF bit on _DYNAMIC.
(_bfd_elf_fix_symbol_flags): Increment PLT count for dynamic
symbols referenced by non-ELF files.
--- bfd/elflink.c.mix 2004-04-22 08:20:09.000000000 -0700
+++ bfd/elflink.c 2004-04-22 10:12:48.000000000 -0700
@@ -218,6 +218,7 @@ _bfd_elf_link_create_dynamic_sections (b
return FALSE;
h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+ h->elf_link_hash_flags &= ~ELF_LINK_NON_ELF;
h->type = STT_OBJECT;
if (! info->executable
@@ -2087,6 +2088,17 @@ _bfd_elf_fix_symbol_flags (struct elf_li
eif->failed = TRUE;
return FALSE;
}
+
+ switch (h->type)
+ {
+ case STT_FUNC:
+ /* We need it to keep the PLT entry. */
+ h->plt.refcount++;
+ break;
+
+ default:
+ break;
+ }
}
}
else