| # .option norelax |
| # .global _start |
| # |
| # .section .reloc_12345678, "ax", @progbits |
| # _start: |
| # foo = 0x12345678 |
| # lui a0, %hi(foo) |
| # addi a0, a0, %lo(foo) |
| # lw a0, %lo(foo)(a0) |
| # |
| # .section .reloc_fedcba98, "ax", @progbits |
| # foo = 0xfedcba98 |
| # lui a0, %hi(foo) |
| # addi a0, a0, %lo(foo) |
| # |
| # REQUIRES: riscv |
| # RUN: yaml2obj %s -o %t.o |
| # RUN: ld.lld %t.o -o %t |
| # RUN: obj2yaml %t | FileCheck %s |
| # |
| # CHECK: - Name: .reloc_12345678 |
| # CHECK: Content: '375534121305856703258567' |
| # 11000: 12345537 lui a0,0x12345 |
| # 11004: 67850513 addi a0,a0,1656 # 12345678 <__global_pointer$+0x12332e78> |
| # 11008: 67852503 lw a0,1656(a0) |
| # |
| # CHECK: - Name: .reloc_fedcba98 |
| # CHECK: Content: 37C5DCFE130585A9 |
| # 1100c: fedcc537 lui a0,0xfedcc |
| # 11010: a9850513 addi a0,a0,-1384 # fedcba98 <__global_pointer$+0xfedb9298> |
| |
| --- !ELF |
| FileHeader: |
| Class: ELFCLASS32 |
| Data: ELFDATA2LSB |
| Type: ET_REL |
| Machine: EM_RISCV |
| Flags: [ EF_RISCV_RVC, EF_RISCV_FLOAT_ABI_SOFT ] |
| Sections: |
| - Name: .text |
| Type: SHT_PROGBITS |
| Flags: [ SHF_ALLOC, SHF_EXECINSTR ] |
| AddressAlign: 0x0000000000000002 |
| Content: '' |
| - Name: .data |
| Type: SHT_PROGBITS |
| Flags: [ SHF_WRITE, SHF_ALLOC ] |
| AddressAlign: 0x0000000000000001 |
| Content: '' |
| - Name: .bss |
| Type: SHT_NOBITS |
| Flags: [ SHF_WRITE, SHF_ALLOC ] |
| AddressAlign: 0x0000000000000001 |
| - Name: .reloc_12345678 |
| Type: SHT_PROGBITS |
| Flags: [ SHF_ALLOC, SHF_EXECINSTR ] |
| AddressAlign: 0x0000000000000001 |
| Content: '375534121305856703258567' |
| - Name: .reloc_fedcba98 |
| Type: SHT_PROGBITS |
| Flags: [ SHF_ALLOC, SHF_EXECINSTR ] |
| AddressAlign: 0x0000000000000001 |
| Content: 37C5DCFE130585A9 |
| Symbols: |
| Local: |
| - Name: .text |
| Type: STT_SECTION |
| Section: .text |
| - Name: .data |
| Type: STT_SECTION |
| Section: .data |
| - Name: .bss |
| Type: STT_SECTION |
| Section: .bss |
| - Name: .reloc_12345678 |
| Type: STT_SECTION |
| Section: .reloc_12345678 |
| - Name: foo |
| Value: 0x00000000FEDCBA98 |
| - Name: .reloc_fedcba98 |
| Type: STT_SECTION |
| Section: .reloc_fedcba98 |
| Global: |
| - Name: _start |
| Section: .reloc_12345678 |
| ... |