From patchwork Thu Oct 19 04:21:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nelson Chu X-Patchwork-Id: 155280 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp152898vqb; Wed, 18 Oct 2023 21:21:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQ8hVfaidSPvBEuuk7OsGZ6vdwEwhIrz4F2LnSxC+3F+RcZKkfq0RlccXU1RnNdgzzQlko X-Received: by 2002:a05:620a:2556:b0:76f:167a:cc4a with SMTP id s22-20020a05620a255600b0076f167acc4amr1018735qko.47.1697689286589; Wed, 18 Oct 2023 21:21:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697689286; cv=pass; d=google.com; s=arc-20160816; b=wDQM/lP2ZH/l5yKltOQhjUE6hJ2ye2O/KhOGsxdZ2GkrYrxzKfqsjpdpXu2aeD20v7 Dop2FeO61ADynBQt5S4i+jc9KlVr4r9oWHib8D1QCSPsfY14cQvNCcwimEjU4zhX/Z3i TkE+C4mM3sZkegHgbkC0cChR+33AK4DsgzXZfpYE20WwiF5TWPV07lwzpyukWmY1abDO LqNcOitSOnUuVxTaabslOnSTEt46K0w0w6cmPlCI4dR6SZ9gCIOxqhtE+kDU/XMs9ml3 GIyNhyR06E3WFlC+tGgS01jmGh518XLdvykS6IWhwf2iNWZ5Nhu4YNd5u2IVP5SgAkQH 8lLQ== 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:message-id:date:subject:cc:to:from:arc-filter :dmarc-filter:delivered-to; bh=ONjhSstXeFNLWFIT0LKYb1g4Kfr+aE6X3Ti4tC9L9gQ=; fh=dkdfcddV4GaGJt+ICEhyDTFCa53Q+qu09EcU9aQUVSQ=; b=XB3p/i7ZpbnoC8z+qDvy0Nlm3yXTzeJF4gfLxhd7uFEtoRsRDyaUoXbbPgvBnu2JE1 YrSU3Drzos91LTfMn0woX5W3bOn41rTVEAlf3+KHOh66HFfaYSpO8OIIdCkVvDT0Ioax jndeNOSBrEGKK7ovMN3BbTblc8tnWwYo3uuApS9aFwwWvi5D3vO/vJ7c9zwkNF7w9uQi TU9QOVB/CHrwBwkhL9VotuaI+ntMV6tPNLAfDmrNKO+M1PtNSUQRtLJQWmxN+h8IvTIX miexLsC9Zv89DqNQF6Li5RVkr7r9JljJ8ebWTT9LyMXxNGXOUkB+2dV2K5U5S3O2TGDX AK9A== ARC-Authentication-Results: i=2; mx.google.com; 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" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id b23-20020a05620a0cd700b0076daeaded07si936888qkj.74.2023.10.18.21.21.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 21:21:26 -0700 (PDT) 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; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B23D13858434 for ; Thu, 19 Oct 2023 04:21:25 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from NelsondeMBP.localdomain (114-25-69-175.dynamic-ip.hinet.net [114.25.69.175]) by sourceware.org (Postfix) with ESMTP id 047E53858C52 for ; Thu, 19 Oct 2023 04:21:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 047E53858C52 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=NelsondeMBP.localdomain ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 047E53858C52 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.25.69.175 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697689280; cv=none; b=u4hPSO0uoKXPXGB033rcaC7eRQao1+ddfPAuUGSCPP536DbOLez2Qyw9n1pU5JiXaLOKJwTBro7CdW7c6IibARzsYkLLu/WZSxe6180S/fMwnmx/ePALi0TuIvcNKiqpV4hq2AB0L3RrwoH5zEtB+mRCC/8FkxDyymE+w5cFvTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697689280; c=relaxed/simple; bh=uZJFOH0x5QyApwV2WW7I7HdITp27jtxAJI99WstqHDo=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=nexVZ6BZrZ5YTfRKwuzlHqYw2kZpXrI6Jb8luuawoPrXQc+4tGSZ0XckXFqZhvDnFAcgS83NqbZdagCULl/R6fi1y2Ze11BWGC3deinJip9PzpLuDxe2Z5w5KU8GRVa+RwXWkc3qiu7upq4ygG32hJscNzENG6HdmhBlK18Ocik= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by NelsondeMBP.localdomain (Postfix, from userid 501) id 3699C129BA3F; Thu, 19 Oct 2023 12:21:15 +0800 (CST) From: Nelson Chu To: binutils@sourceware.org, kito.cheng@sifive.com, palmer@rivosinc.com Cc: nelson.rivosinc.com@NelsondeMBP.localdomain, Nelson Chu Subject: [committed] RISC-V: Don't do undefweak relaxations for the linker_def symbols. Date: Thu, 19 Oct 2023 12:21:13 +0800 Message-Id: <20231019042113.29348-1-nelson@rivosinc.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) MIME-Version: 1.0 X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KHOP_HELO_FCRDNS, NO_DNS_FOR_FROM, RCVD_IN_PBL, RCVD_IN_SORBS_DUL, RDNS_DYNAMIC, SPF_HELO_NONE, SPF_NONE, 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+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780156240531172578 X-GMAIL-MSGID: 1780156240531172578 I get the following truncated errors recently when running riscv-gnu-toolchain regressions, /scratch/riscv-gnu-toolchain/regression/build/linux-rv32imafdc-ilp32d-medlow/build-glibc-linux-rv32imafdc-ilp32d/libc.a(libc-start.o): in function `elf_irela': /scratch/riscv-gnu-toolchain/glibc/csu/../sysdeps/riscv/dl-irel.h:47:(.text+0x88): relocation truncated to fit: R_RISCV_GPREL_I against symbol `__ehdr_start' defined in .note.ABI-tag section in /scratch/riscv-gnu-toolchain/regression/build/linux-rv32imafdc-ilp32d-medlow/build-glibc-linux-rv32imafdc-ilp32d/elf/sln The linker_def symbols like __ehdr_start that may be undefweak in early stages of linking, including relax stage, but are guaranteed to be defined later. Therefore, it seems like we shouldn't do the undefweak relaxations for these kinds of symbols since they may be defined after relaxations. bfd/ * elfnn-riscv.c (_bfd_riscv_relax_section): Don't do undefweak relaxations for the linker_def symbols. --- bfd/elfnn-riscv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index 09aa7be225e..3edf68e3e30 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -5123,7 +5123,13 @@ _bfd_riscv_relax_section (bfd *abfd, asection *sec, if (h != NULL && h->type == STT_GNU_IFUNC) continue; + /* Maybe we should check UNDEFWEAK_NO_DYNAMIC_RELOC here? But that + will break the undefweak relaxation testcases, so just make sure + we won't do relaxations for linker_def symbols in short-term. */ if (h->root.type == bfd_link_hash_undefweak + /* The linker_def symbol like __ehdr_start that may be undefweak + for now, but will be guaranteed to be defined later. */ + && !h->root.linker_def && (relax_func == _bfd_riscv_relax_lui || relax_func == _bfd_riscv_relax_pc)) {