mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-12 09:20:36 +00:00
LibC: Port setjmp syntax to avoid nasm dependency
This commit is contained in:
parent
7afc0fb9c8
commit
a04a58b7eb
Notes:
sideshowbarker
2024-07-19 13:59:18 +09:00
Author: https://github.com/rburchell Commit: https://github.com/SerenityOS/serenity/commit/a04a58b7ebb Pull-request: https://github.com/SerenityOS/serenity/pull/73 Reviewed-by: https://github.com/awesomekling
5 changed files with 34 additions and 42 deletions
|
@ -48,7 +48,7 @@ LIBC_OBJS = \
|
|||
netdb.o \
|
||||
sched.o
|
||||
|
||||
ASM_OBJS = setjmp.no crti.ao crtn.ao
|
||||
ASM_OBJS = setjmp.ao crti.ao crtn.ao
|
||||
|
||||
CPP_OBJS = $(AK_OBJS) $(WIDGETS_OBJS) $(LIBC_OBJS)
|
||||
|
||||
|
@ -68,9 +68,6 @@ $(LIBRARY): $(CPP_OBJS) $(ASM_OBJS)
|
|||
.cpp.o:
|
||||
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
|
||||
|
||||
%.no: %.asm
|
||||
@echo "NASM $@"; nasm -f elf -o $@ $<
|
||||
|
||||
%.ao: %.S
|
||||
@echo "AS $@"; $(AS) -o $@ $<
|
||||
|
||||
|
|
31
LibC/setjmp.S
Normal file
31
LibC/setjmp.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
.global setjmp
|
||||
setjmp:
|
||||
mov 4(%esp), %eax
|
||||
mov %ebx, 0(%eax)
|
||||
mov %esi, 4(%eax)
|
||||
mov %edi, 8(%eax)
|
||||
mov %ebp, 12(%eax)
|
||||
lea 4(%esp), %ecx
|
||||
mov %ecx, 16(%eax)
|
||||
mov (%esp), %ecx
|
||||
mov %ecx, 20(%eax)
|
||||
xor %eax, %eax
|
||||
ret
|
||||
|
||||
.global longjmp
|
||||
longjmp:
|
||||
mov 4(%esp), %edx
|
||||
mov 8(%esp), %eax
|
||||
mov 0(%edx), %ebx
|
||||
mov 4(%edx), %esi
|
||||
mov 8(%edx), %edi
|
||||
mov 12(%edx), %ebp
|
||||
mov 16(%edx), %ecx
|
||||
mov %ecx, %esp
|
||||
mov 20(%edx), %ecx
|
||||
test %eax, %eax
|
||||
jnz .nonzero
|
||||
mov 1, %eax
|
||||
.nonzero:
|
||||
jmp *%ecx
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
; asmsyntax=nasm
|
||||
|
||||
global setjmp
|
||||
setjmp:
|
||||
mov eax, [esp + 4]
|
||||
mov [eax + 0 * 4], ebx
|
||||
mov [eax + 1 * 4], esi
|
||||
mov [eax + 2 * 4], edi
|
||||
mov [eax + 3 * 4], ebp
|
||||
lea ecx, [esp + 4]
|
||||
mov [eax + 4 * 4], ecx
|
||||
mov ecx, [esp]
|
||||
mov [eax + 5 * 4], ecx
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
global longjmp
|
||||
longjmp:
|
||||
mov edx, [esp + 4]
|
||||
mov eax, [esp + 8]
|
||||
mov ebx, [edx + 0 * 4]
|
||||
mov esi, [edx + 1 * 4]
|
||||
mov edi, [edx + 2 * 4]
|
||||
mov ebp, [edx + 3 * 4]
|
||||
mov ecx, [edx + 4 * 4]
|
||||
mov esp, ecx
|
||||
mov ecx, [edx + 5 * 4]
|
||||
test eax, eax
|
||||
jnz .nonzero
|
||||
mov eax, 1
|
||||
.nonzero:
|
||||
jmp ecx
|
||||
|
|
@ -13,9 +13,6 @@ $(LIBRARY): $(OBJS)
|
|||
.cpp.o:
|
||||
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
|
||||
|
||||
%.no: %.asm
|
||||
@echo "NASM $@"; nasm -f elf -o $@ $<
|
||||
|
||||
-include $(OBJS:%.o=%.d)
|
||||
|
||||
clean:
|
||||
|
|
|
@ -12,9 +12,9 @@ First off, GCC needs MPFR, MPC and GMP. On Ubuntu, this is as simple as:
|
|||
|
||||
sudo apt install libmpfr-dev libmpc-dev libgmp-dev
|
||||
|
||||
For Serenity, we will need nasm, e2fsprogs and QEMU:
|
||||
For Serenity, we will need e2fsprogs and QEMU:
|
||||
|
||||
sudo apt install nasm e2fsprogs qemu-system-i386
|
||||
sudo apt install e2fsprogs qemu-system-i386
|
||||
|
||||
## Binutils:
|
||||
|
||||
|
|
Loading…
Reference in a new issue