diff --git a/Clock/Makefile b/Clock/Makefile index 1123db515b..60431e8279 100644 --- a/Clock/Makefile +++ b/Clock/Makefile @@ -8,7 +8,7 @@ ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc USERLAND_FLAGS = -ffreestanding -fno-stack-protector -fno-ident WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -FLAVOR_FLAGS = -march=i386 -mregparm=3 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic +FLAVOR_FLAGS = -march=i386 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic OPTIMIZATION_FLAGS = -Oz -fno-asynchronous-unwind-tables INCLUDE_FLAGS = -I.. -I. -I../LibC diff --git a/FontEditor/Makefile b/FontEditor/Makefile index 27d976d494..e80b0620ea 100644 --- a/FontEditor/Makefile +++ b/FontEditor/Makefile @@ -8,7 +8,7 @@ ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc USERLAND_FLAGS = -ffreestanding -fno-stack-protector -fno-ident WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -FLAVOR_FLAGS = -march=i386 -mregparm=3 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic +FLAVOR_FLAGS = -march=i386 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic OPTIMIZATION_FLAGS = -Oz -fno-asynchronous-unwind-tables INCLUDE_FLAGS = -I.. -I. -I../LibC diff --git a/Launcher/Launcher b/Launcher/Launcher index d0a35e2e36..80b31262b4 100755 Binary files a/Launcher/Launcher and b/Launcher/Launcher differ diff --git a/Launcher/Makefile b/Launcher/Makefile index 29b4322700..60c143b40b 100644 --- a/Launcher/Makefile +++ b/Launcher/Makefile @@ -7,7 +7,7 @@ ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc USERLAND_FLAGS = -ffreestanding -fno-stack-protector -fno-ident WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -FLAVOR_FLAGS = -march=i386 -mregparm=3 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic +FLAVOR_FLAGS = -march=i386 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic OPTIMIZATION_FLAGS = -Oz -fno-asynchronous-unwind-tables INCLUDE_FLAGS = -I.. -I. -I../LibC diff --git a/LibC/.gitignore b/LibC/.gitignore index 196c9f02af..5191909171 100644 --- a/LibC/.gitignore +++ b/LibC/.gitignore @@ -1,3 +1,4 @@ *.o +*.no *.d LibC.a diff --git a/LibC/Makefile b/LibC/Makefile index e44257aacb..3254a55339 100644 --- a/LibC/Makefile +++ b/LibC/Makefile @@ -31,7 +31,6 @@ LIBC_OBJS = \ grp.o \ times.o \ termcap.o \ - setjmp.o \ stat.o \ mntent.o \ ctype.o \ @@ -47,14 +46,16 @@ LIBC_OBJS = \ poll.o \ entry.o -OBJS = $(AK_OBJS) $(WIDGETS_OBJS) $(LIBC_OBJS) $(SHAREDGRAPHICS_OBJS) +ASM_OBJS = setjmp.no + +CPP_OBJS = $(AK_OBJS) $(WIDGETS_OBJS) $(LIBC_OBJS) $(SHAREDGRAPHICS_OBJS) LIBRARY = LibC.a ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc LIBC_FLAGS = -ffreestanding -fno-stack-protector -fno-ident WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -FLAVOR_FLAGS = -fomit-frame-pointer -mregparm=3 -march=i386 -m32 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic +FLAVOR_FLAGS = -fomit-frame-pointer -march=i386 -m32 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic OPTIMIZATION_FLAGS = -O2 -fno-asynchronous-unwind-tables INCLUDE_FLAGS = -I.. -I. @@ -68,14 +69,17 @@ LDFLAGS = -T linker.ld --strip-debug -melf_i386 --gc-sections all: $(LIBRARY) -$(LIBRARY): $(OBJS) - @echo "LIB $@"; $(AR) rcs $@ $(OBJS) +$(LIBRARY): $(CPP_OBJS) $(ASM_OBJS) + @echo "LIB $@"; $(AR) rcs $@ $(CPP_OBJS) $(ASM_OBJS) .cpp.o: @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< +%.no: %.asm + @echo "NASM $@"; nasm -f elf -o $@ $< + -include $(OBJS:%.o=%.d) clean: - @echo "CLEAN"; rm -f $(LIBRARY) $(OBJS) *.d + @echo "CLEAN"; rm -f $(LIBRARY) $(CPP_OBJS) $(ASM_OBJS) *.d diff --git a/LibC/setjmp.asm b/LibC/setjmp.asm new file mode 100644 index 0000000000..7f1f13feec --- /dev/null +++ b/LibC/setjmp.asm @@ -0,0 +1,33 @@ +; asmsyntax=nasm + +global setjmp +setjmp: + mov eax, [esp + 4] + mov [eax * 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 * 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/LibC/setjmp.cpp b/LibC/setjmp.cpp deleted file mode 100644 index 57b864f79c..0000000000 --- a/LibC/setjmp.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include - -asm( -".globl setjmp\n\ -setjmp:\n\ - movl %ebx, 0(%eax)\n\ - movl %esi, 4(%eax)\n\ - movl %edi, 8(%eax)\n\ - movl %ebp, 12(%eax)\n\ - movl %esp, 16(%eax)\n\ - movl (%esp), %ecx\n\ - movl %ecx, 20(%eax)\n\ - xorl %eax, %eax\n\ - ret\n\ -"); - -asm( -".globl longjmp\n\ -longjmp:\n\ - xchgl %edx, %eax\n\ - test %eax, %eax\n\ - jnz 1f\n\ - incl %eax\n\ -1:\n\ - mov 0(%edx), %ebx\n\ - mov 4(%edx), %esi\n\ - mov 8(%edx), %edi\n\ - mov 12(%edx), %ebp\n\ - mov 16(%edx), %ecx\n\ - mov %ecx, %esp\n\ - mov 20(%edx), %ecx\n\ - jmp *%ecx\n\ -"); diff --git a/LibGUI/Makefile b/LibGUI/Makefile index f90e7398f8..6d1dc21472 100644 --- a/LibGUI/Makefile +++ b/LibGUI/Makefile @@ -26,7 +26,7 @@ ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc LIBC_FLAGS = -ffreestanding -fno-stack-protector -fno-ident WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -FLAVOR_FLAGS = -fomit-frame-pointer -mregparm=3 -march=i386 -m32 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic +FLAVOR_FLAGS = -fomit-frame-pointer -march=i386 -m32 -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic OPTIMIZATION_FLAGS = -Oz -fno-asynchronous-unwind-tables INCLUDE_FLAGS = -I../LibC -I.. -I. diff --git a/Terminal/Makefile b/Terminal/Makefile index c8c0faf712..9b448b9055 100644 --- a/Terminal/Makefile +++ b/Terminal/Makefile @@ -8,7 +8,7 @@ ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc USERLAND_FLAGS = -ffreestanding -fno-stack-protector -fno-ident WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -FLAVOR_FLAGS = -march=i386 -mregparm=3 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic +FLAVOR_FLAGS = -march=i386 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic OPTIMIZATION_FLAGS = -Oz -fno-asynchronous-unwind-tables INCLUDE_FLAGS = -I.. -I. -I../LibC diff --git a/Userland/Makefile b/Userland/Makefile index 4893210c38..a21cbe9610 100644 --- a/Userland/Makefile +++ b/Userland/Makefile @@ -65,7 +65,7 @@ ARCH_FLAGS = STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib -nostdinc USERLAND_FLAGS = -ffreestanding -fno-stack-protector -fno-ident WARNING_FLAGS = -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -FLAVOR_FLAGS = -march=i386 -mregparm=3 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic +FLAVOR_FLAGS = -march=i386 -m32 -fno-exceptions -fno-rtti -fmerge-all-constants -fno-unroll-loops -fno-pie -fno-pic OPTIMIZATION_FLAGS = -Oz -fno-asynchronous-unwind-tables INCLUDE_FLAGS = -I.. -I. -I../LibC