Skip to content

Commit 5affe53

Browse files
chengangclijinxia
authored andcommitted
tools: acrn-crashlog: update Makefile flags
This patch is to sync the compiler options as the Makefile of device model. Tracked-On: #1122 Signed-off-by: CHEN Gang <gang.c.chen@intel.com> Reviewed-by: Zhi Jin <zhi.jin@intel.com> Reviewed-by: Liu, Xinwu <xinwu.liu@intel.com>
1 parent 726711e commit 5affe53

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

tools/acrn-crashlog/Makefile

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,50 @@
55
BASEDIR := $(shell pwd)
66
OUT_DIR ?= $(BASEDIR)
77
BUILDDIR := $(OUT_DIR)/acrn-crashlog
8-
CC := gcc
8+
CC ?= gcc
99
RM = rm
1010
RELEASE ?= 0
1111

12-
CFLAGS := -Wall -Wextra -pedantic
13-
CFLAGS += -m64 -D_GNU_SOURCE
1412
ifeq ($(RELEASE),0)
1513
CFLAGS += -DDEBUG_ACRN_CRASHLOG
1614
endif
15+
16+
CFLAGS := -g -O0 -std=gnu11
17+
CFLAGS += -D_GNU_SOURCE
18+
CFLAGS += -m64
19+
CFLAGS += -Wall -ffunction-sections
20+
CFLAGS += -Werror
21+
CFLAGS += -O2 -D_FORTIFY_SOURCE=2
22+
CFLAGS += -Wformat -Wformat-security -fno-strict-aliasing
1723
CFLAGS += -fpie
24+
CFLAGS += -Wall -Wextra -pedantic
25+
26+
CFLAGS += -I$(BASEDIR)/include
27+
CFLAGS += -I$(BASEDIR)/include/public
28+
29+
GCC_MAJOR=$(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1)
30+
GCC_MINOR=$(shell echo __GNUC_MINOR__ | $(CC) -E -x c - | tail -n 1)
31+
32+
#enable stack overflow check
33+
STACK_PROTECTOR := 1
34+
35+
ifdef STACK_PROTECTOR
36+
ifeq (true, $(shell [ $(GCC_MAJOR) -gt 4 ] && echo true))
37+
CFLAGS += -fstack-protector-strong
38+
else
39+
ifeq (true, $(shell [ $(GCC_MAJOR) -eq 4 ] && [ $(GCC_MINOR) -ge 9 ] && echo true))
40+
CFLAGS += -fstack-protector-strong
41+
else
42+
CFLAGS += -fstack-protector
43+
endif
44+
endif
45+
endif
46+
47+
LDFLAGS += -Wl,-z,noexecstack
48+
LDFLAGS += -Wl,-z,relro,-z,now
1849
LDFLAGS += -pie
1950
INCLUDE := -I $(BASEDIR)/common/include
51+
2052
export INCLUDE
2153
export BUILDDIR
2254
export CC

tools/acrn-crashlog/acrnprobe/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ LIBS = -lpthread -lxml2 -lcrypto -lrt -lblkid -lext2fs -lcom_err \
88
INCLUDE += -I $(CURDIR)/include -I /usr/include/libxml2
99
INCLUDE += -I $(BUILDDIR)/include/acrnprobe
1010
CFLAGS += $(INCLUDE)
11-
CFLAGS += -g -O0 -std=gnu11
12-
CFLAGS += -ffunction-sections -fdata-sections
11+
CFLAGS += -fdata-sections
1312

1413
LDFLAGS += $(LIBS) -Wl,--gc-sections
1514

0 commit comments

Comments
 (0)