mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-27 22:48:57 +08:00
Fix riscv malloc error on small alignment after norvc.
gas/ * config/tc-riscv.c (riscv_frag_align_code): New local insn_alignment. Early return if bytes less than or equal to insn_alignment. * testsuite/gas/riscv/align-1.l: New. * testsuite/gas/riscv/align-1.s: New. * testsuite/gas/riscv/riscv.exp: Use run_dump_tests. Use run_list_test for align-1.
This commit is contained in:
@ -1,5 +1,12 @@
|
|||||||
2017-11-29 Jim Wilson <jimw@sifive.com>
|
2017-11-29 Jim Wilson <jimw@sifive.com>
|
||||||
|
|
||||||
|
* config/tc-riscv.c (riscv_frag_align_code): New local insn_alignment.
|
||||||
|
Early return if bytes less than or equal to insn_alignment.
|
||||||
|
* testsuite/gas/riscv/align-1.l: New.
|
||||||
|
* testsuite/gas/riscv/align-1.s: New.
|
||||||
|
* testsuite/gas/riscv/riscv.exp: Use run_dump_tests. Use run_list_test
|
||||||
|
for align-1.
|
||||||
|
|
||||||
PR gas/22464
|
PR gas/22464
|
||||||
* doc/c-i386.texi (-n): Clarify docs.
|
* doc/c-i386.texi (-n): Clarify docs.
|
||||||
|
|
||||||
|
@ -2319,10 +2319,18 @@ bfd_boolean
|
|||||||
riscv_frag_align_code (int n)
|
riscv_frag_align_code (int n)
|
||||||
{
|
{
|
||||||
bfd_vma bytes = (bfd_vma) 1 << n;
|
bfd_vma bytes = (bfd_vma) 1 << n;
|
||||||
bfd_vma worst_case_bytes = bytes - (riscv_opts.rvc ? 2 : 4);
|
bfd_vma insn_alignment = riscv_opts.rvc ? 2 : 4;
|
||||||
char *nops = frag_more (worst_case_bytes);
|
bfd_vma worst_case_bytes = bytes - insn_alignment;
|
||||||
|
char *nops;
|
||||||
expressionS ex;
|
expressionS ex;
|
||||||
|
|
||||||
|
/* If we are moving to a smaller alignment than the instruction size, then no
|
||||||
|
alignment is required. */
|
||||||
|
if (bytes <= insn_alignment)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
nops = frag_more (worst_case_bytes);
|
||||||
|
|
||||||
/* When not relaxing, riscv_handle_align handles code alignment. */
|
/* When not relaxing, riscv_handle_align handles code alignment. */
|
||||||
if (!riscv_opts.relax)
|
if (!riscv_opts.relax)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
1
gas/testsuite/gas/riscv/align-1.l
Normal file
1
gas/testsuite/gas/riscv/align-1.l
Normal file
@ -0,0 +1 @@
|
|||||||
|
# No warning or error expected.
|
3
gas/testsuite/gas/riscv/align-1.s
Normal file
3
gas/testsuite/gas/riscv/align-1.s
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.option norvc
|
||||||
|
.align 2
|
||||||
|
.align 1
|
@ -19,13 +19,6 @@
|
|||||||
# MA 02110-1301, USA.
|
# MA 02110-1301, USA.
|
||||||
|
|
||||||
if [istarget riscv*-*-*] {
|
if [istarget riscv*-*-*] {
|
||||||
run_dump_test "t_insns"
|
run_dump_tests [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
|
||||||
run_dump_test "fmv.x"
|
run_list_test "align-1"
|
||||||
run_dump_test "c-lui-fail"
|
|
||||||
run_dump_test "c-addi4spn-fail"
|
|
||||||
run_dump_test "c-addi16sp-fail"
|
|
||||||
run_dump_test "satp"
|
|
||||||
run_dump_test "eh-relocs"
|
|
||||||
run_dump_test "c-lw"
|
|
||||||
run_dump_test "c-ld"
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user