summaryrefslogtreecommitdiff
path: root/gnuefi/crt0-efi-mips64el.S
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2023-03-28 13:28:40 +0100
committerNigel Croxon <ncroxon@redhat.com>2023-03-28 08:59:41 -0400
commit4f8b339facb471192e021fffd5db545a0fbddbc3 (patch)
tree578d91044f85a64c0323a4930629310154f874c5 /gnuefi/crt0-efi-mips64el.S
parent14899d899b230eff3e3ff41011405f742aad6724 (diff)
downloadgnu-efi-4f8b339facb471192e021fffd5db545a0fbddbc3.tar.gz
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>
Diffstat (limited to 'gnuefi/crt0-efi-mips64el.S')
-rw-r--r--gnuefi/crt0-efi-mips64el.S4
1 files changed, 2 insertions, 2 deletions
diff --git a/gnuefi/crt0-efi-mips64el.S b/gnuefi/crt0-efi-mips64el.S
index 4b2c1b2..cecabfb 100644
--- a/gnuefi/crt0-efi-mips64el.S
+++ b/gnuefi/crt0-efi-mips64el.S
@@ -172,8 +172,8 @@ _pc:
// a0: ImageHandle
ld $a0, 16($sp)
- // call efi_main
- dla $t9, efi_main
+ // call _start
+ dla $t9, _entry
jalr $t9
// a1: SystemTable
ld $a1, 24($sp)