From patchwork Tue Feb 20 17:55:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tatsuyuki Ishi X-Patchwork-Id: 203728 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp571786dyc; Tue, 20 Feb 2024 10:02:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUJAVaOWj2hb8CHYIS223nmZ6v0Iuvfc9kA5S8poC0TpNAue9z7+QjIdWcOsQFPtJZIPrDI82rsaNTXR7fKndbzenlAVw== X-Google-Smtp-Source: AGHT+IEka7K+iWo2ovyfNjcd1WxXKywH16LBy1FtdU0yxG9YGzdZPNqqEROGlhv0Ed6+afestG/C X-Received: by 2002:a0c:da8d:0:b0:68f:721e:9ad1 with SMTP id z13-20020a0cda8d000000b0068f721e9ad1mr5811539qvj.65.1708452131791; Tue, 20 Feb 2024 10:02:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708452131; cv=pass; d=google.com; s=arc-20160816; b=k5bqgYaNi7gVKUg8oTfJOx2pz6eAzNn5uzimFZA0hvOicHKoHqbjCRdmVcaGlR1Q0q U7uvlranzPeypRkGOIfXmMb7+gsUEl2L0CKFndMXxmJzwwDOelB+jj49n3XG48Fe/YOq gycYn4xXGnmHELzhXUgyMhnQM89L2jGjj/yDqkfFTrl5h/9FgtRhJBjLlRATTAuSmNKX muaOn8s4rauZiE/g5aq/rb5YtP6KGdno+pMos6e21SWduv4lgNed0cW8P9k6OHTxfgOU 0G/wJUYBN+aWXQEpFa60XWwUUddaY8XHeyx1R3UqO3WYKLYoJEAxfVAy9evL2xwyDA0e 884w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=DNrOBFf8/pwu+DtubgIpDhc+heOFu5Yj769tqGEEopQ=; fh=YSa8tbAsFM03BU4mjhbbHsdQe1vIF6KegOb6Q0/FrUw=; b=nLx6NAah9PwTCipCOdUNa4RxCbs85ui62F5v+IVSPRQLlESUUbzJtjbBPNKr0wQw0l 61iBQO5oBMa/ky+qqyV8rX6qJs/CaCZKrKm3q0qz/apct+NZ6DHm6X6YyFoPH3IWQosB uG8GWzwqpR+ZznnPEOpM1kfZTtWNu8daZ0XAFkLTjBSd71F8+KxZOrjKk1RSdGjAV8vU xR7iRfU7BZzetDy7nXBmKxgVGA/9+B4ElIo734nxG3+kBV/9zV8dRFxh3Vr80MGne94g 7EyPLYDwVkE2IHoB2AQbdCD8gwF5VX/I39N8nNTz3YNsO/N3L7JPZ9MJM5IpTHmkrC3v blCg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="JBWo/BeZ"; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gw13-20020a0562140f0d00b0068f3fdcaf25si9372313qvb.243.2024.02.20.10.02.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 10:02:11 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="JBWo/BeZ"; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D81F23861839 for ; Tue, 20 Feb 2024 18:01:01 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-oo1-xc34.google.com (mail-oo1-xc34.google.com [IPv6:2607:f8b0:4864:20::c34]) by sourceware.org (Postfix) with ESMTPS id 8B43D3858D28 for ; Tue, 20 Feb 2024 17:56:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8B43D3858D28 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 8B43D3858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c34 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708451806; cv=none; b=qzOor3OfCkjyKaQfGbMjT1UdNEEJIo6O1Wg0Ziej8iVBNIt/a9P/NeNpyPznzYmV+inv9M/q+2NBH7sRoG2oWL/DCV66FBCYjb4zQj9aa0aywE/EkK6acagx10lRkVaZAV5OjjbLdBAZDnOJNmG3rz6SH6zjyyaSaOMmnLuQpqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708451806; c=relaxed/simple; bh=6pm6TK+hpvuC3A/32SZ46Lb1R6SO1q0+TTH9x7f8bfw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wPreFkg0AKvY9foqjMX7gUZshDODdY9FfnGlbEpqPfWHGOrl0sYzUib8kPFaQ17HO4f86k+pKQ/DsaPcsqQpIe6yMQtNfJCbjQqyyrNo4gMtZHfNJZIfJgyUiyIWBxExyiiWgTbHhNGs1o1VFdAJNHwd1YWjcnvu0yQNbIeUp08= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc34.google.com with SMTP id 006d021491bc7-59fcf83f92fso189659eaf.1 for ; Tue, 20 Feb 2024 09:56:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708451802; x=1709056602; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DNrOBFf8/pwu+DtubgIpDhc+heOFu5Yj769tqGEEopQ=; b=JBWo/BeZsCfasl65RRSAG8OdttbSceZJWjNIBpULCxKWcwbKj3GQaVZO/v3yOBqot6 znMigi9ebmdFZgjzZ3BWkCDIHPWhBLyx6zuJv1nQiMs2Ej31u9ds2McGZHilBjPHnMdF 94DuJKPt/dkD4q1vuTo4S0bLTFOj64t0tBHrPWECPOgZ8HRGT3Ny+Jzg94bE+2/kWhkO 5hQwigQNUqHrpT9c/Ha7klzG1yIkVUhKg4lWqVZAMj1OL/i24UdJmk7Zf5SVYVU8SVy9 nn1xvaMX+6LgFRxHDDK701XLC23KbMa18IbDrrKhB2rwrk5qVjz0NEYH8SOwgb2pzUVc p02g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708451802; x=1709056602; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DNrOBFf8/pwu+DtubgIpDhc+heOFu5Yj769tqGEEopQ=; b=XD4cQ4NgUM5hBT31IJGCEvZZ44CQVJ7FjyfeQrDbJHtlyjRmJusXy2erU1atugD1pm 6XUmZQhlACz78PonB3+PJPQP72JtOgHjwUoaEZQHDb/afPG1zkEgP8xefOoReNAhmkud BCZ/smqmN/GDgheMRFtaBAtGZwTzsrUHmeg3yDdIbs2GZBgcmhhNkwDHkhdMA//2IgaH 2KAg9u2TqAIY0yP1tHBiVGx7o8p13xKsTfJx3qPE0eDQXMvIHgU0f1a0HPSH1Q7YIns/ pcDfs+418E++qfZ83BEKfq133ywIIxo3y5gu2SsvKmVUPZMQgasusNBd0WvabR3q+aHs pKmA== X-Gm-Message-State: AOJu0YzOqvM+U7sdeQfgA5XdNxEXNWrIMww0fgqmLmwMOcPUMxUNpHPc ezYHFKbNjHrchBLCb1TRTFe7e+n6Hy2BfePL8+eIdbCAXcJoN2u8H3tY7bXOFcEgdg== X-Received: by 2002:a05:6358:e49a:b0:178:9f1d:65e3 with SMTP id by26-20020a056358e49a00b001789f1d65e3mr14584137rwb.0.1708451801820; Tue, 20 Feb 2024 09:56:41 -0800 (PST) Received: from localhost (zz20184013906F627101.userreverse.dion.ne.jp. [111.98.113.1]) by smtp.gmail.com with ESMTPSA id b186-20020a6334c3000000b005dc120fa3b2sm6768549pga.18.2024.02.20.09.56.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 09:56:41 -0800 (PST) From: Tatsuyuki Ishi To: binutils@sourceware.org Cc: i@maskray.me, nelson@rivosinc.com, rui314@gmail.com, ruiu@bluewhale.systems, Tatsuyuki Ishi Subject: [PATCH v4 8/9] RISC-V: Add elf_link_hash_entry to relax_func args. Date: Wed, 21 Feb 2024 02:55:55 +0900 Message-ID: <20240220175556.304692-9-ishitatsuyuki@gmail.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240220175556.304692-1-ishitatsuyuki@gmail.com> References: <20230817180852.121628-2-ishitatsuyuki@gmail.com> <20240220175556.304692-1-ishitatsuyuki@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791441902528586743 X-GMAIL-MSGID: 1791441902528586743 bfd/ * elfnn-riscv.c (riscv_pcgp_hi_reloc): Add a field for hash_entry. (riscv_record_pcgp_hi_reloc): Add argument and record the hash_entry. (_bfd_riscv_relax_*): Add unused hash_entry argument. (_bfd_riscv_relax_pc): Also record the hash_entry, for consistency (but it is not used by the LO reloc handling). (_bfd_riscv_relax_section): Move h to outer scope and pass into relax helpers. --- bfd/elfnn-riscv.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index 1fbb0698ce1..acc45ebb549 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -4235,6 +4235,7 @@ struct riscv_pcgp_hi_reloc bfd_vma hi_addr; unsigned hi_sym; asection *sym_sec; + struct elf_link_hash_entry *h; bool undefined_weak; riscv_pcgp_hi_reloc *next; }; @@ -4295,6 +4296,7 @@ static bool riscv_record_pcgp_hi_reloc (riscv_pcgp_relocs *p, bfd_vma hi_sec_off, bfd_vma hi_addend, bfd_vma hi_addr, unsigned hi_sym, asection *sym_sec, + struct elf_link_hash_entry *h, bool undefined_weak) { riscv_pcgp_hi_reloc *new = bfd_malloc (sizeof (*new)); @@ -4305,6 +4307,7 @@ riscv_record_pcgp_hi_reloc (riscv_pcgp_relocs *p, bfd_vma hi_sec_off, new->hi_addr = hi_addr; new->hi_sym = hi_sym; new->sym_sec = sym_sec; + new->h = h; new->undefined_weak = undefined_weak; new->next = p->hi; p->hi = new; @@ -4607,6 +4610,7 @@ riscv_relax_resolve_delete_relocs (bfd *abfd, typedef bool (*relax_func_t) (bfd *, asection *, asection *, struct bfd_link_info *, + struct elf_link_hash_entry *, Elf_Internal_Rela *, bfd_vma, bfd_vma, bfd_vma, bool *, riscv_pcgp_relocs *, @@ -4617,6 +4621,7 @@ typedef bool (*relax_func_t) (bfd *, asection *, asection *, static bool _bfd_riscv_relax_call (bfd *abfd, asection *sec, asection *sym_sec, struct bfd_link_info *link_info, + struct elf_link_hash_entry *_h ATTRIBUTE_UNUSED, Elf_Internal_Rela *rel, bfd_vma symval, bfd_vma max_alignment, @@ -4723,6 +4728,7 @@ _bfd_riscv_relax_lui (bfd *abfd, asection *sec, asection *sym_sec, struct bfd_link_info *link_info, + struct elf_link_hash_entry *_h ATTRIBUTE_UNUSED, Elf_Internal_Rela *rel, bfd_vma symval, bfd_vma max_alignment, @@ -4836,6 +4842,7 @@ _bfd_riscv_relax_tls_le (bfd *abfd, asection *sec, asection *sym_sec ATTRIBUTE_UNUSED, struct bfd_link_info *link_info, + struct elf_link_hash_entry *_h ATTRIBUTE_UNUSED, Elf_Internal_Rela *rel, bfd_vma symval, bfd_vma max_alignment ATTRIBUTE_UNUSED, @@ -4878,6 +4885,7 @@ static bool _bfd_riscv_relax_align (bfd *abfd, asection *sec, asection *sym_sec, struct bfd_link_info *link_info, + struct elf_link_hash_entry *_h ATTRIBUTE_UNUSED, Elf_Internal_Rela *rel, bfd_vma symval, bfd_vma max_alignment ATTRIBUTE_UNUSED, @@ -4938,6 +4946,7 @@ _bfd_riscv_relax_pc (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, asection *sym_sec, struct bfd_link_info *link_info, + struct elf_link_hash_entry *_h, Elf_Internal_Rela *rel, bfd_vma symval, bfd_vma max_alignment, @@ -5058,6 +5067,7 @@ _bfd_riscv_relax_pc (bfd *abfd ATTRIBUTE_UNUSED, symval, ELFNN_R_SYM(rel->r_info), sym_sec, + _h, undefined_weak); /* Delete unnecessary AUIPC and reuse the reloc. */ *again = true; @@ -5147,6 +5157,7 @@ _bfd_riscv_relax_section (bfd *abfd, asection *sec, /* Examine and consider relaxing each reloc. */ for (i = 0; i < sec->reloc_count; i++) { + struct elf_link_hash_entry *h = NULL; asection *sym_sec; Elf_Internal_Rela *rel = relocs + i; relax_func_t relax_func; @@ -5249,7 +5260,6 @@ _bfd_riscv_relax_section (bfd *abfd, asection *sec, else { unsigned long indx; - struct elf_link_hash_entry *h; indx = ELFNN_R_SYM (rel->r_info) - symtab_hdr->sh_info; h = elf_sym_hashes (abfd)[indx]; @@ -5351,7 +5361,7 @@ _bfd_riscv_relax_section (bfd *abfd, asection *sec, symval += sec_addr (sym_sec); - if (!relax_func (abfd, sec, sym_sec, info, rel, symval, + if (!relax_func (abfd, sec, sym_sec, info, h, rel, symval, max_alignment, reserve_size, again, &pcgp_relocs, undefined_weak)) goto fail;