freebsd-src/sys/conf/ldscript.powerpc64
Zhenlei Huang 3e76d05231 kernel: Add defination of .init_array and .fini_array for all other platforms
Currently these sections are not used but defined only for amd64 and
i386. Added them for all other platforms to keep all platforms in sync.
There should be no functional change.

This change is extracted from a bigger patch [1] of hselasky, with
additional fix for the order of .fini_array section.

1. https://reviews.freebsd.org/D40467

Obtained from:	hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45214
2024-09-02 12:26:48 +08:00

168 lines
4.5 KiB
Plaintext

OUTPUT_FORMAT("elf64-powerpc-freebsd", "elf64-powerpc-freebsd",
"elf64-powerpc-freebsd")
OUTPUT_ARCH(powerpc:common64)
ENTRY(__start)
SEARCH_DIR(/usr/lib);
PROVIDE (__stack = 0);
PHDRS
{
kernel PT_LOAD;
dynamic PT_DYNAMIC;
}
SECTIONS
{
/* Low-address wrapper for bootloaders (kexec/kboot) that can't parse ELF */
. = kernbase - 0x100;
.kboot : { *(.text.kboot) } :kernel
/* Read-only sections, merged into text segment: */
. = kernbase;
PROVIDE (begin = .);
.text :
{
*(.glink)
*(.text)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
} =0
_etext = .;
PROVIDE (etext = .);
/* Do not emit PT_INTERP section, which confuses some loaders (kexec-lite) */
/DISCARD/ : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.note.gnu.build-id : {
PROVIDE (__build_id_start = .);
*(.note.gnu.build-id)
PROVIDE (__build_id_end = .);
}
/* Do not emit any additional notes. */
/DISCARD/ : { *(.note.*) }
.rela.text :
{ *(.rela.text) *(.rela.gnu.linkonce.t*) }
.rela.data :
{ *(.rela.data) *(.rela.gnu.linkonce.d*) }
.rela.rodata :
{ *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
.rela.got : { *(.rela.got) }
.rela.got1 : { *(.rela.got1) }
.rela.got2 : { *(.rela.got2) }
.rela.ctors : { *(.rela.ctors) }
.rela.dtors : { *(.rela.dtors) }
.rela.init : { *(.rela.init) }
.rela.fini : { *(.rela.fini) }
.rela.bss : { *(.rela.bss) }
.rela.plt : { *(.rela.plt) }
.rela.sdata : { *(.rela.sdata) }
.rela.sbss : { *(.rela.sbss) }
.rela.sdata2 : { *(.rela.sdata2) }
.rela.sbss2 : { *(.rela.sbss2) }
.init : { *(.init) } =0
.fini : { *(.fini) } =0
.rodata : { *(.rodata) *(.gnu.linkonce.r*) }
.rodata1 : { *(.rodata1) }
.sdata2 : { *(.sdata2) }
.sbss2 : { *(.sbss2) }
/* Adjust the address for the data segment to the next page up. */
. = ALIGN(4096);
.data.read_frequently :
{
*(SORT_BY_ALIGNMENT(.data.read_frequently))
}
.data.read_mostly :
{
*(.data.read_mostly)
}
. = ALIGN(128);
.data.exclusive_cache_line :
{
*(.data.exclusive_cache_line)
}
. = ALIGN(128);
.data :
{
*(.data)
*(.gnu.linkonce.d*)
}
.data1 : { *(.data1) }
.toc1 : ALIGN(8) { *(.toc1) }
.opd : ALIGN(8) { KEEP (*(.opd)) }
.branch_lt : ALIGN(8) { *(.branch_lt) }
. = 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 (*(SORT_BY_INIT_PRIORITY(.fini_array.*)))
KEEP (*(.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.
The current compiler no longer needs this, but keep it around for 2.7.2 */
PROVIDE (_GOT2_START_ = .);
.got2 : { *(.got2) } :kernel
PROVIDE (__CTOR_LIST__ = .);
.ctors : { *(.ctors) }
PROVIDE (__CTOR_END__ = .);
PROVIDE (__DTOR_LIST__ = .);
.dtors : { *(.dtors) }
PROVIDE (__DTOR_END__ = .);
PROVIDE (_FIXUP_START_ = .);
.fixup : { *(.fixup) }
PROVIDE (_FIXUP_END_ = .);
PROVIDE (_GOT2_END_ = .);
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
we can shorten the on-disk segment size. */
.sdata : { *(.sdata) }
_edata = .;
PROVIDE (edata = .);
.sbss :
{
PROVIDE (__sbss_start = .);
*(.sbss)
*(.scommon)
*(.dynsbss)
PROVIDE (__sbss_end = .);
}
.plt : { *(.plt) }
.bss :
{
PROVIDE (__bss_start = .);
*(.dynbss)
*(.bss)
*(COMMON)
}
_end = . ;
PROVIDE (end = .);
/* Debug */
INCLUDE debuginfo.ldscript
.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
/DISCARD/ : { *(.note.GNU-stack) }
}