
This approach is different from Simon's approach. It uses objcopy to convert u-boot-dtb.bin into an ELF object with all the binary content included in the .data section. This elinimates the need to include a special section in the payload's linker script. Also there is no need to add any ASFLAGS_REMOVE for u-boot-dtb.o.
Signed-off-by: Bin Meng bmeng.cn@gmail.com
--- This patch needs to be applied on top of Simon's efi series.
Makefile | 21 +++++---------------- arch/x86/config.mk | 6 +++++- arch/x86/cpu/efi/elf_ia32_efi.lds | 3 --- arch/x86/cpu/efi/elf_x86_64_efi.lds | 3 --- include/efi.h | 2 +- lib/efi/efi_stub.c | 5 +++-- scripts/Makefile.build | 8 -------- 7 files changed, 14 insertions(+), 34 deletions(-)
diff --git a/Makefile b/Makefile index 6e3edb4..02aaa9e 100644 --- a/Makefile +++ b/Makefile @@ -789,6 +789,9 @@ cmd_objcopy = $(OBJCOPY) --gap-fill=0xff $(OBJCOPYFLAGS) \ quiet_cmd_zobjcopy = OBJCOPY $@ cmd_zobjcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
+quiet_cmd_efipayload = OBJCOPY $@ +cmd_efipayload = $(OBJCOPY) -I binary -O $(EFIPAYLOAD_BFDTARGET) -B $(EFIPAYLOAD_BFDARCH) $< $@ + quiet_cmd_mkimage = MKIMAGE $@ cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \ $(if $(KBUILD_VERBOSE:1=), >/dev/null) @@ -1086,22 +1089,8 @@ OBJCOPYFLAGS_u-boot.efi := $(OBJCOPYFLAGS_EFI) u-boot.efi: u-boot FORCE $(call if_changed,zobjcopy)
-# Generate an assembly file to wrap a binary file -quiet_cmd_bin_S = BIN $@ -cmd_bin_S = \ -( \ - echo '.section .u_boot_bin.init.rodata,"a"'; \ - echo '.balign 16'; \ - echo '.global __u_boot_bin_begin'; \ - echo '__u_boot_bin_begin:'; \ - echo '.incbin "$<" '; \ - echo '__u_boot_bin_end:'; \ - echo '.global __u_boot_bin_end'; \ - echo '.balign 16'; \ -) > $@ - -u-boot-dtb.bin.S: u-boot-dtb.bin FORCE - $(call if_changed,bin_S) +u-boot-dtb.bin.o: u-boot-dtb.bin FORCE + $(call if_changed,efipayload)
u-boot-payload.lds: $(LDSCRIPT_EFI) FORCE $(call if_changed_dep,cpp_lds) diff --git a/arch/x86/config.mk b/arch/x86/config.mk index 5107b43..7cebceb 100644 --- a/arch/x86/config.mk +++ b/arch/x86/config.mk @@ -36,12 +36,16 @@ OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \ CFLAGS_NON_EFI := -mregparm=3 CFLAGS_EFI := -fpic -fshort-wchar $(call cc-option, -mno-red-zone)
-ifeq ($(CONFIG_X86_64)$(CONFIG_EFI_STUB_64BIT),) +ifeq ($(CONFIG_EFI_STUB_64BIT),) EFIARCH=ia32 +EFIPAYLOAD_BFDTARGET = elf32-i386 else EFIARCH=x86_64 +EFIPAYLOAD_BFDTARGET = elf64-x86-64 endif
+EFIPAYLOAD_BFDARCH = i386 + LDSCRIPT_EFI := $(srctree)/$(CPUDIR)/efi/elf_$(EFIARCH)_efi.lds EFISTUB := crt0-efi-$(EFIARCH).o reloc_$(EFIARCH).o OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH) diff --git a/arch/x86/cpu/efi/elf_ia32_efi.lds b/arch/x86/cpu/efi/elf_ia32_efi.lds index 87ddb4d..fca008b 100644 --- a/arch/x86/cpu/efi/elf_ia32_efi.lds +++ b/arch/x86/cpu/efi/elf_ia32_efi.lds @@ -57,9 +57,6 @@ SECTIONS KEEP(*(SORT(.u_boot_list*))); . = ALIGN(8); KEEP(*(.dtb*)); - /* Keep U-Boot payload */ - . = ALIGN(8); - KEEP(*(.u_boot_bin.*)); } .dynamic : { *(.dynamic) } . = ALIGN(4096); diff --git a/arch/x86/cpu/efi/elf_x86_64_efi.lds b/arch/x86/cpu/efi/elf_x86_64_efi.lds index 369f146..dcb2fee 100644 --- a/arch/x86/cpu/efi/elf_x86_64_efi.lds +++ b/arch/x86/cpu/efi/elf_x86_64_efi.lds @@ -57,9 +57,6 @@ SECTIONS KEEP(*(SORT(.u_boot_list*))); . = ALIGN(8); KEEP(*(.dtb*)); - /* Keep U-Boot payload */ - . = ALIGN(8); - KEEP(*(.u_boot_bin.*)); }
. = ALIGN(4096); diff --git a/include/efi.h b/include/efi.h index edc8cd9..36d6d17 100644 --- a/include/efi.h +++ b/include/efi.h @@ -269,7 +269,7 @@ struct efi_priv { extern char ImageBase[];
/* Start and end of U-Boot image (for payload) */ -extern char __u_boot_bin_begin[], __u_boot_bin_end[]; +extern char _binary_u_boot_dtb_bin_start[], _binary_u_boot_dtb_bin_end[];
/** * efi_get_sys_table() - Get access to the main EFI system table diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c index 36f14ff..279ff4a 100644 --- a/lib/efi/efi_stub.c +++ b/lib/efi/efi_stub.c @@ -325,8 +325,9 @@ efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table) /* The EFI UART won't work now, switch to a debug one */ use_uart = true;
- memcpy((void *)CONFIG_SYS_TEXT_BASE, __u_boot_bin_begin, - (ulong)__u_boot_bin_end - (ulong)__u_boot_bin_begin); + memcpy((void *)CONFIG_SYS_TEXT_BASE, _binary_u_boot_dtb_bin_start, + (ulong)_binary_u_boot_dtb_bin_end - + (ulong)_binary_u_boot_dtb_bin_start);
#ifdef DEBUG puts("EFI table at "); diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 9a7d28d..ac0554e 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -294,14 +294,6 @@ $(obj)/%.lst: $(src)/%.c FORCE # Compile assembler sources (.S) # ---------------------------------------------------------------------------
-# TODO(sjg@chromium.org): Move this to a sensible place. It does not seem to -# work if placed in arch/x86/config.mk, etc. It is placed here so that -# we use the correct flags when assembling u-boot-dtb.bin.S. -ifdef CONFIG_X86 -AFLAGS_REMOVE_u-boot-dtb.bin.o += -mregparm=3 -march=i386 -m32 -AFLAGS_u-boot-dtb.bin.o += -fpic -fshort-wchar -endif - modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)
$(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)