Commit 26d96fc2 authored by PoroCYon's avatar PoroCYon Committed by PoroCYon
Browse files

get rid of a few more bytes

parent 5e19c274
...@@ -84,6 +84,7 @@ $(OBJDIR)/stub.%.start.o: $(OBJDIR)/symbols.%.start.asm $(SRCDIR)/header32.asm \ ...@@ -84,6 +84,7 @@ $(OBJDIR)/stub.%.start.o: $(OBJDIR)/symbols.%.start.asm $(SRCDIR)/header32.asm \
$(BINDIR)/%: $(OBJDIR)/%.o $(OBJDIR)/stub.%.o $(BINDIR)/ $(BINDIR)/%: $(OBJDIR)/%.o $(OBJDIR)/stub.%.o $(BINDIR)/
$(CC) -Wl,-Map=$(BINDIR)/$*.map $(LDFLAGS_) $(OBJDIR)/$*.o $(OBJDIR)/stub.$*.o -o "$@" $(CC) -Wl,-Map=$(BINDIR)/$*.map $(LDFLAGS_) $(OBJDIR)/$*.o $(OBJDIR)/stub.$*.o -o "$@"
./rmtrailzero.py "$@" "$(OBJDIR)/$(notdir $@)" && mv "$(OBJDIR)/$(notdir $@)" "$@" && chmod +x "$@"
$(BINDIR)/%-crt: $(OBJDIR)/%.start.o $(OBJDIR)/stub.%.start.o $(BINDIR)/ $(BINDIR)/%-crt: $(OBJDIR)/%.start.o $(OBJDIR)/stub.%.start.o $(BINDIR)/
$(CC) -Wl,-Map=$(BINDIR)/$*-crt.map $(LDFLAGS_) $(OBJDIR)/$*.start.o $(OBJDIR)/stub.$*.start.o -o "$@" $(CC) -Wl,-Map=$(BINDIR)/$*-crt.map $(LDFLAGS_) $(OBJDIR)/$*.start.o $(OBJDIR)/stub.$*.start.o -o "$@"
......
#!/usr/bin/env python3
import argparse
import sys
def main(argv):
parser = argparse.ArgumentParser()
parser.add_argument('input', type=argparse.FileType('rb'), \
help="input file to truncate")
parser.add_argument('output', type=argparse.FileType('wb'), \
help="output file")
args = parser.parse_args()
data = args.input.read()
i = 0
while data[-i - 1] == 0:
i = i + 1
args.output.write(data[0:len(data)-i])
if __name__ == '__main__':
rv = main(sys.argv)
exit(0 if rv is None else rv)
...@@ -41,8 +41,6 @@ _smol_start: ...@@ -41,8 +41,6 @@ _smol_start:
mov r12, [r12 + L_NEXT_OFF] ; skip this binary mov r12, [r12 + L_NEXT_OFF] ; skip this binary
; mov r12, [r12 + L_NEXT_OFF] ; skip the vdso ; mov r12, [r12 + L_NEXT_OFF] ; skip the vdso
; the second one isn't needed anymore, see code below (.next_link) ; the second one isn't needed anymore, see code below (.next_link)
;%elifdef USE_DNLOAD_LOADER
; mov r12, [r12 + L_NEXT_OFF] ; skip this binary
%endif %endif
%ifdef USE_DNLOAD_LOADER %ifdef USE_DNLOAD_LOADER
...@@ -53,7 +51,6 @@ _smol_start: ...@@ -53,7 +51,6 @@ _smol_start:
;.loopme: jmp short .loopme ; debugging ;.loopme: jmp short .loopme ; debugging
.next_hash: .next_hash:
;
mov r14d, dword [rdi] mov r14d, dword [rdi]
; assume it's nonzero ; assume it's nonzero
push r11 push r11
...@@ -90,6 +87,7 @@ _smol_start: ...@@ -90,6 +87,7 @@ _smol_start:
jge short .norelsymaddr jge short .norelsymaddr
add rax, rcx add rax, rcx
.norelsymaddr: .norelsymaddr:
; xchg rax, rdx
push rax push rax
pop rdx pop rdx
...@@ -97,36 +95,37 @@ _smol_start: ...@@ -97,36 +95,37 @@ _smol_start:
mov esi, dword [rdx + ST_NAME_OFF] mov esi, dword [rdx + ST_NAME_OFF]
add rsi, r9 add rsi, r9
xor ecx, ecx
push 33 push 33
push 5381 push 5381
push 0 ; push 0
pop rcx ; pop rcx
pop rax pop rax
pop rbx pop rbx
.nexthashiter: .nexthashiter:
; TODO: optimize register usage so that lodsb can be used ; TODO: optimize register usage a bit more
mov cl, byte [rsi] xchg eax, ecx
inc rsi lodsb
or cl, cl or al, al
jz short .breakhash xchg eax, ecx
jz short .breakhash
push rdx
mul ebx push rdx
pop rdx mul ebx
add eax, ecx pop rdx
jmp short .nexthashiter add eax, ecx
jmp short .nexthashiter
.breakhash: .breakhash:
cmp r14d, eax cmp r14d, eax
je short .eq je short .hasheq
add rdx, SYMTAB_SIZE add rdx, SYMTAB_SIZE
cmp rdx, r8 cmp rdx, r8
jl short .next_sym jl short .next_sym
; int3
jmp short .next_link jmp short .next_link
.eq: .hasheq:
mov rax, [rdx + ST_VALUE_OFF] mov rax, [rdx + ST_VALUE_OFF]
add rax, [r12 + L_ADDR_OFF] add rax, [r12 + L_ADDR_OFF]
stosq stosq
...@@ -141,7 +140,7 @@ _smol_start: ...@@ -141,7 +140,7 @@ _smol_start:
pop rcx pop rcx
pop rdi pop rdi
pop rax pop rax
repne scasd ; technically, scasq should be used, but ehhhh repne scasd ; technically, scasq should be used, but meh. this is 1 byte smaller
sub rdi, r12 sub rdi, r12
sub rdi, LF_ENTRY_OFF+4 sub rdi, LF_ENTRY_OFF+4
xchg r9, rdi xchg r9, rdi
......
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