根据当前的RISC-V ABI规范,静态链接时存在30多种Relocations,本文主要介绍R_RISCV_HI20+R_RISCV_LO12_I/R_RISCV_LO12_S、R_RISCV_PCREL_HI20+R_RISCV_PCREL_LO12_I/R_RISCV_PCREL_LO12_S、R_RISCV_BRANCH、R_RISCV_CALL、R_RISCV_JAL这几种Relocations,并会使用实际的例子来展示。想了解更详...
auipc ra, %pcrel_hi(label) jalr ra, %pcrel_lo(label)(ra) ret:从子程序返回。 对应基本指令:jalr x0, 0(ra) 条件跳转伪指令 beqz rs, label:如果 rs == 0,跳转到 label。 对应基本指令:beq rs, x0, label bnez rs, label:如果 rs != 0,跳转到 label。 对应基本指令:bne rs, x0, lab...
0: R_RISCV_PCREL_HI20 msg 4: 00850513 addi a0,a0,8 # 8 <_start+0x8> 4: R_RISCV_PCREL_LO12_I .L11 1. 2. 3. 4. 5. Constants The following example shows loading a constant using the %hi and %lo assembler functions. AI检测代码解析 .equ UART_BASE, 0x40003000 lui a0, %h...
也正因此,auipc通常与la一起使用 auipc rd, %pcrel_hi(symbol) addi rd, rd, %pcrel_lo(symbol) 2.5B-Types 作用对象:同样是两个源寄存器与一个立即数 (similar to S-Type),有时称为 SB-type 在RISC-V中,标签用于识别代码中的特定位置,然而,在机器码中不存在标签,因此在将RISC-V代码转换为二进制形...
2>&1 | FileCheck %s++# CHECK: error: {{.*}}:(.text.sec_one+0x0): R_RISCV_PCREL_LO12 relocation points to a symbol '.Lpcrel_hi0' in a different section '.text.sec_two'+# CHECK: error: {{.*}}:(.text.sec_one+0x4): R_RISCV_PCREL_LO12 relocation points to a symbol ...
1: auipc t0, %pcrel_hi(mtvec) addi t0, t0, %pcrel(1b)Assembler NotationDescription %hi(symbol) Absolute(HI20) %lo(symbol) Absolute(LO12) %pcrel_hi(symbol) PC-relative (HI20) %pcrel_lo(label) PC-relative (LO12)nm软件nm软件可以列出目标文件中的符号。直接nm加上文件名,不使用交叉...
Long tail calls use the following instruction sequence on RISC-V: ``` 1: auipc xi, %pcrel_hi(sym) jalr zero, %pcrel_lo(1b)(xi) ``` Since the second instruction in isolation looks like an indirect branch, this confused BOLT and most functions containing a long tail call got marked...
.section.text.globl _start_start:1: auipca0, %pcrel_hi(msg)# load msg(hi)addia0,a0, %pcrel_lo(1b)# load msg(lo)jalra, puts2:j2b.section.rodatamsg:.string"Hello World\n" which generates the following assembler output and relocations as seen by objdump: ...
Integer Register Convention Floating-point Register Convention Procedure Calling Convention Integer Calling Convention Hardware Floating-point Calling Convention RV32E Calling Convention ...
1: auipc t0, %pcrel_hi(global) addi t1, t0, %pcrel_lo(1b)+0 addi t0, t0, %pcrel_lo(1b)+8 .data .balign 4096 global: .fill 2, 8, 0 In this case we generate a pre-linked object file that looks like you'd expect, essentially the same as what's above but with different...