From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 9B53D3858D20 for ; Wed, 12 Jul 2023 06:35:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9B53D3858D20 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 loongson.cn (unknown [10.20.4.171]) by gateway (Coremail) with SMTP id _____8DxxPDDSa5kANUDAA--.11125S3; Wed, 12 Jul 2023 14:35:48 +0800 (CST) Received: from [10.20.4.171] (unknown [10.20.4.171]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dx_yPDSa5kQ+wpAA--.12120S3; Wed, 12 Jul 2023 14:35:47 +0800 (CST) Subject: Re: [PATCH 1/2] LoongArch: bfd: Remove elf_seg_map condition in loongarch_elf_relax_section To: Jinyang He , Chenghua Xu , Zhensong Liu , WANG Xuerui Cc: binutils@sourceware.org, Xing Li , yala , Peng Fan References: <20230711084931.18978-1-hejinyang@loongson.cn> From: mengqinggang Message-ID: Date: Wed, 12 Jul 2023 14:35:47 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20230711084931.18978-1-hejinyang@loongson.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID:AQAAf8Dx_yPDSa5kQ+wpAA--.12120S3 X-CM-SenderInfo: 5phqw15lqjwttqj6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoWxCFWrur48Jr18WF4fKF1UXFc_yoW5Aw1rp3 sxZFyfCF18A3Z7Gr9rG3y5X3Z8Jrs7GryF9Fyft34I9rs8Xry0qw4Fy393WFs8J3y5WryY vF18tw15uF4vyrcCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUv2b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lc7I2V7IY0VAS07 AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02 F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GF ylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7Cj xVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r 1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU1Ek sDUUUUU== X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,NICE_REPLY_A,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 List-Id: Hi, Without this condition, the value of 'symbol - pc' may be differences between loongarch_elf_relax_section and  loongarch_elf_relocate_section. And it will cause some spec2006 test errors. 在 2023/7/11 下午4:49, Jinyang He 写道: > When I tried "./ld-new sth." the relax does not work because the > elf_seg_map (info->output_bfd) was NULL in loongarch_elf_relax_section. > There is no need for the segment info, we can get the address through > the section info. Thus, remove this condition. > > bfd/ChangeLog: > > * elfnn-loongarch.c (loongarch_elf_relax_section): Remove > elf_seg_map condition. > > ld/ChangeLog: > > * testsuite/ld-loongarch-elf/relax.exp: Update trigger method. > * testsuite/ld-loongarch-elf/relax.dd: New test. > --- > bfd/elfnn-loongarch.c | 1 - > ld/testsuite/ld-loongarch-elf/relax.dd | 6 +++++ > ld/testsuite/ld-loongarch-elf/relax.exp | 35 +++++++------------------ > 3 files changed, 16 insertions(+), 26 deletions(-) > create mode 100644 ld/testsuite/ld-loongarch-elf/relax.dd > > diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c > index d3d8419d8..01f349a24 100644 > --- a/bfd/elfnn-loongarch.c > +++ b/bfd/elfnn-loongarch.c > @@ -3845,7 +3845,6 @@ loongarch_elf_relax_section (bfd *abfd, asection *sec, > || sec->sec_flg0 > || (sec->flags & SEC_RELOC) == 0 > || sec->reloc_count == 0 > - || elf_seg_map (info->output_bfd) == NULL > || (info->disable_target_specific_optimizations > && info->relax_pass == 0) > /* The exp_seg_relro_adjust is enum phase_enum (0x4), > diff --git a/ld/testsuite/ld-loongarch-elf/relax.dd b/ld/testsuite/ld-loongarch-elf/relax.dd > new file mode 100644 > index 000000000..e266beb8f > --- /dev/null > +++ b/ld/testsuite/ld-loongarch-elf/relax.dd > @@ -0,0 +1,6 @@ > +#... > +.*pcaddi.* > +.*ld.w.* > +.*pcaddi.* > +.*ld.w.* > +#pass > diff --git a/ld/testsuite/ld-loongarch-elf/relax.exp b/ld/testsuite/ld-loongarch-elf/relax.exp > index 7ff876d79..d2bb967c6 100644 > --- a/ld/testsuite/ld-loongarch-elf/relax.exp > +++ b/ld/testsuite/ld-loongarch-elf/relax.exp > @@ -21,31 +21,6 @@ > > if [istarget loongarch64-*-*] { > > - if [isbuild loongarch64-*-*] { > - set testname "loongarch relax build" > - set pre_builds [list \ > - [list \ > - "$testname" \ > - "" \ > - "" \ > - {relax.s} \ > - {} \ > - "relax" \ > - ] \ > - ] > - > - run_cc_link_tests $pre_builds > - > - if [file exist "tmpdir/relax"] { > - set objdump_output [run_host_cmd "objdump" "-d tmpdir/relax"] > - if { [ regexp ".*pcaddi.*pcaddi.*" $objdump_output] } { > - pass "loongarch relax" > - } { > - fail "loongarch relax" > - } > - } > - } > - > run_ld_link_tests \ > [list \ > [list \ > @@ -58,6 +33,16 @@ if [istarget loongarch64-*-*] { > ] \ > "relax-align" \ > ] \ > + [list \ > + "relax" \ > + "-e 0 -Ttext 0x10000 -Tdata 0x20000" "" \ > + "" \ > + {relax.s} \ > + [list \ > + [list objdump -d relax.dd] \ > + ] \ > + "relax" \ > + ] \ > ] > > set objdump_flags "-s -j .data"