reactos/boot/freeldr/freeldr/freeldr_i386.lds
Hermès Bélusca-Maïto ed83552229
[FREELDR] Introduce a MSVC "linker script" file that centralizes the commands for defining section-limit symbols, and the ordering and merging of PE sections, and the necessary CMake code to use it. (#1224)
As the MSVC linker alone doesn't permit such control, the file uses
ASM language (C can alternatively be used), together with extra linker
command-line switches.

It is pre-processed 3 times: first for generating the ASM code, second
for the C code and the third time for generating the linker response
file.

In our case, the ASM code defines the __bss_start__ and __bss_end__
symbols that allow us to find the limits of the .bss section (which is
by the way automatically appended to the .data section by the MSVC linker).
The C code is used to specify the list of linker switches that can be
passed through the `#pragma comment(linker, ...)' directive (the can be
alternatively specified in the linker response section).
Finally the linker response section contains all the linker switches
that cannot be specified with the `#pragma comment(linker, ...)'
directive.

Using all this we can recycle the BSS initialization code, that has been
written originally for GCC only, also for the MSVC builds.

Also, remove the outdated .text16 section merging.
2019-01-27 00:51:25 +01:00

184 lines
3.9 KiB
Plaintext

SECTIONS
{
.text __image_base__ + __section_alignment__ :
{
*(.text)
*(SORT(.text*))
*(INIT)
*(SORT(INIT*))
*(.data)
*(SORT(.data*))
*(.rdata)
*(SORT(.rdata*))
}
/*
* LD needs an explicit .edata block to make the binary correctly export
* symbols, otherwise, if .edata is merged with another section (e.g. .rdata)
* the exports are not exported!
*/
.edata BLOCK(__file_alignment__) :
{
*(.edata)
}
.bss :
{
__bss_start__ = . ;
*(.bss)
*(COMMON)
__bss_end__ = . ;
}
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section. Unlike other targets that fake this by putting the
section VMA at 0, the PE format will not allow it. */
/* DWARF 1.1 and DWARF 2. */
.debug_aranges BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_aranges)
}
.zdebug_aranges BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_aranges)
}
.debug_pubnames BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_pubnames)
}
.zdebug_pubnames BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_pubnames)
}
.debug_pubtypes BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_pubtypes)
}
.zdebug_pubtypes BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_pubtypes)
}
/* DWARF 2. */
.debug_info BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_info .gnu.linkonce.wi.*)
}
.zdebug_info BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_info .zdebug.gnu.linkonce.wi.*)
}
.debug_abbrev BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_abbrev)
}
.zdebug_abbrev BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_abbrev)
}
.debug_line BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_line)
}
.zdebug_line BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_line)
}
.debug_frame BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_frame*)
}
.zdebug_frame BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_frame*)
}
.debug_str BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_str)
}
.zdebug_str BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_str)
}
.debug_loc BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_loc)
}
.zdebug_loc BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_loc)
}
.debug_macinfo BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_macinfo)
}
.zdebug_macinfo BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_macinfo)
}
/* SGI/MIPS DWARF 2 extensions. */
.debug_weaknames BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_weaknames)
}
.zdebug_weaknames BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_weaknames)
}
.debug_funcnames BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_funcnames)
}
.zdebug_funcnames BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_funcnames)
}
.debug_typenames BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_typenames)
}
.zdebug_typenames BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_typenames)
}
.debug_varnames BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_varnames)
}
.zdebug_varnames BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_varnames)
}
.debug_macro BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_macro)
}
.zdebug_macro BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_macro)
}
/* DWARF 3. */
.debug_ranges BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_ranges)
}
.zdebug_ranges BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_ranges)
}
/* DWARF 4. */
.debug_types BLOCK(__section_alignment__) (NOLOAD) :
{
*(.debug_types .gnu.linkonce.wt.*)
}
.zdebug_types BLOCK(__section_alignment__) (NOLOAD) :
{
*(.zdebug_types .gnu.linkonce.wt.*)
}
/DISCARD/ :
{
*(*)
}
}