From 670de4ff055d1a6c812fa01e35f7df6ae1996213 Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 13 Jun 2015 20:31:52 -0400 Subject: binutils-2.24.51: updated patch. + PE/COFF: when exporting a symbol for which both a strong and a weak definition exists, always use the strong definition. signed-off by Z. Gilboa; see copying.midipix (9cd0746c) for additional information. --- binutils-2.24.51.midipix.patch | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/binutils-2.24.51.midipix.patch b/binutils-2.24.51.midipix.patch index 0bb2041..d15277a 100644 --- a/binutils-2.24.51.midipix.patch +++ b/binutils-2.24.51.midipix.patch @@ -370,8 +370,9 @@ diff -ru --new-file a/binutils/winduni.c b/binutils/winduni.c { 1, "WINDOWS-1252" }, { 437, "MS-ANSI" }, { 737, "MS-GREEK" }, +diff -ru a/ld/pe-dll.c b/ld/pe-dll.c --- a/ld/pe-dll.c 2014-07-03 01:37:48.000000000 -0400 -+++ b/ld/pe-dll.c 2015-06-08 22:21:42.593160828 -0400 ++++ b/ld/pe-dll.c 2015-06-13 20:08:00.160401506 -0400 @@ -40,6 +40,7 @@ #include "coff/internal.h" #include "../bfd/libcoff.h" @@ -392,20 +393,27 @@ diff -ru --new-file a/binutils/winduni.c b/binutils/winduni.c { NULL, 0 } }; -@@ -648,6 +653,7 @@ +@@ -644,10 +649,13 @@ + { + int i, j; + struct bfd_link_hash_entry *blhe; ++ struct bfd_link_hash_entry *blhew; + bfd *b; struct bfd_section *s; def_file_export *e = 0; bfd_boolean resort_needed; + char *weaksym; ++ char *objsym; if (!pe_def_file) pe_def_file = def_file_empty (); -@@ -737,6 +743,15 @@ +@@ -737,6 +745,16 @@ if (is_import (sn)) continue; + if (!strncmp (sn, ".weak.", 6) && strchr (sn + 6, '.')) + { ++ objsym = strdup (sn); + weaksym = strdup (sn + 6); + *(strchr (weaksym, '.')) = '\0'; + sn = weaksym; @@ -416,7 +424,7 @@ diff -ru --new-file a/binutils/winduni.c b/binutils/winduni.c name = xmalloc (strlen ("__imp_") + strlen (sn) + 1); sprintf (name, "%s%s", "__imp_", sn); -@@ -745,7 +760,8 @@ +@@ -745,7 +763,8 @@ free (name); if (blhe && blhe->type == bfd_link_hash_defined) @@ -426,15 +434,20 @@ diff -ru --new-file a/binutils/winduni.c b/binutils/winduni.c } if (pe_details->underscored && *sn == '_') -@@ -761,7 +777,15 @@ +@@ -761,7 +780,20 @@ /* Fill data flag properly, from dlltool.c. */ if (!is_dup) p->flag_data = !(symbols[j]->flags & BSF_FUNCTION); + + if (weaksym) + { -+ free (p->internal_name); -+ p->internal_name = strdup (weaksym); ++ blhew = bfd_link_hash_lookup (info->hash, weaksym, ++ FALSE, FALSE, FALSE); ++ if (blhew->type != bfd_link_hash_defined) ++ { ++ free (p->internal_name); ++ p->internal_name = objsym; ++ } + } } + if (weaksym) @@ -442,7 +455,7 @@ diff -ru --new-file a/binutils/winduni.c b/binutils/winduni.c } } } -@@ -910,6 +934,7 @@ +@@ -910,6 +942,7 @@ if (blhe && (blhe->type == bfd_link_hash_defined @@ -450,7 +463,7 @@ diff -ru --new-file a/binutils/winduni.c b/binutils/winduni.c || (blhe->type == bfd_link_hash_common))) { count_exported++; -@@ -919,7 +944,7 @@ +@@ -919,7 +952,7 @@ /* Only fill in the sections. The actual offsets are computed in fill_exported_offsets() after common symbols are laid out. */ @@ -550,7 +563,7 @@ diff -ru --new-file a/gas/configure.tgt b/gas/configure.tgt i*) fmt=coff em=pe ;; diff -ru a/bfd/cofflink.c b/bfd/cofflink.c --- a/bfd/cofflink.c 2014-07-03 01:37:20.000000000 -0400 -+++ b/bfd/cofflink.c 2015-06-06 18:01:06.848274823 -0400 ++++ b/bfd/cofflink.c 2015-06-13 20:22:46.000389638 -0400 @@ -202,6 +202,7 @@ bfd_size_type symesz; bfd_byte *esym; @@ -594,12 +607,18 @@ diff -ru a/bfd/cofflink.c b/bfd/cofflink.c symcount = obj_raw_syment_count (abfd); -@@ -476,6 +491,14 @@ +@@ -476,6 +491,20 @@ addit = FALSE; } + if (!strncmp (name, ".weak.", 6) && strchr (name + 6, '.')) + { ++ if (! (bfd_coff_link_add_one_symbol ++ (info, abfd, name, flags, section, value, ++ (const char *) NULL, copy, FALSE, ++ (struct bfd_link_hash_entry **) sym_hash))) ++ goto error_return; ++ + weaksym = strdup (name + 6); + *(strchr(weaksym, '.')) = 0; + name = weaksym; -- cgit v1.2.3