diff options
author | Regina König | 2021-06-29 12:21:37 +0200 |
---|---|---|
committer | Regina König | 2021-06-29 12:21:37 +0200 |
commit | 2d5eae76f91c09a5fcf3f09b5d14e386f6e2372a (patch) | |
tree | 8fedacc8a743430a30e4020860c5d84efada1b96 | |
parent | Add new options in shell script to use gdb (diff) | |
download | memtest86-2d5eae76f91c09a5fcf3f09b5d14e386f6e2372a.tar.gz memtest86-2d5eae76f91c09a5fcf3f09b5d14e386f6e2372a.tar.xz memtest86-2d5eae76f91c09a5fcf3f09b5d14e386f6e2372a.zip |
Create second version of Makefile to produce an extra version for debugging
-rw-r--r-- | efi_memtest/_Makefile | 214 |
1 files changed, 214 insertions, 0 deletions
diff --git a/efi_memtest/_Makefile b/efi_memtest/_Makefile new file mode 100644 index 0000000..ab3a34b --- /dev/null +++ b/efi_memtest/_Makefile @@ -0,0 +1,214 @@ +MAIN_FILE = MemtestEfi + +CC = gcc + +# Warnings +CFLAGS = -Werror -Wall -Wno-array-bounds -Wno-address +CFLAGS += -fno-builtin +# EFI requires -fshort-wchar +CFLAGS += -fshort-wchar +CFLAGS += -fno-common +CFLAGS += -fno-strict-aliasing -g +# EFI uses Microsoft ABI so no red zone is defined +CFLAGS += -mno-red-zone + +# use %rip-relative addressing wherever possible?? Or not? +CFLAGS += -fpie +#CFLAGS += -fno-pie -no-pie -static + +CFLAGS += -fPIC +CFLAGS += -ffunction-sections +CFLAGS += -fdata-sections +CFLAGS += -flto +CFLAGS += -maccumulate-outgoing-args +CFLAGS += -fno-asynchronous-unwind-tables +CFLAGS += -nostdlib +CFLAGS += -mcmodel=small +#CFLAGS += -fno-stack-protector e + +M64=-m64 + +M32=-m32 + +M=$(M64) + +PREPROCESSOR=-DUEFI -DUSING_LTO -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 \ + lib.o logger.o main.o memory_tables.o memsize.o page_allocator.o patn.o pci.o reloc.o \ + screen_buffer.o random.o smp.o spd.o test.o vmem.o \ + BaseLib.o BaseMemoryLib.o BasePrintLib.o \ + UefiDebugLibStdErr.o UefiDevicePathLib2.o UefiLib2.o ApplicationEntryPoint.o \ + BaseDebugPrintErrorLevelLib.o UefiMemoryAllocationLib.o BasePcdLibNull.o \ + UefiRuntimeServicesTableLib.o UefiBootServicesTableLib.o MemtestEfi.obj + + +BaseMemoryLib_OBJS=CompareMemWrapper.o CopyMem.o CopyMemWrapper.o IsZeroBufferWrapper.o \ + MemLibGeneric.o MemLibGuid.o ScanMem16Wrapper.o ScanMem32Wrapper.o ScanMem64Wrapper.o \ + ScanMem8Wrapper.o SetMem.o SetMem16Wrapper.o SetMem32Wrapper.o SetMem64Wrapper.o \ + SetMemWrapper.o ZeroMemWrapper.o + +UefiDevicePathLib_OBJS=DevicePathFromText.o DevicePathToText.o DevicePathUtilities.o \ + DevicePathUtilitiesDxeSmm.o DevicePathUtilitiesStandaloneMm.o UefiDevicePathLib.o \ + UefiDevicePathLibOptionalDevicePathProtocol.o + +BaseLib_OBJS=ARShiftU64.o BitField.o CheckSum.o CpuDeadLoop.o Cpu.o DivU64x64Remainder.o \ + DivU64x32Remainder.o DivU64x32.o DivS64x64Remainder.o FilePaths.o GetPowerOfTwo64.o \ + GetPowerOfTwo32.o HighBitSet64.o HighBitSet32.o LongJump.o LRotU64.o LowBitSet64.o \ + LowBitSet32.o LRotU32.o LShiftU64.o Math64.o ModU64x32.o MultU64x64.o MultU64x32.o MultS64x64.o \ + RRotU32.o RRotU64.o RShiftU64.o SafeString.o String.o SetJump.o SwapBytes64.o SwapBytes32.o \ + SwapBytes16.o SwitchStack.o Unaligned.o + + + +LIBRARIES=OUTPUT/MemtestEfi.lib + +all: clean MemtestEfi.efi move run + + +$(MAIN_FILE).efi: $(MAIN_FILE).dll + ./memtest86+/efi/Include/GenFw -e UEFI_APPLICATION -o $(MAIN_FILE).efi $(MAIN_FILE).dll + + +$(MAIN_FILE).dll: $(MAIN_FILE).lib + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) $(LIBRARIES) -o $(MAIN_FILE).dll \ + -nostdlib \ + -Wl,-n,-q,--gc-sections \ + -Wl,--entry,_ModuleEntryPoint \ + -Wl,-Map,$(MAIN_FILE).map,--whole-archive \ + -Wl,-melf_x86_64,--oformat=elf64-x86-64,-pie \ + -Wl,--defsym=PECOFF_HEADER_SIZE=0x228 \ + -Wl,--script=memtest86+/efi/Include/GccBase.lds \ + -z common-page-size=0x40 \ + -u _ModuleEntryPoint \ + -DSTRING_ARRAY_NAME=${MAIN_FILE}Strings + objcopy --strip-unneeded -R .eh_frame -v $(MAIN_FILE).dll $(MAIN_FILE).dll + strip -R .strtab MemtestEfi.dll + +$(MAIN_FILE).lib: $(OBJS) + gcc-ar crv OUTPUT/$(MAIN_FILE).lib $^ + #rm $^ + +$(MAIN_FILE).obj: $(MAIN_FILE).c + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -o $(MAIN_FILE).obj \ + -MMD -MF OUTPUT/$(MAIN_FILE).obj.deps \ + -c \ + -include memtest86+/efi/Include/Efi_Defs.h \ + -DSTRING_ARRAY_NAME=${MAIN_FILE}Strings \ + -I . \ + -I"memtest86+" \ + -I"memtest86+/efi/Include" \ + $(MAIN_FILE).c + +Efi_Defs.obj: memtest86+/efi/Include/Efi_Defs.c + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -o $@ $< \ + -c \ + -I"memtest86+/efi/Include" + +%.o: memtest86+/%.c + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -c -o $@ $< \ + -I"memtest86+/efi" + +%.o: memtest86+/efi/Include/src/%.c + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -c -o $@ $< \ + -I"memtest86+/efi/Include" \ + -I"memtest86+/efi/Include/Library" + +%.o: memtest86+/efi/Include/src/UefiLib/%.c + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -c -o $@ $< \ + -I"memtest86+/efi/Include" \ + -I"memtest86+/efi/Include/Protocol" \ + -I"memtest86+/efi/Include/Guid" + +BasePcdLibNull.o: memtest86+/efi/Include/src/PcdLib.c + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -c -o $@ $< \ + -I"memtest86+/efi/Include" + +UefiMemoryAllocationLib.o: memtest86+/efi/Include/src/MemoryAllocationLib.c + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -c -o $@ $< \ + -I"memtest86+/efi/Include" + +UefiLib2.o: Acpi.o Console.o UefiDriverModel.o UefiLib.o UefiLibPrint.o UefiNotTiano.o + ld -r -o $@ $^ + rm $^ + +%.o: memtest86+/efi/Include/src/UefiDebugLibStdErr/%.c + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -c -o $@ $< \ + -I"memtest86+/efi/Include" + +UefiDebugLibStdErr.o: DebugLib.o DebugLibConstructor.o + ld -r -o $@ $^ + rm $^ + +%.o: memtest86+/efi/Include/src/BaseMemoryLib/%.c + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -c -o $@ $< \ + -I"memtest86+/efi/Include" + +BaseMemoryLib.o: $(BaseMemoryLib_OBJS) + ld -r -o $@ $^ + rm $^ + +%.o: memtest86+/efi/Include/src/BasePrintLib/%.c + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -c -o $@ $< \ + -I"memtest86+/efi/Include" + +BasePrintLib.o: PrintLib.o PrintLibInternal.o + ld -r -o $@ $^ + rm $^ + +%.o: memtest86+/efi/Include/src/UefiDevicePathLib/%.c + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -c -o $@ $< \ + -I"memtest86+/efi/Include" + +UefiDevicePathLib2.o: $(UefiDevicePathLib_OBJS) + ld -r -o $@ $^ + rm $^ + +%.o: memtest86+/efi/Include/src/BaseLib/%.c + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -c -o $@ $< \ + -I"memtest86+/efi/Include" + +BaseLib.o: $(BaseLib_OBJS) + ld -r -o $@ $^ + rm $^ + +%.o: memtest86+/efi/%.c + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -c -o $@ $< \ + -I"memtest86+" \ + -I"memtest86+/efi" \ + -I"memtest86+/efi/Include" + +clean: + rm -f OUTPUT/* + rm -f memtest86+/*.o + rm -f *.o + rm -f MemtestEfi.obj + rm -f MemtestEfi.map + rm -f MemtestEfi.dll + rm -f MemtestEfi.efi + rm -f MemtestEfi.txt + rm -f Efi_Defs.obj + + +move: + cp MemtestEfi.efi ../test_code/hda-contents + +run: + sudo ./run.sh + + + + + + + + + + + + + + + + |