Skip to content

Commit

Permalink
LoongArch: gas: Don't define LoongArch .align
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cloudspurs authored and lzshhxx committed Jan 24, 2024
1 parent ab9bb41 commit 27a750d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
13 changes: 0 additions & 13 deletions gas/config/tc-loongarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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 },
Expand Down
1 change: 1 addition & 0 deletions gas/testsuite/gas/loongarch/align.l
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# No warning or error expected.
5 changes: 5 additions & 0 deletions gas/testsuite/gas/loongarch/align.s
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions gas/testsuite/gas/loongarch/loongarch.exp
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ if [istarget loongarch*-*-*] {
}
}

run_list_test "align"
}

0 comments on commit 27a750d

Please sign in to comment.