From 366a2e44af1b06a523807c6ade07af6e5556c2ab Mon Sep 17 00:00:00 2001 From: Hung-Te Lin Date: Tue, 13 May 2014 21:10:49 +0800 Subject: [PATCH] payload/ubootcli: Minimal changes to fix build errors. The libpayload build environment has been changed slightly and here are the minimal changes to compile ubootcli under ebuild system: - Allow overriding LIBPAYLOAD_DIR. - Include only single libpayload.a. - Revise build flags. - Increase heap/stack size so video console init is fine. - Remove abort() which may be defined in libpayload. - Change weak link default function to non-inline (so it will be provided). BUG=none TEST=With a crafted ubootcli.ebuild: emerge-nyan ubootcli # arm pass emerge-rambi ubootcli # x86 pass Change-Id: Icd3bd9f29a3682cd1a2c148a2a57ce44efe33664 Signed-off-by: Hung-Te Lin Reviewed-on: https://chromium-review.googlesource.com/199476 Reviewed-by: Julius Werner --- payloads/ubootcli/Makefile | 37 +++++++++++------------- payloads/ubootcli/build/libpayload | 1 - payloads/ubootcli/main.c | 13 ++++----- payloads/ubootcli/ubootcli.ldscript.arm | 5 ++-- payloads/ubootcli/ubootcli.ldscript.i386 | 5 ++-- 5 files changed, 28 insertions(+), 33 deletions(-) delete mode 120000 payloads/ubootcli/build/libpayload diff --git a/payloads/ubootcli/Makefile b/payloads/ubootcli/Makefile index 10535c0d37..4477acef23 100644 --- a/payloads/ubootcli/Makefile +++ b/payloads/ubootcli/Makefile @@ -17,12 +17,12 @@ ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ## -include build/libpayload/libpayload.config - export src := $(shell pwd) export obj := $(src)/build -LIBPAYLOAD_DIR := $(obj)/libpayload +LIBPAYLOAD_DIR ?= $(src)/../libpayload/install/libpayload + +include $(LIBPAYLOAD_DIR)/libpayload.config $(if $(wildcard .xcompile),,$(eval $(shell bash ../libpayload/util/xcompile/xcompile > .xcompile))) include .xcompile @@ -32,15 +32,8 @@ ARCHDIR-$(CONFIG_LP_ARCH_X86) := x86 ARCH-y := $(ARCHDIR-y) -classes-$(CONFIG_LP_PCI) += build/libpayload/lib/libpci.a -classes-$(CONFIG_LP_CURSES) += build/libpayload/lib/libcurses.a -classes-$(CONFIG_LP_PDCURSES) += build/libpayload/lib/libmenu.a -classes-$(CONFIG_LP_PDCURSES) += build/libpayload/lib/libform.a -classes-$(CONFIG_LP_PDCURSES) += build/libpayload/lib/libpanel.a -classes-$(CONFIG_LP_CBFS) += build/libpayload/lib/libcbfs.a -classes-$(CONFIG_LP_LZMA) += build/libpayload/lib/liblzma.a -classes-$(CONFIG_LP_LIBC) += build/libpayload/lib/libc.a -headdoto= build/libpayload/lib/$(ARCHDIR-y)/head.o +classes-y += $(LIBPAYLOAD_DIR)/lib/libpayload.a +headdoto= $(LIBPAYLOAD_DIR)/lib/$(ARCHDIR-y)/head.o libraries := $(classes-y) # If architecture folder name is different from GCC binutils architecture name, @@ -58,22 +51,26 @@ READELF := $(READELF_$(ARCH-y)) STRIP := $(STRIP_$(ARCH-y)) AR := $(AR_$(ARCH-y)) -CFLAGS_arm= -mfloat-abi=softfp -marm -mabi=aapcs -CFLAGS_arm += -march=armv7-a -Os -fno-builtin -CFLAGS_arm += -ffreestanding -fomit-frame-pointer +CFLAGS_arm = -mthumb -march=armv7-a LIBGCC_FILE_NAME := $(shell test -r `$(LPCC) -print-libgcc-file-name` && \ $(LPCC) -print-libgcc-file-name) -OBJECTS-y=main.o command.o cmd_help.o cmd_license.o - +OBJECTS-y := main.o command.o cmd_help.o cmd_license.o OBJECTS-y += $(libraries) $(LIBGCC_FILE_NAME) -CFLAGS= -Wall -Werror -Os $(FFLAGS-y) -Ibuild/libpayload/include -I. -CFLAGS+= -Ibuild/libpayload/include/$(ARCHDIR-y) -CFLAGS+= $(CFLAGS_$(ARCH-y)) +# Common build params from Depthcharge +ABI_FLAGS := $(ARCH_ABI_FLAGS) -ffreestanding -fno-builtin \ + -fno-stack-protector -fomit-frame-pointer + +CFLAGS= -Wall -Werror -g -Os $(FFLAGS-y) -I$(LIBPAYLOAD_DIR)/include -I. +CFLAGS+= -I$(LIBPAYLOAD_DIR)/include/$(ARCHDIR-y) +CFLAGS+= $(CFLAGS_$(ARCH-y)) $(ABI_FLAGS) +CFLAGS+= -fdata-sections -ffunction-sections -std=gnu99 LDFLAGS=-Wl,-T,ubootcli.ldscript.$(ARCH-y) -static -nostartfiles -nostdlib +LDFLAGS+=$(ARCH_LINK_FLAGS) $(ABI_FLAGS) -fuse-ld=bfd +LDFLAGS+=-Wl,--gc-sections -Wl,-Map=$@.map LIBGCC=$(shell $(CC) -m32 -print-libgcc-file-name) diff --git a/payloads/ubootcli/build/libpayload b/payloads/ubootcli/build/libpayload deleted file mode 120000 index eb13cf6bad..0000000000 --- a/payloads/ubootcli/build/libpayload +++ /dev/null @@ -1 +0,0 @@ -../../libpayload/install/libpayload \ No newline at end of file diff --git a/payloads/ubootcli/main.c b/payloads/ubootcli/main.c index 0ca6dba8d2..2d7dab187d 100644 --- a/payloads/ubootcli/main.c +++ b/payloads/ubootcli/main.c @@ -32,7 +32,7 @@ /* * Board-specific Platform code can reimplement show_boot_progress () if needed */ -void inline __show_boot_progress (int val) {} +void __show_boot_progress (int val) {} void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress"))); #define MAX_DELAY_STOP_STR 32 @@ -1087,15 +1087,12 @@ int do_run (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) } #endif -void abort(void) -{ - printf("abort()\n"); - while (1) - die("abort"); -} - int main(int argc, char *argv[]) { +#if CONFIG_LP_SKIP_CONSOLE_INIT + serial_console_init(); + video_console_init(); +#endif main_loop(); return 0; } diff --git a/payloads/ubootcli/ubootcli.ldscript.arm b/payloads/ubootcli/ubootcli.ldscript.arm index 108a94252c..1717dee8cf 100644 --- a/payloads/ubootcli/ubootcli.ldscript.arm +++ b/payloads/ubootcli/ubootcli.ldscript.arm @@ -34,8 +34,9 @@ OUTPUT_ARCH(arm)*/ ENTRY(_entry) -HEAP_SIZE = 16384; -STACK_SIZE = 16384; +/* The heap size must be large enough to contain video console buffer. */ +HEAP_SIZE = 65536; +STACK_SIZE = 65536; SECTIONS { diff --git a/payloads/ubootcli/ubootcli.ldscript.i386 b/payloads/ubootcli/ubootcli.ldscript.i386 index 86baaecb2e..9e2eeac6e6 100644 --- a/payloads/ubootcli/ubootcli.ldscript.i386 +++ b/payloads/ubootcli/ubootcli.ldscript.i386 @@ -34,8 +34,9 @@ OUTPUT_ARCH(i386) ENTRY(_entry) -HEAP_SIZE = 16384; -STACK_SIZE = 16384; +/* The heap size must be large enough to contain video console buffer. */ +HEAP_SIZE = 65536; +STACK_SIZE = 65536; SECTIONS {