summaryrefslogtreecommitdiff
path: root/bfd/cofflink.c
diff options
context:
space:
mode:
authorChristopher Faylor <me+cygwin@cgf.cx>2004-07-03 16:07:51 +0000
committerChristopher Faylor <me+cygwin@cgf.cx>2004-07-03 16:07:51 +0000
commitc1c5dc0e88ea9196142e71bcd3f61cd3de4c97bd (patch)
treef4d61ba874786f045701ea315a1922667a177d5e /bfd/cofflink.c
parent0cd36cc9585026047d5dbd9c92735e4a9c809746 (diff)
downloadbinutils-redhat-c1c5dc0e88ea9196142e71bcd3f61cd3de4c97bd.tar.gz
2004-07-04 Aaron W. LaFramboise <aaron98wiridge9@aaronwl.com>
* bfd/cofflink.c (_bfd_coff_generic_relocate_section): Resolve PE weak externals properly. * src/gas/config/obj-coff.c (obj_coff_weak): New .weak syntax for PE weak externals. * binutils/doc/binutils.texi (nm): Clarify weak symbol description. * gas/config/tc-i386.c (tc_gen_reloc): Use addend for weak symbols in TE_PE. * gas/doc/as.texinfo (Weak): Document PE weak symbols. * ld/ld.texinfo (WIN32): Document PE weak symbols.
Diffstat (limited to 'bfd/cofflink.c')
-rw-r--r--bfd/cofflink.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index 1af86abaec..af6dd3d699 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -2923,16 +2923,41 @@ _bfd_coff_generic_relocate_section (bfd *output_bfd,
if (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak)
{
+ /* Defined weak symbols are a GNU extension. */
asection *sec;
sec = h->root.u.def.section;
val = (h->root.u.def.value
+ sec->output_section->vma
+ sec->output_offset);
- }
+ }
else if (h->root.type == bfd_link_hash_undefweak)
- val = 0;
+ {
+ if (h->class == C_NT_WEAK && h->numaux == 1)
+ {
+ /* See _Microsoft Portable Executable and Common Object
+ * File Format Specification_, section 5.5.3.
+ * Note that weak symbols without aux records are a GNU
+ * extension.
+ * FIXME: All weak externals are treated as having
+ * characteristics IMAGE_WEAK_EXTERN_SEARCH_LIBRARY (2).
+ * There are no known uses of the other two types of
+ * weak externals.
+ */
+ asection *sec;
+ struct coff_link_hash_entry *h2 =
+ input_bfd->tdata.coff_obj_data->sym_hashes[
+ h->aux->x_sym.x_tagndx.l];
+
+ sec = h2->root.u.def.section;
+ val = h2->root.u.def.value + sec->output_section->vma
+ + sec->output_offset;
+ }
+ else
+ /* This is a GNU extension. */
+ val = 0;
+ }
else if (! info->relocatable)
{