summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRegia König2022-03-11 15:15:54 +0100
committerRegia König2022-03-11 15:15:54 +0100
commitaa69a6edf4d1c2cdb1ae27afa804a7eee9f55f36 (patch)
tree2829d1ae487ad9a842bb1f3c78904d1a5864d9c9
parentSplit build process into debug build and release build (gdb vs lto) (diff)
downloadmemtest86-aa69a6edf4d1c2cdb1ae27afa804a7eee9f55f36.tar.gz
memtest86-aa69a6edf4d1c2cdb1ae27afa804a7eee9f55f36.tar.xz
memtest86-aa69a6edf4d1c2cdb1ae27afa804a7eee9f55f36.zip
Add a bunch of flags for debugging (Warning flags)
-rw-r--r--efi_memtest/.gitignore1
-rw-r--r--efi_memtest/Makefile26
2 files changed, 21 insertions, 6 deletions
diff --git a/efi_memtest/.gitignore b/efi_memtest/.gitignore
index 86416ca..69e84b9 100644
--- a/efi_memtest/.gitignore
+++ b/efi_memtest/.gitignore
@@ -6,3 +6,4 @@
*.txt
*.lib
*.obj.deps
+*.su
diff --git a/efi_memtest/Makefile b/efi_memtest/Makefile
index 24d0875..ed061bd 100644
--- a/efi_memtest/Makefile
+++ b/efi_memtest/Makefile
@@ -3,15 +3,26 @@ MAIN_FILE = MemtestEfi
CC = gcc
# Treat all warnings as errors
-#CFLAGS = -Werror
+#CFLAGS = -Werror
+CFLAGS += -Wall
+# Warnings not covered by Wall
+CFLAGS += -Wextra
+CFLAGS += -Wshadow
+CFLAGS += -Wdouble-promotion
+CFLAGS += -Wformat=2 -Wformat-truncation -Wformat-overflow
+CFLAGS += -Wundef # for undefined macros
+#CFLAGS += -Wno-array-bounds
+CFLAGS += -Wconversion
+CFLAGS += -Wpadded
-CFLAGS += -Wall -Wno-array-bounds
CFLAGS += -fno-builtin
+CFLAGS += -ffunction-sections # Each functions gets own section. Unused sections can be culled at a final optimization
+
# EFI requires -fshort-wchar
CFLAGS += -fshort-wchar
-CFLAGS += -fno-common
+CFLAGS += -fno-common # Disabled the ability for tentative definitions to be merged into a pre-existing definition
CFLAGS += -fno-strict-aliasing
# EFI uses Microsoft ABI so no red zone is defined
@@ -74,7 +85,10 @@ BaseLib_OBJS=ARShiftU64.o BitField.o CheckSum.o CpuDeadLoop.o Cpu.o DivU64x64Rem
LIBRARIES=MemtestEfi.lib
-debug: CFLAGS += -g
+debug: CFLAGS += -g3
+debug: CFLAGS += -fstack-usage # emit .su (stack usage) files for each c file you compile
+debug: CFLAGS += -Wstack-usage=255
+debug: CFLAGS += -Werror
debug: all
release: #CFLAGS += -flto
@@ -89,11 +103,11 @@ $(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
-
+# gc-sections culls unused sections
$(MAIN_FILE).dll: $(MAIN_FILE).lib
$(CC) $(CFLAGS) $(PREPROCESSOR) $(M) $(LIBRARIES) -o $(MAIN_FILE).dll \
-nostdlib \
- -Wl,-n,-q,--gc-sections \
+ -Wl,-n,-q,--gc-sections,--print-gc-sections \
-Wl,--entry,_ModuleEntryPoint \
-Wl,-Map,$(MAIN_FILE).map,--whole-archive \
-Wl,-melf_x86_64,--oformat=elf64-x86-64,-pie \