cmd_u-boot_payload ?= $(LD) $(LDFLAGS_EFI_PAYLOAD) -o $@ \
-T u-boot-payload.lds arch/x86/cpu/call32.o \
lib/efi/efi.o lib/efi/efi_stub.o u-boot.bin.o \
- $(addprefix arch/$(ARCH)/lib/efi/,$(EFISTUB))
+ $(addprefix arch/$(ARCH)/lib/,$(EFISTUB))
u-boot-payload: u-boot.bin.o u-boot-payload.lds FORCE
$(call if_changed,u-boot_payload)
EFIPAYLOAD_BFDARCH = i386
LDSCRIPT_EFI := $(srctree)/arch/x86/lib/elf_$(EFIARCH)_efi.lds
-EFISTUB := crt0-efi-$(EFIARCH).o reloc_$(EFIARCH).o
+EFISTUB := crt0_$(EFIARCH)_efi.o reloc_$(EFIARCH)_efi.o
OBJCOPYFLAGS_EFI += --target=efi-app-$(EFIARCH)
CPPFLAGS_REMOVE_crt0-efi-$(EFIARCH).o += $(CFLAGS_NON_EFI)
OBJCOPYFLAGS := --prefix-symbols=__normal_
$(obj)/lib.a: $(NORMAL_LIBGCC) FORCE
$(call if_changed,objcopy)
+
+obj-$(CONFIG_EFI_APP) += crt0_ia32_efi.o reloc_ia32_efi.o
+
+ifneq ($(CONFIG_EFI_STUB),)
+
+CFLAGS_REMOVE_reloc_ia32_efi.o += -mregparm=3
+CFLAGS_reloc_ia32_efi.o += -fpic -fshort-wchar
+
+# When building for 64-bit we must remove the i386-specific flags
+CFLAGS_REMOVE_reloc_x86_64_efi.o += -mregparm=3 -march=i386 -m32
+CFLAGS_reloc_x86_64_efi.o += -fpic -fshort-wchar
+
+AFLAGS_REMOVE_crt0_x86_64_efi.o += -mregparm=3 -march=i386 -m32
+AFLAGS_crt0_x86_64_efi.o += -fpic -fshort-wchar
+
+extra-$(CONFIG_EFI_STUB_32BIT) += crt0_ia32_efi.o reloc_ia32_efi.o
+extra-$(CONFIG_EFI_STUB_64BIT) += crt0_x86_64_efi.o reloc_x86_64_efi.o
+endif
--- /dev/null
+/*
+ * crt0-efi-ia32.S - x86 EFI startup code.
+ *
+ * Copyright (C) 1999 Hewlett-Packard Co.
+ * Contributed by David Mosberger <davidm@hpl.hp.com>.
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+ .text
+ .align 4
+
+ .globl _start
+_start:
+ pushl %ebp
+ movl %esp,%ebp
+
+ pushl 12(%ebp) # copy "image" argument
+ pushl 8(%ebp) # copy "systab" argument
+
+ call 0f
+0: popl %eax
+ movl %eax,%ebx
+
+ addl $image_base-0b,%eax # %eax = ldbase
+ addl $_DYNAMIC-0b,%ebx # %ebx = _DYNAMIC
+
+ pushl %ebx # pass _DYNAMIC as second argument
+ pushl %eax # pass ldbase as first argument
+ call _relocate
+ popl %ebx
+ popl %ebx
+ testl %eax,%eax
+ jne .exit
+ call efi_main # call app with "image" and "systab" argument
+
+.exit: leave
+ ret
+
+ /*
+ * hand-craft a dummy .reloc section so EFI knows it's a relocatable
+ * executable:
+ */
+ .data
+dummy: .long 0
+
+#define IMAGE_REL_ABSOLUTE 0
+ .section .reloc
+ .long dummy /* Page RVA */
+ .long 10 /* Block Size (2*4+2) */
+ .word (IMAGE_REL_ABSOLUTE << 12) + 0 /* reloc for dummy */
--- /dev/null
+/*
+ * crt0-efi-x86_64.S - x86_64 EFI startup code.
+ * Copyright (C) 1999 Hewlett-Packard Co.
+ * Contributed by David Mosberger <davidm@hpl.hp.com>.
+ * Copyright (C) 2005 Intel Co.
+ * Contributed by Fenghua Yu <fenghua.yu@intel.com>.
+ *
+ * All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+ .text
+ .align 4
+
+ .globl _start
+_start:
+ subq $8, %rsp
+ pushq %rcx
+ pushq %rdx
+
+0:
+ lea image_base(%rip), %rdi
+ lea _DYNAMIC(%rip), %rsi
+
+ popq %rcx
+ popq %rdx
+ pushq %rcx
+ pushq %rdx
+ call _relocate
+
+ popq %rdi
+ popq %rsi
+
+ call efi_main
+ addq $8, %rsp
+
+.exit:
+ ret
+
+ /*
+ * hand-craft a dummy .reloc section so EFI knows it's a relocatable
+ * executable:
+ */
+ .data
+dummy: .long 0
+
+#define IMAGE_REL_ABSOLUTE 0
+ .section .reloc, "a"
+label1:
+ .long dummy-label1 /* Page RVA */
+ .long 10 /* Block Size (2*4+2) */
+ .word (IMAGE_REL_ABSOLUTE << 12) + 0 /* reloc for dummy */
obj-$(CONFIG_EFI_STUB) += car.o
obj-$(CONFIG_EFI_STUB) += efi.o
-
-obj-$(CONFIG_EFI_APP) += crt0-efi-ia32.o reloc_ia32.o
-
-ifneq ($(CONFIG_EFI_STUB),)
-
-CFLAGS_REMOVE_reloc_ia32.o += -mregparm=3
-CFLAGS_reloc_ia32.o += -fpic -fshort-wchar
-
-# When building for 64-bit we must remove the i386-specific flags
-CFLAGS_REMOVE_reloc_x86_64.o += -mregparm=3 -march=i386 -m32
-CFLAGS_reloc_x86_64.o += -fpic -fshort-wchar
-
-AFLAGS_REMOVE_crt0-efi-x86_64.o += -mregparm=3 -march=i386 -m32
-AFLAGS_crt0-efi-x86_64.o += -fpic -fshort-wchar
-
-extra-$(CONFIG_EFI_STUB_32BIT) += crt0-efi-ia32.o reloc_ia32.o
-extra-$(CONFIG_EFI_STUB_64BIT) += crt0-efi-x86_64.o reloc_x86_64.o
-endif
+++ /dev/null
-/*
- * crt0-efi-ia32.S - x86 EFI startup code.
- *
- * Copyright (C) 1999 Hewlett-Packard Co.
- * Contributed by David Mosberger <davidm@hpl.hp.com>.
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
- .text
- .align 4
-
- .globl _start
-_start:
- pushl %ebp
- movl %esp,%ebp
-
- pushl 12(%ebp) # copy "image" argument
- pushl 8(%ebp) # copy "systab" argument
-
- call 0f
-0: popl %eax
- movl %eax,%ebx
-
- addl $image_base-0b,%eax # %eax = ldbase
- addl $_DYNAMIC-0b,%ebx # %ebx = _DYNAMIC
-
- pushl %ebx # pass _DYNAMIC as second argument
- pushl %eax # pass ldbase as first argument
- call _relocate
- popl %ebx
- popl %ebx
- testl %eax,%eax
- jne .exit
- call efi_main # call app with "image" and "systab" argument
-
-.exit: leave
- ret
-
- /*
- * hand-craft a dummy .reloc section so EFI knows it's a relocatable
- * executable:
- */
- .data
-dummy: .long 0
-
-#define IMAGE_REL_ABSOLUTE 0
- .section .reloc
- .long dummy /* Page RVA */
- .long 10 /* Block Size (2*4+2) */
- .word (IMAGE_REL_ABSOLUTE << 12) + 0 /* reloc for dummy */
+++ /dev/null
-/*
- * crt0-efi-x86_64.S - x86_64 EFI startup code.
- * Copyright (C) 1999 Hewlett-Packard Co.
- * Contributed by David Mosberger <davidm@hpl.hp.com>.
- * Copyright (C) 2005 Intel Co.
- * Contributed by Fenghua Yu <fenghua.yu@intel.com>.
- *
- * All rights reserved.
- * SPDX-License-Identifier: BSD-3-Clause
- */
- .text
- .align 4
-
- .globl _start
-_start:
- subq $8, %rsp
- pushq %rcx
- pushq %rdx
-
-0:
- lea image_base(%rip), %rdi
- lea _DYNAMIC(%rip), %rsi
-
- popq %rcx
- popq %rdx
- pushq %rcx
- pushq %rdx
- call _relocate
-
- popq %rdi
- popq %rsi
-
- call efi_main
- addq $8, %rsp
-
-.exit:
- ret
-
- /*
- * hand-craft a dummy .reloc section so EFI knows it's a relocatable
- * executable:
- */
- .data
-dummy: .long 0
-
-#define IMAGE_REL_ABSOLUTE 0
- .section .reloc, "a"
-label1:
- .long dummy-label1 /* Page RVA */
- .long 10 /* Block Size (2*4+2) */
- .word (IMAGE_REL_ABSOLUTE << 12) + 0 /* reloc for dummy */
+++ /dev/null
-/*
- * reloc_ia32.c - position independent x86 ELF shared object relocator
- * Copyright (C) 1999 Hewlett-Packard Co.
- * Contributed by David Mosberger <davidm@hpl.hp.com>.
- *
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <common.h>
-#include <efi.h>
-#include <elf.h>
-#include <asm/elf.h>
-
-efi_status_t _relocate(long ldbase, Elf32_Dyn *dyn, efi_handle_t image,
- struct efi_system_table *systab)
-{
- long relsz = 0, relent = 0;
- Elf32_Rel *rel = 0;
- unsigned long *addr;
- int i;
-
- for (i = 0; dyn[i].d_tag != DT_NULL; ++i) {
- switch (dyn[i].d_tag) {
- case DT_REL:
- rel = (Elf32_Rel *)((unsigned long)dyn[i].d_un.d_ptr +
- ldbase);
- break;
-
- case DT_RELSZ:
- relsz = dyn[i].d_un.d_val;
- break;
-
- case DT_RELENT:
- relent = dyn[i].d_un.d_val;
- break;
-
- case DT_RELA:
- break;
-
- default:
- break;
- }
- }
-
- if (!rel && relent == 0)
- return EFI_SUCCESS;
-
- if (!rel || relent == 0)
- return EFI_LOAD_ERROR;
-
- while (relsz > 0) {
- /* apply the relocs */
- switch (ELF32_R_TYPE(rel->r_info)) {
- case R_386_NONE:
- break;
-
- case R_386_RELATIVE:
- addr = (unsigned long *)(ldbase + rel->r_offset);
- *addr += ldbase;
- break;
-
- default:
- break;
- }
- rel = (Elf32_Rel *)((char *)rel + relent);
- relsz -= relent;
- }
-
- return EFI_SUCCESS;
-}
+++ /dev/null
-/*
- * reloc_x86_64.c - position independent x86_64 ELF shared object relocator
- * Copyright (C) 1999 Hewlett-Packard Co.
- * Contributed by David Mosberger <davidm@hpl.hp.com>.
- * Copyright (C) 2005 Intel Co.
- * Contributed by Fenghua Yu <fenghua.yu@intel.com>.
- *
- * All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <common.h>
-#include <efi.h>
-#include <elf.h>
-#include <asm/elf.h>
-
-efi_status_t _relocate(long ldbase, Elf64_Dyn *dyn, efi_handle_t image,
- struct efi_system_table *systab)
-{
- long relsz = 0, relent = 0;
- Elf64_Rel *rel = 0;
- unsigned long *addr;
- int i;
-
- for (i = 0; dyn[i].d_tag != DT_NULL; ++i) {
- switch (dyn[i].d_tag) {
- case DT_RELA:
- rel = (Elf64_Rel *)
- ((unsigned long)dyn[i].d_un.d_ptr + ldbase);
- break;
- case DT_RELASZ:
- relsz = dyn[i].d_un.d_val;
- break;
- case DT_RELAENT:
- relent = dyn[i].d_un.d_val;
- break;
- default:
- break;
- }
- }
-
- if (!rel && relent == 0)
- return EFI_SUCCESS;
-
- if (!rel || relent == 0)
- return EFI_LOAD_ERROR;
-
- while (relsz > 0) {
- /* apply the relocs */
- switch (ELF64_R_TYPE(rel->r_info)) {
- case R_X86_64_NONE:
- break;
- case R_X86_64_RELATIVE:
- addr = (unsigned long *)(ldbase + rel->r_offset);
- *addr += ldbase;
- break;
- default:
- break;
- }
- rel = (Elf64_Rel *)((char *)rel + relent);
- relsz -= relent;
- }
-
- return EFI_SUCCESS;
-}
--- /dev/null
+/*
+ * reloc_ia32.c - position independent x86 ELF shared object relocator
+ * Copyright (C) 1999 Hewlett-Packard Co.
+ * Contributed by David Mosberger <davidm@hpl.hp.com>.
+ *
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <common.h>
+#include <efi.h>
+#include <elf.h>
+#include <asm/elf.h>
+
+efi_status_t _relocate(long ldbase, Elf32_Dyn *dyn, efi_handle_t image,
+ struct efi_system_table *systab)
+{
+ long relsz = 0, relent = 0;
+ Elf32_Rel *rel = 0;
+ unsigned long *addr;
+ int i;
+
+ for (i = 0; dyn[i].d_tag != DT_NULL; ++i) {
+ switch (dyn[i].d_tag) {
+ case DT_REL:
+ rel = (Elf32_Rel *)((unsigned long)dyn[i].d_un.d_ptr +
+ ldbase);
+ break;
+
+ case DT_RELSZ:
+ relsz = dyn[i].d_un.d_val;
+ break;
+
+ case DT_RELENT:
+ relent = dyn[i].d_un.d_val;
+ break;
+
+ case DT_RELA:
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if (!rel && relent == 0)
+ return EFI_SUCCESS;
+
+ if (!rel || relent == 0)
+ return EFI_LOAD_ERROR;
+
+ while (relsz > 0) {
+ /* apply the relocs */
+ switch (ELF32_R_TYPE(rel->r_info)) {
+ case R_386_NONE:
+ break;
+
+ case R_386_RELATIVE:
+ addr = (unsigned long *)(ldbase + rel->r_offset);
+ *addr += ldbase;
+ break;
+
+ default:
+ break;
+ }
+ rel = (Elf32_Rel *)((char *)rel + relent);
+ relsz -= relent;
+ }
+
+ return EFI_SUCCESS;
+}
--- /dev/null
+/*
+ * reloc_x86_64.c - position independent x86_64 ELF shared object relocator
+ * Copyright (C) 1999 Hewlett-Packard Co.
+ * Contributed by David Mosberger <davidm@hpl.hp.com>.
+ * Copyright (C) 2005 Intel Co.
+ * Contributed by Fenghua Yu <fenghua.yu@intel.com>.
+ *
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <common.h>
+#include <efi.h>
+#include <elf.h>
+#include <asm/elf.h>
+
+efi_status_t _relocate(long ldbase, Elf64_Dyn *dyn, efi_handle_t image,
+ struct efi_system_table *systab)
+{
+ long relsz = 0, relent = 0;
+ Elf64_Rel *rel = 0;
+ unsigned long *addr;
+ int i;
+
+ for (i = 0; dyn[i].d_tag != DT_NULL; ++i) {
+ switch (dyn[i].d_tag) {
+ case DT_RELA:
+ rel = (Elf64_Rel *)
+ ((unsigned long)dyn[i].d_un.d_ptr + ldbase);
+ break;
+ case DT_RELASZ:
+ relsz = dyn[i].d_un.d_val;
+ break;
+ case DT_RELAENT:
+ relent = dyn[i].d_un.d_val;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (!rel && relent == 0)
+ return EFI_SUCCESS;
+
+ if (!rel || relent == 0)
+ return EFI_LOAD_ERROR;
+
+ while (relsz > 0) {
+ /* apply the relocs */
+ switch (ELF64_R_TYPE(rel->r_info)) {
+ case R_X86_64_NONE:
+ break;
+ case R_X86_64_RELATIVE:
+ addr = (unsigned long *)(ldbase + rel->r_offset);
+ *addr += ldbase;
+ break;
+ default:
+ break;
+ }
+ rel = (Elf64_Rel *)((char *)rel + relent);
+ relsz -= relent;
+ }
+
+ return EFI_SUCCESS;
+}