summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCallum Farmer <gmbr3@opensuse.org>2023-05-07 16:31:32 +0100
committerCallum Farmer <gmbr3@opensuse.org>2023-05-07 16:43:20 +0100
commitba150f34d68e8ddea000bbe4cf64300aec5b80bf (patch)
tree02339eb14705872915543af83c573200d1235020
parente1efa4d70aa17627ee7f2e74e52d09163c9e2d8a (diff)
downloadgnu-efi-ba150f34d68e8ddea000bbe4cf64300aec5b80bf.tar.gz
Add test for ctors & dtors with a priority
Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
-rw-r--r--apps/Makefile2
-rw-r--r--apps/ctors_dtors_priority_test.c29
2 files changed, 30 insertions, 1 deletions
diff --git a/apps/Makefile b/apps/Makefile
index 6ebd438..424ee9d 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -64,7 +64,7 @@ TARGET_APPS = t.efi t2.efi t3.efi t4.efi t5.efi t6.efi \
route80h.efi drv0_use.efi AllocPages.efi exit.efi \
FreePages.efi setjmp.efi debughook.efi debughook.efi.debug \
bltgrid.efi lfbgrid.efi setdbg.efi unsetdbg.efi \
- ctors_test.efi
+ ctors_test.efi ctors_dtors_priority_test.efi
TARGET_BSDRIVERS = drv0.efi
TARGET_RTDRIVERS =
diff --git a/apps/ctors_dtors_priority_test.c b/apps/ctors_dtors_priority_test.c
new file mode 100644
index 0000000..0458c08
--- /dev/null
+++ b/apps/ctors_dtors_priority_test.c
@@ -0,0 +1,29 @@
+#include <efi.h>
+#include <efilib.h>
+
+// 101 in init_array, 65434 in ctors
+static void __attribute__((constructor(101))) ctors101() {
+ Print(L"1) ctor with lower numbered priority \r\n");
+}
+
+// 65434 in init_array, 101 in ctors
+static void __attribute__((constructor(65434))) ctors65434() {
+ Print(L"2) ctor with higher numbered priority \r\n");
+}
+
+// 101 in fini_array, 65434 in dtors
+static void __attribute__((destructor(101))) dtors101() {
+ Print(L"4) dtor with lower numbered priority \r\n");
+}
+
+// 65434 in fini_array, 101 in dtors
+static void __attribute__((destructor(65434))) dtors65434() {
+ Print(L"3) dtor with higher numbered priority \r\n");
+}
+
+EFI_STATUS
+efi_main (EFI_HANDLE image EFI_UNUSED, EFI_SYSTEM_TABLE *systab EFI_UNUSED)
+{
+ Print(L"Main function \r\n");
+ return EFI_SUCCESS;
+} \ No newline at end of file