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:
Jim Wilson
2017-11-29 10:36:46 -08:00
parent f923328821
commit 36877bfb88
5 changed files with 23 additions and 11 deletions

View File

@@ -2319,10 +2319,18 @@ bfd_boolean
riscv_frag_align_code (int n)
{
bfd_vma bytes = (bfd_vma) 1 << n;
bfd_vma worst_case_bytes = bytes - (riscv_opts.rvc ? 2 : 4);
char *nops = frag_more (worst_case_bytes);
bfd_vma insn_alignment = riscv_opts.rvc ? 2 : 4;
bfd_vma worst_case_bytes = bytes - insn_alignment;
char *nops;
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. */
if (!riscv_opts.relax)
return FALSE;