]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
LoongArch: gas: Don't define LoongArch .align
authormengqinggang <mengqinggang@loongson.cn>
Sun, 1 Oct 2023 07:29:44 +0000 (15:29 +0800)
committerliuzhensong <liuzhensong@loongson.cn>
Wed, 24 Jan 2024 08:32:34 +0000 (16:32 +0800)
Gcc may generate "\t.align\t%d,54525952,4\n" before commit
b20c7ee066cb7d952fa193972e8bc6362c6e4063. To write 54525952 (NOP) to object
file, we call s_align_ptwo (-4). It result in alignment padding must be a
multiple of 4 if .align has second parameter.

Use default s_align_ptwo for .align.

gas/config/tc-loongarch.c
gas/testsuite/gas/loongarch/align.l [new file with mode: 0644]
gas/testsuite/gas/loongarch/align.s [new file with mode: 0644]
gas/testsuite/gas/loongarch/loongarch.exp

index 863ac9cea434ed590fc3a2bed34f6b75a883c505..3c7d40027fdfcb4314b9f360b33ea4180feac063 100644 (file)
@@ -436,18 +436,6 @@ loongarch_mach (void)
 
 static const expressionS const_0 = { .X_op = O_constant, .X_add_number = 0 };
 
-static void
-s_loongarch_align (int arg)
-{
-  const char *t = input_line_pointer;
-  while (!is_end_of_line[(unsigned char) *t] && *t != ',')
-    ++t;
-  if (*t == ',')
-    s_align_ptwo (arg);
-  else
-    s_align_ptwo (0);
-}
-
 /* Handle the .dtprelword and .dtpreldword pseudo-ops.  They generate
    a 32-bit or 64-bit DTP-relative relocation (BYTES says which) for
    use in DWARF debug information.  */
@@ -479,7 +467,6 @@ s_dtprel (int bytes)
 
 static const pseudo_typeS loongarch_pseudo_table[] =
 {
-  { "align", s_loongarch_align, -4 },
   { "dword", cons, 8 },
   { "word", cons, 4 },
   { "half", cons, 2 },
diff --git a/gas/testsuite/gas/loongarch/align.l b/gas/testsuite/gas/loongarch/align.l
new file mode 100644 (file)
index 0000000..8ea739b
--- /dev/null
@@ -0,0 +1 @@
+# No warning or error expected.
diff --git a/gas/testsuite/gas/loongarch/align.s b/gas/testsuite/gas/loongarch/align.s
new file mode 100644 (file)
index 0000000..93f2528
--- /dev/null
@@ -0,0 +1,5 @@
+# Fix bug: alignment padding must a multiple of 4 if .align has second parameter
+.data
+  .byte 1
+  .align 3, 2
+  .4byte 3
index baa4908f8f96dd4f37b0ecfb5f6a3dbbdba96d66..9ece4e810ffc9f66dabd03c512d6daf33f04fe65 100644 (file)
@@ -30,4 +30,5 @@ if [istarget loongarch*-*-*] {
       }
     }
 
+  run_list_test "align"
 }