Add hardening flags (NOHARDENING=1 to disable them) and fix Windows stringop-overflow

This commit is contained in:
Philippe Teuwen committed 2026-02-28 16:22:44 +01:00
1 parent 0e5ca3a796
commit f9cfda9a72
3 files changed
+78 -43

No files matched your search

+16 -18
View File
@@ -100,10 +100,10 @@ LUALIBINC = -I$(LUALIBPATH)
LUALIB = $(LUALIBPATH)/liblua.a
LUALIBLD =
LUAPLATFORM = generic
ifneq (,$(findstring MINGW,$(platform)))
ifdef IS_MINGW
LUAPLATFORM = mingw
else
ifeq ($(platform),Darwin)
ifdef IS_DARWIN
LUAPLATFORM = macosx
else
LUALIBLD += -ldl
@@ -112,8 +112,8 @@ else
endif
## Winsock2
ifneq (,$(findstring MINGW,$(platform)))
LDLIBS += -lws2_32
ifdef IS_MINGW
LDLIBS += -lws2_32
endif
## Reveng
@@ -262,7 +262,7 @@ PM3INCLUDES += $(MQTTLIBINC)
# RPi Zero gcc requires -latomic
# but MacOSX /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
# doesn't recognize option --as-needed
ifneq ($(platform),Darwin)
ifndef IS_DARWIN
LDLIBS += -Wl,--as-needed -latomic -Wl,--no-as-needed
endif
@@ -433,7 +433,7 @@ PM3CFLAGS += -I./src -I./include -I../include -I../common -I../common_fpga $(PM3
#PM3CFLAGS += -std=c11 -pedantic
PREFIX ?= /usr/local
ifneq (,$(findstring MINGW,$(platform)))
ifdef IS_MINGW
# Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
# and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
# FTR __USE_MINGW_ANSI_STDIO seems deprecated in Mingw32
@@ -496,14 +496,12 @@ LDFLAGS ?= $(DEFLDFLAGS)
LDFLAGS += $(MYLDFLAGS)
PM3LDFLAGS = $(LDFLAGS)
ifeq ($(platform),Darwin)
ifeq ($(shell uname -p),arm64)
# The platform is iOS
PM3LDFLAGS += -framework Foundation -framework UIKit
else
# M* macOS devices return arm
PM3LDFLAGS += -framework Foundation -framework AppKit
endif
ifdef IS_IOS
PM3LDFLAGS += -framework Foundation -framework UIKit
endif
ifdef IS_MACOS
# M* macOS devices return arm
PM3LDFLAGS += -framework Foundation -framework AppKit
endif
###################
@@ -840,8 +838,8 @@ else
CXXSRCS = guidummy.cpp
endif
# OS X
ifeq ($(platform),Darwin)
# OS X & iOS
ifdef IS_DARWIN
OBJCSRCS = util_darwin.m
endif
@@ -885,7 +883,7 @@ src/ui/ui_overlays.h: src/ui/overlays.ui
$(info [-] UIC $@)
$(Q)$(UIC) $^ > $@
# fix the header generated by some Qt6 versions (seen on 6.4.2 & 6.6.3)
ifeq ($(platform),Darwin)
ifdef IS_DARWIN
$(Q)sed -E -i '' 's/&QLabel::setNum/qOverload<int>(\&QLabel::setNum)/g' $@
else
$(Q)sed -i 's/&QLabel::setNum/qOverload<int>(\&QLabel::setNum)/g' $@
@@ -931,7 +929,7 @@ endif
ifneq (,$(INSTALLSHARE))
$(Q)$(INSTALLSUDO) $(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)
# hack ahead: inject installation path into pm3_resources.py
ifeq ($(platform),Darwin)
ifdef IS_DARWIN
$(Q)sed -E -i '' 's|^TOOLS_PATH \?= \?None|TOOLS_PATH="$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)"|' pyscripts/pm3_resources.py
$(Q)sed -E -i '' 's|^DICTS_PATH \?= \?None|DICTS_PATH="$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)/dictionaries"|' pyscripts/pm3_resources.py
$(Q)$(INSTALLSUDO) $(CP) $(INSTALLSHARE) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)