From 5b3cdaed2783c9b3d5541eb8a8bf8171019f66ed Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Mon, 16 Sep 2013 14:31:36 -0700 Subject: [PATCH] ARMv7: get rmodule support to compile BRANCH=none BUG=none TEST=emerge-peach_pit chromeos-coreboot-peach_pit compiles successfully when CONFIG_VBOOT_VERIFY_FIRMWARE=y Signed-off-by: Stefan Reinauer Change-Id: I4a8f26d2e6ba92e4145022512d67e8a469fbba2f Reviewed-on: https://chromium-review.googlesource.com/169372 Reviewed-by: David Hendrix --- src/arch/armv7/Makefile.inc | 21 +++++++++++++++------ src/arch/armv7/eabi_compat.c | 3 --- src/cpu/samsung/exynos5420/Makefile.inc | 6 ++++++ src/lib/Makefile.inc | 20 +++++++++++++++++++- src/lib/rmodule.ld | 3 --- src/vendorcode/google/chromeos/Makefile.inc | 8 +++++++- 6 files changed, 47 insertions(+), 14 deletions(-) diff --git a/src/arch/armv7/Makefile.inc b/src/arch/armv7/Makefile.inc index 858ab9f127..57ee876cbb 100644 --- a/src/arch/armv7/Makefile.inc +++ b/src/arch/armv7/Makefile.inc @@ -170,16 +170,25 @@ bootblock-y += eabi_compat.c ramstage-y += boot.c ramstage-y += tables.c -romstage-y += memset.S -ramstage-y += memset.S bootblock-y += memset.S -romstage-y += memcpy.S -ramstage-y += memcpy.S bootblock-y += memcpy.S -romstage-y += memmove.S -ramstage-y += memmove.S bootblock-y += memmove.S +romstage-y += memset.S +romstage-y += memcpy.S +romstage-y += memmove.S + +ramstage-y += memset.S +ramstage-y += memcpy.S +ramstage-y += memmove.S + +rmodules-y += memset.S +rmodules-y += memcpy.S +rmodules-y += memmove.S +rmodules-y += eabi_compat.c + +VBOOT_STUB_DEPS += $(obj)/arch/armv7/eabi_compat.rmodules.o + romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c diff --git a/src/arch/armv7/eabi_compat.c b/src/arch/armv7/eabi_compat.c index 0c79cd51d3..c27c54e350 100644 --- a/src/arch/armv7/eabi_compat.c +++ b/src/arch/armv7/eabi_compat.c @@ -11,15 +11,12 @@ #include -/* FIXME(dhendrix): prototypes added for assembler */ int raise (int signum) __attribute__((used)); int raise (int signum) { - printk(BIOS_CRIT, "raise: Signal # %d caught\n", signum); return 0; } -/* Dummy function to avoid linker complaints */ void __aeabi_unwind_cpp_pr0(void) __attribute__((used)); void __aeabi_unwind_cpp_pr0(void) { diff --git a/src/cpu/samsung/exynos5420/Makefile.inc b/src/cpu/samsung/exynos5420/Makefile.inc index d01dabd069..3b3ae0517a 100644 --- a/src/cpu/samsung/exynos5420/Makefile.inc +++ b/src/cpu/samsung/exynos5420/Makefile.inc @@ -53,6 +53,12 @@ ramstage-y += dp.c dp_lowlevel.c fimd.c ramstage-y += usb.c ramstage-y += cbmem.c +rmodules-y += monotonic_timer.c +rmodules-y += mct.c + +VBOOT_STUB_DEPS += $(obj)/cpu/samsung/exynos5420/monotonic_timer.rmodules.o +VBOOT_STUB_DEPS += $(obj)/cpu/samsung/exynos5420/mct.rmodules.o + exynos5420_add_bl1: $(obj)/coreboot.pre printf " DD Adding Samsung Exynos5420 BL1\n" dd if=3rdparty/cpu/samsung/exynos5420/bl1.bin \ diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc index f9b6994ce5..de3b381527 100644 --- a/src/lib/Makefile.inc +++ b/src/lib/Makefile.inc @@ -143,6 +143,8 @@ ramstage-y += rmodule.c romstage-$(CONFIG_RELOCATABLE_RAMSTAGE) += rmodule.c RMODULE_LDSCRIPT := $(src)/lib/rmodule.ld + +ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) RMODULE_LDFLAGS := -nostartfiles -shared -z defs -nostdlib -Bsymbolic -T $(RMODULE_LDSCRIPT) # rmodule_link_rules is a function that should be called with: @@ -152,9 +154,25 @@ RMODULE_LDFLAGS := -nostartfiles -shared -z defs -nostdlib -Bsymbolic -T $(RMOD # It will create the necessary Make rules. define rmodule_link $(strip $(1)): $(strip $(2)) $$(RMODULE_LDSCRIPT) $$(obj)/ldoptions - $$(LD) $$(RMODULE_LDFLAGS) --defsym=__heap_size=$(strip $(3)) -o $$@ $(strip $(2)) + $$(LD) $$(RMODULE_LDFLAGS) --defsym=__heap_size=$(strip $(3)) -o $$@ --start-group $(strip $(2)) $$(LIBGCC_FILE_NAME) --end-group + $$(NM) -n $$@ > $$(basename $$@).map +endef + +else +RMODULE_LDFLAGS := -nostartfiles -Wl,-z,defs -Wl,-Bsymbolic -Wl,-T,$(RMODULE_LDSCRIPT) + +# rmodule_link_rules is a function that should be called with: +# (1) the object name to link +# (2) the dependencies +# (3) heap size of the relocatable module +# It will create the necessary Make rules. +define rmodule_link +$(strip $(1)): $(strip $(2)) $$(RMODULE_LDSCRIPT) $$(obj)/ldoptions + $$(CC) $$(CFLAGS) $$(RMODULE_LDFLAGS) -Wl,--defsym=__heap_size=$(strip $(3)) -o $$@ -Wl,--start-group $(strip $(2)) $$(LIBGCC_FILE_NAME) -Wl,--end-group $$(NM) -n $$@ > $$(basename $$@).map endef endif +endif + diff --git a/src/lib/rmodule.ld b/src/lib/rmodule.ld index 0cdbb2fa25..2d3621a3d6 100644 --- a/src/lib/rmodule.ld +++ b/src/lib/rmodule.ld @@ -1,6 +1,3 @@ -OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") -OUTPUT_ARCH(i386) - /* * This linker script is used to link rmodules (relocatable modules). It * links at zero so that relocation fixups are easy when placing the binaries diff --git a/src/vendorcode/google/chromeos/Makefile.inc b/src/vendorcode/google/chromeos/Makefile.inc index 117ed38b0f..c134de6294 100644 --- a/src/vendorcode/google/chromeos/Makefile.inc +++ b/src/vendorcode/google/chromeos/Makefile.inc @@ -57,8 +57,14 @@ VBOOT_STUB_DOTO = $(VBOOT_STUB_ELF:.elf=.o) # Dependency for the vboot rmodules. Ordering matters. VBOOT_STUB_DEPS += $(obj)/vendorcode/google/chromeos/vboot_wrapper.rmodules.o VBOOT_STUB_DEPS += $(obj)/lib/memcmp.rmodules.o +ifeq ($(CONFIG_ARCH_X86),y) VBOOT_STUB_DEPS += $(obj)/arch/x86/lib/memset.rmodules.o VBOOT_STUB_DEPS += $(obj)/arch/x86/lib/memcpy.rmodules.o +endif +ifeq ($(CONFIG_ARCH_ARMV7),y) +VBOOT_STUB_DEPS += $(obj)/arch/armv7/memset.rmodules.o +VBOOT_STUB_DEPS += $(obj)/arch/armv7/memcpy.rmodules.o +endif VBOOT_STUB_DEPS += $(VB_LIB) # Remove the '-include' option since that will break vboot's build and ensure # vboot_reference can get to coreboot's include files. @@ -66,7 +72,7 @@ VBOOT_CFLAGS += $(patsubst -I%,-I../%,$(filter-out -include $(src)/include/kconf VBOOT_CFLAGS += -DVBOOT_DEBUG $(VBOOT_STUB_DOTO): $(VBOOT_STUB_DEPS) - $(CC) $(LDFLAGS) -nostdlib -r -o $@ $^ + $(CC) $(CFLAGS) $(LDFLAGS) -nostdlib -r -o $@ $^ # Link the vbootstub module with a 64KiB-byte heap. $(eval $(call rmodule_link,$(VBOOT_STUB_ELF), $(VBOOT_STUB_DOTO), 0x10000))