gnu-efi/gnuefi
Peter Jones 4f8b339fac Make ELF constructors and destructors work
This makes setup and teardown functions defined with
__attribute__((__constructor__) and __attribute__((__destructor__)) work
in normal circumstances in EFI binaries.

A couple of notes:
- it implements both the old-style .ctors/.dtors methods and the newer
  style .init_array/.fini_array ELF constructor and destructor arrays,
  processed in the order:
    .init_array[]
    .ctors[]
    efi_main()
    .dtors[]
    .fini_array[]
- Destructors will only be called if efi_main() exits using "return";
  any call to Exit() will still longjmp() past them.
- InitializeLib() has already been called before constructors run, so
  they don't need to call it (and neither does anything else.)  For
  compatibility, it has been altered so calling it more than once is
  safe.
- No attempt is made to handle any constructor or destructor with a
  prototype other than "void func(void);", but note that InitializeLib
  has been called, so LibImageHandle, ST, BS, and RT are set.
- The init_array/ctor/dtor/fini_array lists aren't the using the GNU
  "CONSTRUCTOR" output section command, so they don't start with a size.
- The lists are individually sorted during the link stage via
  SORT_BY_NAME() in the linker script.
- The default (empty) init_array/ctor/dtor/fini_array lists are padded
  out to 8-byte alignment with ".p2align 3, 0", and each list always has
  at least one ".long 0" at the end of it (even if it's completely
  empty).  As a result, they can have NULLs that need to be skipped.
  The sections they're in are mergeable, so the NULLs don't have to be
  exclusively at the end.
- The ia64 and mips64el arches have not been tested.

Signed-off-by: Peter Jones <pjones@redhat.com>
2023-03-28 08:59:41 -04:00
..
crt0-efi-aarch64.S Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
crt0-efi-arm.S Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
crt0-efi-ia32.S Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
crt0-efi-ia64.S Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
crt0-efi-loongarch64.S use jr instead of jirl 2022-07-07 15:16:10 +08:00
crt0-efi-mips64el.S Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
crt0-efi-riscv64.S riscv: Update SPDX license identifiers 2023-03-08 10:32:49 -05:00
crt0-efi-x86_64.S Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
elf_aarch64_efi.lds Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
elf_arm_efi.lds Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
elf_ia32_efi.lds Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
elf_ia32_fbsd_efi.lds Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
elf_ia64_efi.lds Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
elf_loongarch64_efi.lds Add support for LoongArch64 architecture 2021-12-30 15:39:47 +08:00
elf_mips64el_efi.lds Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
elf_riscv64_efi.lds Ensure objcopy sections are aligned 2023-03-09 19:52:44 +00:00
elf_x86_64_efi.lds Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
elf_x86_64_fbsd_efi.lds Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
Makefile gnuefi/Makefile uses a strange rule to create libgnuefi.a, which only works 2019-04-02 09:47:24 -04:00
reloc_aarch64.c Commit 3dd05c and subsequent ones introduced the use of the GNU 2016-03-25 13:32:54 -04:00
reloc_arm.c Commit 3dd05c and subsequent ones introduced the use of the GNU 2016-03-25 13:32:54 -04:00
reloc_ia32.c Commit 3dd05c and subsequent ones introduced the use of the GNU 2016-03-25 13:32:54 -04:00
reloc_ia64.S */*.S: add non-executable GNU stack marking on ELF-linux 2022-08-08 11:35:10 -04:00
reloc_loongarch64.c Add support for LoongArch64 architecture 2021-12-30 15:39:47 +08:00
reloc_mips64el.c Add support for 64 bit MIPS 2017-01-08 07:04:52 -05:00
reloc_riscv64.c riscv: Update SPDX license identifiers 2023-03-08 10:32:49 -05:00
reloc_x86_64.c Commit 3dd05c and subsequent ones introduced the use of the GNU 2016-03-25 13:32:54 -04:00