-
Notifications
You must be signed in to change notification settings - Fork 21
Description
This should be fixed when we update our LLVM toolchain.
Currently, files assembled or compiled by the LLVM toolchain do not contain mapping symbols for regions of code that use a different set of extensions - of interest here is the unratified bit-manipulation extensions - controlled with .option arch directives.
This causes llvm-objdump and Binutils objdump to be unable to disassemble the instructions in those extensions unless given the appropriate --mattr flags, as the regions are not marked as using them. as in Binutils 2.44 generates these symbols and is able to disassemble the instructions just fine.
Demonstration:
Using a test file, test_syms.S:
zbp:
.option push
.option arch, +zbp0p93
grev a0, a1, a2
.option pop
Assembled with Binutils as and Clang, respectively:
$ ./lowrisc-toolchains/build/dist/bin/riscv32-unknown-elf-as -march=rv32i test_syms.S -o test_syms_binutils.o
$ bazel run @lowrisc_rv32imcb_toolchain//:bin/clang -- -march=rv32i -c ~/test_syms.S -o ~/test_syms_llvm.o
Binutils objdump is able to disassemble the instruction when assembled with as but not Clang:
$ ./lowrisc-toolchains/build/dist/bin/riscv32-unknown-elf-objdump -d test_syms_binutils.o
test_syms_binutils.o: file format elf32-littleriscv
Disassembly of section .text:
00000000 <zbp>:
0: 68c5d533 grev a0,a1,a2
$ ./lowrisc-toolchains/build/dist/bin/riscv32-unknown-elf-objdump -d test_syms_llvm.o
test_syms_llvm.o: file format elf32-littleriscv
Disassembly of section .text:
00000000 <zbp>:
0: 68c5d533 .insn 4, 0x68c5d533
llvm-objdump is not able to disassemble the instruction in either file, unless instructed to with --mattr=+experimental-zbp:
$ bazel run @lowrisc_rv32imcb_toolchain//:bin/llvm-objdump -- -d ~/test_syms_binutils.o
$ bazel run @lowrisc_rv32imcb_toolchain//:bin/llvm-objdump -- -d ~/test_syms_llvm.o
Disassembly of section .text:
00000000 <zbp>:
0: 33 d5 c5 68 <unknown>
$ bazel run @lowrisc_rv32imcb_toolchain//:bin/llvm-objdump -- --mattr=+experimental_zbp -d ~/test_syms_binutils.o
$ bazel run @lowrisc_rv32imcb_toolchain//:bin/llvm-objdump -- --mattr=+experimental_zbp -d ~/test_syms_llvm.o
~/test_syms_llvm.o: file format elf32-littleriscv
Disassembly of section .text:
00000000 <zbp>:
0: 33 d5 c5 68 grev a0, a1, a2
Both toolchain disassemblers show that the file assembled by the LLVM toolchain is missing the appropriate mapping symbol:
$ ./lowrisc-toolchains/build/dist/bin/riscv32-unknown-elf-objdump --syms --special-syms test_syms_binutils.o
$ bazel run @lowrisc_rv32imcb_toolchain//:bin/llvm-objdump -- --syms ~/test_syms_binutils.o
~/test_syms_binutils.o: file format elf32-littleriscv
SYMBOL TABLE:
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 l .text 00000000 zbp
00000000 l .text 00000000 $xrv32i2p1_zbp0p93
00000000 l d .riscv.attributes 00000000 .riscv.attributes
$ ./lowrisc-toolchains/build/dist/bin/riscv32-unknown-elf-objdump --syms --special-syms test_syms_llvm.o
$ bazel run @lowrisc_rv32imcb_toolchain//:bin/llvm-objdump -- --syms ~/test_syms_llvm.o
~/test_syms_llvm.o: file format elf32-littleriscv
SYMBOL TABLE:
00000000 l .text 00000000 zbp