blob: b77ab3e27b1153d038fa5583aa953919ed34762d [file] [log] [blame]
Andrew Geissler9347dd42023-03-03 12:38:41 -06001From f4d5cf4c3424598a2b3bb391717313b70c79ea28 Mon Sep 17 00:00:00 2001
Brad Bishopbec4ebc2022-08-03 09:55:16 -04002From: Jaxson Han <jaxson.han@arm.com>
3Date: Tue, 28 Dec 2021 17:42:48 +0800
4Subject: [PATCH] Makefile: Add the libfdt to the Makefile system
5
6Add the libfdt into Makefile system. The libfdt uses const value and
7thus gcc will enable the stack guard. The stack guard will fail the
8compile. Add -fno-stack-protector to fix it.
9
10Issue-Id: SCM-3814
11Upstream-Status: Inappropriate [other]
12 Implementation pending further discussion
13Signed-off-by: Jaxson Han <jaxson.han@arm.com>
14Change-Id: I472bc28cdc5cde3b22461a4b7d7a3752ae382b4b
15---
16 Makefile.am | 11 +++++++++--
17 1 file changed, 9 insertions(+), 2 deletions(-)
18
19diff --git a/Makefile.am b/Makefile.am
Andrew Geissler9347dd42023-03-03 12:38:41 -060020index fc66662..ab2c3a9 100644
Brad Bishopbec4ebc2022-08-03 09:55:16 -040021--- a/Makefile.am
22+++ b/Makefile.am
23@@ -36,6 +36,9 @@ PSCI_CPU_OFF := 0x84000002
24 COMMON_SRC := common/
25 COMMON_OBJ := boot.o bakery_lock.o platform.o lib.o
26
27+LIBFDT_SRC := common/libfdt/
28+LIBFDT_OBJS := fdt.o fdt_ro.o fdt_rw.o
29+
30 ARCH_OBJ := boot.o stack.o utils.o
31
32 if BOOTWRAPPER_32
Andrew Geissler9347dd42023-03-03 12:38:41 -060033@@ -127,11 +130,12 @@ CFLAGS += -I$(top_srcdir)/include/ -I$(top_srcdir)/$(ARCH_SRC)/include/
Brad Bishopbec4ebc2022-08-03 09:55:16 -040034 CFLAGS += -Wall -fomit-frame-pointer
Andrew Geissler9347dd42023-03-03 12:38:41 -060035 CFLAGS += -ffreestanding -nostdlib
36 CFLAGS += -fno-stack-protector
Brad Bishopbec4ebc2022-08-03 09:55:16 -040037+CFLAGS += -fno-stack-protector
38 CFLAGS += -ffunction-sections -fdata-sections
39 CFLAGS += -fno-pic -fno-pie
40 LDFLAGS += --gc-sections
41
42-OBJ := $(addprefix $(ARCH_SRC),$(ARCH_OBJ)) $(addprefix $(COMMON_SRC),$(COMMON_OBJ))
43+OBJ := $(addprefix $(ARCH_SRC),$(ARCH_OBJ)) $(addprefix $(COMMON_SRC),$(COMMON_OBJ)) $(addprefix $(LIBFDT_SRC),$(LIBFDT_OBJS))
44
45 # Don't lookup all prerequisites in $(top_srcdir), only the source files. When
46 # building outside the source tree $(ARCH_SRC) needs to be created.
Andrew Geissler9347dd42023-03-03 12:38:41 -060047@@ -152,10 +156,13 @@ $(ARCH_SRC):
Brad Bishopbec4ebc2022-08-03 09:55:16 -040048 $(COMMON_SRC):
49 $(MKDIR_P) $@
50
51+$(LIBFDT_SRC):
52+ $(MKDIR_P) $@
53+
54 %.o: %.S Makefile | $(ARCH_SRC)
55 $(CC) $(CPPFLAGS) -D__ASSEMBLY__ $(CFLAGS) $(DEFINES) -c -o $@ $<
56
57-%.o: %.c Makefile | $(COMMON_SRC)
58+%.o: %.c Makefile | $(COMMON_SRC) $(LIBFDT_SRC)
59 $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c -o $@ $<
60
61 model.lds: $(LD_SCRIPT) Makefile