Commit 0993ec8d authored by PoroCYon's avatar PoroCYon Committed by PoroCYon
Browse files

use repne scas[dq] for searching for l_entry

parent a6c4c6f2
......@@ -37,9 +37,9 @@ ASFLAGS += -DUSE_INTERP -DALIGN_STACK
NASM ?= nasm
PYTHON3 ?= python3
all: $(BINDIR)/hello-crt $(BINDIR)/sdl-crt
all: $(BINDIR)/hello-crt $(BINDIR)/sdl-crt $(BINDIR)/flag-crt
LIBS += $(shell pkg-config --libs sdl2) -lX11 #-lGL
LIBS += $(filter-out -pthread,$(shell pkg-config --libs sdl2)) -lX11 #-lGL
clean:
@$(RM) -vrf $(OBJDIR) $(BINDIR)
......
......@@ -29,16 +29,23 @@ _smol_start:
%endif
mov ebx, eax
mov esi, eax
.looper:
lodsd
cmp dword eax, _smol_start
jne short .looper
sub esi, ebx
sub esi, LM_ENTRY_OFFSET_BASE+4 ; +4: take inc-after from lodsd into acct
; mov esi, eax
;.looper:
; lodsd
; cmp dword eax, _smol_start
; jne short .looper
; sub esi, ebx
; sub esi, LM_ENTRY_OFFSET_BASE+4 ; +4: take inc-after from lodsd into acct
mov edi, eax
push -1
pop ecx
mov eax, _smol_start
repne scasd
sub edi, ebx
sub edi, LM_ENTRY_OFFSET_BASE+4
xchg ebp, ebx
xchg ebx, esi
xchg ebx, edi;esi
mov esi, _symbols
link: ; (struct link_map *root, char *symtable)
......
......@@ -31,30 +31,39 @@ _smol_start:
mov r12, [rsp - 8] ; return address of _dl_init
mov r11d, dword [r12 - 20] ; decode part of 'mov rdi, [rel _rtld_global]'
mov r12, [r12 + r11 - 16] ; ???
; struct link_map* root = r12
;mov r12, rdi
%endif
; struct link_map* root = r12
%ifdef SKIP_ENTRIES
mov r12, [r12 + L_NEXT_OFF] ; skip this binary
mov r12, [r12 + L_NEXT_OFF] ; skip the vdso
%endif
mov rsi, r12
; mov rsi, r12
; size_t* field = (size_t*)root;
; for (; *field != _smol_start; ++field) ;
.next_off:
lodsq
cmp rax, _smol_start
jne short .next_off
; .next_off:
; lodsq
; cmp rax, _smol_start
; jne short .next_off
; // rbx = offsetof(struct link_map* rsi, l_entry) - DEFAULT_OFFSET
; rbx = field - root - offsetof(struct link_map, l_entry)
sub rsi, r12
sub rsi, LF_ENTRY_OFF+8
xchg rbx, rsi
mov esi, _symbols
; sub rsi, r12
; sub rsi, LF_ENTRY_OFF+8
; xchg rbx, rsi
mov rdi, r12
push -1
pop rcx
;mov rax, _smol_start
lea rax, [rel _smol_start]
repne scasq
sub rdi, r12
sub rdi, LF_ENTRY_OFF+8
xchg rbx, rdi
;mov esi, _symbols
lea esi, [rel _symbols]
; for (rsi = (uint8_t*)_symbols; *rsi; ++rsi) {
.next_needed:
......
/* "Tiny X11 Trans Flag" by Suricrasia Online, edited a bit to make testing
* easier */
#include<X11/X.h>
#include<X11/Xlib.h>
#include<X11/Xutil.h>
......@@ -12,8 +14,9 @@
static Atom wmDeleteMessage;
#endif
__attribute__((__used__))
void _start() {
/*__attribute__((__used__))
void _start() {*/
int main() {
//initialize the window
Display* dpy = XOpenDisplay(NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment