tools: acrntrace: update Makefile

Update the Makefiel to sync the compiler options with devicemode
and enable options to harden software.

Tracked-On: #1122
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
This commit is contained in:
Yan, Like 2018-09-20 09:43:24 +08:00 committed by lijinxia
parent 5e0acac490
commit c51e213905
1 changed files with 36 additions and 2 deletions

View File

@ -1,6 +1,37 @@
T := $(CURDIR)
OUT_DIR ?= $(shell mkdir -p $(T)/build;cd $(T)/build;pwd)
CC ?= gcc
OUT_DIR ?= . CFLAGS := -g -O0 -std=gnu11
CFLAGS += -fpie CFLAGS += -D_GNU_SOURCE
CFLAGS += -DNO_OPENSSL
CFLAGS += -m64
CFLAGS += -Wall -ffunction-sections
CFLAGS += -Werror
CFLAGS += -O2 -D_FORTIFY_SOURCE=2
CFLAGS += -Wformat -Wformat-security -fno-strict-aliasing
CFLAGS += -fpie -fpic
GCC_MAJOR=$(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1)
GCC_MINOR=$(shell echo __GNUC_MINOR__ | $(CC) -E -x c - | tail -n 1)
#enable stack overflow check
STACK_PROTECTOR := 1
ifdef STACK_PROTECTOR
ifeq (true, $(shell [ $(GCC_MAJOR) -gt 4 ] && echo true))
CFLAGS += -fstack-protector-strong
else
ifeq (true, $(shell [ $(GCC_MAJOR) -eq 4 ] && [ $(GCC_MINOR) -ge 9 ] && echo true))
CFLAGS += -fstack-protector-strong
else
CFLAGS += -fstack-protector
endif
endif
endif
LDFLAGS := -Wl,-z,noexecstack
LDFLAGS += -Wl,-z,relro,-z,now
LDFLAGS += -pie LDFLAGS += -pie
all: all:
@ -8,6 +39,9 @@ all:
clean: clean:
rm -f $(OUT_DIR)/acrntrace rm -f $(OUT_DIR)/acrntrace
ifneq ($(OUT_DIR),.)
rm -rf $(OUT_DIR)
endif
install: $(OUT_DIR)/acrntrace install: $(OUT_DIR)/acrntrace
install -d $(DESTDIR)/usr/bin install -d $(DESTDIR)/usr/bin