Urs Thuermann
unread,Apr 29, 2021, 8:20:07 AM4/29/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to RISC-V SW Dev
objdump replaces instructions by pseudo instructions which in general
is desirable:
$ printf ".text\naddi a0,a1,0\nmv a0,a1\n" > foo.s
$ riscv64-linux-gnu-as -aln -ofoo.o foo.s
1 .text
2 0000 13850500 addi a0,a1,0
3 0004 13850500 mv a0,a1
$ riscv64-linux-gnu-objdump -dr foo.o
foo.o: file format elf64-littleriscv
Disassembly of section .text:
0000000000000000 <.text>:
0: 00058513 mv a0,a1
4: 00058513 mv a0,a1
But there are cases, e.g. when the immediate zero operand is yet to be
relocated, when the pseudo instruction can be confusing:
$ printf "char c; char *foo() { return &c; }\n" > foo.c
$ riscv64-linux-gnu-gcc -fno-pic -Os -c foo.c
$ riscv64-linux-gnu-objdump -dr foo.o
foo.o: file format elf64-littleriscv
Disassembly of section .text:
0000000000000000 <foo>:
0: 00000537 lui a0,0x0
0: R_RISCV_HI20 c
0: R_RISCV_RELAX *ABS*
4: 00050513 mv a0,a0
4: R_RISCV_LO12_I c
4: R_RISCV_RELAX *ABS*
8: 8082 ret
Here, the mv a0,a0 is actually addi a0,a0,0 where the zero operand
will be replaced. I think it would be more readable to keep the addi
instruction here.
So I suggest not to replace those instructions which are affected by
an entry in any relocation table.
Also, I'd like a command-line option to prevent translation to pseudo
instructions completely, and may a second option to prevent
translation of register names also.
urs