From patchwork Sat Nov 29 00:52:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 125550 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A3D4748F44D4 for ; Sat, 29 Nov 2025 00:54:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A3D4748F44D4 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=AXRBN7Ag X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by sourceware.org (Postfix) with ESMTPS id 32E8048F60DA for ; Sat, 29 Nov 2025 00:53:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 32E8048F60DA 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 32E8048F60DA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.216.46 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1764377618; cv=none; b=C0vkpDsCjnBIUl9ebKBWiqR8osYExXDhzgBej1qyv3U3aCUPMVWk+/6oA3L2UPQlvD69Q2Xgea8CSauHdLFpYXBxUUuH1XwtIJL+tcbTuel69ZiF9eesUiSGbCmva9dEEGwMrMjzhktQRDzLy4pd1ZDS6vioVRTppiOxcCGeEVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1764377618; c=relaxed/simple; bh=aXAk0YorWxbmmKTqQs29WIaTu8Rkj/8JyiKUJ4Cy4Dw=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=vWlxbBgbTs69Ufe+9iywbaSApvIoagePRmglN6ID1WkY8N0VpuvsjOjB/X1QEZV/44QeoMLN5RDFubtwwWXCVkHBwu/C1ELete9n8C09qzEwQQ3cBc3NYY/y+THyKsCAUnNVt/xy4Hb9OcHp65QoB4EHykIw0Towmz4rYv17I2E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32E8048F60DA Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-3438d4ae152so2490036a91.1 for ; Fri, 28 Nov 2025 16:53:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764377617; x=1764982417; darn=sourceware.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=XRLdbG7rjrpPqbUEV14xiQJoj3GFHYYM0sFefxXog0o=; b=AXRBN7Ag1GLGblgqqsCDFgrQMlQWNbhk4g4ylV0YVl3gfkL6YR9IjuY24An0+7tHT/ gK1OeqwXZ3xo/7UecLP4AEwguhvidCD1r+3EEhU7chaZnldyOhYFuruFcF4Nz4Ki+IK6 Svrb9QmHB5M4kya8DKUJCnD2lrSsynM/g9x0BwW67dDI0HMYmCZzX0Y9cgzlq+8ryMCr 0eX4WyWgGLztTvV7cHxGeXjnUNyFdKnHDNAY5UPckXXnZArCH5UShUS6qpjEsBXjmwCu 2JsWpYutvg/+u4zWEAWHH5PQ7we7/7iB68vnA9toauDyTVZl/xFzw+yJC64hrBtzO2cB x9FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764377617; x=1764982417; h=to:subject:message-id:date:from:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XRLdbG7rjrpPqbUEV14xiQJoj3GFHYYM0sFefxXog0o=; b=Na7HPQckDg/vGoqAQO7S/wj2ETrtLjaBodkRY8BToqN1HKPvHVgQwKMVKe295+R0wZ dIEQvKrKIK0tIvUW3r2qrSBkXJtilWJcAFHWHbzYzs/olw2Cv0B07fkcHyh7E1N/0j6Z S9pICFToyGVyLT6bd9EhkaiJgZDvYwughJpgGHKvF5Q8HZWiNMXYrNp5Uj8F07lRJFs8 ZtALWUmOwOBZU5rgC2uJgqx3ONQt6I1ID/sw4kUP7rxr8k3XWS6l20vQpoH0LQviHcTz EiCt17nze20aZi0IbHKo9fni5D2YNTvYovQQCjCsq5eXNO12Zc7nzlLpzzAJPZiwEO67 bPYA== X-Gm-Message-State: AOJu0YwVi0wxbdLHe1Zh1G8eDTVUA/eIOCsbTjyUY/AS9fK9tg7z9Bmr J+k6RggnbaT5ZhA3LzhW4kBViC8uxFAOgH0b1ECycOPaf3ApeNdRpKoxt24xtgvLvmwu2Wan6Ei 3oHM4AOd34qWU2X0nqlWDRbtmDyB5v3rInSOaAQ1TsJWN2Og= X-Gm-Gg: ASbGncuQjUhSB0KV8IlX/hk1HUkiAKM0uQ4iMUlSlQLZcfDeKQaZRzIo8oV0ZDvGj0m q72t8nngSHru4B2b2b6fJvvFnhAWR4Sna3+dZJvpE739aHbzpytTO1KNUmeUhztmhhMu6Lhw+2n UoRHHmiFaXOa69tHIb2wRnW7fgsogS0x7m44gMW0YvGfKQ57WGYLbLKOvM6BA+a6uMnYJyrs0C2 6c/wJX6Y6L+339DDYOPbGo4qyLNycCSCezaiBt5+WXI3MaG/R5NAZQIMTcaCRFzfCdy5tpOC/KP t9/r7DdSm8H8A19KmUBofZ+t X-Google-Smtp-Source: AGHT+IFvix5Una8IdaVLU750t0piXHl725uplWdgW6NvEnHKzECluAIfdrLwLCRkORtyhsfkJZMmqNK0U+S5eBGsV7I= X-Received: by 2002:a17:90b:2d0c:b0:32e:389b:8762 with SMTP id 98e67ed59e1d1-34733d845bemr25571679a91.0.1764377616723; Fri, 28 Nov 2025 16:53:36 -0800 (PST) MIME-Version: 1.0 From: "H.J. Lu" Date: Sat, 29 Nov 2025 08:52:59 +0800 X-Gm-Features: AWmQ_blm-Qd-OfLt92JWWXbZIZEvKpKHkvq-QGiD3Zk82b838DnIh6L8ZMzAr4A Message-ID: Subject: [PATCH] x86: traverse loc_hash_table only if used To: Binutils , Jan Beulich X-Spam-Status: No, score=-3012.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, 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 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 Traverse x86 loc_hash_table only if it is used. * elf32-i386.c (elf_i386_output_arch_local_syms): Traverse loc_hash_table only if has_loc_hash_table is set. * elf64-x86-64.c (elf_x86_64_output_arch_local_syms): Likewise. * elfxx-x86.c (_bfd_elf_x86_get_local_sym_hash): Set has_loc_hash_table. (_bfd_x86_elf_late_size_sections): Traverse loc_hash_table only if has_loc_hash_table is set. * elfxx-x86.h (elf_x86_link_hash_table): Move plt0_pad_byte and add has_loc_hash_table. From e3a9a6162101813437f6a136808866b3e0a4927d Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sat, 29 Nov 2025 08:47:46 +0800 Subject: [PATCH] x86: traverse loc_hash_table only if used Traverse x86 loc_hash_table only if it is used. * elf32-i386.c (elf_i386_output_arch_local_syms): Traverse loc_hash_table only if has_loc_hash_table is set. * elf64-x86-64.c (elf_x86_64_output_arch_local_syms): Likewise. * elfxx-x86.c (_bfd_elf_x86_get_local_sym_hash): Set has_loc_hash_table. (_bfd_x86_elf_late_size_sections): Traverse loc_hash_table only if has_loc_hash_table is set. * elfxx-x86.h (elf_x86_link_hash_table): Move plt0_pad_byte and add has_loc_hash_table. Signed-off-by: H.J. Lu --- bfd/elf32-i386.c | 10 ++++++---- bfd/elf64-x86-64.c | 10 ++++++---- bfd/elfxx-x86.c | 9 ++++++--- bfd/elfxx-x86.h | 9 ++++++--- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index abb361be993..755c2176fd2 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -4271,10 +4271,12 @@ elf_i386_output_arch_local_syms if (htab == NULL) return false; - /* Fill PLT and GOT entries for local STT_GNU_IFUNC symbols. */ - htab_traverse (htab->loc_hash_table, - elf_i386_finish_local_dynamic_symbol, - info); + /* Fill PLT and GOT entries for local STT_GNU_IFUNC symbols if + needed. */ + if (htab->has_loc_hash_table) + htab_traverse (htab->loc_hash_table, + elf_i386_finish_local_dynamic_symbol, + info); return true; } diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 337394fc478..1bffced9a30 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -5777,10 +5777,12 @@ elf_x86_64_output_arch_local_syms if (htab == NULL) return false; - /* Fill PLT and GOT entries for local STT_GNU_IFUNC symbols. */ - htab_traverse (htab->loc_hash_table, - elf_x86_64_finish_local_dynamic_symbol, - info); + /* Fill PLT and GOT entries for local STT_GNU_IFUNC symbols if + needed. */ + if (htab->has_loc_hash_table) + htab_traverse (htab->loc_hash_table, + elf_x86_64_finish_local_dynamic_symbol, + info); return true; } diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index 215a1569e9d..9f425e9bb9b 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -613,6 +613,7 @@ _bfd_elf_x86_get_local_sym_hash (struct elf_x86_link_hash_table *htab, ret->elf.dynindx = -1; ret->plt_got.offset = (bfd_vma) -1; *slot = ret; + htab->has_loc_hash_table = 1; } return &ret->elf; } @@ -2425,9 +2426,11 @@ _bfd_x86_elf_late_size_sections (bfd *output_bfd, elf_link_hash_traverse (&htab->elf, elf_x86_allocate_dynrelocs, info); - /* Allocate .plt and .got entries, and space for local symbols. */ - htab_traverse (htab->loc_hash_table, elf_x86_allocate_local_dynreloc, - info); + /* Allocate .plt and .got entries, and space for local symbols if + needed. */ + if (htab->has_loc_hash_table) + htab_traverse (htab->loc_hash_table, elf_x86_allocate_local_dynreloc, + info); /* For every jump slot reserved in the sgotplt, reloc_count is incremented. However, when we reserve space for TLS descriptors, diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h index 7e196cd0475..99ef9341563 100644 --- a/bfd/elfxx-x86.h +++ b/bfd/elfxx-x86.h @@ -673,9 +673,8 @@ struct elf_x86_link_hash_table /* TRUE if inputs call ___tls_get_addr. This is only used for i386. */ unsigned int has_tls_get_addr_call : 1; - /* Value used to fill the unused bytes of the first PLT entry. This - is only used for i386. */ - bfd_byte plt0_pad_byte; + /* TRUE if loc_hash_table is used. */ + unsigned int has_loc_hash_table : 1; /* TRUE if GOT is referenced. */ unsigned int got_referenced : 1; @@ -688,6 +687,10 @@ struct elf_x86_link_hash_table function address. */ unsigned int pcrel_plt : 1; + /* Value used to fill the unused bytes of the first PLT entry. This + is only used for i386. */ + bfd_byte plt0_pad_byte; + bfd_vma (*r_info) (bfd_vma, bfd_vma); bfd_vma (*r_sym) (bfd_vma); bool (*is_reloc_section) (const char *); -- 2.52.0