From 6ac29f751ac458770ded580f69fa3ce6a157b500 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 12 Dec 2023 20:37:40 +0100 Subject: [PATCH] fix weak[BS] symbol bug in xcoff linker --- binutils/bfd/xcofflink.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/binutils/bfd/xcofflink.c b/binutils/bfd/xcofflink.c index 599983c893..8b55e09c37 100644 --- a/binutils/bfd/xcofflink.c +++ b/binutils/bfd/xcofflink.c @@ -1965,7 +1965,9 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info) if (xcoff_link_add_symbols_to_hash_table (sym, aux)) { csect->flags |= SEC_IS_COMMON; - csect->size = 0; + // Retro68: see AutomatedTests/LocalStatic.cc + if (sym.n_sclass != C_AIX_WEAKEXT) + csect->size = 0; section = csect; value = aux.x_csect.x_scnlen.l; } @@ -2172,8 +2174,12 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info) { if ((*sym_hash)->root.type != bfd_link_hash_common || (*sym_hash)->root.u.c.p->section != csect) - /* We don't need the common csect we just created. */ - csect->size = 0; + { + // Retro68: see AutomatedTests/LocalStatic.cc + if ((*sym_hash)->root.type != bfd_link_hash_defweak) + /* We don't need the common csect we just created. */ + csect->size = 0; + } else (*sym_hash)->root.u.c.p->alignment_power = csect->alignment_power;