aboutsummaryrefslogtreecommitdiff
path: root/gas/testsuite
diff options
context:
space:
mode:
authorNelson Chu <nelson@rivosinc.com>2022-09-29 19:07:46 +0800
committerNelson Chu <nelson@rivosinc.com>2022-10-28 11:11:23 +0800
commit40f1a1a4564b2e5822cf19a43a8c15154aa4c488 (patch)
tree35f083a2767845714fce545b2789d0b903fa41b5 /gas/testsuite
parent58b2ba6d888019278887286e3896ff7ffd12cb2f (diff)
downloadgdb-40f1a1a4564b2e5822cf19a43a8c15154aa4c488.zip
gdb-40f1a1a4564b2e5822cf19a43a8c15154aa4c488.tar.gz
gdb-40f1a1a4564b2e5822cf19a43a8c15154aa4c488.tar.bz2
RISC-V: Output mapping symbols with ISA string.
RISC-V Psabi pr196, https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/196 bfd/ * elfxx-riscv.c (riscv_release_subset_list): Free arch_str if needed. (riscv_copy_subset_list): Copy arch_str as well. * elfxx-riscv.h (riscv_subset_list_t): Store arch_str for each subset list. gas/ * config/tc-riscv.c (riscv_reset_subsets_list_arch_str): Update the architecture string in the subset_list. (riscv_set_arch): Call riscv_reset_subsets_list_arch_str after parsing new architecture string. (s_riscv_option): Likewise. (need_arch_map_symbol): New boolean, used to indicate if .option directives do affect instructions. (make_mapping_symbol): New boolean parameter reset_seg_arch_str. Need to generate $x+arch for MAP_INSN, and then store it into tc_segment_info_data if reset_seg_arch_str is true. (riscv_mapping_state): Decide if we need to add $x+arch for MAP_INSN. For now, only add $x+arch if the architecture strings in subset list and segment are different. Besides, always add $x+arch at the start of section, and do not add $x+arch for code alignment, since rvc for alignment can be judged from addend of R_RISCV_ALIGN. (riscv_remove_mapping_symbol): If current and previous mapping symbol have same value, then remove the current $x only if the previous is $x+arch; Otherwise, always remove previous. (riscv_add_odd_padding_symbol): Updated. (riscv_check_mapping_symbols): Don't need to add any $x+arch if need_arch_map_symbol is false, so changed them to $x. (riscv_frag_align_code): Updated since riscv_mapping_state is changed. (riscv_init_frag): Likewise. (s_riscv_insn): Likewise. (riscv_elf_final_processing): Call riscv_release_subset_list to release subset_list of riscv_rps_as, rather than only release arch_str in the riscv_write_out_attrs. (riscv_write_out_attrs): No need to call riscv_arch_str, just get arch_str from subset_list of riscv_rps_as. * config/tc-riscv.h (riscv_segment_info_type): Record current $x+arch mapping symbol of each segment. * testsuite/gas/riscv/mapping-0*: Merged and replaced by mapping.s. * testsuite/gas/riscv/mapping.s: New testcase, to test most of the cases in one file. * testsuite/gas/riscv/mapping-symbols.d: Likewise. * testsuite/gas/riscv/mapping-dis.d: Likewise. * testsuite/gas/riscv/mapping-non-arch.s: New testcase for the case that does need any $x+arch. * testsuite/gas/riscv/mapping-non-arch.d: Likewise. * testsuite/gas/riscv/option-arch-01a.d: Updated. opcodes/ * riscv-dis.c (riscv_disassemble_insn): Set riscv_fpr_names back to riscv_fpr_names_abi or riscv_fpr_names_numeric when zfinx is disabled for some specfic code region. (riscv_get_map_state): Recognized mapping symbols $x+arch, and then reset the architecture string once the ISA is different.
Diffstat (limited to 'gas/testsuite')
-rw-r--r--gas/testsuite/gas/riscv/mapping-01.s17
-rw-r--r--gas/testsuite/gas/riscv/mapping-01a.d17
-rw-r--r--gas/testsuite/gas/riscv/mapping-01b.d21
-rw-r--r--gas/testsuite/gas/riscv/mapping-02.s12
-rw-r--r--gas/testsuite/gas/riscv/mapping-02a.d15
-rw-r--r--gas/testsuite/gas/riscv/mapping-02b.d16
-rw-r--r--gas/testsuite/gas/riscv/mapping-03.s11
-rw-r--r--gas/testsuite/gas/riscv/mapping-03a.d20
-rw-r--r--gas/testsuite/gas/riscv/mapping-03b.d24
-rw-r--r--gas/testsuite/gas/riscv/mapping-04.s13
-rw-r--r--gas/testsuite/gas/riscv/mapping-04a.d15
-rw-r--r--gas/testsuite/gas/riscv/mapping-04b.d23
-rw-r--r--gas/testsuite/gas/riscv/mapping-dis.d84
-rw-r--r--gas/testsuite/gas/riscv/mapping-non-arch.d17
-rw-r--r--gas/testsuite/gas/riscv/mapping-non-arch.s11
-rw-r--r--gas/testsuite/gas/riscv/mapping-norelax-03a.d21
-rw-r--r--gas/testsuite/gas/riscv/mapping-norelax-03b.d25
-rw-r--r--gas/testsuite/gas/riscv/mapping-norelax-04a.d16
-rw-r--r--gas/testsuite/gas/riscv/mapping-norelax-04b.d24
-rw-r--r--gas/testsuite/gas/riscv/mapping-symbols.d48
-rw-r--r--gas/testsuite/gas/riscv/mapping.s112
-rw-r--r--gas/testsuite/gas/riscv/option-arch-01a.d2
22 files changed, 273 insertions, 291 deletions
diff --git a/gas/testsuite/gas/riscv/mapping-01.s b/gas/testsuite/gas/riscv/mapping-01.s
deleted file mode 100644
index 989463f..0000000
--- a/gas/testsuite/gas/riscv/mapping-01.s
+++ /dev/null
@@ -1,17 +0,0 @@
- .option arch, -c
- .text
- .global funcA
-funcA:
- add a0, a0, a0
- j funcB
- .global funcB
-funcB:
- add a1, a1, a1
- bne a0, a1, funcB
-
- .data
- .word 0x123456
-
- .section .foo, "ax"
-foo:
- add a2, a2, a2
diff --git a/gas/testsuite/gas/riscv/mapping-01a.d b/gas/testsuite/gas/riscv/mapping-01a.d
deleted file mode 100644
index 32e0027..0000000
--- a/gas/testsuite/gas/riscv/mapping-01a.d
+++ /dev/null
@@ -1,17 +0,0 @@
-#as:
-#source: mapping-01.s
-#objdump: --syms --special-syms
-
-.*file format.*riscv.*
-
-SYMBOL TABLE:
-0+00 l d .text 0+00 .text
-0+00 l d .data 0+00 .data
-0+00 l d .bss 0+00 .bss
-0+00 l .text 0+00 \$x
-0+00 l d .foo 0+00 .foo
-0+00 l .foo 0+00 foo
-0+00 l .foo 0+00 \$x
-0+00 l d .riscv.attributes 0+00 .riscv.attributes
-0+00 g .text 0+00 funcA
-0+08 g .text 0+00 funcB
diff --git a/gas/testsuite/gas/riscv/mapping-01b.d b/gas/testsuite/gas/riscv/mapping-01b.d
deleted file mode 100644
index e84b3d6..0000000
--- a/gas/testsuite/gas/riscv/mapping-01b.d
+++ /dev/null
@@ -1,21 +0,0 @@
-#as:
-#source: mapping-01.s
-#objdump: -d
-
-.*:[ ]+file format .*
-
-
-Disassembly of section .text:
-
-0+000 <funcA>:
-[ ]+0:[ ]+00a50533[ ]+add[ ]+a0,a0,a0
-[ ]+4:[ ]+0040006f[ ]+j[ ]+8 <funcB>
-
-0+008 <funcB>:
-[ ]+8:[ ]+00b585b3[ ]+add[ ]+a1,a1,a1
-[ ]+c:[ ]+feb51ee3[ ]+bne[ ]+a0,a1,8 <funcB>
-
-Disassembly of section .foo:
-
-0+000 <foo>:
-[ ]+0:[ ]+00c60633[ ]+add[ ]+a2,a2,a2
diff --git a/gas/testsuite/gas/riscv/mapping-02.s b/gas/testsuite/gas/riscv/mapping-02.s
deleted file mode 100644
index 79468c0..0000000
--- a/gas/testsuite/gas/riscv/mapping-02.s
+++ /dev/null
@@ -1,12 +0,0 @@
- .option arch, -c
- .text
- .word 1
- add a0, a0, a0
-
- .data
- .word 2
-
- .text
- add a1, a1, a1
- .short 3
- add a2, a2, a2
diff --git a/gas/testsuite/gas/riscv/mapping-02a.d b/gas/testsuite/gas/riscv/mapping-02a.d
deleted file mode 100644
index 333f12c..0000000
--- a/gas/testsuite/gas/riscv/mapping-02a.d
+++ /dev/null
@@ -1,15 +0,0 @@
-#as:
-#source: mapping-02.s
-#objdump: --syms --special-syms
-
-.*file format.*riscv.*
-
-SYMBOL TABLE:
-0+00 l d .text 0+00 .text
-0+00 l d .data 0+00 .data
-0+00 l d .bss 0+00 .bss
-0+00 l .text 0+00 \$d
-0+04 l .text 0+00 \$x
-0+0c l .text 0+00 \$d
-0+0e l .text 0+00 \$x
-0+00 l d .riscv.attributes 0+00 .riscv.attributes
diff --git a/gas/testsuite/gas/riscv/mapping-02b.d b/gas/testsuite/gas/riscv/mapping-02b.d
deleted file mode 100644
index 1ed6c08..0000000
--- a/gas/testsuite/gas/riscv/mapping-02b.d
+++ /dev/null
@@ -1,16 +0,0 @@
-#as:
-#source: mapping-02.s
-#objdump: -d
-
-.*:[ ]+file format .*
-
-
-Disassembly of section .text:
-
-0+000 <.text>:
-[ ]+0:[ ]+00000001[ ]+.word[ ]+0x00000001
-[ ]+4:[ ]+00a50533[ ]+add[ ]+a0,a0,a0
-[ ]+8:[ ]+00b585b3[ ]+add[ ]+a1,a1,a1
-[ ]+c:[ ]+0003[ ]+.short[ ]+0x0003
-[ ]+e:[ ]+00c60633[ ]+add[ ]+a2,a2,a2
-#...
diff --git a/gas/testsuite/gas/riscv/mapping-03.s b/gas/testsuite/gas/riscv/mapping-03.s
deleted file mode 100644
index 88f2601..0000000
--- a/gas/testsuite/gas/riscv/mapping-03.s
+++ /dev/null
@@ -1,11 +0,0 @@
- .option arch, -c
- .text
- add a0, a0, a0
- .long 0
- .balign 16
- .word 1
- add a1, a1, a1
- .byte 2
- .long 3
- .balign 16
- .word 5
diff --git a/gas/testsuite/gas/riscv/mapping-03a.d b/gas/testsuite/gas/riscv/mapping-03a.d
deleted file mode 100644
index d3663b6..0000000
--- a/gas/testsuite/gas/riscv/mapping-03a.d
+++ /dev/null
@@ -1,20 +0,0 @@
-#as:
-#source: mapping-03.s
-#objdump: --syms --special-syms
-
-.*file format.*riscv.*
-
-SYMBOL TABLE:
-0+00 l d .text 0+00 .text
-0+00 l d .data 0+00 .data
-0+00 l d .bss 0+00 .bss
-0+00 l .text 0+00 \$x
-0+04 l .text 0+00 \$d
-0+08 l .text 0+00 \$x
-0+14 l .text 0+00 \$d
-0+18 l .text 0+00 \$x
-0+1c l .text 0+00 \$d
-0+21 l .text 0+00 \$x
-0+2d l .text 0+00 \$d
-0+31 l .text 0+00 \$x
-0+00 l d .riscv.attributes 0+00 .riscv.attributes
diff --git a/gas/testsuite/gas/riscv/mapping-03b.d b/gas/testsuite/gas/riscv/mapping-03b.d
deleted file mode 100644
index f4f6726..0000000
--- a/gas/testsuite/gas/riscv/mapping-03b.d
+++ /dev/null
@@ -1,24 +0,0 @@
-#as:
-#source: mapping-03.s
-#objdump: -d
-
-.*:[ ]+file format .*
-
-
-Disassembly of section .text:
-
-0+000 <.text>:
-[ ]+0:[ ]+00a50533[ ]+add[ ]+a0,a0,a0
-[ ]+4:[ ]+00000000[ ]+.word[ ]+0x00000000
-[ ]+8:[ ]+00000013[ ]+nop
-[ ]+c:[ ]+00000013[ ]+nop
-[ ]+10:[ ]+00000013[ ]+nop
-[ ]+14:[ ]+00000001[ ]+.word[ ]+0x00000001
-[ ]+18:[ ]+00b585b3[ ]+add[ ]+a1,a1,a1
-[ ]+1c:[ ]+00000302[ ]+.word[ ]+0x00000302
-[ ]+20:[ ]+00[ ]+.byte[ ]+0x00
-[ ]+21:[ ]+00000013[ ]+nop
-[ ]+25:[ ]+00000013[ ]+nop
-[ ]+29:[ ]+00000013[ ]+nop
-[ ]+2d:[ ]+00000005[ ]+.word[ ]+0x00000005
-#...
diff --git a/gas/testsuite/gas/riscv/mapping-04.s b/gas/testsuite/gas/riscv/mapping-04.s
deleted file mode 100644
index 804b0397..0000000
--- a/gas/testsuite/gas/riscv/mapping-04.s
+++ /dev/null
@@ -1,13 +0,0 @@
- .text
- .option arch, -c
- .fill 2, 4, 0x1001
- .byte 1
- .word 0
- .balign 8
- add a0, a0, a0
- .fill 5, 2, 0x2002
- add a1, a1, a1
-
- .data
- .word 0x1
- .word 0x2
diff --git a/gas/testsuite/gas/riscv/mapping-04a.d b/gas/testsuite/gas/riscv/mapping-04a.d
deleted file mode 100644
index 1ae9653..0000000
--- a/gas/testsuite/gas/riscv/mapping-04a.d
+++ /dev/null
@@ -1,15 +0,0 @@
-#as:
-#source: mapping-04.s
-#objdump: --syms --special-syms
-
-.*file format.*riscv.*
-
-SYMBOL TABLE:
-0+00 l d .text 0+00 .text
-0+00 l d .data 0+00 .data
-0+00 l d .bss 0+00 .bss
-0+00 l .text 0+00 \$d
-0+0d l .text 0+00 \$x
-0+15 l .text 0+00 \$d
-0+1f l .text 0+00 \$x
-0+00 l d .riscv.attributes 0+00 .riscv.attributes
diff --git a/gas/testsuite/gas/riscv/mapping-04b.d b/gas/testsuite/gas/riscv/mapping-04b.d
deleted file mode 100644
index 54bd0af..0000000
--- a/gas/testsuite/gas/riscv/mapping-04b.d
+++ /dev/null
@@ -1,23 +0,0 @@
-#as:
-#source: mapping-04.s
-#objdump: -d
-
-.*:[ ]+file format .*
-
-
-Disassembly of section .text:
-
-0+000 <.text>:
-[ ]+0:[ ]+00001001[ ]+.word[ ]+0x00001001
-[ ]+4:[ ]+00001001[ ]+.word[ ]+0x00001001
-[ ]+8:[ ]+00000001[ ]+.word[ ]+0x00000001
-[ ]+c:[ ]+00[ ]+.byte[ ]+0x00
-[ ]+d:[ ]+00000013[ ]+nop
-[ ]+11:[ ]+00a50533[ ]+add[ ]+a0,a0,a0
-[ ]+15:[ ]+20022002[ ]+.word[ ]+0x20022002
-[ ]+19:[ ]+20022002[ ]+.word[ ]+0x20022002
-[ ]+1d:[ ]+2002[ ]+.short[ ]+0x2002
-[ ]+1f:[ ]+00b585b3[ ]+add[ ]+a1,a1,a1
-[ ]+23:[ ]+0000[ ]+.2byte[ ]+0x0
-[ ]+25:[ ]+0000[ ]+.2byte[ ]+0x0
-#...
diff --git a/gas/testsuite/gas/riscv/mapping-dis.d b/gas/testsuite/gas/riscv/mapping-dis.d
new file mode 100644
index 0000000..246f367
--- /dev/null
+++ b/gas/testsuite/gas/riscv/mapping-dis.d
@@ -0,0 +1,84 @@
+#as:
+#source: mapping.s
+#objdump: -d
+
+.*:[ ]+file format .*
+
+
+Disassembly of section .text.cross.section.A:
+
+0+000 <funcA>:
+[ ]+[0-9a-f]+:[ ]+4505[ ]+li[ ]+a0,1
+[ ]+[0-9a-f]+:[ ]+bffd[ ]+j[ ]+0 <funcA>
+
+Disassembly of section .text.corss.section.B:
+
+0+000 <funcB>:
+[ ]+[0-9a-f]+:[ ]+4509[ ]+li[ ]+a0,2
+[ ]+[0-9a-f]+:[ ]+fffff06f[ ]+j[ ]+0 <funcB>
+
+Disassembly of section .text.data:
+
+0+000 <.text.data>:
+[ ]+[0-9a-f]+:[ ]+00000000[ ]+.word[ ]+0x00000000
+[ ]+[0-9a-f]+:[ ]+00000001[ ]+.word[ ]+0x00000001
+[ ]+[0-9a-f]+:[ ]+4505[ ]+li[ ]+a0,1
+[ ]+[0-9a-f]+:[ ]+4509[ ]+li[ ]+a0,2
+[ ]+[0-9a-f]+:[ ]+05000302[ ]+.word[ ]+0x05000302
+
+Disassembly of section .text.odd.align:
+
+0+000 <.text.odd.align>:
+[ ]+[0-9a-f]+:[ ]+4505[ ]+li[ ]+a0,1
+[ ]+[0-9a-f]+:[ ]+01[ ]+.byte[ ]+0x01
+[ ]+[0-9a-f]+:[ ]+00[ ]+.byte[ ]+0x00
+[ ]+[0-9a-f]+:[ ]+00000013[ ]+nop
+[ ]+[0-9a-f]+:[ ]+00200513[ ]+li[ ]+a0,2
+[ ]+[0-9a-f]+:[ ]+00000013[ ]+nop
+
+Disassembly of section .text.zero.fill.first:
+
+0+000 <.text.zero.fill.first>:
+[ ]+[0-9a-f]+:[ ]+4505[ ]+li[ ]+a0,1
+
+Disassembly of section .text.zero.fill.last:
+
+0+000 <.text.zero.fill.last>:
+[ ]+[0-9a-f]+:[ ]+4505[ ]+li[ ]+a0,1
+[ ]+[0-9a-f]+:[ ]+4509[ ]+li[ ]+a0,2
+
+Disassembly of section .text.zero.fill.align.A:
+
+0+000 <.text.zero.fill.align.A>:
+[ ]+[0-9a-f]+:[ ]+4505[ ]+li[ ]+a0,1
+[ ]+[0-9a-f]+:[ ]+4509[ ]+li[ ]+a0,2
+
+Disassembly of section .text.zero.fill.align.B:
+
+0+000 <.text.zero.fill.align.B>:
+[ ]+[0-9a-f]+:[ ]+00100513[ ]+li[ ]+a0,1
+[ ]+[0-9a-f]+:[ ]+00200513[ ]+li[ ]+a0,2
+
+Disassembly of section .text.last.section:
+
+0+000 <.text.last.section>:
+[ ]+[0-9a-f]+:[ ]+00100513[ ]+li[ ]+a0,1
+[ ]+[0-9a-f]+:[ ]+00000001[ ]+.word[ ]+0x00000001
+
+Disassembly of section .text.section.padding:
+
+0+000 <.text.section.padding>:
+[ ]+[0-9a-f]+:[ ]+4505[ ]+li[ ]+a0,1
+[ ]+[0-9a-f]+:[ ]+0001[ ]+nop
+[ ]+[0-9a-f]+:[ ]+4509[ ]+li[ ]+a0,2
+[ ]+[0-9a-f]+:[ ]+00000001[ ]+.word[ ]+0x00000001
+[ ]+[0-9a-f]+:[ ]+0001[ ]+nop
+
+Disassembly of section .text.relax.align:
+
+0+000 <.text.relax.align>:
+[ ]+[0-9a-f]+:[ ]+0001[ ]+nop
+[ ]+[0-9a-f]+:[ ]+4505[ ]+li[ ]+a0,1
+[ ]+[0-9a-f]+:[ ]+00000013[ ]+nop
+[ ]+[0-9a-f]+:[ ]+00200513[ ]+li[ ]+a0,2
+[ ]+[0-9a-f]+:[ ]+00000013[ ]+nop
diff --git a/gas/testsuite/gas/riscv/mapping-non-arch.d b/gas/testsuite/gas/riscv/mapping-non-arch.d
new file mode 100644
index 0000000..f69e719
--- /dev/null
+++ b/gas/testsuite/gas/riscv/mapping-non-arch.d
@@ -0,0 +1,17 @@
+#as:
+#source: mapping-non-arch.s
+#objdump: --syms --special-syms
+
+.*file format.*riscv.*
+
+SYMBOL TABLE:
+00+00 l d .text 00+00 .text
+00+00 l d .data 00+00 .data
+00+00 l d .bss 00+00 .bss
+00+00 l .text 00+00 \$x
+00+08 l .text 00+00 \$d
+00+0c l .text 00+00 \$x
+00+00 l d text.A 00+00 text.A
+00+00 l text.A 00+00 \$x
+00+02 l text.A 00+00 \$d
+00+00 l d .riscv.attributes 00+00 .riscv.attributes
diff --git a/gas/testsuite/gas/riscv/mapping-non-arch.s b/gas/testsuite/gas/riscv/mapping-non-arch.s
new file mode 100644
index 0000000..03b2d75
--- /dev/null
+++ b/gas/testsuite/gas/riscv/mapping-non-arch.s
@@ -0,0 +1,11 @@
+.attribute arch, "rv32i"
+.option arch, +c
+.text
+addi a0, zero, 1
+.align 3
+.word 0x1
+addi a0, zero, 2
+
+.section text.A, "ax"
+addi a0, zero, 3
+.word 0x2
diff --git a/gas/testsuite/gas/riscv/mapping-norelax-03a.d b/gas/testsuite/gas/riscv/mapping-norelax-03a.d
deleted file mode 100644
index 916f732..0000000
--- a/gas/testsuite/gas/riscv/mapping-norelax-03a.d
+++ /dev/null
@@ -1,21 +0,0 @@
-#as: -mno-relax
-#source: mapping-03.s
-#objdump: --syms --special-syms
-
-.*file format.*riscv.*
-
-SYMBOL TABLE:
-0+00 l d .text 0+00 .text
-0+00 l d .data 0+00 .data
-0+00 l d .bss 0+00 .bss
-0+00 l .text 0+00 \$x
-0+04 l .text 0+00 \$d
-0+08 l .text 0+00 \$x
-0+10 l .text 0+00 \$d
-0+14 l .text 0+00 \$x
-0+18 l .text 0+00 \$d
-0+20 l .text 0+00 \$d
-0+24 l .text 0+00 \$x
-0+1d l .text 0+00 \$d
-0+1e l .text 0+00 \$x
-0+00 l d .riscv.attributes 0+00 .riscv.attributes
diff --git a/gas/testsuite/gas/riscv/mapping-norelax-03b.d b/gas/testsuite/gas/riscv/mapping-norelax-03b.d
deleted file mode 100644
index 9e77735..0000000
--- a/gas/testsuite/gas/riscv/mapping-norelax-03b.d
+++ /dev/null
@@ -1,25 +0,0 @@
-#as: -mno-relax
-#source: mapping-03.s
-#objdump: -d
-
-.*:[ ]+file format .*
-
-
-Disassembly of section .text:
-
-0+000 <.text>:
-[ ]+0:[ ]+00a50533[ ]+add[ ]+a0,a0,a0
-[ ]+4:[ ]+00000000[ ]+.word[ ]+0x00000000
-[ ]+8:[ ]+00000013[ ]+nop
-[ ]+c:[ ]+00000013[ ]+nop
-[ ]+10:[ ]+00000001[ ]+.word[ ]+0x00000001
-[ ]+14:[ ]+00b585b3[ ]+add[ ]+a1,a1,a1
-[ ]+18:[ ]+00000302[ ]+.word[ ]+0x00000302
-[ ]+1c:[ ]+00[ ]+.byte[ ]+0x00
-[ ]+1d:[ ]+00[ ]+.byte[ ]+0x00
-[ ]+1e:[ ]+0001[ ]+.2byte[ ]+0x1
-[ ]+20:[ ]+00000005[ ]+.word[ ]+0x00000005
-[ ]+24:[ ]+00000013[ ]+nop
-[ ]+28:[ ]+00000013[ ]+nop
-[ ]+2c:[ ]+00000013[ ]+nop
-#...
diff --git a/gas/testsuite/gas/riscv/mapping-norelax-04a.d b/gas/testsuite/gas/riscv/mapping-norelax-04a.d
deleted file mode 100644
index d552a7f..0000000
--- a/gas/testsuite/gas/riscv/mapping-norelax-04a.d
+++ /dev/null
@@ -1,16 +0,0 @@
-#as: -mno-relax
-#source: mapping-04.s
-#objdump: --syms --special-syms
-
-.*file format.*riscv.*
-
-SYMBOL TABLE:
-0+00 l d .text 0+00 .text
-0+00 l d .data 0+00 .data
-0+00 l d .bss 0+00 .bss
-0+00 l .text 0+00 \$d
-0+14 l .text 0+00 \$d
-0+1e l .text 0+00 \$x
-0+0d l .text 0+00 \$d
-0+0e l .text 0+00 \$x
-0+00 l d .riscv.attributes 0+00 .riscv.attributes
diff --git a/gas/testsuite/gas/riscv/mapping-norelax-04b.d b/gas/testsuite/gas/riscv/mapping-norelax-04b.d
deleted file mode 100644
index be668f2..0000000
--- a/gas/testsuite/gas/riscv/mapping-norelax-04b.d
+++ /dev/null
@@ -1,24 +0,0 @@
-#as: -mno-relax
-#source: mapping-04.s
-#objdump: -d
-
-.*:[ ]+file format .*
-
-
-Disassembly of section .text:
-
-0+000 <.text>:
-[ ]+0:[ ]+00001001[ ]+.word[ ]+0x00001001
-[ ]+4:[ ]+00001001[ ]+.word[ ]+0x00001001
-[ ]+8:[ ]+00000001[ ]+.word[ ]+0x00000001
-[ ]+c:[ ]+00[ ]+.byte[ ]+0x00
-[ ]+d:[ ]+00[ ]+.byte[ ]+0x00
-[ ]+e:[ ]+0001[ ]+.2byte[ ]+0x1
-[ ]+10:[ ]+00a50533[ ]+add[ ]+a0,a0,a0
-[ ]+14:[ ]+20022002[ ]+.word[ ]+0x20022002
-[ ]+18:[ ]+20022002[ ]+.word[ ]+0x20022002
-[ ]+1c:[ ]+2002[ ]+.short[ ]+0x2002
-[ ]+1e:[ ]+00b585b3[ ]+add[ ]+a1,a1,a1
-[ ]+22:[ ]+0001[ ]+.2byte[ ]+0x1
-[ ]+24:[ ]+00000013[ ]+nop
-#...
diff --git a/gas/testsuite/gas/riscv/mapping-symbols.d b/gas/testsuite/gas/riscv/mapping-symbols.d
new file mode 100644
index 0000000..db9a8dd
--- /dev/null
+++ b/gas/testsuite/gas/riscv/mapping-symbols.d
@@ -0,0 +1,48 @@
+#as: -misa-spec=20191213
+#source: mapping.s
+#objdump: --syms --special-syms
+
+.*file format.*riscv.*
+
+SYMBOL TABLE:
+0+00 l d .text 0+00 .text
+0+00 l d .data 0+00 .data
+0+00 l d .bss 0+00 .bss
+0+00 l d .text.cross.section.A 0+00 .text.cross.section.A
+0+00 l .text.cross.section.A 0+00 \$xrv32i2p1_c2p0
+0+00 l d .text.corss.section.B 0+00 .text.corss.section.B
+0+00 l .text.corss.section.B 0+00 \$xrv32i2p1_c2p0
+0+02 l .text.corss.section.B 0+00 \$xrv32i2p1
+0+00 l d .text.data 0+00 .text.data
+0+00 l .text.data 0+00 \$d
+0+08 l .text.data 0+00 \$xrv32i2p1_c2p0
+0+0c l .text.data 0+00 \$d
+0+00 l d .text.odd.align 0+00 .text.odd.align
+0+00 l .text.odd.align 0+00 \$xrv32i2p1_c2p0
+0+02 l .text.odd.align 0+00 \$d
+0+08 l .text.odd.align 0+00 \$xrv32i2p1
+0+00 l d .text.zero.fill.first 0+00 .text.zero.fill.first
+0+00 l .text.zero.fill.first 0+00 \$xrv32i2p1_c2p0
+0+00 l d .text.zero.fill.last 0+00 .text.zero.fill.last
+0+00 l .text.zero.fill.last 0+00 \$xrv32i2p1_c2p0
+0+02 l .text.zero.fill.last 0+00 \$x
+0+00 l d .text.zero.fill.align.A 0+00 .text.zero.fill.align.A
+0+00 l .text.zero.fill.align.A 0+00 \$xrv32i2p1_c2p0
+0+00 l d .text.zero.fill.align.B 0+00 .text.zero.fill.align.B
+0+00 l .text.zero.fill.align.B 0+00 \$xrv32i2p1
+0+00 l d .text.last.section 0+00 .text.last.section
+0+00 l .text.last.section 0+00 \$xrv32i2p1
+0+04 l .text.last.section 0+00 \$d
+0+00 l d .text.section.padding 0+00 .text.section.padding
+0+00 l .text.section.padding 0+00 \$xrv32i2p1_c2p0
+0+04 l .text.section.padding 0+00 \$xrv32i2p1_a2p1_c2p0
+0+06 l .text.section.padding 0+00 \$d
+0+00 l d .text.relax.align 0+00 .text.relax.align
+0+00 l .text.relax.align 0+00 \$xrv32i2p1_c2p0
+0+08 l .text.relax.align 0+00 \$xrv32i2p1
+0+0a l .text.section.padding 0+00 \$x
+0+03 l .text.odd.align 0+00 \$d
+0+04 l .text.odd.align 0+00 \$x
+0+00 l d .riscv.attributes 0+00 .riscv.attributes
+0+00 g .text.cross.section.A 0+00 funcA
+0+00 g .text.corss.section.B 0+00 funcB
diff --git a/gas/testsuite/gas/riscv/mapping.s b/gas/testsuite/gas/riscv/mapping.s
new file mode 100644
index 0000000..a0e6c74
--- /dev/null
+++ b/gas/testsuite/gas/riscv/mapping.s
@@ -0,0 +1,112 @@
+.attribute arch, "rv32ic"
+.option norelax # FIXME: assembler fill the paddings after parsing everything,
+ # so we probably won't fill anything for the norelax region when
+ # the riscv_opts.relax is enabled at somewhere.
+
+.section .text.cross.section.A, "ax"
+.option push
+.global funcA
+funcA:
+addi a0, zero, 1 # rv32i
+.option arch, +c
+j funcA # rv32ic
+.section .text.corss.section.B, "ax"
+.globl funcB
+funcB:
+addi a0, zero, 2 # rv32ic, need to be added since start of section
+.option arch, -c
+j funcB # rv32i
+.option pop
+
+.section .text.data, "ax"
+.option push
+.word 0 # $d
+.long 1
+addi a0, zero, 1 # rv32ic
+.data
+.word 2 # don't add mapping symbols for non-text section
+.section .text.data
+addi a0, zero, 2 # $x, but same as previous addi, so removed
+.byte 2 # $d, dumped as .word
+.short 3
+.byte 5
+.option pop
+
+.section .text.odd.align, "ax"
+.option push
+.option norelax
+.option arch, +c
+addi a0, zero, 1 # $xrv32ic
+.byte 1 # $d
+.option arch, -c
+.align 3 # odd alignment, $x replaced by $d + $x
+addi a0, zero, 2 # $xrv32i
+.option pop
+
+.section .text.zero.fill.first, "ax"
+.option push
+.option norelax
+.fill 1, 0, 0 # $d with zero size, removed in make_mapping_symbol
+addi a0, zero, 1 # $xrv32ic
+.option pop
+
+.section .text.zero.fill.last, "ax"
+.option push
+.option norelax
+addi a0, zero, 1 # $xrv32ic
+.fill 1, 0, 0 # $d with zero size, removed in make_mapping_symbol
+addi a0, zero, 2 # $x, FIXME: need find a way to remove?
+.option pop
+
+# last overlap next first
+.section .text.zero.fill.align.A, "ax"
+.option push
+.option norelax
+.align 2 # $xrv32ic, .align and .fill are in the different frag, so neither be removed
+.fill 1, 0, 0 # $d with zero size, removed in make_mapping_symbol when adding $xrv32ic
+addi a0, zero, 1 # $x, should be removed in riscv_check_mapping_symbols
+addi a0, zero, 2
+.option pop
+
+# last overlap next first
+.section .text.zero.fill.align.B, "ax"
+.option push
+.option norelax
+.align 2 # $xrv32ic, .align and .fill are in the different frag, so neither be removed,
+ # but will be removed in riscv_check_mapping_symbols
+.fill 1, 0, 0 # $d with zero size, removed in make_mapping_symbol when adding $xrv32ic
+.option arch, -c
+addi a0, zero, 1 # $xrv32i
+addi a0, zero, 2
+.option pop
+
+.section .text.last.section, "ax"
+.option push
+.option norelax
+.option arch, -c
+addi a0, zero, 1 # $xrv32i
+.word 1 # $d
+.align 2 # zero section padding, $x at the end of section, removed in riscv_check_mapping_symbols
+.option pop
+
+.section .text.section.padding, "ax"
+.option push
+.option norelax
+.align 2
+addi a0, zero, 1 # $rv32ic
+.option arch, +a
+.align 2 # 2-byte padding, $x, removed
+addi a0, zero, 2 # $xrv32iac
+.word 1 # $d
+.option pop # 2-byte padding, $x
+
+.section .text.relax.align, "ax"
+.option push
+.option relax
+.option arch, rv32ic
+.balign 4 # $xrv32ic, add at the start of section
+addi a0, zero, 1 # $x, won't added
+.option arch, -c
+.align 3 # $x, won't added
+addi a0, zero, 2 # $xrv32i
+.option pop
diff --git a/gas/testsuite/gas/riscv/option-arch-01a.d b/gas/testsuite/gas/riscv/option-arch-01a.d
index aed4ca8..1d14c60 100644
--- a/gas/testsuite/gas/riscv/option-arch-01a.d
+++ b/gas/testsuite/gas/riscv/option-arch-01a.d
@@ -10,5 +10,5 @@ Disassembly of section .text:
0+000 <.text>:
[ ]+[0-9a-f]+:[ ]+952e[ ]+add[ ]+a0,a0,a1
[ ]+[0-9a-f]+:[ ]+00b50533[ ]+add[ ]+a0,a0,a1
-[ ]+[0-9a-f]+:[ ]+00302573[ ]+csrr[ ]+a0,fcsr
+[ ]+[0-9a-f]+:[ ]+00302573[ ]+frcsr[ ]+a0
#...