Skip to content

Instantly share code, notes, and snippets.

@kaloronahuang
Created February 16, 2023 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaloronahuang/b7d37d33b5a4e840041cd5c65c773b3c to your computer and use it in GitHub Desktop.
Save kaloronahuang/b7d37d33b5a4e840041cd5c65c773b3c to your computer and use it in GitHub Desktop.
An example runelf result from test_elf.
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: EXEC (Executable file)
Machine: RISC-V
Version: 0x1
Entry point address: 0x10450
Start of program headers: 64 (bytes into file)
Start of section headers: 12152 (bytes into file)
Flags: 0x5, RVC, double-float ABI
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 10
Size of section headers: 64 (bytes)
Number of section headers: 35
Section header string table index: 34
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .interp PROGBITS 0000000000010270 00000270
0000000000000021 0000000000000000 A 0 0 1
[ 2] .note.ABI-tag NOTE 0000000000010294 00000294
0000000000000020 0000000000000000 A 0 0 4
[ 3] .hash HASH 00000000000102b8 000002b8
0000000000000024 0000000000000004 A 5 0 8
[ 4] .gnu.hash GNU_HASH 00000000000102e0 000002e0
0000000000000030 0000000000000000 A 5 0 8
[ 5] .dynsym DYNSYM 0000000000010310 00000310
0000000000000060 0000000000000018 A 6 1 8
[ 6] .dynstr STRTAB 0000000000010370 00000370
0000000000000041 0000000000000000 A 0 0 1
[ 7] .gnu.version VERSYM 00000000000103b2 000003b2
0000000000000008 0000000000000002 A 5 0 2
[ 8] .gnu.version_r VERNEED 00000000000103c0 000003c0
0000000000000020 0000000000000000 A 6 1 8
[ 9] .rela.plt RELA 00000000000103e0 000003e0
0000000000000030 0000000000000018 AI 5 19 8
[10] .plt PROGBITS 0000000000010410 00000410
0000000000000040 0000000000000010 AX 0 0 16
[11] .text PROGBITS 0000000000010450 00000450
0000000000000134 0000000000000000 AX 0 0 4
[12] .rodata PROGBITS 0000000000010588 00000588
0000000000000004 0000000000000000 A 0 0 8
[13] .eh_frame_hdr PROGBITS 000000000001058c 0000058c
0000000000000014 0000000000000000 A 0 0 4
[14] .eh_frame PROGBITS 00000000000105a0 000005a0
000000000000002c 0000000000000000 A 0 0 8
[15] .preinit_array PREINIT_ARRAY 0000000000011e08 00000e08
0000000000000008 0000000000000008 WA 0 0 1
[16] .init_array INIT_ARRAY 0000000000011e10 00000e10
0000000000000008 0000000000000008 WA 0 0 8
[17] .fini_array FINI_ARRAY 0000000000011e18 00000e18
0000000000000008 0000000000000008 WA 0 0 8
[18] .dynamic DYNAMIC 0000000000011e20 00000e20
00000000000001e0 0000000000000010 WA 6 0 8
[19] .got PROGBITS 0000000000012000 00001000
0000000000000028 0000000000000008 WA 0 0 8
[20] .sdata PROGBITS 0000000000012028 00001028
0000000000000010 0000000000000000 WA 0 0 8
[21] .bss NOBITS 0000000000012038 00001038
0000000000000008 0000000000000000 WA 0 0 1
[22] .comment PROGBITS 0000000000000000 00001038
000000000000002d 0000000000000001 MS 0 0 1
[23] .riscv.attributes RISCV_ATTRIBUTE 0000000000000000 00001065
0000000000000035 0000000000000000 0 0 1
[24] .debug_aranges PROGBITS 0000000000000000 000010a0
00000000000000a0 0000000000000000 0 0 16
[25] .debug_info PROGBITS 0000000000000000 00001140
0000000000000683 0000000000000000 0 0 1
[26] .debug_abbrev PROGBITS 0000000000000000 000017c3
000000000000027b 0000000000000000 0 0 1
[27] .debug_line PROGBITS 0000000000000000 00001a3e
0000000000000244 0000000000000000 0 0 1
[28] .debug_frame PROGBITS 0000000000000000 00001c88
0000000000000068 0000000000000000 0 0 8
[29] .debug_str PROGBITS 0000000000000000 00001cf0
00000000000004e0 0000000000000001 MS 0 0 1
[30] .debug_line_str PROGBITS 0000000000000000 000021d0
0000000000000174 0000000000000001 MS 0 0 1
[31] .debug_loclists PROGBITS 0000000000000000 00002344
000000000000012b 0000000000000000 0 0 1
[32] .symtab SYMTAB 0000000000000000 00002470
0000000000000768 0000000000000018 33 61 8
[33] .strtab STRTAB 0000000000000000 00002bd8
0000000000000239 0000000000000000 0 0 1
[34] .shstrtab STRTAB 0000000000000000 00002e11
0000000000000160 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),
D (mbind), p (processor specific)
There are no section groups in this file.
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x0000000000010040 0x0000000000010040
0x0000000000000230 0x0000000000000230 R 0x8
INTERP 0x0000000000000270 0x0000000000010270 0x0000000000010270
0x0000000000000021 0x0000000000000021 R 0x1
[Requesting program interpreter: /lib/ld-linux-riscv64-lp64d.so.1]
RISCV_ATTRIBUT 0x0000000000001065 0x0000000000000000 0x0000000000000000
0x0000000000000035 0x0000000000000000 R 0x1
LOAD 0x0000000000000000 0x0000000000010000 0x0000000000010000
0x00000000000005cc 0x00000000000005cc R E 0x1000
LOAD 0x0000000000000e08 0x0000000000011e08 0x0000000000011e08
0x0000000000000230 0x0000000000000238 RW 0x1000
DYNAMIC 0x0000000000000e20 0x0000000000011e20 0x0000000000011e20
0x00000000000001e0 0x00000000000001e0 RW 0x8
NOTE 0x0000000000000294 0x0000000000010294 0x0000000000010294
0x0000000000000020 0x0000000000000020 R 0x4
GNU_EH_FRAME 0x000000000000058c 0x000000000001058c 0x000000000001058c
0x0000000000000014 0x0000000000000014 R 0x4
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0x10
GNU_RELRO 0x0000000000000e08 0x0000000000011e08 0x0000000000011e08
0x00000000000001f8 0x00000000000001f8 R 0x1
Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .riscv.attributes
03 .interp .note.ABI-tag .hash .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.plt .plt .text .rodata .eh_frame_hdr .eh_frame
04 .preinit_array .init_array .fini_array .dynamic .got .sdata .bss
05 .dynamic
06 .note.ABI-tag
07 .eh_frame_hdr
08
09 .preinit_array .init_array .fini_array .dynamic
Dynamic section at offset 0xe20 contains 25 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x0000000000000020 (PREINIT_ARRAY) 0x11e08
0x0000000000000021 (PREINIT_ARRAYSZ) 8 (bytes)
0x0000000000000019 (INIT_ARRAY) 0x11e10
0x000000000000001b (INIT_ARRAYSZ) 8 (bytes)
0x000000000000001a (FINI_ARRAY) 0x11e18
0x000000000000001c (FINI_ARRAYSZ) 8 (bytes)
0x0000000000000004 (HASH) 0x102b8
0x000000006ffffef5 (GNU_HASH) 0x102e0
0x0000000000000005 (STRTAB) 0x10370
0x0000000000000006 (SYMTAB) 0x10310
0x000000000000000a (STRSZ) 65 (bytes)
0x000000000000000b (SYMENT) 24 (bytes)
0x0000000000000015 (DEBUG) 0x0
0x0000000000000003 (PLTGOT) 0x12000
0x0000000000000002 (PLTRELSZ) 48 (bytes)
0x0000000000000014 (PLTREL) RELA
0x0000000000000017 (JMPREL) 0x103e0
0x0000000000000007 (RELA) 0x103e0
0x0000000000000008 (RELASZ) 48 (bytes)
0x0000000000000009 (RELAENT) 24 (bytes)
0x000000006ffffffe (VERNEED) 0x103c0
0x000000006fffffff (VERNEEDNUM) 1
0x000000006ffffff0 (VERSYM) 0x103b2
0x0000000000000000 (NULL) 0x0
Relocation section '.rela.plt' at offset 0x3e0 contains 2 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000012010 000300000005 R_RISCV_JUMP_SLOT 0000000000010430 __libc_start_main@GLIBC_2.27 + 0
000000012018 000200000005 R_RISCV_JUMP_SLOT 0000000000010440 printf@GLIBC_2.27 + 0
The decoding of unwind sections for machine type RISC-V is not currently supported.
Symbol table '.dynsym' contains 4 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000012800 0 NOTYPE GLOBAL DEFAULT ABS __global_pointer$
2: 0000000000010440 0 FUNC GLOBAL DEFAULT UND printf@GLIBC_2.27 (2)
3: 0000000000010430 0 FUNC GLOBAL DEFAULT UND _[...]@GLIBC_2.27 (2)
Symbol table '.symtab' contains 79 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000010270 0 SECTION LOCAL DEFAULT 1 .interp
2: 0000000000010294 0 SECTION LOCAL DEFAULT 2 .note.ABI-tag
3: 00000000000102b8 0 SECTION LOCAL DEFAULT 3 .hash
4: 00000000000102e0 0 SECTION LOCAL DEFAULT 4 .gnu.hash
5: 0000000000010310 0 SECTION LOCAL DEFAULT 5 .dynsym
6: 0000000000010370 0 SECTION LOCAL DEFAULT 6 .dynstr
7: 00000000000103b2 0 SECTION LOCAL DEFAULT 7 .gnu.version
8: 00000000000103c0 0 SECTION LOCAL DEFAULT 8 .gnu.version_r
9: 00000000000103e0 0 SECTION LOCAL DEFAULT 9 .rela.plt
10: 0000000000010410 0 SECTION LOCAL DEFAULT 10 .plt
11: 0000000000010450 0 SECTION LOCAL DEFAULT 11 .text
12: 0000000000010588 0 SECTION LOCAL DEFAULT 12 .rodata
13: 000000000001058c 0 SECTION LOCAL DEFAULT 13 .eh_frame_hdr
14: 00000000000105a0 0 SECTION LOCAL DEFAULT 14 .eh_frame
15: 0000000000011e08 0 SECTION LOCAL DEFAULT 15 .preinit_array
16: 0000000000011e10 0 SECTION LOCAL DEFAULT 16 .init_array
17: 0000000000011e18 0 SECTION LOCAL DEFAULT 17 .fini_array
18: 0000000000011e20 0 SECTION LOCAL DEFAULT 18 .dynamic
19: 0000000000012000 0 SECTION LOCAL DEFAULT 19 .got
20: 0000000000012028 0 SECTION LOCAL DEFAULT 20 .sdata
21: 0000000000012038 0 SECTION LOCAL DEFAULT 21 .bss
22: 0000000000000000 0 SECTION LOCAL DEFAULT 22 .comment
23: 0000000000000000 0 SECTION LOCAL DEFAULT 23 .riscv.attributes
24: 0000000000000000 0 SECTION LOCAL DEFAULT 24 .debug_aranges
25: 0000000000000000 0 SECTION LOCAL DEFAULT 25 .debug_info
26: 0000000000000000 0 SECTION LOCAL DEFAULT 26 .debug_abbrev
27: 0000000000000000 0 SECTION LOCAL DEFAULT 27 .debug_line
28: 0000000000000000 0 SECTION LOCAL DEFAULT 28 .debug_frame
29: 0000000000000000 0 SECTION LOCAL DEFAULT 29 .debug_str
30: 0000000000000000 0 SECTION LOCAL DEFAULT 30 .debug_line_str
31: 0000000000000000 0 SECTION LOCAL DEFAULT 31 .debug_loclists
32: 0000000000000000 0 FILE LOCAL DEFAULT ABS abi-note.c
33: 0000000000010294 32 OBJECT LOCAL DEFAULT 2 __abi_tag
34: 0000000000000000 0 FILE LOCAL DEFAULT ABS start.o
35: 0000000000010450 0 NOTYPE LOCAL DEFAULT 11 $x
36: 000000000001047e 0 NOTYPE LOCAL DEFAULT 11 load_gp
37: 0000000000000000 0 FILE LOCAL DEFAULT ABS init.c
38: 0000000000000000 0 FILE LOCAL DEFAULT ABS static-reloc.c
39: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
40: 000000000001048a 0 FUNC LOCAL DEFAULT 11 deregister_tm_clones
41: 000000000001048a 0 NOTYPE LOCAL DEFAULT 11 $x
42: 00000000000104a8 0 FUNC LOCAL DEFAULT 11 register_tm_clones
43: 00000000000104d0 0 FUNC LOCAL DEFAULT 11 __do_global_dtors_aux
44: 0000000000012038 1 OBJECT LOCAL DEFAULT 21 completed.0
45: 0000000000011e18 0 OBJECT LOCAL DEFAULT 17 __do_global_dtor[...]
46: 00000000000104ee 0 FUNC LOCAL DEFAULT 11 frame_dummy
47: 0000000000011e10 0 OBJECT LOCAL DEFAULT 16 __frame_dummy_in[...]
48: 0000000000000000 0 FILE LOCAL DEFAULT ABS test_elf.c
49: 00000000000104f0 0 NOTYPE LOCAL DEFAULT 11 $x
50: 0000000000000000 0 FILE LOCAL DEFAULT ABS elf-init.c
51: 000000000001052a 0 NOTYPE LOCAL DEFAULT 11 $x
52: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
53: 00000000000105c8 0 OBJECT LOCAL DEFAULT 14 __FRAME_END__
54: 0000000000000000 0 FILE LOCAL DEFAULT ABS
55: 0000000000010410 0 OBJECT LOCAL DEFAULT 10 _PROCEDURE_LINKA[...]
56: 0000000000011e18 0 NOTYPE LOCAL DEFAULT 16 __init_array_end
57: 0000000000011e20 0 OBJECT LOCAL DEFAULT 18 _DYNAMIC
58: 0000000000011e10 0 NOTYPE LOCAL DEFAULT 16 __init_array_start
59: 000000000001058c 0 NOTYPE LOCAL DEFAULT 13 __GNU_EH_FRAME_HDR
60: 0000000000012020 0 OBJECT LOCAL DEFAULT 19 _GLOBAL_OFFSET_TABLE_
61: 0000000000010582 2 FUNC GLOBAL DEFAULT 11 __libc_csu_fini
62: 0000000000012000 0 NOTYPE WEAK DEFAULT 19 data_start
63: 0000000000012040 0 NOTYPE GLOBAL DEFAULT 21 __BSS_END__
64: 0000000000012038 0 NOTYPE GLOBAL DEFAULT 20 _edata
65: 0000000000012028 0 NOTYPE GLOBAL DEFAULT 20 __SDATA_BEGIN__
66: 0000000000012000 0 NOTYPE GLOBAL DEFAULT 19 __DATA_BEGIN__
67: 0000000000010430 0 FUNC GLOBAL DEFAULT UND __libc_start_mai[...]
68: 0000000000012000 0 NOTYPE GLOBAL DEFAULT 19 __data_start
69: 0000000000012030 0 OBJECT GLOBAL HIDDEN 20 __dso_handle
70: 0000000000012028 4 OBJECT GLOBAL DEFAULT 20 _IO_stdin_used
71: 000000000001052a 88 FUNC GLOBAL DEFAULT 11 __libc_csu_init
72: 0000000000012040 0 NOTYPE GLOBAL DEFAULT 21 _end
73: 0000000000010450 46 FUNC GLOBAL DEFAULT 11 _start
74: 0000000000012800 0 NOTYPE GLOBAL DEFAULT ABS __global_pointer$
75: 0000000000012038 0 NOTYPE GLOBAL DEFAULT 21 __bss_start
76: 00000000000104f0 58 FUNC GLOBAL DEFAULT 11 main
77: 0000000000010440 0 FUNC GLOBAL DEFAULT UND printf@GLIBC_2.27
78: 0000000000012000 0 OBJECT GLOBAL HIDDEN 19 __TMC_END__
Histogram for bucket list length (total of 3 buckets):
Length Number % of total Coverage
0 0 ( 0.0%)
1 3 (100.0%) 100.0%
Histogram for `.gnu.hash' bucket list length (total of 3 buckets):
Length Number % of total Coverage
0 1 ( 33.3%)
1 1 ( 33.3%) 33.3%
2 1 ( 33.3%) 100.0%
Version symbols section '.gnu.version' contains 4 entries:
Addr: 0x00000000000103b2 Offset: 0x0003b2 Link: 5 (.dynsym)
000: 0 (*local*) 1 (*global*) 2 (GLIBC_2.27) 2 (GLIBC_2.27)
Version needs section '.gnu.version_r' contains 1 entry:
Addr: 0x00000000000103c0 Offset: 0x0003c0 Link: 6 (.dynstr)
000000: Version: 1 File: libc.so.6 Cnt: 1
0x0010: Name: GLIBC_2.27 Flags: none Version: 2
Displaying notes found in: .note.ABI-tag
Owner Data size Description
GNU 0x00000010 NT_GNU_ABI_TAG (ABI version tag)
OS: Linux, ABI: 4.15.0
Attribute Section: riscv
File Attributes
Tag_RISCV_stack_align: 16-bytes
Tag_RISCV_arch: "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment