MicroCorruption/21-Cold Lake/coldlake.s

278 lines
6.2 KiB
ArmAsm
Raw Normal View History

2022-12-11 21:32:46 +00:00
.file "coldlake.c"
.cpu 430
.mpy none
; GNU C (mspgcc_20120406) version 4.6.3 20120301 (mspgcc LTS 20120406 unpatched) (msp430)
; compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.0-p13, MPC version 1.2.1
; GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
; options passed: coldlake.c -O0 -fverbose-asm
; options enabled: -fauto-inc-dec -fbranch-count-reg -fcommon
; -fdelete-null-pointer-checks -fearly-inlining
; -feliminate-unused-debug-types -ffunction-cse -fgcse-lm -fident
; -finline-functions-called-once -fira-share-save-slots
; -fira-share-spill-slots -fivopts -fkeep-static-consts
; -fleading-underscore -fmath-errno -fmerge-debug-strings
; -fmove-loop-invariants -fpeephole -fprefetch-loop-arrays
; -freg-struct-return -fsched-critical-path-heuristic
; -fsched-dep-count-heuristic -fsched-group-heuristic -fsched-interblock
; -fsched-last-insn-heuristic -fsched-rank-heuristic -fsched-spec
; -fsched-spec-insn-heuristic -fsched-stalled-insns-dep -fshow-column
; -fsigned-zeros -fsplit-ivs-in-unroller -fstrict-volatile-bitfields
; -ftrapping-math -ftree-forwprop -ftree-loop-if-convert -ftree-loop-im
; -ftree-loop-ivcanon -ftree-loop-optimize -ftree-parallelize-loops=
; -ftree-phiprop -ftree-pta -ftree-reassoc -ftree-scev-cprop
; -ftree-slp-vectorize -ftree-vect-loop-version -funit-at-a-time
; -fverbose-asm -fzero-initialized-in-bss
; Compiler executable checksum: e798769d5090625420b1df34770b8edb
.section .rodata
.LC0:
.string "Welcome to the secure program loader."
.LC1:
.string "Please enter second stage load address."
.LC2:
.string "Please enter the second stage program."
.LC3:
.string "Please enter program signature."
.LC4:
.string "Signature valid, executing payload"
.LC5:
.string "ACCESS GRANTED"
.LC6:
.string "ACCESS DENIED"
.LC7:
.string "Incorrect signature, continuing"
.LC8:
.string "Load address outside allowed range of 0x8000-0xF000"
.section .init9,"ax",@progbits
.p2align 1,0
.global main
.type main,@function
/***********************
* Function `main'
***********************/
main:
mov sp, r4 ; ,
add #2, r4 ; ,
add #llo(-324), sp ; ,
mov #.LC0, r15 ; ,
call #puts ;
.L7:
mov #.LC1, r15 ; ,
call #puts ;
mov #2, r14 ; ,
mov r4, r15 ; ,
add #llo(-326), r15 ; ,
call #getsn ;
mov #.LC2, r15 ; ,
call #puts ;
mov r4, r15 ; , tmp34
add #llo(-259), r15 ; , tmp34
mov #257, r14 ; , tmp36
mov r14, r13 ; tmp36,
mov #0, r14 ; ,
call #memset ;
mov r4, r15 ; , tmp38
add #llo(-259), r15 ; , tmp38
mov #256, r14 ; ,
call #getsn ;
mov #.LC3, r15 ; ,
call #puts ;
mov r4, r15 ; , tmp39
add #llo(-324), r15 ; , tmp39
mov #65, r14 ; , tmp41
mov r14, r13 ; tmp41,
mov #0, r14 ; ,
call #memset ;
mov r4, r15 ; , tmp43
add #llo(-324), r15 ; , tmp43
mov #64, r14 ; ,
call #getsn ;
mov -326(r4), r15 ; loadaddr, loadaddr.0
cmp #0, r15 ; , loadaddr.1
jge .L2 ;
mov -326(r4), r15 ; loadaddr, loadaddr.2
cmp #llo(-4095), r15 ; , loadaddr.3
jhs .L2 ;
mov -326(r4), r15 ; loadaddr, loadaddr.4
mov r4, r14 ; , tmp44
add #llo(-259), r14 ; , tmp44
mov #256, r13 ; , tmp47
call #memcpy ;
mov -326(r4), r15 ; loadaddr, loadaddr.5
mov r4, r14 ; , tmp49
add #llo(-324), r14 ; , tmp49
mov r14, r12 ; tmp49,
mov #256, r13 ; ,
mov r15, r14 ; loadaddr.5,
mov #9216, r15 ; ,
call #verify_ed25519 ;
cmp #1, r15 ; , D.1328
jne .L3 ;
mov #.LC4, r15 ; ,
call #puts ;
mov -326(r4), r15 ; loadaddr, loadaddr.6
call r15 ; loadaddr.6
cmp #0, r15 ; , D.1332
jeq .L4 ;
mov #.LC5, r15 ; ,
call #puts ;
push #0 ;
push #0 ;
push #127 ;
call #INT ;
add #6, sp ; ,
mov #0, r15 ; ,
call #exit ;
.L4:
mov #.LC6, r15 ; ,
call #puts ;
jmp .L6 ;
.L3:
mov #.LC7, r15 ; ,
call #puts ;
jmp .L6 ;
.L2:
mov #.LC8, r15 ; ,
call #puts ;
jmp .L7 ;
.L6:
jmp .L7 ;
.LIRD0:
.Lfe1:
.size main,.Lfe1-main
;; End of function
.text
.p2align 1,0
.global INT
.type INT,@function
/***********************
* Function `INT'
***********************/
INT:
push r4 ;
mov sp, r4 ; ,
add #2, r4 ; ,
pop r4 ;
ret
.Lfe2:
.size INT,.Lfe2-INT
;; End of function
.p2align 1,0
.global verify_ed25519
.type verify_ed25519,@function
/***********************
* Function `verify_ed25519'
***********************/
verify_ed25519:
push r4 ;
mov sp, r4 ; ,
add #2, r4 ; ,
add #llo(-10), sp ; ,
mov r15, -10(r4) ; ed25519_pubkey, ed25519_pubkey
mov r14, -8(r4) ; buf, buf
mov r13, -6(r4) ; size, size
mov r12, -4(r4) ; signature, signature
mov #0, -12(r4) ; , result
mov #llo(-12), r15 ; ,
add r4, r15 ; ,
push r15 ;
push -4(r4) ; signature
push -6(r4) ; size
push -8(r4) ; buf
push -10(r4) ; ed25519_pubkey
push #51 ;
call #INT ;
add #12, sp ; ,
mov -12(r4), r15 ; result, D.1316
add #10, sp ; ,
pop r4 ;
ret
.Lfe3:
.size verify_ed25519,.Lfe3-verify_ed25519
;; End of function
.p2align 1,0
.global getsn
.type getsn,@function
/***********************
* Function `getsn'
***********************/
getsn:
push r4 ;
mov sp, r4 ; ,
add #2, r4 ; ,
sub #4, sp ; ,
mov r15, -6(r4) ; buf, buf
mov r14, -4(r4) ; length, length
push -4(r4) ; length
push -6(r4) ; buf
push #2 ;
call #INT ;
add #6, sp ; ,
add #4, sp ; ,
pop r4 ;
ret
.Lfe4:
.size getsn,.Lfe4-getsn
;; End of function
.p2align 1,0
.global putchar
.type putchar,@function
/***********************
* Function `putchar'
***********************/
putchar:
push r4 ;
mov sp, r4 ; ,
add #2, r4 ; ,
sub #2, sp ; ,
mov r15, -4(r4) ; c, c
push -4(r4) ; c
push #0 ;
call #INT ;
add #4, sp ; ,
add #2, sp ; ,
pop r4 ;
ret
.Lfe5:
.size putchar,.Lfe5-putchar
;; End of function
.p2align 1,0
.global puts
.type puts,@function
/***********************
* Function `puts'
***********************/
puts:
push r4 ;
mov sp, r4 ; ,
add #2, r4 ; ,
sub #4, sp ; ,
mov r15, -4(r4) ; str, str
jmp .L13 ;
.L14:
add #1, -4(r4) ; , str
mov.b -6(r4), r15 ; c, D.1313
sxt r15 ; D.1313
call #putchar ;
.L13:
mov -4(r4), r15 ; str, tmp27
mov.b @r15, -6(r4) ; *str_1, c
cmp.b #0, -6(r4) ; , c
jne .L14 ;
mov #10, r15 ; ,
call #putchar ;
mov #0, r15 ; , D.1314
add #4, sp ; ,
pop r4 ;
ret
.Lfe6:
.size puts,.Lfe6-puts
;; End of function