From: mengqinggang <mengqinggang@loongson.cn>
To: binutils@sourceware.org
Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn,
liuzhensong@loongson.cn, cailulu@loongson.cn, xry111@xry111.site,
i.swmail@xen0n.name, maskray@google.com, luweining@loongson.cn,
wanglei@loongson.cn, hejinyang@loongson.cn,
mengqinggang@loongson.cn
Subject: [PATCH] LoongArch: gas: Try to avoid R_LARCH_ALIGN associate with a symbol
Date: Mon, 5 Feb 2024 17:32:31 +0800 [thread overview]
Message-ID: <20240205093231.2817816-1-mengqinggang@loongson.cn> (raw)
The R_LARCH_ALIGN need to associated with a symbol if .align has the first
and third expressions. If R_LARCH_ALIGN associate with a symbol, the addend can
represent the first and third expression of .align.
For '.align 3', the addend of R_LARCH_ALIGN only need to represent the alignment
and R_LARCH_ALIGN not need to associate with a symbol.
---
gas/config/tc-loongarch.c | 23 +++++++++++++++--------
gas/testsuite/gas/loongarch/relax_align.d | 16 ++++++++--------
2 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c
index 91f5f1d0681..831a463879b 100644
--- a/gas/config/tc-loongarch.c
+++ b/gas/config/tc-loongarch.c
@@ -1746,14 +1746,21 @@ loongarch_frag_align_code (int n, int max)
nops = frag_more (worst_case_bytes);
- s = symbol_find (".Lla-relax-align");
- if (s == NULL)
- s = (symbolS *)local_symbol_make (".Lla-relax-align", now_seg,
- &zero_address_frag, 0);
-
- ex.X_add_symbol = s;
- ex.X_op = O_symbol;
- ex.X_add_number = (max << 8) | n;
+ if (max)
+ {
+ s = symbol_find (".Lla-relax-align");
+ if (s == NULL)
+ s = (symbolS *)local_symbol_make (".Lla-relax-align", now_seg,
+ &zero_address_frag, 0);
+ ex.X_add_symbol = s;
+ ex.X_op = O_symbol;
+ ex.X_add_number = (max << 8) | n;
+ }
+ else
+ {
+ ex.X_op = O_constant;
+ ex.X_add_number = worst_case_bytes;
+ }
loongarch_make_nops (nops, worst_case_bytes);
diff --git a/gas/testsuite/gas/loongarch/relax_align.d b/gas/testsuite/gas/loongarch/relax_align.d
index 2cc6c86d38a..e86d0d592b6 100644
--- a/gas/testsuite/gas/loongarch/relax_align.d
+++ b/gas/testsuite/gas/loongarch/relax_align.d
@@ -1,4 +1,4 @@
-#as: --no-warn
+#as:
#objdump: -dr
#skip: loongarch32-*-*
@@ -14,20 +14,20 @@ Disassembly of section .text:
[ ]+4:[ ]+02c00084[ ]+addi.d[ ]+\$a0, \$a0, 0
[ ]+4: R_LARCH_PCALA_LO12[ ]+L1
[ ]+4: R_LARCH_RELAX[ ]+\*ABS\*
-[ ]+8:[ ]+03400000[ ]+nop.*
-[ ]+8: R_LARCH_ALIGN[ ]+.Lla-relax-align\+0x4
-[ ]+c:[ ]+03400000[ ]+nop.*
-[ ]+10:[ ]+03400000[ ]+nop.*
+[ ]+8:[ ]+03400000[ ]+nop
+[ ]+8: R_LARCH_ALIGN[ ]+\*ABS\*\+0xc
+[ ]+c:[ ]+03400000[ ]+nop
+[ ]+10:[ ]+03400000[ ]+nop
[ ]+14:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0, 0
[ ]+14: R_LARCH_PCALA_HI20[ ]+L1
[ ]+14: R_LARCH_RELAX[ ]+\*ABS\*
[ ]+18:[ ]+02c00084[ ]+addi.d[ ]+\$a0, \$a0, 0
[ ]+18: R_LARCH_PCALA_LO12[ ]+L1
[ ]+18: R_LARCH_RELAX[ ]+\*ABS\*
-[ ]+1c:[ ]+03400000[ ]+nop.*
+[ ]+1c:[ ]+03400000[ ]+nop
[ ]+1c: R_LARCH_ALIGN[ ]+.Lla-relax-align\+0x404
-[ ]+20:[ ]+03400000[ ]+nop.*
-[ ]+24:[ ]+03400000[ ]+nop.*
+[ ]+20:[ ]+03400000[ ]+nop
+[ ]+24:[ ]+03400000[ ]+nop
[ ]+28:[ ]+1a000004[ ]+pcalau12i[ ]+\$a0, 0
[ ]+28: R_LARCH_PCALA_HI20[ ]+L1
[ ]+28: R_LARCH_RELAX[ ]+\*ABS\*
--
2.36.0
reply other threads:[~2024-02-05 9:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240205093231.2817816-1-mengqinggang@loongson.cn \
--to=mengqinggang@loongson.cn \
--cc=binutils@sourceware.org \
--cc=cailulu@loongson.cn \
--cc=chenglulu@loongson.cn \
--cc=hejinyang@loongson.cn \
--cc=i.swmail@xen0n.name \
--cc=liuzhensong@loongson.cn \
--cc=luweining@loongson.cn \
--cc=maskray@google.com \
--cc=wanglei@loongson.cn \
--cc=xry111@xry111.site \
--cc=xuchenghua@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).