diff options
Diffstat (limited to 'debugging_demo/Makefile')
-rw-r--r-- | debugging_demo/Makefile | 190 |
1 files changed, 190 insertions, 0 deletions
diff --git a/debugging_demo/Makefile b/debugging_demo/Makefile new file mode 100644 index 0000000..c34dbca --- /dev/null +++ b/debugging_demo/Makefile @@ -0,0 +1,190 @@ +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 + +# the UEFI PE executables must be relocatable +CFLAGS += -fPIC +CFLAGS += -ffunction-sections +CFLAGS += -fdata-sections +CFLAGS += -flto + +# function calls must include the number of arguments passed to the functions +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.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.o + + +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 + +SECTIONS=.text .sdata .data .dynamic .dynsym .rel .rela .reloc + +all: clean MemtestEfi.efi move run + +MemtestEfi.efi: OUTPUT/MemtestEfi.so + objcopy $(foreach sec,$(SECTIONS), -j $(sec)) --target=pei-x86-64 --subsystem=10 $< $@ + +OUTPUT/$(MAIN_FILE).so: $(OBJS) + ld -shared -Bsymbolic -Telf_x86_64_efi.lds -o $@ $^ + #rm $^ + +$(MAIN_FILE).o: $(MAIN_FILE).c + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -c -o $@ $< \ + -include memtest86+/efi/Include/Efi_Defs.h \ + -I . \ + -I"memtest86+" \ + -I"memtest86+/efi/Include" + +Efi_Defs.o: memtest86+/efi/Include/Efi_Defs.c + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -c -o $@ $< \ + -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 + + + + + + + + + + + + + + + + |