This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] [PR ld/22269] arm: Avoid dynamic relocs for undefweak symbols in static PIE
- From: Szabolcs Nagy <Szabolcs dot Nagy at arm dot com>
- To: Binutils <binutils at sourceware dot org>
- Cc: nd <nd at arm dot com>
- Date: Fri, 10 Jan 2020 10:08:36 +0000
- Subject: [PATCH] [PR ld/22269] arm: Avoid dynamic relocs for undefweak symbols in static PIE
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MTKlnDnoaJgDlcnAHibFxEkCIg4N4pQYfZ8QRZlNDyk=; b=Elzni334GMyXzoF8zvjI7Kw3BNbL4rb0dGJADOv7gxupexHLUnKdBAX2HFD59bLr3lejuyr1KgiLltTNxwYSV44TXPRhJtuVx+nAQk2T33czt9f0GAUoBY2hq7m8LA5up2fcszcyL8KwyJDa6z0A6cRZRCfKSFlEZkxjy9qn99vSlErHx3hu/6N7MdjkQDQn64KSZ/WDI0PQ0ONH/QTSk/UuMXupQYlgCn4HRROV3mxrZ/o8vkz6A1PIh01EvKyWmG9SaCt1zRHy0KjP8mYk8wsIe6o96C5+EvzwsE1BXNXjgca+zzfjNLITLqHAxV21wleitQT80/vJtJ8+plVnKQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=An/Q1Vau2ZJ4NxUufMn7eSg4FuRn3l57C0jX+9zSsMCdt3mZdXnBhZqzJMOSN4rGDLM78W4wJC9iiuvg7oFBkss/TWNYtdnqTutbpeo2C39rQetFbSl76L65NYWQ8dexo75rKXhDNiTYPVPVQsLl+8D66GsQZPPfsBCQVmVPjw0QEAFTVy+A/kclkXu8daeZkShWcGCKEMgVosXkFJLBOep0vTBJlphDaHu7ay6fB/s6LdnQ1JSr9kvwoU3Y/XLVkZizKp8tFFV6wYyTLsDxRdsbeR6vy7gOZ88GvJeB6LGxFVnAY12685A2Bg0Elmum31Vy9re0krq4O2QW3O8VaA==
- Original-authentication-results: spf=none (sender IP is ) smtp.mailfrom=Szabolcs dot Nagy at arm dot com;
With static PIE linking undefined weak symbols are resolved to 0, so no
dynamic relocation is needed for them. The UNDEFWEAK_NO_DYNAMIC_RELOC
macro was introduced so this case can be handled easily, but it was not
applied consistently in the first attempt to fix ld/22269 for arm:
commit 95b03e4ad68e7a90f5096b47df595636344b783a
arm: Check UNDEFWEAK_NO_DYNAMIC_RELOC
This patch fixes spurious relative relocs in static PIE binaries against
GOT entries created for undefined weak symbols on arm*-*, this fixes
FAIL: pr22269-1 (static pie undefined weak)
bfd/ChangeLog:
2020-01-10 Szabolcs Nagy <szabolcs.nagy@arm.com>
PR ld/22269
* elf32-arm.c (elf32_arm_final_link_relocate): Use
UNDEFWEAK_NO_DYNAMIC_RELOC.
(allocate_dynrelocs_for_symbol): Likewise.
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 2bf355a331..faf8376f20 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -11578,8 +11578,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto,
if (dynreloc_st_type == STT_GNU_IFUNC)
outrel.r_info = ELF32_R_INFO (0, R_ARM_IRELATIVE);
else if (bfd_link_pic (info)
- && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
- || h->root.type != bfd_link_hash_undefweak))
+ && !UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE);
else
{
@@ -16452,8 +16451,7 @@ allocate_dynrelocs_for_symbol (struct elf_link_hash_entry *h, void * inf)
GOT entry's R_ARM_IRELATIVE relocation. */
elf32_arm_allocate_irelocs (info, htab->root.srelgot, 1);
else if (bfd_link_pic (info)
- && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
- || h->root.type != bfd_link_hash_undefweak))
+ && !UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
/* Reserve room for the GOT entry's R_ARM_RELATIVE relocation. */
elf32_arm_allocate_dynrelocs (info, htab->root.srelgot, 1);
else if (htab->fdpic_p && tls_type == GOT_NORMAL)