From patchwork Sat Oct 14 05:03:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsukasa OI X-Patchwork-Id: 15364 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp2305851vqb; Fri, 13 Oct 2023 22:03:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHODFcO5CGInPkE862YvM0p6WAWJLidiL3ymeHfNRoygg/RVLVfwpPBk7ZvGPrthcqZCpF3 X-Received: by 2002:a05:620a:3188:b0:76f:509:c78a with SMTP id bi8-20020a05620a318800b0076f0509c78amr33679470qkb.22.1697259825104; Fri, 13 Oct 2023 22:03:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697259825; cv=pass; d=google.com; s=arc-20160816; b=e3vJ2gBRXQICA/QzSIB0655QJPFosPBoiNc0Rehwr+2yhuR567rjNivCCiDlprOklX Wtu2alEqw0LUPS9Ab5nJ5BJYqQFk/QlTIh5RAqcu6ks+hDkxcDulxoxg75UpE/bCYrfL DKmK1nvrQryRDcddMeuQwGXP55LZ0JwWrJZsxNEBUljRT11HIY71dkI+osXW4tKtjfSw vkOQM2INOzh4gY1EdwaQIPQb1NyPHuTTnI/SBZbfMKCvX5Kft8pUasv6oSbR4vz82WGQ J3BofJwMX9MUWYeej91pZ5uRtkrGSEMlUrNjWj8Vomejh0JWQUNPnjtF1n8wwPj3oNEO 287Q== 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:dkim-signature :dmarc-filter:arc-filter:delivered-to; bh=Gks5QI6yQdhZtv4aT0uw+Qr5/lJtdeLfCeTorBaJBBk=; fh=Q+ZPQdyJDzJx4BfovHNTR1lP4msTSfN6TDra8V1lyf8=; b=RX6dr8vVH0x0CQUaRJ+bXqrtZE4sZ8maEp6RnxVabFdl6rVNOSFakQfDfCDWYbhvU8 bnlgVSV0ccZkGSKm1l+E6ioa+yuDx3ahk+qpijz2hEMAnbbttfBooujDbOfKI/v8RtSY 3fJZxp4+f0Nq21yJ6FTaL7uehTFqyC6ZNgQymkzjLcw6DUu8H7Ql864+t107vXT2GxK1 e45XEV1OcE0kngUjbBeZiw90H77bEVDIiylIcFX2AHeeDrL8pNNJhRyZXwe+Vo7Ir6pI +Bo6kcCwX0hSJ6dANYEnxDLI+FpyTCR5Twlb2054haVDM0Des9xV1RsQ024etV7ocshc qGBA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@irq.a4lg.com header.s=2017s01 header.b=Z+11zwIe; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=irq.a4lg.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id fb20-20020ad44f14000000b00651861e9275si2284210qvb.437.2023.10.13.22.03.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 22:03:45 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@irq.a4lg.com header.s=2017s01 header.b=Z+11zwIe; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=irq.a4lg.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D051E3858298 for ; Sat, 14 Oct 2023 05:03:44 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-sender-0.a4lg.com (mail-sender-0.a4lg.com [IPv6:2401:2500:203:30b:4000:6bfe:4757:0]) by sourceware.org (Postfix) with ESMTPS id 799CD3858C2B for ; Sat, 14 Oct 2023 05:03:38 +0000 (GMT) ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 799CD3858C2B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2401:2500:203:30b:4000:6bfe:4757:0 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697259820; cv=none; b=rj3c6t3Jvdfo6Ic58XJS56wlYtY/mCwYxl6wlMKGEBBPMOmBp3W6YwoGpsyuj3L2HK7nyS0yX/YKR4ZmmZ7qJ4d54UMH4U9CZh0IbxDmPjgNlfY8AjTRQwijYGoRvAZHbDXYoOGRyW6t7YKhW4rKI6iMOE7L0+rlKJo7NIpS8dE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697259820; c=relaxed/simple; bh=xRARMvwUJ25AEfSMz6j8FZ780Tg80+alhnGtXzocBTU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:Mime-Version; b=vVeEpmPSeuJnunJnwExNxSinfnvb+Fj90Db5eIy5cdAwd5+d76dXT0rdkbthHMi8oaZVg1XrttW57BzWI9W9GJLjP79nOf2nAsPSS5JuxfmMk+9hXQ9jtmoAMbUVUJBUcCyFkR4ob4bo5cXGSXueM4Ff//97cFx3RMtiIR1loF0= ARC-Authentication-Results: i=1; server2.sourceware.org DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 799CD3858C2B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=irq.a4lg.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=irq.a4lg.com Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id A06A8300089; Sat, 14 Oct 2023 05:03:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irq.a4lg.com; s=2017s01; t=1697259815; bh=Gks5QI6yQdhZtv4aT0uw+Qr5/lJtdeLfCeTorBaJBBk=; h=From:To:Cc:Subject:Date:Message-ID:Mime-Version: Content-Transfer-Encoding; b=Z+11zwIegMQ92Nx6TsK/5xchw0l4kRMYrUDlEI3ayCU4GPhHL9Q+1Y8IxSDr0vqv0 UV2bwmLe15/Vx+2br0DIKziz+kqipeQxibvhqag+neLamvezRp/rNViQm0W4CSMYzQ yUmTYUHryRwnAmYct4RgOUUtajNU3Umj98gyhOlE= From: Tsukasa OI To: Tsukasa OI , Palmer Dabbelt , Andrew Waterman , Jim Wilson , Nelson Chu , Kito Cheng Cc: binutils@sourceware.org Subject: [PATCH 0/2] RISC-V: Preparation for more generic linker relaxation Date: Sat, 14 Oct 2023 05:03:20 +0000 Message-ID: Mime-Version: 1.0 X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KAM_MANYTO, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no 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: 1779705918066884337 X-GMAIL-MSGID: 1779705918066884337 Hi, It *seems* a generic tidying patch set which does nothing useful. However, this is a part of my attempt to implement Qualcomm's proposal of Code Size Reduction Instructions (tentatively called 'Zics') but without any 'Zics'- specific code. Qualcomm's proposal of Code Size Reduction Instructions: My test branch implementing most of them (except assembler/linker support of PC-relative load instructions): This patch set intends to improve clarity and maintainability of the linker relaxation so that 'Zics'-related linker relaxation can be implemented easily. I believe that it will be helpful even if 'Zics' is not approved. 'Zics' attempts to reduce the code size by providing PC-relative load instructions (as well as other many additional addressing modes). However, Qualcomm's proposal of the PC-relative load instructions is exactly the same as GNU Binutils' macro load instructions (except "lb" and "lbu", that Qualcomm's proposal does not have a counterpart). GNU Binutils' macro load instruction: label: lw a0, symbol will generate instruction sequence like this: 0: 00000517 auipc a0,0x0 0: R_RISCV_PCREL_HI20 symbol 0: R_RISCV_RELAX *ABS* 4: 00052503 lw a0,0(a0) # 0 <_start> 4: R_RISCV_PCREL_LO12_I label 4: R_RISCV_RELAX *ABS* If "symbol" is near enough (relative to the second "lw"), the linker may relax the instruction sequence like this (pseudo objdump output): 0: d0807503 lw a0,400 # This "lw" encoding is a proposed variant by Qualcomm. It will require a few changes (riscv_pc_relax_hi_reloc must store additional information such like reference count to keep track of whether HI20 instruction can be removed; this is because we may not be able to remove instruction with HI20 relocation if (a) multiple LO12 relocations are corresponding (b) there are multiple types of linker relaxations utilizing this type and (c) at least one of them, relaxation possibility is determined based on the instruction address with LO12 relocation, not HI20 one). That got a quite long but even if Qualcomm's proposal didn't progress any further, this patch alone set will be helpful to implement such like **proper** Zero-page relaxation (current zero-page relaxation reusing the code from PCREL->GPREL is too restrictive). Thanks, Tsukasa Tsukasa OI (2): RISC-V: Group relaxation features RISC-V: Prepare for more generic PCREL relaxations bfd/elfnn-riscv.c | 176 ++++++++++++++++++++++++++-------------------- 1 file changed, 100 insertions(+), 76 deletions(-) base-commit: 5e2c9ce9c0bf4763a6d17a3a5bee9011ec710f10