mirror of https://github.com/Shizmob/smol
better code arrangement for SKIP_ZERO_VALUE && IFUNC_SUPPORT && USE_DNLOAD_LOADER
This commit is contained in:
parent
ebaa50357d
commit
62406b12e6
2
Makefile
2
Makefile
|
@ -41,7 +41,7 @@ LIBS = $(filter-out -pthread,$(shell pkg-config --libs sdl2)) -lX11 -lm -lc #-lG
|
||||||
PWD ?= .
|
PWD ?= .
|
||||||
|
|
||||||
SMOLFLAGS = --smolrt "$(PWD)/rt" --smolld "$(PWD)/ld" \
|
SMOLFLAGS = --smolrt "$(PWD)/rt" --smolld "$(PWD)/ld" \
|
||||||
-falign-stack -fuse-interp -fifunc-support \
|
-falign-stack -fuse-interp -fifunc-support -fskip-zero-value \
|
||||||
--verbose #--keeptmp
|
--verbose #--keeptmp
|
||||||
# -fuse-dnload-loader -fskip-zero-value -fuse-nx -fskip-entries -fuse-dt-debug
|
# -fuse-dnload-loader -fskip-zero-value -fuse-nx -fskip-entries -fuse-dt-debug
|
||||||
# -fuse-dl-fini -fno-start-arg -funsafe-dynamic
|
# -fuse-dl-fini -fno-start-arg -funsafe-dynamic
|
||||||
|
|
|
@ -137,16 +137,35 @@ _smol_start:
|
||||||
%endif
|
%endif
|
||||||
add rax, [r12 + L_ADDR_OFF]
|
add rax, [r12 + L_ADDR_OFF]
|
||||||
%ifdef IFUNC_SUPPORT
|
%ifdef IFUNC_SUPPORT
|
||||||
and cl, ST_INFO__STT_MASK
|
and cl, ST_INFO__STT_MASK
|
||||||
cmp cl, STT_GNU_IFUNC
|
cmp cl, STT_GNU_IFUNC
|
||||||
je .ifunc
|
%ifdef SKIP_ZERO_VALUE
|
||||||
|
jne short .no_ifunc2
|
||||||
|
push rdi
|
||||||
|
push r11
|
||||||
|
call rax
|
||||||
|
pop r11
|
||||||
|
pop rdi
|
||||||
|
.no_ifunc2:
|
||||||
|
%else ; !SKIP_ZERO_VALUE
|
||||||
|
je short .ifunc
|
||||||
.no_ifunc:
|
.no_ifunc:
|
||||||
|
%endif
|
||||||
%endif
|
%endif
|
||||||
stosq
|
stosq
|
||||||
cmp word [rdi], 0
|
cmp word [rdi], 0
|
||||||
|
%ifdef IFUNC_SUPPORT
|
||||||
|
%ifdef SKIP_ZERO_VALUE
|
||||||
|
jne .next_hash;short .next_hash
|
||||||
|
%else ; IFUNC_SUPPORT && !SKIP_ZERO_VALUE
|
||||||
jne short .next_hash
|
jne short .next_hash
|
||||||
|
%endif
|
||||||
|
%else ; !IFUNC_SUPPORT
|
||||||
|
jne short .next_hash
|
||||||
|
%endif
|
||||||
|
|
||||||
%ifdef IFUNC_SUPPORT
|
%ifdef IFUNC_SUPPORT
|
||||||
|
%ifndef SKIP_ZERO_VALUE
|
||||||
jmp short .break_loop
|
jmp short .break_loop
|
||||||
.ifunc:
|
.ifunc:
|
||||||
;;int3 ; in this call, we lose rax rcx rdx rsi rdi r8 r9 r10 r11
|
;;int3 ; in this call, we lose rax rcx rdx rsi rdi r8 r9 r10 r11
|
||||||
|
@ -171,6 +190,7 @@ _smol_start:
|
||||||
jmp short .no_ifunc
|
jmp short .no_ifunc
|
||||||
.break_loop:
|
.break_loop:
|
||||||
%endif
|
%endif
|
||||||
|
%endif
|
||||||
|
|
||||||
; if USE_DNLOAD_LOADER
|
; if USE_DNLOAD_LOADER
|
||||||
%else
|
%else
|
||||||
|
|
|
@ -127,11 +127,16 @@ def get_hashtbl(elf, blob, args):
|
||||||
#eprintf("htoff = 0x%08x, len=%08x" % (htoff, len(blob)))
|
#eprintf("htoff = 0x%08x, len=%08x" % (htoff, len(blob)))
|
||||||
if len(blob) <= htoff and len(tbl) > 0:
|
if len(blob) <= htoff and len(tbl) > 0:
|
||||||
break
|
break
|
||||||
|
#if elf.is32bit:
|
||||||
if struct.unpack('<B', blob[htoff:htoff+1])[0] == 0:
|
if struct.unpack('<B', blob[htoff:htoff+1])[0] == 0:
|
||||||
break
|
break
|
||||||
|
#else:
|
||||||
|
# if struct.unpack('<H', blob[htoff:htoff+2])[0] == 0:
|
||||||
|
# break
|
||||||
val = struct.unpack('<I', blob[htoff:htoff+4])[0]
|
val = struct.unpack('<I', blob[htoff:htoff+4])[0]
|
||||||
if (val & 0xFF) == 0: break
|
if (val & 0xFFFF) == 0: break
|
||||||
tbl.append(val)
|
tbl.append(val)
|
||||||
|
#eprintf("sym %08x" % val)
|
||||||
htoff = htoff + (4 if elf.is32bit else 8)
|
htoff = htoff + (4 if elf.is32bit else 8)
|
||||||
|
|
||||||
return tbl
|
return tbl
|
||||||
|
|
Loading…
Reference in New Issue