Re: [kvm-unit-tests PATCH v2 03/17] x86 UEFI: Copy code from GNU-EFI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 27, 2021 at 03:12:08AM +0000, Zixuan Wang wrote:
> To build x86 test cases with UEFI, we need to borrow some source
> code from GNU-EFI, which includes the initialization code and linker
> scripts. This commit only copies the source code, without any
> modification. These source code files are not used by KVM-Unit-Tests
> in this commit.
> 
> The following source code is copied from GNU-EFI:
>    1. x86/efi/elf_x86_64_efi.lds
>    2. x86/efi/reloc_x86_64.c
>    3. x86/efi/crt0-efi-x86_64.S
> 
> We put these EFI-related files under a new dir `x86/efi` because:
>    1. EFI-related code is easy to find
>    2. EFI-related code is separated from the original code in `x86/`
>    3. EFI-related code can still reuse the Makefile and test case code
>       in its parent dir `x86/`
> 
> GNU-EFI repo and version:
>    GIT URL: https://git.code.sf.net/p/gnu-efi/code
>    Commit ID: 4fe83e102674
>    Website: https://sourceforge.net/p/gnu-efi/code/ci/4fe83e/tree/
> 
> Co-developed-by: Varad Gautam <varad.gautam@xxxxxxxx>
> Signed-off-by: Varad Gautam <varad.gautam@xxxxxxxx>
> Signed-off-by: Zixuan Wang <zixuanwang@xxxxxxxxxx>
> ---
>  x86/efi/README.md          |  25 ++++++++++
>  x86/efi/crt0-efi-x86_64.S  |  79 +++++++++++++++++++++++++++++
>  x86/efi/elf_x86_64_efi.lds |  77 ++++++++++++++++++++++++++++
>  x86/efi/reloc_x86_64.c     | 100 +++++++++++++++++++++++++++++++++++++
>  4 files changed, 281 insertions(+)
>  create mode 100644 x86/efi/README.md
>  create mode 100644 x86/efi/crt0-efi-x86_64.S
>  create mode 100644 x86/efi/elf_x86_64_efi.lds
>  create mode 100644 x86/efi/reloc_x86_64.c
> 
> diff --git a/x86/efi/README.md b/x86/efi/README.md
> new file mode 100644
> index 0000000..256ef8c
> --- /dev/null
> +++ b/x86/efi/README.md
> @@ -0,0 +1,25 @@
> +# EFI Startup Code and Linker Script
> +
> +This dir contains source code and linker script copied from
> +[GNU-EFI](https://sourceforge.net/projects/gnu-efi/):
> +   - crt0-efi-x86_64.S: startup code of an EFI application
> +   - elf_x86_64_efi.lds: linker script to build an EFI application
> +   - reloc_x86_64.c: position independent x86_64 ELF shared object relocator
> +
> +EFI application binaries should be relocatable as UEFI loads binaries to dynamic
> +runtime addresses. To build such relocatable binaries, GNU-EFI utilizes the
> +above-mentioned files in its build process:
> +
> +   1. build an ELF shared object and link it using linker script
> +      `elf_x86_64_efi.lds` to organize the sections in a way UEFI recognizes
> +   2. link the shared object with self-relocator `reloc_x86_64.c` that applies
> +      dynamic relocations that may be present in the shared object
> +   3. link the entry point code `crt0-efi-x86_64.S` that invokes self-relocator
> +      and then jumps to EFI application's `efi_main()` function
> +   4. convert the shared object to an EFI binary
> +
> +More details can be found in `GNU-EFI/README.gnuefi`, section "Building
> +Relocatable Binaries".
> +
> +KVM-Unit-Tests follows a similar build process, but does not link with GNU-EFI
> +library.

So, for AArch64, I also want to drop the gnu-efi dependency of my original
PoC. My second PoC, which I haven't finished, took things a bit further
than this does, though. I was integrating a PE/COFF header and linker
script changes directly into the kvm-unit-tests code rather than copying
these files over.

Thanks,
drew




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux