From a04a58b7ebbcb13d49639b2fd9e8ebed6da1f2f7 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Thu, 23 May 2019 10:14:19 +0200 Subject: [PATCH] LibC: Port setjmp syntax to avoid nasm dependency --- LibC/Makefile | 5 +---- LibC/setjmp.S | 31 +++++++++++++++++++++++++++++++ LibC/setjmp.asm | 33 --------------------------------- LibM/Makefile | 3 --- Meta/BuildInstructions.md | 4 ++-- 5 files changed, 34 insertions(+), 42 deletions(-) create mode 100644 LibC/setjmp.S delete mode 100644 LibC/setjmp.asm diff --git a/LibC/Makefile b/LibC/Makefile index ab307c5cbd..acdc8975d3 100644 --- a/LibC/Makefile +++ b/LibC/Makefile @@ -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 $@ $< diff --git a/LibC/setjmp.S b/LibC/setjmp.S new file mode 100644 index 0000000000..b063023f56 --- /dev/null +++ b/LibC/setjmp.S @@ -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 + diff --git a/LibC/setjmp.asm b/LibC/setjmp.asm deleted file mode 100644 index 68d08ef7d9..0000000000 --- a/LibC/setjmp.asm +++ /dev/null @@ -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 - diff --git a/LibM/Makefile b/LibM/Makefile index f6701e34d5..1c19cabadf 100644 --- a/LibM/Makefile +++ b/LibM/Makefile @@ -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: diff --git a/Meta/BuildInstructions.md b/Meta/BuildInstructions.md index 09de420aa2..8ee623a3d3 100644 --- a/Meta/BuildInstructions.md +++ b/Meta/BuildInstructions.md @@ -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: