From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7867) id A54CF384640E; Thu, 25 Apr 2024 03:53:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A54CF384640E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1714017223; bh=9YNU7CcHzjgmKHP5skytRmEvJ/bgnPkygO7YgekjfF0=; h=From:To:Subject:Date:From; b=NiAimpcxrb+HzrvYrdyZerT6iTVBc2TEmf1otrk6veTs41ckEnEJZfSvd3Dwe+2pp +SJJXw1dLXusCCdot68XdWCcUalgit+zzw9GvxZ9CXNDMkpwHjf7Zex8B6xV64P61n VLLLfKTEgNK6rQnqrd+CVC6MYjAZB/q+h7Id5GSE= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: liu & zhensong To: binutils-cvs@sourceware.org Subject: [binutils-gdb] LoongArch: gas: Simplify relocations in sections without code flag X-Act-Checkin: binutils-gdb X-Git-Author: Jinyang He X-Git-Refname: refs/heads/master X-Git-Oldrev: 66156bae7a0581879763514382d112716464db8a X-Git-Newrev: 035068a0cd846653e1fb0903aece42f4258803fb Message-Id: <20240425035343.A54CF384640E@sourceware.org> Date: Thu, 25 Apr 2024 03:53:43 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D035068a0cd84= 6653e1fb0903aece42f4258803fb commit 035068a0cd846653e1fb0903aece42f4258803fb Author: Jinyang He Date: Mon Apr 22 17:49:50 2024 +0800 LoongArch: gas: Simplify relocations in sections without code flag =20 Gas should not emit ADD/SUB relocation pairs for label differences if they are in the same section without code flag even relax enabled. Because the real value is not be affected by relaxation and it can be compute out in assembly stage. Thus, correct the `TC_FORCE_RELOCATION _SUB_SAME` and the label differences in same section without code flag can be resolved in fixup_segment(). Diff: --- gas/config/tc-loongarch.h | 4 +--- gas/testsuite/gas/loongarch/relax_debug_line.d | 12 ++++++++++++ gas/testsuite/gas/loongarch/relax_debug_line.s | 6 ++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/gas/config/tc-loongarch.h b/gas/config/tc-loongarch.h index e0d0962e5f0..e1ef42c1314 100644 --- a/gas/config/tc-loongarch.h +++ b/gas/config/tc-loongarch.h @@ -91,9 +91,7 @@ extern bool loongarch_frag_align_code (int, int); #define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC) \ (LARCH_opts.relax ? \ (GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC) \ - || ((SEC)->flags & SEC_CODE) !=3D 0 \ - || ((SEC)->flags & SEC_DEBUGGING) !=3D 0 \ - || TC_FORCE_RELOCATION (FIX)) \ + || ((SEC)->flags & SEC_CODE) !=3D 0) \ : (GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC))) \ =20 #define TC_LINKRELAX_FIXUP(seg) ((seg->flags & SEC_CODE) \ diff --git a/gas/testsuite/gas/loongarch/relax_debug_line.d b/gas/testsuite= /gas/loongarch/relax_debug_line.d new file mode 100644 index 00000000000..c17813c20ed --- /dev/null +++ b/gas/testsuite/gas/loongarch/relax_debug_line.d @@ -0,0 +1,12 @@ +#as: --gdwarf-5 +#readelf: -r --wide +#skip: loongarch32-*-* + +Relocation section '\.rela\.debug_line' at offset .* contains 5 entries: +#... +0+22.*R_LARCH_32[ \t]+[0-9]+.* +0+2c.*R_LARCH_32[ \t]+[0-9]+.* +0+36.*R_LARCH_64[ \t]+[0-9]+.* +0+42.*R_LARCH_ADD16[ \t]+[0-9]+.* +0+42.*R_LARCH_SUB16[ \t]+[0-9]+.* +#pass diff --git a/gas/testsuite/gas/loongarch/relax_debug_line.s b/gas/testsuite= /gas/loongarch/relax_debug_line.s new file mode 100644 index 00000000000..d2852bb91e2 --- /dev/null +++ b/gas/testsuite/gas/loongarch/relax_debug_line.s @@ -0,0 +1,6 @@ + .file 0 "test" + .text + .loc 0 10 0 + nop + +.section .debug_line, "", @progbits