Skip to content

Commit

Permalink
logger/Makefile: Add hardening flags, pass CFLAGS into LDFLAGS
Browse files Browse the repository at this point in the history
  • Loading branch information
solardiz committed Feb 3, 2025
1 parent 87c07fe commit 67e6c83
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions logger/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ LD = $(CC)
RM = rm -f
MKDIR = mkdir -p
INSTALL = install -c
CFLAGS = -Wall -W -O2 -fomit-frame-pointer
LDFLAGS = -s
# -pie is a linker option. but let's have it in CFLAGS to ensure -fPIE and -pie
# are ever overridden or not together
CFLAGS = -Wall -W -O2 -fomit-frame-pointer -fPIE -pie -fstack-protector-strong -D_FORTIFY_SOURCE=2
# Include CFLAGS into LDFLAGS for two reasons:
# 1. "For predictable results, you must also specify the same set of options
# used for compilation (-fpie, -fPIE, or model suboptions) when you specify
# this linker option." (as gcc man page says about "-pie")
# 2. In case the package only overrides CFLAGS, we want the distro's hardening
# or other flags to also propagate to the linker.
LDFLAGS = -s -Wl,-z,defs -Wl,-z,relro -Wl,-z,now $(CFLAGS)

DESTDIR =
PREFIX = /usr/local
Expand Down

0 comments on commit 67e6c83

Please sign in to comment.