Skip to content

Commit

Permalink
feat: Enable PIE support for ASLR and full RELRO
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Chen <[email protected]>
  • Loading branch information
jackchenjc committed Oct 14, 2024
1 parent f54ffb4 commit b564a46
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ CGO_CFLAGS="-O2 -pipe -fno-plt"
CGO_CXXFLAGS="-O2 -pipe -fno-plt"
CGO_LDFLAGS="-Wl,-O1,–sort-common,–as-needed,-z,relro,-z,now"

# change the following boolean flag to enable or disable the Full RELRO (RELocation Read Only) for linux ELF (Executable and Linkable Format) binaries
ENABLE_FULL_RELRO:="true"
# change the following boolean flag to enable or disable PIE for linux binaries which is needed for ASLR (Address Space Layout Randomization) on Linux, the ASLR support on Windows is enabled by default
ENABLE_PIE:="true"

MICROSERVICES=cmd/device-usb-camera
.PHONY: $(MICROSERVICES)

Expand All @@ -22,6 +27,14 @@ GOFLAGS=-ldflags "-X github.com/edgexfoundry/device-usb-camera.Version=$(VERSION

ARCH=$(shell uname -m)

ifeq ($(ENABLE_FULL_RELRO), "true")
GOFLAGS += -ldflags "-bindnow"
endif

ifeq ($(ENABLE_PIE), "true")
GOFLAGS += -buildmode=pie
endif

build: $(MICROSERVICES)

build-nats:
Expand Down

0 comments on commit b564a46

Please sign in to comment.