diff --git a/sys/conf/ldscript.amd64 b/sys/conf/ldscript.amd64 --- a/sys/conf/ldscript.amd64 +++ b/sys/conf/ldscript.amd64 @@ -94,7 +94,7 @@ .init_array : { PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*))) KEEP (*(.init_array)) PROVIDE_HIDDEN (__init_array_end = .); } @@ -102,7 +102,7 @@ { PROVIDE_HIDDEN (__fini_array_start = .); KEEP (*(.fini_array)) - KEEP (*(SORT(.fini_array.*))) + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*))) PROVIDE_HIDDEN (__fini_array_end = .); } _start_ctors = .; diff --git a/sys/conf/ldscript.arm b/sys/conf/ldscript.arm --- a/sys/conf/ldscript.arm +++ b/sys/conf/ldscript.arm @@ -84,6 +84,20 @@ } .data1 : { *(.data1) } . = ALIGN(32 / 8); + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + } + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(.fini_array)) + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*))) + PROVIDE_HIDDEN (__fini_array_end = .); + } _start_ctors = .; PROVIDE (start_ctors = .); .ctors : diff --git a/sys/conf/ldscript.arm64 b/sys/conf/ldscript.arm64 --- a/sys/conf/ldscript.arm64 +++ b/sys/conf/ldscript.arm64 @@ -99,6 +99,20 @@ . = ALIGN(128); .data1 : { *(.data1) } . = ALIGN(32 / 8); + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + } + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(.fini_array)) + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*))) + PROVIDE_HIDDEN (__fini_array_end = .); + } _start_ctors = .; PROVIDE (start_ctors = .); .ctors : diff --git a/sys/conf/ldscript.i386 b/sys/conf/ldscript.i386 --- a/sys/conf/ldscript.i386 +++ b/sys/conf/ldscript.i386 @@ -88,7 +88,7 @@ .init_array : { PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*))) KEEP (*(.init_array)) PROVIDE_HIDDEN (__init_array_end = .); } @@ -96,7 +96,7 @@ { PROVIDE_HIDDEN (__fini_array_start = .); KEEP (*(.fini_array)) - KEEP (*(SORT(.fini_array.*))) + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*))) PROVIDE_HIDDEN (__fini_array_end = .); } _start_ctors = .; diff --git a/sys/conf/ldscript.powerpc b/sys/conf/ldscript.powerpc --- a/sys/conf/ldscript.powerpc +++ b/sys/conf/ldscript.powerpc @@ -80,8 +80,20 @@ . = ALIGN(4096); .got : { *(.got) } .got.plt : { *(.got.plt) } - - + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + } + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(.fini_array)) + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*))) + PROVIDE_HIDDEN (__fini_array_end = .); + } .dynamic : { *(.dynamic) } :kernel :dynamic /* Put .ctors and .dtors next to the .got2 section, so that the pointers get relocated with -mrelocatable. Also put in the .fixup pointers. diff --git a/sys/conf/ldscript.powerpc64 b/sys/conf/ldscript.powerpc64 --- a/sys/conf/ldscript.powerpc64 +++ b/sys/conf/ldscript.powerpc64 @@ -106,7 +106,20 @@ . = ALIGN(4096); .got : ALIGN(8) { __tocbase = .; *(.got) } .toc : ALIGN(8) { *(.toc) } - + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + } + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(.fini_array)) + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*))) + PROVIDE_HIDDEN (__fini_array_end = .); + } .dynamic : { *(.dynamic) } :kernel :dynamic /* Put .ctors and .dtors next to the .got2 section, so that the pointers get relocated with -mrelocatable. Also put in the .fixup pointers. diff --git a/sys/conf/ldscript.powerpc64le b/sys/conf/ldscript.powerpc64le --- a/sys/conf/ldscript.powerpc64le +++ b/sys/conf/ldscript.powerpc64le @@ -105,7 +105,20 @@ . = ALIGN(4096); .got : ALIGN(8) { __tocbase = .; *(.got) } .toc : ALIGN(8) { *(.toc) } - + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + } + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(.fini_array)) + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*))) + PROVIDE_HIDDEN (__fini_array_end = .); + } .dynamic : { *(.dynamic) } :text :dynamic /* Put .ctors and .dtors next to the .got2 section, so that the pointers get relocated with -mrelocatable. Also put in the .fixup pointers. diff --git a/sys/conf/ldscript.powerpcspe b/sys/conf/ldscript.powerpcspe --- a/sys/conf/ldscript.powerpcspe +++ b/sys/conf/ldscript.powerpcspe @@ -81,8 +81,20 @@ . = ALIGN(4096); .got : { *(.got) } .got.plt : { *(.got.plt) } - - + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + } + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(.fini_array)) + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*))) + PROVIDE_HIDDEN (__fini_array_end = .); + } .dynamic : { *(.dynamic) } :kernel :dynamic /* Put .ctors and .dtors next to the .got2 section, so that the pointers get relocated with -mrelocatable. Also put in the .fixup pointers. diff --git a/sys/conf/ldscript.riscv b/sys/conf/ldscript.riscv --- a/sys/conf/ldscript.riscv +++ b/sys/conf/ldscript.riscv @@ -72,6 +72,20 @@ } .data1 : { *(.data1) } . = ALIGN(32 / 8); + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + } + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(.fini_array)) + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*))) + PROVIDE_HIDDEN (__fini_array_end = .); + } _start_ctors = .; PROVIDE (start_ctors = .); .ctors :