summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRegina König2021-06-29 16:28:39 +0200
committerRegina König2021-06-29 16:28:39 +0200
commit531a37d5dcd63c7ec15f99ef5da773a11f1427fd (patch)
tree98f3744e3269837974071a6d8ce54e27e2b9881c
parentGet a more consistent version of new Makefile (diff)
downloadmemtest86-531a37d5dcd63c7ec15f99ef5da773a11f1427fd.tar.gz
memtest86-531a37d5dcd63c7ec15f99ef5da773a11f1427fd.tar.xz
memtest86-531a37d5dcd63c7ec15f99ef5da773a11f1427fd.zip
Try to get a debug version
-rw-r--r--efi_memtest/Makefile29
-rw-r--r--efi_memtest/Makefile_orig2
-rw-r--r--efi_memtest/elf_x86_64_efi.lds76
3 files changed, 82 insertions, 25 deletions
diff --git a/efi_memtest/Makefile b/efi_memtest/Makefile
index 65ac462..d006b69 100644
--- a/efi_memtest/Makefile
+++ b/efi_memtest/Makefile
@@ -63,39 +63,20 @@ 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
all: clean MemtestEfi.efi move run
+MemtestEfi.efi: OUTPUT/MemtestEfi.so
+ objcopy $(foreach sec,$(SECTIONS), -j $(sec)) --target=pei-x86-64 --subsystem=10 $< $@
-$(MAIN_FILE).efi: $(MAIN_FILE).dll
- ./memtest86+/efi/Include/GenFw -e UEFI_APPLICATION -o $(MAIN_FILE).efi $(MAIN_FILE).dll
-
-
-$(MAIN_FILE).dll: OUTPUT/$(MAIN_FILE).lib
- $(CC) $(CFLAGS) $(PREPROCESSOR) $(M) -o $@ $< \
- -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
-
-OUTPUT/$(MAIN_FILE).lib: $(OBJS)
- gcc-ar crv OUTPUT/$(MAIN_FILE).lib $^
+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 $@ $< \
- -MMD -MF OUTPUT/$(MAIN_FILE).obj.deps \
-include memtest86+/efi/Include/Efi_Defs.h \
- -DSTRING_ARRAY_NAME=${MAIN_FILE}Strings \
-I . \
-I"memtest86+" \
-I"memtest86+/efi/Include"
diff --git a/efi_memtest/Makefile_orig b/efi_memtest/Makefile_orig
index ab3a34b..57f4f7c 100644
--- a/efi_memtest/Makefile_orig
+++ b/efi_memtest/Makefile_orig
@@ -24,7 +24,7 @@ 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
diff --git a/efi_memtest/elf_x86_64_efi.lds b/efi_memtest/elf_x86_64_efi.lds
new file mode 100644
index 0000000..b91cd54
--- /dev/null
+++ b/efi_memtest/elf_x86_64_efi.lds
@@ -0,0 +1,76 @@
+/* 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) }
+}