From patchwork Fri Oct 4 08:23:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 98359 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6DAA63845158 for ; Fri, 4 Oct 2024 08:23:50 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 0B2223849AD7 for ; Fri, 4 Oct 2024 08:23:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B2223849AD7 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0B2223849AD7 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::532 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728030200; cv=none; b=H5V8fbf8kyMp9RMzGdIoW9WXLkgeNtNxx7oE116W/VSpMTVD+TPpbmqmyLJ2/V3U+wsT0vzWED3+jrTvtQhvrKF51oUU305MP2sRqV751s2Nwtr+P9eljvEbN7xUQ2hH3XJaMQRNMYfMrQW6WBQj0jJjVOpoBGdr8naQXrbBPII= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728030200; c=relaxed/simple; bh=GjzEvDoEyY47Jwh6NM/pwcQulLnY0mZXnvganNLXYjw=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=Yv9974bWB+++a+/tl65CzIBSpwrovkxhbrvzIYKi6Bpn5kHGJ7N5ZqYivQB1+oCDsgLE7m6u0i4ccqtJTDrC+m6/HKTmTGexgYmfWRwoljHcBp1OVzh4m0ZrSdjzhOZ5kaxfQe8ob+Uy1uVZwBsYvLxV6y0Y/I6yzjp9oYnCz78= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-7e6afa8baeaso1539997a12.3 for ; Fri, 04 Oct 2024 01:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728030196; x=1728634996; darn=sourceware.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=rTr34DThnaA+t170Rk53vyv0SRK35qbE3YEVs0e1WeA=; b=MIu1HT9mEJn+3ZjFynXj6mBb2pRGh8Y8VwULyOAZnyyc4wtFKM0eFo31dumFcUrzQW 9NDjdkfeXhxU3oOSrxTzwTiOgxS78C/rYXUNw6yf3oh952OTLVh8/0KvNiw5OoDgaq9X QqOxV9XQOERMsejXoqEQYxQDAUinvxxwyfp2QLxHdmDI0umZaFu4GDDsW3DfFvYR2UNc FbHWAJJrGkhRaBY9cQnLmA88uE6Z7R0/PkeOdb6gL78YPrNceLzw/4cNxF8YiNruExI2 AZ6tN7AXNFulHlmTl5mHqtr7rqppxkRKm2+rHLUOAqFjBR9J+xdmSYj/nE4I6n8paWcT ZepA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728030196; x=1728634996; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rTr34DThnaA+t170Rk53vyv0SRK35qbE3YEVs0e1WeA=; b=IdGQ4e+BTxRAQQcLaw0ClXXfwcnbKikrZHkzH3O4S5L1XcjwVFCk+JdFShQhI0Zb15 oNluHYe4ZhvLVGXE0Q80j9CgFuoy/rlRrkPPVkBUSbQZ1Kq/X9REnuVeiltL1dPNvRxF oJ/uQ/E+aIrhZVZFTlkbJp/XQP9IgDkPEUkTWqOdH2nGU8ecuhs9ZJLXimIIU19nm5vG NnPtuY4vgKiy6HgXqmzqzjg/sp592UFHyV4cGkfkj8ASc7hAIYxLWskP71gjr40j+sWq PLxlHncCAmIDblH+bdrAJD06+DXPZHH6t+9Mbo8cVvdWJIWFiBkQM8pQlUelOvXGDpx4 Xxww== X-Gm-Message-State: AOJu0Yza/HRLjS6++28rTfFSx93Vo5KagJPd0sQ8JMt/S7/JrjXUDnV2 w3875UTkAnasAoZjkezGqgQkfZZWn1sWIjNScIfbkMSiivj9FHmHoSDiyA== X-Google-Smtp-Source: AGHT+IH26fdzlmzvPwG2ZOM38sAWhibOsy4PQeXnnFuv2Fclaq7n6cMCIIjyxMMLTInfIuHbDx8nlQ== X-Received: by 2002:a05:6a20:c916:b0:1d2:ea38:39bc with SMTP id adf61e73a8af0-1d6dfa33d08mr3572872637.11.1728030195285; Fri, 04 Oct 2024 01:23:15 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:f861:b057:7729:e742]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71dea2a2454sm598400b3a.84.2024.10.04.01.23.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 01:23:14 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 742EB1141336; Fri, 4 Oct 2024 17:53:12 +0930 (ACST) Date: Fri, 4 Oct 2024 17:53:12 +0930 From: Alan Modra To: binutils@sourceware.org Subject: get_synthetic_symtab fixes for commit 68bbe1183379 Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3032.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org Given that relocation symbol name can now be NULL for ELF, adjust various get_synthetic_symtab routines so they don't segfault. * elf.c (_bfd_elf_get_synthetic_symtab): Cope with sym->name possibly being NULL. * elf32-arm.c (elf32_arm_get_synthetic_symtab): Likewise. * elf32-ppc.c (ppc_elf_get_synthetic_symtab): Likewise. * elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Likewise. * elfxx-mips.c (_bfd_mips_elf_get_synthetic_symtab): Likewise. * elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Likewise. diff --git a/bfd/elf.c b/bfd/elf.c index 38bfb1c2064..39ee641097b 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -13537,17 +13537,19 @@ _bfd_elf_get_synthetic_symtab (bfd *abfd, size = count * sizeof (asymbol); p = relplt->relocation; for (i = 0; i < count; i++, p += bed->s->int_rels_per_ext_rel) - { - size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt"); - if (p->addend != 0) - { + if ((*p->sym_ptr_ptr)->name != NULL) + { + size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt"); + if (p->addend != 0) + { #ifdef BFD64 - size += sizeof ("+0x") - 1 + 8 + 8 * (bed->s->elfclass == ELFCLASS64); + size += (sizeof ("+0x") - 1 + 8 + + 8 * (bed->s->elfclass == ELFCLASS64)); #else - size += sizeof ("+0x") - 1 + 8; + size += sizeof ("+0x") - 1 + 8; #endif - } - } + } + } s = *ret = (asymbol *) bfd_malloc (size); if (s == NULL) @@ -13565,6 +13567,9 @@ _bfd_elf_get_synthetic_symtab (bfd *abfd, if (addr == (bfd_vma) -1) continue; + if ((*p->sym_ptr_ptr)->name == NULL) + continue; + *s = **p->sym_ptr_ptr; /* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since we are defining a symbol, ensure one of them is set. */ diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 17df8b30eb6..f1d23342e66 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -20100,6 +20100,7 @@ elf32_arm_get_synthetic_symtab (bfd *abfd, char *names; asection *plt; bfd_vma offset; + bfd_vma plt_size; bfd_byte *data; *ret = NULL; @@ -20134,11 +20135,12 @@ elf32_arm_get_synthetic_symtab (bfd *abfd, size = count * sizeof (asymbol); p = relplt->relocation; for (i = 0; i < count; i++, p += elf32_arm_size_info.int_rels_per_ext_rel) - { - size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt"); - if (p->addend != 0) - size += sizeof ("+0x") - 1 + 8; - } + if ((*p->sym_ptr_ptr)->name != NULL) + { + size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt"); + if (p->addend != 0) + size += sizeof ("+0x") - 1 + 8; + } offset = elf32_arm_plt0_size (abfd, data, plt->size); if (offset == (bfd_vma) -1 @@ -20149,16 +20151,19 @@ elf32_arm_get_synthetic_symtab (bfd *abfd, } names = (char *) (s + count); - p = relplt->relocation; - n = 0; - for (i = 0; i < count; i++, p += elf32_arm_size_info.int_rels_per_ext_rel) + for (i = 0, p = relplt->relocation, n = 0; + i < count; + i++, p += elf32_arm_size_info.int_rels_per_ext_rel, offset += plt_size) { size_t len; - bfd_vma plt_size = elf32_arm_plt_size (abfd, data, offset, plt->size); + plt_size = elf32_arm_plt_size (abfd, data, offset, plt->size); if (plt_size == (bfd_vma) -1) break; + if ((*p->sym_ptr_ptr)->name == NULL) + continue; + *s = **p->sym_ptr_ptr; /* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since we are defining a symbol, ensure one of them is set. */ @@ -20188,7 +20193,6 @@ elf32_arm_get_synthetic_symtab (bfd *abfd, memcpy (names, "@plt", sizeof ("@plt")); names += sizeof ("@plt"); ++s, ++n; - offset += plt_size; } free (data); diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index a5370a0624e..0d415d60936 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -1806,7 +1806,7 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms, bfd_vma stub_off; asymbol *s; arelent *p; - size_t count, i, stub_delta; + size_t count, n, i, stub_delta; size_t size; char *names; bfd_byte buf[4]; @@ -1935,11 +1935,12 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms, size = count * sizeof (asymbol); p = relplt->relocation; for (i = 0; i < count; i++, p++) - { - size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt"); - if (p->addend != 0) - size += sizeof ("+0x") - 1 + 8; - } + if ((*p->sym_ptr_ptr)->name != NULL) + { + size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt"); + if (p->addend != 0) + size += sizeof ("+0x") - 1 + 8; + } size += sizeof (asymbol) + sizeof ("__glink"); @@ -1953,38 +1954,40 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms, stub_off = glink_vma - glink->vma; names = (char *) (s + count + 1 + (resolv_vma != 0)); p = relplt->relocation + count - 1; - for (i = 0; i < count; i++) - { - size_t len; - - stub_off -= stub_delta; - if (strcmp ((*p->sym_ptr_ptr)->name, "__tls_get_addr_opt") == 0) - stub_off -= 32; - *s = **p->sym_ptr_ptr; - /* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since - we are defining a symbol, ensure one of them is set. */ - if ((s->flags & BSF_LOCAL) == 0) - s->flags |= BSF_GLOBAL; - s->flags |= BSF_SYNTHETIC; - s->section = glink; - s->value = stub_off; - s->name = names; - s->udata.p = NULL; - len = strlen ((*p->sym_ptr_ptr)->name); - memcpy (names, (*p->sym_ptr_ptr)->name, len); - names += len; - if (p->addend != 0) - { - memcpy (names, "+0x", sizeof ("+0x") - 1); - names += sizeof ("+0x") - 1; - bfd_sprintf_vma (abfd, names, p->addend); - names += strlen (names); - } - memcpy (names, "@plt", sizeof ("@plt")); - names += sizeof ("@plt"); - ++s; - --p; - } + for (n = 0, i = 0; i < count; i++) + if ((*p->sym_ptr_ptr)->name != NULL) + { + size_t len; + + stub_off -= stub_delta; + if (strcmp ((*p->sym_ptr_ptr)->name, "__tls_get_addr_opt") == 0) + stub_off -= 32; + *s = **p->sym_ptr_ptr; + /* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since + we are defining a symbol, ensure one of them is set. */ + if ((s->flags & BSF_LOCAL) == 0) + s->flags |= BSF_GLOBAL; + s->flags |= BSF_SYNTHETIC; + s->section = glink; + s->value = stub_off; + s->name = names; + s->udata.p = NULL; + len = strlen ((*p->sym_ptr_ptr)->name); + memcpy (names, (*p->sym_ptr_ptr)->name, len); + names += len; + if (p->addend != 0) + { + memcpy (names, "+0x", sizeof ("+0x") - 1); + names += sizeof ("+0x") - 1; + bfd_sprintf_vma (abfd, names, p->addend); + names += strlen (names); + } + memcpy (names, "@plt", sizeof ("@plt")); + names += sizeof ("@plt"); + ++s; + --p; + ++n; + } /* Add a symbol at the start of the glink branch table. */ memset (s, 0, sizeof *s); @@ -1996,7 +1999,7 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms, memcpy (names, "__glink", sizeof ("__glink")); names += sizeof ("__glink"); s++; - count++; + n++; if (resolv_vma) { @@ -2010,10 +2013,10 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms, memcpy (names, "__glink_PLTresolve", sizeof ("__glink_PLTresolve")); names += sizeof ("__glink_PLTresolve"); s++; - count++; + n++; } - return count; + return n; } /* The following functions are specific to the ELF linker, while diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index cd3aaacaeb3..29221033cb0 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -2402,7 +2402,8 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd, sym = *r->sym_ptr_ptr; if (!sym_exists_at (syms, opdsymend, symcount, - sym->section->id, sym->value + r->addend)) + sym->section->id, sym->value + r->addend) + && syms[i]->name != NULL) { ++count; size += sizeof (asymbol); @@ -2440,7 +2441,8 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd, sym = *r->sym_ptr_ptr; if (!sym_exists_at (syms, opdsymend, symcount, - sym->section->id, sym->value + r->addend)) + sym->section->id, sym->value + r->addend) + && syms[i]->name != NULL) { size_t len; @@ -2491,7 +2493,8 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd, continue; ent = bfd_get_64 (abfd, contents + syms[i]->value); - if (!sym_exists_at (syms, opdsymend, symcount, -1, ent)) + if (!sym_exists_at (syms, opdsymend, symcount, -1, ent) + && syms[i]->name != NULL) { ++count; size += sizeof (asymbol); @@ -2579,11 +2582,12 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd, p = relplt->relocation; for (i = 0; i < plt_count; i++, p++) - { - size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt"); - if (p->addend != 0) - size += sizeof ("+0x") - 1 + 16; - } + if ((*p->sym_ptr_ptr)->name != NULL) + { + size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt"); + if (p->addend != 0) + size += sizeof ("+0x") - 1 + 16; + } } } @@ -2603,7 +2607,8 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd, continue; ent = bfd_get_64 (abfd, contents + syms[i]->value); - if (!sym_exists_at (syms, opdsymend, symcount, -1, ent)) + if (!sym_exists_at (syms, opdsymend, symcount, -1, ent) + && syms[i]->name != NULL) { size_t lo, hi; size_t len; @@ -2691,42 +2696,43 @@ ppc64_elf_get_synthetic_symtab (bfd *abfd, for pending shared library loads. */ p = relplt->relocation; for (i = 0; i < plt_count; i++, p++) - { - size_t len; - - *s = **p->sym_ptr_ptr; - /* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since - we are defining a symbol, ensure one of them is set. */ - if ((s->flags & BSF_LOCAL) == 0) - s->flags |= BSF_GLOBAL; - s->flags |= BSF_SYNTHETIC; - s->section = glink; - s->value = glink_vma - glink->vma; - s->name = names; - s->udata.p = NULL; - len = strlen ((*p->sym_ptr_ptr)->name); - memcpy (names, (*p->sym_ptr_ptr)->name, len); - names += len; - if (p->addend != 0) - { - memcpy (names, "+0x", sizeof ("+0x") - 1); - names += sizeof ("+0x") - 1; - bfd_sprintf_vma (abfd, names, p->addend); - names += strlen (names); - } - memcpy (names, "@plt", sizeof ("@plt")); - names += sizeof ("@plt"); - s++; - if (abi < 2) - { - glink_vma += 8; - if (i >= 0x8000) - glink_vma += 4; - } - else - glink_vma += 4; - } - count += plt_count; + if ((*p->sym_ptr_ptr)->name != NULL) + { + size_t len; + + *s = **p->sym_ptr_ptr; + /* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since + we are defining a symbol, ensure one of them is set. */ + if ((s->flags & BSF_LOCAL) == 0) + s->flags |= BSF_GLOBAL; + s->flags |= BSF_SYNTHETIC; + s->section = glink; + s->value = glink_vma - glink->vma; + s->name = names; + s->udata.p = NULL; + len = strlen ((*p->sym_ptr_ptr)->name); + memcpy (names, (*p->sym_ptr_ptr)->name, len); + names += len; + if (p->addend != 0) + { + memcpy (names, "+0x", sizeof ("+0x") - 1); + names += sizeof ("+0x") - 1; + bfd_sprintf_vma (abfd, names, p->addend); + names += strlen (names); + } + memcpy (names, "@plt", sizeof ("@plt")); + names += sizeof ("@plt"); + s++; + if (abi < 2) + { + glink_vma += 8; + if (i >= 0x8000) + glink_vma += 4; + } + else + glink_vma += 4; + count++; + } } } diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 59444b063a4..4c7cd7f77b0 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -16624,7 +16624,8 @@ _bfd_mips_elf_get_synthetic_symtab (bfd *abfd, size += count * (sizeof (mipssuffix) + (micromips_p ? sizeof (microsuffix) : sizeof (m16suffix))); for (pi = 0; pi < counti; pi += bed->s->int_rels_per_ext_rel) - size += 2 * strlen ((*p[pi].sym_ptr_ptr)->name); + if ((*p[pi].sym_ptr_ptr)->name != NULL) + size += 2 * strlen ((*p[pi].sym_ptr_ptr)->name); /* Add the size of "_PROCEDURE_LINKAGE_TABLE_" too. */ size += sizeof (asymbol) + sizeof (pltname); @@ -16754,31 +16755,34 @@ _bfd_mips_elf_get_synthetic_symtab (bfd *abfd, if (i < count) { - size_t namelen; - size_t len; - - *s = **p[pi].sym_ptr_ptr; - /* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since - we are defining a symbol, ensure one of them is set. */ - if ((s->flags & BSF_LOCAL) == 0) - s->flags |= BSF_GLOBAL; - s->flags |= BSF_SYNTHETIC; - s->section = plt; - s->value = plt_offset; - s->name = names; - s->udata.i = other; - - len = strlen ((*p[pi].sym_ptr_ptr)->name); - namelen = len + suffixlen; - if (names + namelen > nend) - break; + if ((*p[pi].sym_ptr_ptr)->name != NULL) + { + size_t namelen; + size_t len; + + *s = **p[pi].sym_ptr_ptr; + /* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since + we are defining a symbol, ensure one of them is set. */ + if ((s->flags & BSF_LOCAL) == 0) + s->flags |= BSF_GLOBAL; + s->flags |= BSF_SYNTHETIC; + s->section = plt; + s->value = plt_offset; + s->name = names; + s->udata.i = other; + + len = strlen ((*p[pi].sym_ptr_ptr)->name); + namelen = len + suffixlen; + if (names + namelen > nend) + break; - memcpy (names, (*p[pi].sym_ptr_ptr)->name, len); - names += len; - memcpy (names, suffix, suffixlen); - names += suffixlen; + memcpy (names, (*p[pi].sym_ptr_ptr)->name, len); + names += len; + memcpy (names, suffix, suffixlen); + names += suffixlen; - ++s, ++n; + ++s, ++n; + } pi = (pi + bed->s->int_rels_per_ext_rel) % counti; } } diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index dd951b91f50..dda3c7a9d7a 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -3710,9 +3710,12 @@ _bfd_x86_elf_get_synthetic_symtab (bfd *abfd, for (i = 0; i < dynrelcount; i++) { p = dynrelbuf[i]; - size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt"); - if (p->addend != 0) - size += sizeof ("+0x") - 1 + 8 + 8 * ABI_64_P (abfd); + if ((*p->sym_ptr_ptr)->name != NULL) + { + size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt"); + if (p->addend != 0) + size += sizeof ("+0x") - 1 + 8 + 8 * ABI_64_P (abfd); + } } s = *ret = (asymbol *) bfd_zmalloc (size); @@ -3817,7 +3820,8 @@ _bfd_x86_elf_get_synthetic_symtab (bfd *abfd, /* Skip unknown relocation. PR 17512: file: bc9d6cf5. */ if (got_vma == p->address && p->howto != NULL - && valid_plt_reloc_p (p->howto->type)) + && valid_plt_reloc_p (p->howto->type) + && (*p->sym_ptr_ptr)->name != NULL) { *s = **p->sym_ptr_ptr; /* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL