Created
March 11, 2020 20:17
-
-
Save Irvise/2499c2a6776d0040538ec57a32c113a6 to your computer and use it in GitHub Desktop.
Disassembly of Freedom Studios' elf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;-- section..init: | |
;-- segment.LOAD0: | |
;-- .init: | |
;-- _enter: | |
(fcn) entry0 280 | |
entry0 (); | |
0x20010000 auipc gp, 0x5fff1 ; entry.S:24 la gp, __global_pointer$ ; [01] -r-x section size 404 named .init | |
0x20010004 addi gp, gp, 648 | |
0x20010008 auipc t0, 0x0 ; entry.S:29 la t0, early_trap_vector | |
0x2001000c addi t0, t0, 88 | |
0x20010010 csrw mtvec, t0 ; entry.S:30 csrw mtvec, t0 | |
0x20010014 li t0, 0 ; entry.S:32 la t0, __metal_chicken_bit | |
0x20010018 beqz t0, 0x20010020 ; entry.S:33 beqz t0, 1f | |
0x2001001c csrwi 0x7c1, 0 ; entry.S:34 csrwi 0x7C1, 0 | |
0x20010020 auipc sp, 0xdfff0 ; entry.S:43 la sp, __metal_stack_pointer | |
0x20010024 addi sp, sp, -32 | |
0x20010028 auipc ra, 0xdfff0 ; entry.S:52 la ra, __metal_before_start | |
0x2001002c addi ra, ra, -40 | |
0x20010030 beqz ra, 0x20010036 ; entry.S:53 beqz ra, 1f | |
0x20010034 jalr ra ; entry.S:54 jalr ra | |
0x20010036 csrr a0, mhartid ; entry.S:60 csrr a0, mhartid | |
0x2001003a li a1, 0 ; entry.S:61 li a1, 0 | |
0x2001003c li a2, 0 ; entry.S:62 li a2, 0 | |
0x2001003e jal sym._start ; entry.S:63 call _start | |
0x20010040 auipc ra, 0xdfff0 ; entry.S:68 la ra, __metal_after_main | |
0x20010044 addi ra, ra, -64 | |
0x20010048 beqz ra, 0x2001004e ; entry.S:69 beqz ra, 1f ; entry0+0x4e | |
0x2001004c jalr ra ; entry.S:70 jalr ra | |
0x2001004e auipc t0, 0x0 ; entry.S:75 la t0, 1f | |
0x20010052 addi t0, t0, 12 | |
0x20010056 csrw mtvec, t0 ; entry.S:76 csrw mtvec, t0 | |
0x2001005a lw t1, 0(zero) ; entry.S:78 lw t1, 0(x0) | |
0x2001005e j 0x2001005a ; entry.S:79 j 1b | |
;-- early_trap_vector: | |
0x20010060 csrr t0, mcause | |
0x20010064 csrr t1, mepc | |
0x20010068 csrr t2, mbadaddr | |
0x2001006c j loc.early_trap_vector | |
;-- __register_frame_info: | |
0x2001006e ret | |
;-- __metal_synchronize_harts: | |
0x20010070 addi sp, sp, -16 ; synchronize_harts.c:19 void __metal_synchronize_harts() { | |
0x20010072 sw s0, 12(sp) | |
0x20010074 addi s0, sp, 16 | |
0x20010076 nop ; synchronize_harts.c:61 } | |
0x20010078 lw s0, 12(sp) | |
0x2001007a addi sp, sp, 16 | |
0x2001007c ret | |
;-- _start: | |
0x2001007e mv s0, ra ; crt0.S:36 mv s0, ra | |
0x20010080 auipc gp, 0x5fff1 ; crt0.S:44 la gp, __global_pointer$ | |
0x20010084 addi gp, gp, 520 | |
0x20010088 addi sp, gp, -796 ; crt0.S:51 la sp, _sp | |
0x2001008c li t0, 0 ; crt0.S:54 li t0, 0 | |
0x2001008e li t1, loc.__stack_size ; crt0.S:55 la t1, __stack_size | |
0x20010092 beq t0, a0, 0x2001009c ; crt0.S:57 beq t0, a0, 1f | |
0x20010096 add sp, sp, t1 ; crt0.S:58 add sp, sp, t1 | |
0x20010098 addi t0, t0, 1 ; crt0.S:59 addi t0, t0, 1 | |
0x2001009a j 0x20010092 ; crt0.S:60 j 1b | |
0x2001009c andi sp, sp, -16 ; crt0.S:62 andi sp, sp, -16 | |
0x200100a0 li t0, 0 ; crt0.S:65 la t0, __metal_boot_hart | |
0x200100a4 bne a0, t0, loc._skip_init ; crt0.S:66 bne a0, t0, _skip_init ; entry0+0x136 | |
0x200100a8 auipc t0, 0x6 ; crt0.S:75 la t0, metal_segment_data_source_start | |
0x200100ac addi t0, t0, -8 | |
0x200100b0 auipc t1, 0x5fff0 ; crt0.S:76 la t1, metal_segment_data_target_start | |
0x200100b4 addi t1, t1, -176 | |
0x200100b8 addi t2, gp, -1976 ; crt0.S:77 la t2, metal_segment_data_target_end | |
0x200100bc beq t0, t1, 0x200100d4 ; crt0.S:79 beq t0, t1, 2f | |
0x200100c0 ble t2, t1, 0x200100d4 ; crt0.S:80 bge t1, t2, 2f | |
0x200100c4 lw a0, 0(t0) ; crt0.S:84 lw a0, 0(t0) | |
0x200100c8 addi t0, t0, 4 ; crt0.S:85 addi t0, t0, 4 | |
0x200100ca sw a0, 0(t1) ; crt0.S:86 sw a0, 0(t1) | |
0x200100ce addi t1, t1, 4 ; crt0.S:87 addi t1, t1, 4 | |
0x200100d0 blt t1, t2, 0x200100c4 ; crt0.S:88 blt t1, t2, 1b | |
0x200100d4 auipc t0, 0x6 ; crt0.S:99 la t0, metal_segment_itim_source_start | |
0x200100d8 addi t0, t0, -52 | |
0x200100dc auipc t1, 0xe7ff0 ; crt0.S:100 la t1, metal_segment_itim_target_start | |
0x200100e0 addi t1, t1, -220 | |
0x200100e4 auipc t2, 0xe7ff0 ; crt0.S:101 la t2, metal_segment_itim_target_end | |
0x200100e8 addi t2, t2, -228 | |
0x200100ec beq t0, t1, 0x20010104 ; crt0.S:103 beq t0, t1, 2f | |
0x200100f0 ble t2, t1, 0x20010104 ; crt0.S:104 bge t1, t2, 2f | |
0x200100f4 lw a0, 0(t0) ; crt0.S:108 lw a0, 0(t0) | |
0x200100f8 addi t0, t0, 4 ; crt0.S:109 addi t0, t0, 4 | |
0x200100fa sw a0, 0(t1) ; crt0.S:110 sw a0, 0(t1) | |
0x200100fe addi t1, t1, 4 ; crt0.S:111 addi t1, t1, 4 | |
0x20010100 blt t1, t2, 0x200100f4 ; crt0.S:112 blt t1, t2, 1b | |
0x20010104 fence.i ; crt0.S:124 fence.i | |
0x20010108 auipc t1, 0x5fff1 ; crt0.S:127 la t1, metal_segment_bss_target_start | |
0x2001010c addi t1, t1, -1592 | |
0x20010110 addi t2, gp, -1820 ; crt0.S:128 la t2, metal_segment_bss_target_end | |
0x20010114 ble t2, t1, 0x20010122 ; crt0.S:130 bge t1, t2, 2f | |
0x20010118 sw zero, 0(t1) ; crt0.S:134 sw x0, 0(t1) | |
0x2001011c addi t1, t1, 4 ; crt0.S:135 addi t1, t1, 4 | |
0x2001011e blt t1, t2, 0x20010118 ; crt0.S:136 blt t1, t2, 1b | |
0x20010122 beqz a2, 0x20010126 ; crt0.S:147 beqz a2, 1f | |
0x20010124 jalr a2 ; crt0.S:148 jalr a2 | |
0x20010126 auipc a0, 0x1 ; crt0.S:152 la a0, __libc_fini_array | |
0x2001012a addi a0, a0, -404 | |
0x2001012e jal ra, sym.atexit ; crt0.S:153 call atexit ; sym._write+0x6e ; ssize_t write(int fd, const char *ptr, size_t nbytes) | |
0x20010132 jal ra, sym.__libc_init_array ; crt0.S:154 call __libc_init_array | |
;-- _skip_init: | |
0x20010136 jal sym.__metal_synchronize_harts ; crt0.S:160 call __metal_synchronize_harts | |
0x20010138 csrr a5, misa ; crt0.S:163 csrr a5, misa | |
0x2001013c lui a4, 0x10 ; crt0.S:164 li a4, 0x10028 | |
0x20010140 addi a4, a4, 40 | |
0x20010144 and a5, a5, a4 ; crt0.S:165 and a5, a5, a4 | |
0x20010146 beqz a5, 0x20010158 ; crt0.S:166 beqz a5, 1f | |
0x20010148 csrr a5, mstatus ; crt0.S:167 csrr a5, mstatus | |
0x2001014c lui a4, 0x2 ; crt0.S:168 lui a4, 0x2 | |
0x2001014e or a5, a5, a4 ; crt0.S:169 or a5, a5, a4 | |
0x20010150 csrw mstatus, a5 ; crt0.S:170 csrw mstatus, a5 | |
0x20010154 csrwi fcsr, 0 ; crt0.S:171 csrwi fcsr, 0 | |
0x20010158 li a0, 1 ; crt0.S:177 li a0, 1 /* argc=1 */ | |
0x2001015a auipc a1, 0x5 ; crt0.S:178 la a1, argv /* argv = {"libgloss", NULL} */ | |
0x2001015e addi a1, a1, 858 | |
0x20010162 auipc a2, 0x5 ; crt0.S:179 la a2, envp /* envp = {NULL} */ | |
0x20010166 addi a2, a2, 854 | |
0x2001016a jal sym.secondary_main ; crt0.S:180 call secondary_main | |
0x2001016c jal ra, sym.exit ; crt0.S:186 call exit ; sym.__errno+0xc | |
0x20010170 mv ra, s0 ; crt0.S:191 mv ra, s0 | |
0x20010172 ret ; crt0.S:192 ret | |
;-- _fini: | |
(fcn) sym._init 16 | |
sym._init (); | |
0x20010174 ret ; crt0.S:204 ret | |
;-- secondary_main: | |
0x20010176 addi sp, sp, -16 ; crt0.S:215 addi sp, sp, -16 | |
0x20010178 sw ra, 4(sp) ; crt0.S:217 sw ra, 4(sp) | |
0x2001017a csrr t0, mhartid ; crt0.S:221 csrr t0, mhartid | |
0x2001017e li t1, 0 ; crt0.S:222 la t1, __metal_boot_hart | |
0x20010182 beq t0, t1, 0x2001018c ; crt0.S:223 beq t0, t1, 2f | |
0x20010186 wfi ; crt0.S:225 wfi | |
0x2001018a j 0x20010186 ; crt0.S:226 j 1b | |
0x2001018c jal main ; crt0.S:228 call main | |
0x2001018e lw ra, 4(sp) ; crt0.S:230 lw ra, 4(sp) | |
0x20010190 addi sp, sp, 16 ; crt0.S:234 addi sp, sp, 16 | |
0x20010192 ret ; crt0.S:235 ret | |
0x20010194 unimp | |
0x20010196 unimp | |
0x20010198 unimp | |
0x2001019a unimp | |
0x2001019c unimp | |
0x2001019e unimp | |
0x200101a0 unimp | |
0x200101a2 unimp | |
0x200101a4 unimp | |
0x200101a6 unimp | |
0x200101a8 unimp | |
0x200101aa unimp | |
0x200101ac unimp | |
0x200101ae unimp | |
0x200101b0 unimp | |
0x200101b2 unimp | |
0x200101b4 unimp | |
0x200101b6 unimp | |
0x200101b8 unimp | |
0x200101ba unimp | |
0x200101bc unimp | |
0x200101be unimp | |
0x200101c0 unimp | |
0x200101c2 unimp | |
0x200101c4 unimp | |
0x200101c6 unimp | |
0x200101c8 unimp | |
0x200101ca unimp | |
0x200101cc unimp | |
0x200101ce unimp | |
0x200101d0 unimp | |
0x200101d2 unimp | |
0x200101d4 unimp | |
0x200101d6 unimp | |
0x200101d8 unimp | |
0x200101da unimp | |
0x200101dc unimp | |
0x200101de unimp | |
0x200101e0 unimp | |
0x200101e2 unimp | |
0x200101e4 unimp | |
0x200101e6 unimp | |
0x200101e8 unimp | |
0x200101ea unimp | |
0x200101ec unimp | |
0x200101ee unimp | |
0x200101f0 unimp | |
0x200101f2 unimp | |
0x200101f4 unimp | |
0x200101f6 unimp | |
0x200101f8 unimp | |
0x200101fa unimp | |
0x200101fc unimp | |
0x200101fe unimp | |
;-- section..text: | |
;-- .text: | |
(fcn) main 100 | |
int main (int argc, char **argv, char **envp); | |
0x20010200 addi sp, sp, -16 ; [02] -r-x section size 21060 named .text | |
0x20010202 sw ra, 12(sp) | |
0x20010204 sw s0, 8(sp) | |
0x20010206 addi s0, sp, 16 | |
0x20010208 lui a5, 0x20015 | |
0x2001020c addi a0, a5, 1092 | |
0x20010210 jal sym.puts | |
0x20010212 li a5, 0 | |
0x20010214 mv a0, a5 | |
0x20010216 lw ra, 12(sp) | |
0x20010218 lw s0, 8(sp) | |
0x2001021a addi sp, sp, 16 | |
0x2001021c ret | |
;-- _puts_r: | |
0x2001021e addi sp, sp, -32 | |
0x20010220 sw s1, 20(sp) | |
0x20010222 sw s2, 16(sp) | |
0x20010224 sw ra, 28(sp) | |
0x20010226 sw s0, 24(sp) | |
0x20010228 sw s3, 12(sp) | |
0x2001022a sw s4, 8(sp) | |
0x2001022c mv s1, a0 | |
0x2001022e mv s2, a1 | |
0x20010230 beqz a0, 0x20010238 | |
0x20010232 lw a5, 24(a0) | |
0x20010234 bnez a5, 0x20010238 | |
0x20010236 jal sym.__sinit | |
0x20010238 lw a5, 24(s1) | |
0x2001023a lw s0, 8(s1) | |
0x2001023c bnez a5, 0x20010242 | |
0x2001023e mv a0, s1 | |
0x20010240 jal sym.__sinit | |
0x20010242 auipc a5, 0x5 | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment