From 7309536a8066effa6ac16ae20fd363b0471818cb Mon Sep 17 00:00:00 2001 From: midipix Date: Tue, 8 Jan 2019 04:20:28 -0500 Subject: binutils-2.24.51: properly handle weak symbols that are also hidden. --- binutils-2.24.51.midipix.patch | 50 ++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/binutils-2.24.51.midipix.patch b/binutils-2.24.51.midipix.patch index 68e6ec9..c6baf39 100644 --- a/binutils-2.24.51.midipix.patch +++ b/binutils-2.24.51.midipix.patch @@ -581,24 +581,40 @@ diff -ru a/ld/pe-dll.c b/ld/pe-dll.c } if (pe_details->underscored && *sn == '_') -@@ -761,7 +781,20 @@ - /* Fill data flag properly, from dlltool.c. */ - if (!is_dup) - p->flag_data = !(symbols[j]->flags & BSF_FUNCTION); +@@ -756,12 +776,30 @@ + int is_dup = 0; + def_file_export *p; + +- p = def_file_add_export (pe_def_file, sn, 0, -1, +- NULL, &is_dup); +- /* Fill data flag properly, from dlltool.c. */ +- if (!is_dup) +- p->flag_data = !(symbols[j]->flags & BSF_FUNCTION); +- } ++ if (weaksym) { ++ blhew = bfd_link_hash_lookup (info->hash, weaksym, ++ FALSE, FALSE, FALSE); ++ } + -+ if (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) -+ free (weaksym); ++ if (!weaksym || blhew) { ++ p = def_file_add_export (pe_def_file, sn, 0, -1, ++ NULL, &is_dup); ++ ++ /* Fill data flag properly, from dlltool.c. */ ++ if (!is_dup) ++ p->flag_data = !(symbols[j]->flags & BSF_FUNCTION); ++ ++ if (weaksym) { ++ if (blhew->type != bfd_link_hash_defined) { ++ free (p->internal_name); ++ p->internal_name = objsym; ++ } ++ } ++ ++ if (weaksym) ++ free (weaksym); ++ } ++ } } } } -- cgit v1.2.3