ctors_dtors_priority_test.c 914 B

1234567891011121314151617181920212223242526272829
  1. #include <efi.h>
  2. #include <efilib.h>
  3. // 101 in init_array, 65434 in ctors
  4. static void __attribute__((constructor(101))) EFI_NO_TAIL_CALL ctors101() {
  5. Print(L"1) ctor with lower numbered priority \r\n");
  6. }
  7. // 65434 in init_array, 101 in ctors
  8. static void __attribute__((constructor(65434))) EFI_NO_TAIL_CALL ctors65434() {
  9. Print(L"2) ctor with higher numbered priority \r\n");
  10. }
  11. // 101 in fini_array, 65434 in dtors
  12. static void __attribute__((destructor(101))) EFI_NO_TAIL_CALL dtors101() {
  13. Print(L"4) dtor with lower numbered priority \r\n");
  14. }
  15. // 65434 in fini_array, 101 in dtors
  16. static void __attribute__((destructor(65434))) EFI_NO_TAIL_CALL dtors65434() {
  17. Print(L"3) dtor with higher numbered priority \r\n");
  18. }
  19. EFI_STATUS
  20. efi_main (EFI_HANDLE image EFI_UNUSED, EFI_SYSTEM_TABLE *systab EFI_UNUSED)
  21. {
  22. Print(L"Main function \r\n");
  23. return EFI_SUCCESS;
  24. }