summaryrefslogtreecommitdiff
path: root/binutils-2.24.51.midipix.patch
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-06-06 18:19:54 -0400
committermidipix <writeonce@midipix.org>2015-06-06 18:19:54 -0400
commit1db189fe768b1e7e8e3da1f4db60a63407a97530 (patch)
tree89c697c27491f852f045dfeac0427d8b992f8477 /binutils-2.24.51.midipix.patch
parent7ead5aa3032e3cf04f0beb03a8833147db0a2639 (diff)
downloadchainport-1db189fe768b1e7e8e3da1f4db60a63407a97530.tar.bz2
chainport-1db189fe768b1e7e8e3da1f4db60a63407a97530.tar.xz
binutils-2.24.51: updated patch.
+ PE/COFF: allow a weak definition in an archive member to satisfy a reference to an undefined external symbol in another object. + a special thanks to Rich Felker, primary author of musl libc, for identifying the spot at which a fix needed to be applied. signed-off by Z. Gilboa; see copying.midipix (9cd0746c) for additional information.
Diffstat (limited to 'binutils-2.24.51.midipix.patch')
-rw-r--r--binutils-2.24.51.midipix.patch66
1 files changed, 63 insertions, 3 deletions
diff --git a/binutils-2.24.51.midipix.patch b/binutils-2.24.51.midipix.patch
index 4cf660e..720fc96 100644
--- a/binutils-2.24.51.midipix.patch
+++ b/binutils-2.24.51.midipix.patch
@@ -540,8 +540,43 @@ 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 11:07:57.716291339 -0400
-@@ -320,6 +320,7 @@
++++ b/bfd/cofflink.c 2015-06-06 18:01:06.848274823 -0400
+@@ -202,6 +202,7 @@
+ bfd_size_type symesz;
+ bfd_byte *esym;
+ bfd_byte *esym_end;
++ char *weaksym;
+
+ *pneeded = FALSE;
+
+@@ -236,6 +237,16 @@
+ && CONST_STRNEQ (name, "__imp_"))
+ h = bfd_link_hash_lookup (info->hash, name + 6, FALSE, FALSE, TRUE);
+
++ if (!h && !strncmp (name, ".weak.", 6) && strchr (name + 6, '.'))
++ {
++ weaksym = strdup (name + 6);
++ *(strchr (weaksym, '.')) = '\0';
++ h = bfd_link_hash_lookup (info->hash, weaksym, FALSE, FALSE, TRUE);
++ name = weaksym;
++ }
++ else
++ weaksym = 0;
++
+ /* We are only interested in symbols that are currently
+ undefined. If a symbol is currently known to be common,
+ COFF linkers do not bring in an object file which defines
+@@ -249,6 +260,9 @@
+ *pneeded = TRUE;
+ return TRUE;
+ }
++
++ if (weaksym)
++ free (weaksym);
+ }
+
+ esym += (sym.n_numaux + 1) * symesz;
+@@ -320,6 +334,7 @@
bfd_byte *esym;
bfd_byte *esym_end;
bfd_size_type amt;
@@ -549,7 +584,7 @@ diff -ru a/bfd/cofflink.c b/bfd/cofflink.c
symcount = obj_raw_syment_count (abfd);
-@@ -476,6 +477,14 @@
+@@ -476,6 +491,14 @@
addit = FALSE;
}
@@ -564,3 +599,28 @@ diff -ru a/bfd/cofflink.c b/bfd/cofflink.c
if (addit)
{
if (! (bfd_coff_link_add_one_symbol
+diff -ru a/bfd/linker.c b/bfd/linker.c
+--- a/bfd/linker.c 2014-07-03 01:37:21.000000000 -0400
++++ b/bfd/linker.c 2015-06-06 17:51:24.148275212 -0400
+@@ -1050,6 +1050,7 @@
+ struct archive_hash_table arsym_hash;
+ unsigned int indx;
+ struct bfd_link_hash_entry **pundef;
++ char *weaksym;
+
+ if (! bfd_has_map (abfd))
+ {
+@@ -1073,6 +1074,13 @@
+ struct archive_hash_entry *arh;
+ struct archive_list *l, **pp;
+
++ if (!strncmp (arsym->name, ".weak.", 6) && strchr (arsym->name + 6, '.'))
++ {
++ weaksym = strdup (arsym->name + 6);
++ *(strchr (weaksym, '.')) = '\0';
++ arsym->name = weaksym;
++ }
++
+ arh = archive_hash_lookup (&arsym_hash, arsym->name, TRUE, FALSE);
+ if (arh == NULL)
+ goto error_return;