Closed buhe closed 2 years ago
example.o
riscv-gcc/bin/riscv64-unknown-elf-readelf -a example.o
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: RISC-V
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 592 (bytes into file)
Flags: 0x5, RVC, double-float ABI
Size of this header: 64 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 64 (bytes)
Number of section headers: 9
Section header string table index: 8
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .text PROGBITS 0000000000000000 00000040
0000000000000094 0000000000000000 AX 0 0 4
[ 2] .rela.text RELA 0000000000000000 000001c0
0000000000000048 0000000000000018 I 6 1 8
[ 3] .data PROGBITS 0000000000000000 000000d4
0000000000000000 0000000000000000 WA 0 0 1
[ 4] .bss NOBITS 0000000000000000 000000d4
0000000000000000 0000000000000000 WA 0 0 1
[ 5] .riscv.attributes RISCV_ATTRIBUTE 0000000000000000 000000d4
0000000000000033 0000000000000000 0 0 1
[ 6] .symtab SYMTAB 0000000000000000 00000108
00000000000000a8 0000000000000018 7 5 8
[ 7] .strtab STRTAB 0000000000000000 000001b0
000000000000000e 0000000000000000 0 0 1
[ 8] .shstrtab STRTAB 0000000000000000 00000208
0000000000000043 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
p (processor specific)
There are no section groups in this file.
There are no program headers in this file.
There is no dynamic section in this file.
Relocation section '.rela.text' at offset 0x1c0 contains 3 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000000 00000000002b R_RISCV_ALIGN 2
000000000046 000600000012 R_RISCV_CALL 0000000000000000 print + 0
000000000046 000000000033 R_RISCV_RELAX 0
The decoding of unwind sections for machine type RISC-V is not currently supported.
Symbol table '.symtab' contains 7 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 SECTION LOCAL DEFAULT 1
2: 0000000000000000 0 SECTION LOCAL DEFAULT 3
3: 0000000000000000 0 SECTION LOCAL DEFAULT 4
4: 0000000000000000 0 SECTION LOCAL DEFAULT 5
5: 0000000000000002 0 NOTYPE GLOBAL DEFAULT 1 print2
6: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND print
No version information found in this file.
Attribute Section: riscv
File Attributes
Tag_RISCV_arch: "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
h.o(h.c)
riscv-gcc/bin/riscv64-unknown-elf-readelf -a h.o
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: RISC-V
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 560 (bytes into file)
Flags: 0x5, RVC, double-float ABI
Size of this header: 64 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 64 (bytes)
Number of section headers: 10
Section header string table index: 9
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .text PROGBITS 0000000000000000 00000040
000000000000001e 0000000000000000 AX 0 0 2
[ 2] .rela.text RELA 0000000000000000 000001b0
0000000000000030 0000000000000018 I 7 1 8
[ 3] .data PROGBITS 0000000000000000 0000005e
0000000000000000 0000000000000000 WA 0 0 1
[ 4] .bss NOBITS 0000000000000000 0000005e
0000000000000000 0000000000000000 WA 0 0 1
[ 5] .comment PROGBITS 0000000000000000 0000005e
0000000000000029 0000000000000001 MS 0 0 1
[ 6] .riscv.attributes RISCV_ATTRIBUTE 0000000000000000 00000087
0000000000000035 0000000000000000 0 0 1
[ 7] .symtab SYMTAB 0000000000000000 000000c0
00000000000000d8 0000000000000018 8 7 8
[ 8] .strtab STRTAB 0000000000000000 00000198
0000000000000012 0000000000000000 0 0 1
[ 9] .shstrtab STRTAB 0000000000000000 000001e0
000000000000004c 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
p (processor specific)
There are no section groups in this file.
There are no program headers in this file.
There is no dynamic section in this file.
Relocation section '.rela.text' at offset 0x1b0 contains 2 entries:
Offset Info Type Sym. Value Sym. Name + Addend
00000000000a 000800000012 R_RISCV_CALL 0000000000000000 print + 0
00000000000a 000000000033 R_RISCV_RELAX 0
The decoding of unwind sections for machine type RISC-V is not currently supported.
Symbol table '.symtab' contains 9 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS h.c
2: 0000000000000000 0 SECTION LOCAL DEFAULT 1
3: 0000000000000000 0 SECTION LOCAL DEFAULT 3
4: 0000000000000000 0 SECTION LOCAL DEFAULT 4
5: 0000000000000000 0 SECTION LOCAL DEFAULT 5
6: 0000000000000000 0 SECTION LOCAL DEFAULT 6
7: 0000000000000000 30 FUNC GLOBAL DEFAULT 1 print2
8: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND print
No version information found in this file.
Attribute Section: riscv
File Attributes
Tag_RISCV_stack_align: 16-bytes
Tag_RISCV_arch: "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
h.S
.file "h.c"
.option nopic
.attribute arch, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
.attribute unaligned_access, 0
.attribute stack_align, 16
.text
.align 1
.globl print2
.type print2, @function
print2:
addi sp,sp,-16
sd ra,8(sp)
sd s0,0(sp)
addi s0,sp,16
li a0,5
call print
mv a5,a0
mv a0,a5
ld ra,8(sp)
ld s0,0(sp)
addi sp,sp,16
jr ra
.size print2, .-print2
.ident "GCC: (GNU) 10.2.0"
example.S
.text
.align 2
.global print2
print2:
addi sp, sp, -56
sw s0, 0(sp)
sw s1, 4(sp)
sw s2, 8(sp)
sw s3, 12(sp)
sw s4, 16(sp)
sw s5, 20(sp)
sw s6, 24(sp)
sw s7, 28(sp)
sw s8, 32(sp)
sw s9, 36(sp)
sw s10, 40(sp)
sw s11, 44(sp)
li t0, 5
addi sp, sp, -60
sw ra, 0(sp)
sw t0, 4(sp)
sw t1, 8(sp)
sw t2, 12(sp)
sw t3, 16(sp)
sw t4, 20(sp)
sw t5, 24(sp)
sw t6, 28(sp)
sw a0, 32(sp)
sw a1, 36(sp)
sw a2, 40(sp)
sw a3, 44(sp)
sw a4, 48(sp)
sw a5, 52(sp)
sw a6, 56(sp)
sw a7, 60(sp)
mv a0 ,t0
call print
lw ra, 0(sp)
lw t0, 4(sp)
lw t1, 8(sp)
lw t2, 12(sp)
lw t3, 16(sp)
lw t4, 20(sp)
lw t5, 24(sp)
lw t6, 28(sp)
lw a1, 36(sp)
lw a2, 40(sp)
lw a3, 44(sp)
lw a4, 48(sp)
lw a5, 52(sp)
lw a6, 56(sp)
lw a7, 60(sp)
addi sp, sp, 60
mv t1 ,a0
lw a0, 32(sp)
mv a0, t1
lw s0, 0(sp)
lw s1, 4(sp)
lw s2, 8(sp)
lw s3, 12(sp)
lw s4, 16(sp)
lw s5, 20(sp)
lw s6, 24(sp)
lw s7, 28(sp)
lw s8, 32(sp)
lw s9, 36(sp)
lw s10, 40(sp)
lw s11, 44(sp)
addi sp, sp, 56
ret
rustsbi/rustsbi-k210#6
c
custom