gnu-efi/apps
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
..
AllocPages.c Fix some types gcc doesn't like 2018-03-14 14:50:22 -04:00
bltgrid.c Fix a minor coverity complaint in some apps 2023-03-28 08:38:37 -04:00
ctors_fns.c Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
ctors_test.c Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
debughook.c Fix a sign error in the debughook example app 2018-03-14 14:50:23 -04:00
drv0_use.c Restore correct operation of BS driver test 2017-01-08 06:58:30 -05:00
drv0.c Restore correct operation of BS driver test 2017-01-08 06:58:30 -05:00
drv0.h Restore correct operation of BS driver test 2017-01-08 06:58:30 -05:00
exit.c add-Exit - Add Exit() library function which calls BS->Exit() 2017-02-17 16:30:28 -05:00
FreePages.c Fix some types gcc doesn't like 2018-03-14 14:50:22 -04:00
lfbgrid.c Fix a minor coverity complaint in some apps 2023-03-28 08:38:37 -04:00
Makefile Make ELF constructors and destructors work 2023-03-28 08:59:41 -04:00
modelist.c apps: simplify logical constraints 2021-06-23 22:53:26 +02:00
printenv.c The gnu-efi-3.0 toplevel subdirectory is really annoying. Kill it. 2014-11-25 10:09:50 -05:00
route80h.c Work around -Werror=maybe-uninitialized not being very bright. 2018-03-14 14:50:23 -04:00
setdbg.c Add debug helper applications 2018-03-14 14:50:23 -04:00
setjmp.c Do not include efisetjmp.h on efi.h 2019-05-15 05:32:24 +02:00
t2.c This -Wall -Wextra thing actually caught a real bug. 2016-03-03 16:55:26 -05:00
t3.c The gnu-efi-3.0 toplevel subdirectory is really annoying. Kill it. 2014-11-25 10:09:50 -05:00
t4.c This -Wall -Wextra thing actually caught a real bug. 2016-03-03 16:55:26 -05:00
t5.c The gnu-efi-3.0 toplevel subdirectory is really annoying. Kill it. 2014-11-25 10:09:50 -05:00
t6.c The gnu-efi-3.0 toplevel subdirectory is really annoying. Kill it. 2014-11-25 10:09:50 -05:00
t7.c This -Wall -Wextra thing actually caught a real bug. 2016-03-03 16:55:26 -05:00
t8.c The gnu-efi-3.0 toplevel subdirectory is really annoying. Kill it. 2014-11-25 10:09:50 -05:00
t.c The gnu-efi-3.0 toplevel subdirectory is really annoying. Kill it. 2014-11-25 10:09:50 -05:00
tcc.c apps/tcc: tcc marcked ok for non x86-64 archs 2017-03-10 16:02:03 -05:00
tpause.c The gnu-efi-3.0 toplevel subdirectory is really annoying. Kill it. 2014-11-25 10:09:50 -05:00
trivial.S */*.S: add non-executable GNU stack marking on ELF-linux 2022-08-08 11:35:10 -04:00
unsetdbg.c Add debug helper applications 2018-03-14 14:50:23 -04:00