Skip to content

Commit

Permalink
Merge pull request #146 from jackchenjc/edgex-go-issue-4916
Browse files Browse the repository at this point in the history
feat: Enable PIE support for ASLR and full RELRO
  • Loading branch information
cloudxxx8 authored Oct 14, 2024
2 parents 2069e48 + c510f15 commit fb1cfc1
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 @@ -16,6 +16,11 @@

.PHONY: build tidy docker test clean vendor

# 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"

# VERSION file is not needed for local development, In the CI/CD pipeline, a temporary VERSION file is written
# if you need a specific version, just override below
APPVERSION=$(shell cat ./VERSION 2>/dev/null || echo 0.0.0)
Expand All @@ -34,6 +39,14 @@ GIT_SHA=$(shell git rev-parse HEAD)

ARCH=$(shell uname -m)

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

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

# CGO is enabled by default and causes docker builds to fail due to no gcc,
# but is required for test with -race, so must disable it for the builds only
build:
Expand Down

0 comments on commit fb1cfc1

Please sign in to comment.