diff options
author | Jim Wilson <jimw@sifive.com> | 2017-11-29 10:36:46 -0800 |
---|---|---|
committer | Jim Wilson <jimw@sifive.com> | 2017-11-29 10:36:46 -0800 |
commit | 36877bfb88f99dd0e4336f98233f7caaa1d594a7 (patch) | |
tree | 55ba6231b5b84e4eeb1d6bf26c57cec3bc6ff7fc /gas/config | |
parent | f923328821e2e835c725822bce2aac6e10c52dd9 (diff) | |
download | gdb-36877bfb88f99dd0e4336f98233f7caaa1d594a7.zip gdb-36877bfb88f99dd0e4336f98233f7caaa1d594a7.tar.gz gdb-36877bfb88f99dd0e4336f98233f7caaa1d594a7.tar.bz2 |
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.
Diffstat (limited to 'gas/config')
-rw-r--r-- | gas/config/tc-riscv.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index 8bb400e..c2e5f30 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -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; |