diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ctors.S | 29 | ||||
-rw-r--r-- | lib/dpath.c | 5 | ||||
-rw-r--r-- | lib/entry.c | 42 | ||||
-rw-r--r-- | lib/error.c | 9 |
4 files changed, 45 insertions, 40 deletions
diff --git a/lib/ctors.S b/lib/ctors.S index 4a0c6ab..de3f231 100644 --- a/lib/ctors.S +++ b/lib/ctors.S @@ -8,38 +8,35 @@ * end/END definitions, and the fact that they're mergeable, they can also * have NULLs which aren't guaranteed to be at the end. */ - .section .init_array, "aM", @init_array + .section .init_array, "aw", @init_array .p2align 3, 0 - .globl _init_array -_init_array: + .globl __init_array_start +__init_array_start: .p2align 3, 0 - .globl _init_array_end -_init_array_end: - .long 0 - .section .ctors, "aM", @init_array + .globl __init_array_end +__init_array_end: + .section .ctors, "aw", @progbits .p2align 3, 0 .globl __CTOR_LIST__ __CTOR_LIST__: .p2align 3, 0 .globl __CTOR_END__ __CTOR_END__: - .long 0 - .section .dtors, "aM", @fini_array + .section .dtors, "aw", @progbits .p2align 3, 0 .globl __DTOR_LIST__ __DTOR_LIST__: .p2align 3, 0 .globl __DTOR_END__ __DTOR_END__: - .long 0 - .section .fini_array, "aM", @fini_array + .section .fini_array, "aw", @fini_array .p2align 3, 0 - .globl _fini_array -_fini_array: + .globl __fini_array_start +__fini_array_start: + .p2align 3, 0 + .globl __fini_array_end +__fini_array_end: .p2align 3, 0 - .globl _fini_array_end -_fini_array_end: - .long 0 #if defined(__ELF__) && defined(__linux__) .section .note.GNU-stack,"",%progbits diff --git a/lib/dpath.c b/lib/dpath.c index 5e079d6..63e4e70 100644 --- a/lib/dpath.c +++ b/lib/dpath.c @@ -1083,11 +1083,12 @@ _DevPathNodeUnknown ( * Entries hold "Type" and "SubType" for know values. * Special "SubType" 0 is used as default for known type with unknown subtype. */ -struct { +typedef struct { UINT8 Type; UINT8 SubType; VOID (*Function)(POOL_PRINT *, VOID *); -} DevPathTable[] = { +} DevPathTable_Type; +DevPathTable_Type DevPathTable[] = { { HARDWARE_DEVICE_PATH, HW_PCI_DP, _DevPathPci}, { HARDWARE_DEVICE_PATH, HW_PCCARD_DP, _DevPathPccard}, { HARDWARE_DEVICE_PATH, HW_MEMMAP_DP, _DevPathMemMap}, diff --git a/lib/entry.c b/lib/entry.c index d852608..3baa91d 100644 --- a/lib/entry.c +++ b/lib/entry.c @@ -7,45 +7,51 @@ #include <efi.h> #include <efilib.h> +typedef void (*funcp)(void); + /* * Note that these aren't the using the GNU "CONSTRUCTOR" output section * command, so they don't start with a size. Because of p2align and the * end/END definitions, and the fact that they're mergeable, they can also * have NULLs which aren't guaranteed to be at the end. */ -extern UINTN _init_array, _init_array_end; -extern UINTN __CTOR_LIST__, __CTOR_END__; -extern UINTN _fini_array, _fini_array_end; -extern UINTN __DTOR_LIST__, __DTOR_END__; - -typedef void (*funcp)(void); +extern funcp __init_array_start[], __init_array_end[]; +extern funcp __CTOR_LIST__[], __CTOR_END__[]; +extern funcp __fini_array_start[], __fini_array_end[]; +extern funcp __DTOR_LIST__[], __DTOR_END__[]; static void ctors(void) { - for (funcp *location = (void *)&_init_array; location < (funcp *)&_init_array_end; location++) { - funcp func = *location; - if (location != NULL) + size_t __init_array_length = __init_array_end - __init_array_start; + for (size_t i = 0; i < __init_array_length; i++) { + funcp func = __init_array_start[i]; + if (func != NULL) func(); } - for (funcp *location = (void *)&__CTOR_LIST__; location < (funcp *)&__CTOR_END__; location++) { - funcp func = *location; - if (location != NULL) + size_t __CTOR_length = __CTOR_END__ - __CTOR_LIST__; + for (size_t i = 0; i < __CTOR_length; i++) { + size_t current = __CTOR_length - i - 1; + funcp func = __CTOR_LIST__[current]; + if (func != NULL) func(); } } static void dtors(void) { - for (funcp *location = (void *)&__DTOR_LIST__; location < (funcp *)&__DTOR_END__; location++) { - funcp func = *location; - if (location != NULL) + size_t __DTOR_length = __DTOR_END__ - __DTOR_LIST__; + for (size_t i = 0; i < __DTOR_length; i++) { + funcp func = __DTOR_LIST__[i]; + if (func != NULL) func(); } - for (funcp *location = (void *)&_fini_array; location < (funcp *)&_fini_array_end; location++) { - funcp func = *location; - if (location != NULL) + size_t __fini_array_length = __fini_array_end - __fini_array_start; + for (size_t i = 0; i < __fini_array_length; i++) { + size_t current = __fini_array_length - i - 1; + funcp func = __fini_array_start[current]; + if (func != NULL) func(); } } diff --git a/lib/error.c b/lib/error.c index 2399a06..9f3b230 100644 --- a/lib/error.c +++ b/lib/error.c @@ -18,10 +18,11 @@ Revision History #include "lib.h" -struct { - EFI_STATUS Code; - WCHAR *Desc; -} ErrorCodeTable[] = { +typedef struct { + EFI_STATUS Code; + WCHAR *Desc; +} ErrorCodeTable_Type; +ErrorCodeTable_Type ErrorCodeTable[] = { { EFI_SUCCESS, L"Success"}, { EFI_LOAD_ERROR, L"Load Error"}, { EFI_INVALID_PARAMETER, L"Invalid Parameter"}, |