Skip to content

Instantly share code, notes, and snippets.

@lupyuen
Last active January 30, 2024 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lupyuen/ab8febefa9c649ad7c242ee3f7aaf974 to your computer and use it in GitHub Desktop.
Save lupyuen/ab8febefa9c649ad7c242ee3f7aaf974 to your computer and use it in GitHub Desktop.
RISC-V Disassembly of TCC Compiler Output. See https://github.com/lupyuen/tcc-riscv32-wasm
## Dump the RISC-V Disassembly of TCC Output
$ riscv64-unknown-elf-objdump \
--syms --source --reloc --demangle \
--line-numbers --wide --debugging \
a.out
a.out: file format elf64-littleriscv
SYMBOL TABLE:
0000000000000000 l df *ABS* 0000000000000000 hello.c
0000000000000000 l O .data.ro 0000000000000010 L.0
000000000000001c l .text 0000000000000000
0000000000000000 g F .text 0000000000000040 main
0000000000000000 F *UND* 0000000000000000 printf
Disassembly of section .text:
0000000000000000 <main>:
main():
0: fe010113 addi sp,sp,-32
4: 00113c23 sd ra,24(sp)
8: 00813823 sd s0,16(sp)
c: 02010413 addi s0,sp,32
10: 00000013 nop
14: fea43423 sd a0,-24(s0)
18: feb43023 sd a1,-32(s0)
1c: 00000517 auipc a0,0x0 1c: R_RISCV_PCREL_HI20 L.0
20: 00050513 mv a0,a0 20: R_RISCV_PCREL_LO12_I .text
24: 00000097 auipc ra,0x0 24: R_RISCV_CALL_PLT printf
28: 000080e7 jalr ra # 24 <main+0x24>
2c: 0000051b sext.w a0,zero
30: 01813083 ld ra,24(sp)
34: 01013403 ld s0,16(sp)
38: 02010113 addi sp,sp,32
3c: 00008067 ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment