lowRISC / lowRISC/lowrisc-toolchains
LLVM Toolchain not generating mapping symbols
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 49
- Forks
- 22
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 2
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 :
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 :
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 :
0: 33 d5 c5 68
$ 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 :
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
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the mentioned test_syms.S input and the LLVM toolchain commands, then inspect the generated symbol tables with llvm-objdump and Binutils objdump. Done means the LLVM-assembled object contains the appropriate mapping symbol and both disassemblers recognize the extension instruction without extra mattr flags.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100