diff --git a/Makefile b/Makefile index 9b608be4..dd32d32a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,10 @@ .PHONY: build test unittest lint clean prepare update docker +# 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-mqtt ARCH=$(shell uname -m) @@ -18,6 +23,14 @@ GOFLAGS=-ldflags "-X github.com/edgexfoundry/device-mqtt-go.Version=$(VERSION) \ -X github.com/edgexfoundry/device-sdk-go/v3/internal/common.SDKVersion=$(SDKVERSION)" \ -trimpath -mod=readonly +ifeq ($(ENABLE_FULL_RELRO), "true") + GOFLAGS += -ldflags "-bindnow" +endif + +ifeq ($(ENABLE_PIE), "true") + GOFLAGS += -buildmode=pie +endif + build: $(MICROSERVICES) build-nats: