From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 75AE138356AE for ; Mon, 18 Jul 2022 08:45:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 75AE138356AE Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from 5.5.5 (unknown [10.2.5.5]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dx39BnHdVi6HQmAA--.33370S6; Mon, 18 Jul 2022 16:45:12 +0800 (CST) From: liuzhensong To: binutils@sourceware.org Cc: xuchenghua@loongson.cn, mengqinggang@loongson.cn, liuzhensong Subject: [PATCH 5/5 v1] LoongArch: Delete R_LARCH_NONE from dynamic info. Date: Mon, 18 Jul 2022 16:43:21 +0800 Message-Id: <20220718084316.390672-5-liuzhensong@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220718084316.390672-1-liuzhensong@loongson.cn> References: <20220718084316.390672-1-liuzhensong@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf9Dx39BnHdVi6HQmAA--.33370S6 X-Coremail-Antispam: 1UD129KBjvJXoWxKFW7AFW3Cr1ktF4xZF4kCrg_yoW7WrWxp3 Z8Zw4ayF4kGF17WasFqw1kZF4fXrWkCFyxtFWIvw109rs7JrykXFn3trnxGF42qa1YqFW3 ZryFgw15ua1kArUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBq14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26F4UJVW0owA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE 3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2I x0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8 JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc2xSY4AK6svPMxAIw2 8IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4l x2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrw CI42IY6xIIjxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI 42IY6xAIw20EY4v20xvaj40_Gr0_Zr1lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z2 80aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUjLvKUUUUUU== X-CM-SenderInfo: holx6xphqv003j6o00pqjv00gofq/ X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, 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.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2022 08:45:16 -0000 Some R_LARCH_64 in section .eh_frame will to generate R_LARCH_NONE, we change relocation to R_LARCH_32_PCREL from R_LARCH_64 in setction .eh_frame and not generate dynamic relocation for R_LARCH_32_PCREL. Add New relocate type R_LARCH_32_PCREL for .eh_frame. include/elf/ loongarch.h bfd/ bfd/bfd-in2.h libbfd.h reloc.c elfxx-loongarch.c elfnn-loongarch.c gas/config/ tc-loongarch.c binutils/ readelf.c ld/testsuite/ld-elf/ eh5.d --- bfd/bfd-in2.h | 1 + bfd/elfnn-loongarch.c | 11 +++++++++++ bfd/elfxx-loongarch.c | 19 ++++++++++++++++++- bfd/libbfd.h | 1 + bfd/reloc.c | 3 +++ binutils/readelf.c | 2 ++ include/elf/loongarch.h | 5 ++++- ld/testsuite/ld-elf/eh5.d | 2 +- 8 files changed, 41 insertions(+), 3 deletions(-) diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index a71b3e82057..53abf36477f 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -6309,6 +6309,7 @@ assembler and not (currently) written to any object files. */ BFD_RELOC_LARCH_TLS_LD64_HI20, BFD_RELOC_LARCH_TLS_GD_PC_HI20, BFD_RELOC_LARCH_TLS_GD64_HI20, + BFD_RELOC_LARCH_32_PCREL, BFD_RELOC_LARCH_RELAX, BFD_RELOC_UNUSED }; diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c index 5bb7596e5d0..44b8d6dca9b 100644 --- a/bfd/elfnn-loongarch.c +++ b/bfd/elfnn-loongarch.c @@ -2011,6 +2011,17 @@ perform_relocation (const Elf_Internal_Rela *rel, asection *input_section, bfd_put (bits, input_bfd, opr1 - value, contents + rel->r_offset); break; + /* For eh_frame and debug info. */ + case R_LARCH_32_PCREL: + value -= sec_addr (input_section) + rel->r_offset; + value += rel->r_addend; + bfd_vma word = bfd_get (howto->bitsize, input_bfd, + contents + rel->r_offset); + word = (word & ~howto->dst_mask) | (value & howto->dst_mask); + bfd_put (howto->bitsize, input_bfd, word, contents + rel->r_offset); + r = bfd_reloc_ok; + break; + /* New reloc type. R_LARCH_B16 ~ R_LARCH_TLS_GD64_HI20. */ case R_LARCH_B16: diff --git a/bfd/elfxx-loongarch.c b/bfd/elfxx-loongarch.c index 1f6346ef5f3..1a4f99a8927 100644 --- a/bfd/elfxx-loongarch.c +++ b/bfd/elfxx-loongarch.c @@ -1327,7 +1327,24 @@ static loongarch_reloc_howto_type loongarch_howto_table[] = reloc_bits, /* adjust_reloc_bits */ "gd64_hi20"), /* larch_reloc_type_name */ - LOONGARCH_HOWTO (R_LARCH_RELAX, /* type (99). */ + LOONGARCH_HOWTO (R_LARCH_32_PCREL, /* type (99). */ + 0, /* rightshift. */ + 4, /* size. */ + 32, /* bitsize. */ + true, /* pc_relative. */ + 0, /* bitpos. */ + complain_overflow_dont, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_32_PCREL", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask */ + 0xffffffff, /* dst_mask */ + false, /* pcrel_offset */ + BFD_RELOC_LARCH_32_PCREL, /* bfd_reloc_code_real_type */ + NULL, /* adjust_reloc_bits */ + NULL), /* larch_reloc_type_name */ + + LOONGARCH_HOWTO (R_LARCH_RELAX, /* type (100). */ 0, /* rightshift */ 1, /* size */ 0, /* bitsize */ diff --git a/bfd/libbfd.h b/bfd/libbfd.h index b23ae4b755c..0b8610524e1 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -3492,6 +3492,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_LARCH_TLS_LD64_HI20", "BFD_RELOC_LARCH_TLS_GD_PC_HI20", "BFD_RELOC_LARCH_TLS_GD64_HI20", + "BFD_RELOC_LARCH_32_PCREL", "BFD_RELOC_LARCH_RELAX", "@@overflow: BFD_RELOC_UNUSED@@", }; diff --git a/bfd/reloc.c b/bfd/reloc.c index 836fa162108..6f092235369 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -8304,6 +8304,9 @@ ENUMX ENUMX BFD_RELOC_LARCH_TLS_GD64_HI20 +ENUMX + BFD_RELOC_LARCH_32_PCREL + ENUMX BFD_RELOC_LARCH_RELAX diff --git a/binutils/readelf.c b/binutils/readelf.c index 0f5977bc072..74f59d49fdc 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -14388,6 +14388,8 @@ is_32bit_pcrel_reloc (Filedata * filedata, unsigned int reloc_type) case EM_AVR_OLD: case EM_AVR: return reloc_type == 36; /* R_AVR_32_PCREL. */ + case EM_LOONGARCH: + return reloc_type == 99; /* R_LARCH_32_PCREL. */ case EM_MICROBLAZE: return reloc_type == 2; /* R_MICROBLAZE_32_PCREL. */ case EM_OR1K: diff --git a/include/elf/loongarch.h b/include/elf/loongarch.h index 863dad3a371..9e0a5217f60 100644 --- a/include/elf/loongarch.h +++ b/include/elf/loongarch.h @@ -223,8 +223,11 @@ RELOC_NUMBER (R_LARCH_TLS_GD_PC_HI20, 97) %gd64_hi20 (sym). */ RELOC_NUMBER (R_LARCH_TLS_GD64_HI20, 98) +/* For eh_frame and debug info. */ +RELOC_NUMBER (R_LARCH_32_PCREL, 99) + /* RELAX. */ -RELOC_NUMBER (R_LARCH_RELAX, 99) +RELOC_NUMBER (R_LARCH_RELAX, 100) END_RELOC_NUMBERS (R_LARCH_count) diff --git a/ld/testsuite/ld-elf/eh5.d b/ld/testsuite/ld-elf/eh5.d index d614251587c..4a697482355 100644 --- a/ld/testsuite/ld-elf/eh5.d +++ b/ld/testsuite/ld-elf/eh5.d @@ -4,7 +4,7 @@ #ld: #readelf: -wf #target: [check_as_cfi] -#xfail: alpha-*-*ecoff hppa64-*-* tile*-*-* visium-*-* loongarch64-*-* +#xfail: alpha-*-*ecoff hppa64-*-* tile*-*-* visium-*-* Contents of the .eh_frame section: -- 2.31.1