diff options
author | Regia König | 2022-03-10 14:51:02 +0100 |
---|---|---|
committer | Regia König | 2022-03-10 14:51:02 +0100 |
commit | e97baaaa249e922a15b586d10a340c8e1076ad6d (patch) | |
tree | 76098632d8a8bb965963cbe5675fd00318d0b3ff /efi_memtest | |
parent | Add stuff (diff) | |
download | memtest86-e97baaaa249e922a15b586d10a340c8e1076ad6d.tar.gz memtest86-e97baaaa249e922a15b586d10a340c8e1076ad6d.tar.xz memtest86-e97baaaa249e922a15b586d10a340c8e1076ad6d.zip |
Split build process into debug build and release build (gdb vs lto)
Diffstat (limited to 'efi_memtest')
-rw-r--r-- | efi_memtest/Makefile | 33 | ||||
-rw-r--r-- | efi_memtest/MemtestEfi.c | 3 | ||||
-rw-r--r-- | efi_memtest/MemtestEfi.debug | bin | 0 -> 2506896 bytes | |||
-rw-r--r-- | efi_memtest/logger_config.h | 2 | ||||
-rw-r--r-- | efi_memtest/memtest86+/efi/init.c | 18 | ||||
-rw-r--r-- | efi_memtest/memtest86+/efi/lib.c | 2 | ||||
-rw-r--r-- | efi_memtest/memtest86+/reloc.c | 2 |
7 files changed, 40 insertions, 20 deletions
diff --git a/efi_memtest/Makefile b/efi_memtest/Makefile index 4574cfa..24d0875 100644 --- a/efi_memtest/Makefile +++ b/efi_memtest/Makefile @@ -2,15 +2,18 @@ MAIN_FILE = MemtestEfi CC = gcc -# Warnings -CFLAGS = -Werror -Wall -Wno-array-bounds -Wno-address +# Treat all warnings as errors +#CFLAGS = -Werror + +CFLAGS += -Wall -Wno-array-bounds CFLAGS += -fno-builtin + # EFI requires -fshort-wchar CFLAGS += -fshort-wchar + CFLAGS += -fno-common -CFLAGS += -fno-strict-aliasing -# Create debugging symbols -CFLAGS += -g +CFLAGS += -fno-strict-aliasing + # EFI uses Microsoft ABI so no red zone is defined CFLAGS += -mno-red-zone @@ -21,21 +24,25 @@ CFLAGS += -fpie CFLAGS += -fPIC CFLAGS += -ffunction-sections CFLAGS += -fdata-sections -CFLAGS += -flto + CFLAGS += -maccumulate-outgoing-args CFLAGS += -fno-asynchronous-unwind-tables + +# Don't use standard library CFLAGS += -nostdlib + CFLAGS += -mcmodel=small #CFLAGS += -fno-stack-protector e -M64=-m64 -march=x86-64 +M64=-m64 +#-march=x86-64 M32=-m32 M=$(M64) -PREPROCESSOR=-DUEFI -DUSING_LTO -Os \ +PREPROCESSOR=-DUEFI -Os \ -D DISABLE_NEW_DEPRECATED_INTERFACES "-DEFIAPI=__attribute__((ms_abi))" OBJS=Efi_Defs.obj config.o controller.o cpuid.o display.o dmi.o error.o init.o \ @@ -67,11 +74,20 @@ BaseLib_OBJS=ARShiftU64.o BitField.o CheckSum.o CpuDeadLoop.o Cpu.o DivU64x64Rem LIBRARIES=MemtestEfi.lib +debug: CFLAGS += -g +debug: all + +release: #CFLAGS += -flto +release: PREPROCESSOR += -DUSING_LTO +release: all + + all: clean MemtestEfi.efi move run clean $(MAIN_FILE).efi: $(MAIN_FILE).dll ./memtest86+/efi/Include/GenFw -e UEFI_APPLICATION -o $(MAIN_FILE).efi $(MAIN_FILE).dll + #objcopy --add-gnu-debuglink=MemtestEfi.debug MemtestEfi.efi $(MAIN_FILE).dll: $(MAIN_FILE).lib @@ -91,6 +107,7 @@ $(MAIN_FILE).dll: $(MAIN_FILE).lib $(MAIN_FILE).lib: $(OBJS) gcc-ar crv $(MAIN_FILE).lib $^ + #objcopy --only-keep-debug MemtestEfi.lib MemtestEfi.debug #rm $^ $(MAIN_FILE).obj: $(MAIN_FILE).c diff --git a/efi_memtest/MemtestEfi.c b/efi_memtest/MemtestEfi.c index c2ed3de..03143b3 100644 --- a/efi_memtest/MemtestEfi.c +++ b/efi_memtest/MemtestEfi.c @@ -3,6 +3,7 @@ #include "Library/UefiApplicationEntryPoint.h" #include "Guid/FileSystemInfo.h" #include "Protocol/LoadedImage.h" +#include "Library/DebugLib.h" #include "main.h" // TODO move into main dir #include "memtest86+/logger.h" @@ -32,6 +33,7 @@ UefiMain ( IN EFI_SYSTEM_TABLE *SystemTable ) { + DEBUG ((EFI_D_INFO, "My Entry point: 0x%08x\r\n", (CHAR16*)UefiMain)); SystemTable->ConOut->ClearScreen(SystemTable->ConOut); SystemTable->ConOut->SetCursorPosition(SystemTable->ConOut, 0, 0); @@ -45,6 +47,7 @@ UefiMain ( print_log(msg, sizeof(msg) - 1); } + // TODO remove. Just for debugging /* if (logflag) { char log[41] = "Address of UefiMain: "; diff --git a/efi_memtest/MemtestEfi.debug b/efi_memtest/MemtestEfi.debug Binary files differnew file mode 100644 index 0000000..e9a4153 --- /dev/null +++ b/efi_memtest/MemtestEfi.debug diff --git a/efi_memtest/logger_config.h b/efi_memtest/logger_config.h index 30744b6..59da4eb 100644 --- a/efi_memtest/logger_config.h +++ b/efi_memtest/logger_config.h @@ -1,5 +1,5 @@ // General -short logflag = 0; +short logflag = 1; short log_fine = 0; // Timing diff --git a/efi_memtest/memtest86+/efi/init.c b/efi_memtest/memtest86+/efi/init.c index 1d2f9a3..f3a2e66 100644 --- a/efi_memtest/memtest86+/efi/init.c +++ b/efi_memtest/memtest86+/efi/init.c @@ -1268,9 +1268,9 @@ ulong memspeed(ulong src, ulong len, int iter) asm __volatile__ ("rdtsc":"=a" (st_low),"=d" (st_high)); for (i=0; i<iter; i++) { asm __volatile__ ( - "movl %0,%%esi\n\t" \ - "mov %1,%%rdi\n\t" \ - "movl %2,%%ecx\n\t" \ + "movq %0,%%rsi\n\t" \ + "movq %1,%%rdi\n\t" \ + "movq %2,%%rcx\n\t" \ "cld\n\t" \ "rep\n\t" \ "movsl\n\t" \ @@ -1326,9 +1326,9 @@ ulong memspeed(ulong src, ulong len, int iter) /* Now measure the speed */ /* Do the first copy to prime the cache */ asm __volatile__ ( - "movl %0,%%esi\n\t" \ - "mov %1,%%rdi\n\t" \ - "mov %2,%%rcx\n\t" \ + "movq %0,%%rsi\n\t" \ + "movq %1,%%rdi\n\t" \ + "movq %2,%%rcx\n\t" \ "cld\n\t" \ "rep\n\t" \ "movsl\n\t" \ @@ -1338,9 +1338,9 @@ ulong memspeed(ulong src, ulong len, int iter) asm __volatile__ ("rdtsc":"=a" (st_low),"=d" (st_high)); for (i=0; i<iter; i++) { asm __volatile__ ( - "movl %0,%%esi\n\t" \ - "mov %1,%%rdi\n\t" \ - "mov %2,%%rcx\n\t" \ + "movq %0,%%rsi\n\t" \ + "movq %1,%%rdi\n\t" \ + "movq %2,%%rcx\n\t" \ "cld\n\t" \ "rep\n\t" \ "movsl\n\t" \ diff --git a/efi_memtest/memtest86+/efi/lib.c b/efi_memtest/memtest86+/efi/lib.c index 35304e3..aa9ca63 100644 --- a/efi_memtest/memtest86+/efi/lib.c +++ b/efi_memtest/memtest86+/efi/lib.c @@ -517,7 +517,7 @@ void inter(struct eregs *trap_regs) /* Get the page fault address */ if (trap_regs->vect == 14) { - __asm__("movl %%cr2,%0":"=r" (address)); + __asm__("movq %%cr2,%0":"=r" (address)); } #ifdef PARITY_MEM diff --git a/efi_memtest/memtest86+/reloc.c b/efi_memtest/memtest86+/reloc.c index 97f7081..33322e4 100644 --- a/efi_memtest/memtest86+/reloc.c +++ b/efi_memtest/memtest86+/reloc.c @@ -68,7 +68,7 @@ elf_machine_dynamic(void) { static inline Elf32_Addr __attribute__ ((unused)) elf_machine_load_address(void) { Elf32_Addr addr; - asm volatile ("leal _start@GOTOFF(%%ebx), %0\n" + asm volatile ("leaq _start@GOTOFF(%%rbx), %0\n" : "=r" (addr) : : "cc"); return addr; } |