Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 1 | From de5d2b6c200ae5dd8113751e58bf7cf5844eec5a Mon Sep 17 00:00:00 2001 |
| 2 | From: Jaxson Han <jaxson.han@arm.com> |
| 3 | Date: Tue, 28 Dec 2021 17:42:48 +0800 |
| 4 | Subject: [PATCH] Makefile: Add the libfdt to the Makefile system |
| 5 | |
| 6 | Add the libfdt into Makefile system. The libfdt uses const value and |
| 7 | thus gcc will enable the stack guard. The stack guard will fail the |
| 8 | compile. Add -fno-stack-protector to fix it. |
| 9 | |
| 10 | Issue-Id: SCM-3814 |
| 11 | Upstream-Status: Inappropriate [other] |
| 12 | Implementation pending further discussion |
| 13 | Signed-off-by: Jaxson Han <jaxson.han@arm.com> |
| 14 | Change-Id: I472bc28cdc5cde3b22461a4b7d7a3752ae382b4b |
| 15 | --- |
| 16 | Makefile.am | 11 +++++++++-- |
| 17 | 1 file changed, 9 insertions(+), 2 deletions(-) |
| 18 | |
| 19 | diff --git a/Makefile.am b/Makefile.am |
| 20 | index 88a27de..5e8668a 100644 |
| 21 | --- 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 |
| 33 | @@ -125,11 +128,12 @@ CHOSEN_NODE := chosen { \ |
| 34 | CPPFLAGS += $(INITRD_FLAGS) |
| 35 | CFLAGS += -I$(top_srcdir)/include/ -I$(top_srcdir)/$(ARCH_SRC)/include/ |
| 36 | CFLAGS += -Wall -fomit-frame-pointer |
| 37 | +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. |
| 47 | @@ -150,10 +154,13 @@ $(ARCH_SRC): |
| 48 | $(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 |