Archived
1
0

.o's to .so

This commit is contained in:
Sweet Bread 2022-12-06 00:29:05 +03:00
parent 1eeb7d4eac
commit b6dfb0ac29
18 changed files with 155 additions and 72 deletions

BIN
dnstoys.o

Binary file not shown.

Binary file not shown.

View File

@ -1,16 +1,13 @@
all: main
main: ../../std.o ../../string.o main.o
ld -m elf_i386 main.o ../../std.o ../../string.o --output main
main: /lib/sbalib.so main.o
ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 main.o /lib/sbalib.so -o main
main.o:
fasm main.asm
fasm main.asm > /dev/null
../../std.o:
make -C ../../ std.o
../../string.o:
make -C ../../ string.o
/lib/sbalib.so:
make -C ../../
clear:
rm main.o main

Binary file not shown.

View File

@ -1,22 +1,13 @@
all: main
main: ../../file.o ../../std.o ../../path.o ../../string.o main.o
ld -m elf_i386 main.o ../../file.o ../../std.o ../../path.o ../../string.o --output main
main: /lib/sbalib.so main.o
ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 main.o /lib/sbalib.so -o main
main.o:
fasm main.asm
fasm main.asm > /dev/null
../../std.o:
make -C ../.. std.o
../../file.o:
make -C ../.. file.o
../../path.o:
make -C ../.. path.o
../../string.o:
make -C ../.. string.o
/lib/sbalib.so:
make -C ../../
clear:
rm main.o main

Binary file not shown.

View File

@ -1,25 +1,13 @@
all: main
main: ../../std.o ../../string.o ../../network.o ../../dns.o ../../dnstoys.o main.o
ld -m elf_i386 main.o ../../std.o ../../string.o ../../network.o ../../dns.o ../../dnstoys.o --output main
main: /lib/sbalib.so main.o
ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 main.o /lib/sbalib.so -o main
main.o:
fasm main.asm
fasm main.asm > /dev/null
../../std.o:
make -C ../.. std.o
../../string.o:
make -C ../.. string.o
../../network.o:
make -C ../.. network.o
../../dns.o:
make -C ../.. dns.o
../../dnstoys.o:
make -C ../.. dnstoys.o
/lib/sbalib.so:
make -C ../../
clear:
rm main.o main

BIN
heap.o Normal file

Binary file not shown.

View File

@ -1,25 +1,9 @@
all: std.o string.o file.o path.o network.o dns.o dnstoys.o
all: $(patsubst src/%.asm,%.o, $(wildcard src/*))
ld -m elf_i386 -shared *.o -o sbalib.so
cp sbalib.so /lib/
std.o:
fasm src/std.asm std.o
string.o:
fasm src/string.asm string.o
file.o:
fasm src/file.asm file.o
path.o:
fasm src/path.asm path.o
network.o:
fasm src/network.asm network.o
dns.o:
fasm src/dns.asm dns.o
dnstoys.o:
fasm src/dnstoys.asm dnstoys.o
%.o:
fasm $(patsubst %.o,src/%.asm,$@) $@ > /dev/null
clear:
rm *.o
rm *.o sbalib.so

BIN
network.o

Binary file not shown.

BIN
sbalib.so Normal file

Binary file not shown.

View File

@ -27,7 +27,6 @@ myip:
push dnstoys
call network.get_ip
pop eax
mov eax, [eax]
mov [DNS_server+4], eax
push dword 200

98
src/heap.asm Normal file
View File

@ -0,0 +1,98 @@
format ELF
public _add as 'heap.add'
public del as 'heap.del'
include '../include/macros.inc'
extrn exit
section '.bss' writeable
_heap:
db 0xB ; flag
dd 4 ; size
dd 4096 ; available memory
rd 4096
section '.text' executable
_add:
prelude
mov ecx, [ebp+2*4] ; size
mov eax, _heap
xor edx, edx
.loop:
cmp [eax], byte 0
je .empty
mov bl, [eax]
bt bx, 0
jc .busy
inc eax
cmp edx, 0
jne @f
mov edx, eax
@@:
cmp ecx, [eax]
jl .more
je .equal
; less
sub ecx, [eax]
add eax, [eax]
add eax, 4
jmp .loop
.equal:
mov [edx], byte 9
mov ebx, [ebp+2*4]
mov [edx+1], ebx
add edx, 5
mov [ebp+2*4], edx
postlude
ret
.more:
mov ebx, edx
add ebx, [ebp+2*4]
mov [ebx], byte 9
inc ebx
mov eax, [eax]
sub eax, ecx
mov [ebx], eax
add ebx, [ebp+2*4]
mov [edx-1], byte 9
mov edx, ebx
add edx, 5
mov [ebp+2*4], edx
postlude
ret
.empty:
cmp edx, 0
jne @f
mov edx, eax
@@:
je @f
dec edx
@@:
jmp .equal
.busy:
xor edx, edx
inc eax
add eax, [eax]
add eax, 4
jmp .loop
del:
push eax
mov eax, [esp+4*2]
sub eax, 5
and byte [eax], 254
mov eax, [esp+4]
mov [esp+4*2], eax
pop eax
add esp, 4
ret

View File

@ -26,15 +26,7 @@ get_ip:
push dword 0
call dns.get_field
pop eax
push eax
call string.len
pop ebx
add eax, ebx
cmp ebx, 2
je @f
inc eax
@@:
add eax, 2*3+4
mov eax, [eax]
mov [ebp+2*4], eax
postlude

View File

@ -69,6 +69,7 @@ _bin:
push 2
mov ebx, 2
xor edx, edx
@@:
cmp eax, 2

View File

@ -2,8 +2,10 @@ format ELF
public copy as 'string.copy'
public len as 'string.len'
public parse_int as 'string.parse_int'
public concat as 'string.concat'
include "../include/macros.inc"
extrn heap.add
section '.string.text' executable
copy:
@ -82,3 +84,34 @@ parse_int:
mov [ebp+4*2], eax
postlude
ret
concat:
prelude
push dword [ebp+3*4]
call len
push dword [ebp+2*4]
call len
mov eax, [esp+4]
add [esp], eax
dec dword [esp]
call heap.add
pop eax
mov edx, eax
push dword [ebp+3*4]
push eax
call copy
add eax, [esp]
mov ebx, [ebp+2*4]
mov [esp], ebx
push eax
call copy
mov eax, [ebp+4]
mov [ebp+2*4], eax
mov [ebp+3*4], edx
postlude
add esp, 4
ret

BIN
std.o

Binary file not shown.

BIN
string.o

Binary file not shown.