Displaying 2 results from an estimated 2 matches for "852a".
Did you mean:
852
2017 Jul 12
5
[LLD] Linker Relaxation
...t of relaxation, so it
isn't really optional. For example:
_start:
mv a0, a0
.p2align 2
li a0, 0
The assembler inserts a 3-byte padding (note: this behavior isn't
merged yet, see: https://github.com/riscv/riscv-binutils-gdb/pull/88):
00000000 <_start>:
0: 852a mv a0,a0
2: 00 01 00 # R_RISCV_ALIGN
2: R_RISCV_ALIGN *ABS*+0x3
5: 4501 li a0,0
The linker then remove 1 byte from padding to align to the desired width:
00010054 <_start>:
100...
2017 Jul 11
8
[LLD] Linker Relaxation
Here's an example using the gcc toolchain for embedded 32 bit RISC-V (my
HiFive1 board):
#include <stdio.h>
int foo(int i){
if (i < 100){
printf("%d\n", i);
}
return i;
}
int main(){
foo(10);
return 0;
}
After compiling to a .o with -O2 -march=RV32IC we get (just looking at foo)
00000000 <foo>:
0: 1141 addi sp,sp,-16