diff options
author | Regina König | 2021-07-01 09:17:33 +0200 |
---|---|---|
committer | Regina König | 2021-07-01 09:17:33 +0200 |
commit | 8eb889cfd04d91e80c47b6665574f2147445ff72 (patch) | |
tree | 9a575d5bb81edd0eb52eea06dc098476f9c77cf1 | |
parent | Try to create a debugging version (diff) | |
download | memtest86-8eb889cfd04d91e80c47b6665574f2147445ff72.tar.gz memtest86-8eb889cfd04d91e80c47b6665574f2147445ff72.tar.xz memtest86-8eb889cfd04d91e80c47b6665574f2147445ff72.zip |
Move debug code into an other subproject
-rw-r--r-- | efi_memtest/Makefile | 53 | ||||
-rw-r--r-- | efi_memtest/elf_x86_64_efi.lds | 76 |
2 files changed, 37 insertions, 92 deletions
diff --git a/efi_memtest/Makefile b/efi_memtest/Makefile index d006b69..57f4f7c 100644 --- a/efi_memtest/Makefile +++ b/efi_memtest/Makefile @@ -16,18 +16,15 @@ CFLAGS += -mno-red-zone 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 +CFLAGS += -fno-stack-protector M64=-m64 @@ -38,13 +35,13 @@ M=$(M64) PREPROCESSOR=-DUEFI -DUSING_LTO -Os \ -D DISABLE_NEW_DEPRECATED_INTERFACES "-DEFIAPI=__attribute__((ms_abi))" -OBJS=Efi_Defs.o config.o controller.o cpuid.o display.o dmi.o error.o init.o \ +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.o + UefiRuntimeServicesTableLib.o UefiBootServicesTableLib.o MemtestEfi.obj BaseMemoryLib_OBJS=CompareMemWrapper.o CopyMem.o CopyMemWrapper.o IsZeroBufferWrapper.o \ @@ -63,26 +60,50 @@ BaseLib_OBJS=ARShiftU64.o BitField.o CheckSum.o CpuDeadLoop.o Cpu.o DivU64x64Rem 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 + + +LIBRARIES=OUTPUT/MemtestEfi.lib 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 $@ $^ +$(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).o: $(MAIN_FILE).c - $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -c -o $@ $< \ +$(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" + -I"memtest86+/efi/Include" \ + $(MAIN_FILE).c -Efi_Defs.o: memtest86+/efi/Include/Efi_Defs.c - $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -c -o $@ $< \ +Efi_Defs.obj: memtest86+/efi/Include/Efi_Defs.c + $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -o $@ $< \ + -c \ -I"memtest86+/efi/Include" %.o: memtest86+/%.c diff --git a/efi_memtest/elf_x86_64_efi.lds b/efi_memtest/elf_x86_64_efi.lds deleted file mode 100644 index b91cd54..0000000 --- a/efi_memtest/elf_x86_64_efi.lds +++ /dev/null @@ -1,76 +0,0 @@ -/* Same as elf_x86_64_fbsd_efi.lds, except for OUTPUT_FORMAT below - KEEP IN SYNC */ -OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") -OUTPUT_ARCH(i386:x86-64) -ENTRY(_ModuleEntryPoint) -SECTIONS -{ - . = 0; - ImageBase = .; - /* .hash and/or .gnu.hash MUST come first! */ - .hash : { *(.hash) } - .gnu.hash : { *(.gnu.hash) } - . = ALIGN(4096); - .eh_frame : - { - *(.eh_frame) - } - . = ALIGN(4096); - .text : - { - _text = .; - *(.text) - *(.text.*) - *(.gnu.linkonce.t.*) - . = ALIGN(16); - } - _etext = .; - _text_size = . - _text; - . = ALIGN(4096); - .reloc : - { - *(.reloc) - } - . = ALIGN(4096); - .data : - { - _data = .; - *(.rodata*) - *(.got.plt) - *(.got) - *(.data*) - *(.sdata) - /* the EFI loader doesn't seem to like a .bss section, so we stick - it all into .data: */ - *(.sbss) - *(.scommon) - *(.dynbss) - *(.bss) - *(COMMON) - *(.rel.local) - } - .note.gnu.build-id : { *(.note.gnu.build-id) } - - _edata = .; - _data_size = . - _etext; - . = ALIGN(4096); - .dynamic : { *(.dynamic) } - . = ALIGN(4096); - .rela : - { - *(.rela.data*) - *(.rela.got) - *(.rela.stab) - } - . = ALIGN(4096); - .dynsym : { *(.dynsym) } - . = ALIGN(4096); - .dynstr : { *(.dynstr) } - . = ALIGN(4096); - .ignored.reloc : - { - *(.rela.reloc) - *(.eh_frame) - *(.note.GNU-stack) - } - .comment 0 : { *(.comment) } -} |