We need to search referenced section based on relocations symbol section to properly match end section symbols. For example on some binaries we can observe that init_array_end/fini_array_end might be "placed" in to the gap and since no section could be found for address the relocation would be skipped resulting in wrong ADRP imm after emitting new text resulting in binary sigsegv. Credits for the test to Vladislav Khmelevskii aka yota9.
13 lines
251 B
Plaintext
13 lines
251 B
Plaintext
SECTIONS {
|
|
.fini_array :
|
|
{
|
|
PROVIDE_HIDDEN (__fini_array_start = .);
|
|
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
|
|
PROVIDE_HIDDEN (__fini_array_end = .);
|
|
}
|
|
|
|
. = . + 128;
|
|
|
|
.text : { *(.text) }
|
|
}
|