diff --git a/Makefile b/Makefile index 48164c4..59f0350 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,10 @@ .PHONY: build test 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-uart .PHONY: $(MICROSERVICES) @@ -14,6 +19,14 @@ GOFLAGS=-ldflags "-X github.com/edgexfoundry/device-uart.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: