mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 13:26:17 +00:00
[FREELDR]
Put uninitialized/zero-initialized data into .bss. Fill it with 0s at startup. svn path=/trunk/; revision=53798
This commit is contained in:
parent
7931e63ab8
commit
719a1ff1cf
4 changed files with 101 additions and 59 deletions
|
@ -203,10 +203,6 @@ if(ARCH MATCHES i386 OR ARCH MATCHES amd64)
|
||||||
list(APPEND SETUPLDR_SOURCE windows/setupldr.c)
|
list(APPEND SETUPLDR_SOURCE windows/setupldr.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT MSVC)
|
|
||||||
set_source_files_properties(${SETUPLDR_SOURCE} PROPERTIES COMPILE_FLAGS "-ffreestanding -fno-builtin -fno-inline -fno-zero-initialized-in-bss")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable(setupldr_pe ${FREELDR_BASE_SOURCE} ${SETUPLDR_SOURCE})
|
add_executable(setupldr_pe ${FREELDR_BASE_SOURCE} ${SETUPLDR_SOURCE})
|
||||||
|
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
|
|
|
@ -70,11 +70,19 @@ _FrldrStartup:
|
||||||
/* Initialize the idt */
|
/* Initialize the idt */
|
||||||
call _InitIdt
|
call _InitIdt
|
||||||
|
|
||||||
/* Pass the command line to BootMain */
|
#ifndef _USE_ML
|
||||||
#ifdef _USE_ML
|
/* Clean out bss */
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
#else
|
mov edi, offset __bss_start__
|
||||||
|
mov ecx, offset __bss_end__ + 3
|
||||||
|
sub ecx, edi
|
||||||
|
shr ecx, 2
|
||||||
|
rep stosd
|
||||||
|
|
||||||
|
/* Pass the command line to BootMain */
|
||||||
mov eax, offset cmdline
|
mov eax, offset cmdline
|
||||||
|
#else
|
||||||
|
xor eax, eax
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* GO! */
|
/* GO! */
|
||||||
|
|
|
@ -58,7 +58,7 @@ MultibootHeader:
|
||||||
/* load_addr */
|
/* load_addr */
|
||||||
.long INITIAL_BASE
|
.long INITIAL_BASE
|
||||||
/* load_end_addr */
|
/* load_end_addr */
|
||||||
.long INITIAL_BASE + __bss_start__ - FREELDR_BASE
|
.long 0
|
||||||
/* bss_end_addr */
|
/* bss_end_addr */
|
||||||
.long 0
|
.long 0
|
||||||
/* entry_addr */
|
/* entry_addr */
|
||||||
|
@ -98,17 +98,10 @@ mb3:
|
||||||
/* Relocate itself to lower address */
|
/* Relocate itself to lower address */
|
||||||
mov esi, INITIAL_BASE
|
mov esi, INITIAL_BASE
|
||||||
mov edi, FREELDR_BASE
|
mov edi, FREELDR_BASE
|
||||||
mov ecx, (offset __bss_start__ - FREELDR_BASE + 3)
|
mov ecx, offset __bss_start__ - FREELDR_BASE
|
||||||
shr ecx, 2
|
shr ecx, 2
|
||||||
rep movsd
|
rep movsd
|
||||||
|
|
||||||
/* Clean out bss */
|
|
||||||
xor eax, eax
|
|
||||||
mov ecx, offset __bss_end__ + 3
|
|
||||||
sub ecx, offset __bss_start__
|
|
||||||
shr ecx, 2
|
|
||||||
rep stosd
|
|
||||||
|
|
||||||
/* Load segment registers for real-address mode */
|
/* Load segment registers for real-address mode */
|
||||||
lgdt gdtptr
|
lgdt gdtptr
|
||||||
mov ax, HEX(10)
|
mov ax, HEX(10)
|
||||||
|
|
|
@ -1,58 +1,103 @@
|
||||||
OUTPUT_FORMAT(pei-i386)
|
|
||||||
ENTRY(_mainCRTStartup)
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
.text __image_base__ + __section_alignment__ :
|
.text __image_base__ + __section_alignment__ :
|
||||||
{
|
{
|
||||||
__text_start__ = .;
|
|
||||||
*(.init)
|
|
||||||
*(.text)
|
*(.text)
|
||||||
*(SORT(.text$*))
|
*(SORT(.text*))
|
||||||
*(.glue_7t)
|
|
||||||
*(.glue_7)
|
|
||||||
___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
|
|
||||||
LONG (-1); *(.ctors); *(.ctor); LONG (0);
|
|
||||||
___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
|
|
||||||
LONG (-1); *(.dtors); *(.dtor); LONG (0);
|
|
||||||
*(.fini)
|
|
||||||
/* ??? Why is .gcc_exc here? */
|
|
||||||
*(.gcc_exc)
|
|
||||||
__text_end__ = .;
|
|
||||||
*(.gcc_except_table)
|
|
||||||
}
|
|
||||||
init BLOCK(__section_alignment__) :
|
|
||||||
{
|
|
||||||
__init_start__ = . ;
|
|
||||||
*(init)
|
|
||||||
__init_end__ = . ;
|
|
||||||
}
|
|
||||||
.data BLOCK(__section_alignment__) :
|
|
||||||
{
|
|
||||||
__data_start__ = . ;
|
|
||||||
*(.data)
|
*(.data)
|
||||||
*(.data2)
|
*(SORT(.data*))
|
||||||
*(SORT(.data$*))
|
|
||||||
*(.rdata)
|
*(.rdata)
|
||||||
*(SORT(.rdata$*))
|
*(SORT(.rdata*))
|
||||||
*(.eh_frame)
|
}
|
||||||
__data_end__ = . ;
|
|
||||||
|
.bss :
|
||||||
|
{
|
||||||
__bss_start__ = . ;
|
__bss_start__ = . ;
|
||||||
*(.bss)
|
*(.bss)
|
||||||
*(COMMON)
|
*(COMMON)
|
||||||
__bss_end__ = . ;
|
__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)
|
||||||
|
}
|
||||||
|
.debug_pubnames BLOCK(__section_alignment__) (NOLOAD) :
|
||||||
|
{
|
||||||
|
*(.debug_pubnames)
|
||||||
|
}
|
||||||
|
.debug_pubtypes BLOCK(__section_alignment__) (NOLOAD) :
|
||||||
|
{
|
||||||
|
*(.debug_pubtypes)
|
||||||
|
}
|
||||||
|
/* DWARF 2. */
|
||||||
|
.debug_info BLOCK(__section_alignment__) (NOLOAD) :
|
||||||
|
{
|
||||||
|
*(.debug_info) *(.gnu.linkonce.wi.*)
|
||||||
|
}
|
||||||
|
.debug_abbrev BLOCK(__section_alignment__) (NOLOAD) :
|
||||||
|
{
|
||||||
|
*(.debug_abbrev)
|
||||||
|
}
|
||||||
|
.debug_line BLOCK(__section_alignment__) (NOLOAD) :
|
||||||
|
{
|
||||||
|
*(.debug_line)
|
||||||
|
}
|
||||||
|
.debug_frame BLOCK(__section_alignment__) (NOLOAD) :
|
||||||
|
{
|
||||||
|
*(.debug_frame*)
|
||||||
|
}
|
||||||
|
.debug_str BLOCK(__section_alignment__) (NOLOAD) :
|
||||||
|
{
|
||||||
|
*(.debug_str)
|
||||||
|
}
|
||||||
|
.debug_loc BLOCK(__section_alignment__) (NOLOAD) :
|
||||||
|
{
|
||||||
|
*(.debug_loc)
|
||||||
|
}
|
||||||
|
.debug_macinfo BLOCK(__section_alignment__) (NOLOAD) :
|
||||||
|
{
|
||||||
|
*(.debug_macinfo)
|
||||||
|
}
|
||||||
|
/* SGI/MIPS DWARF 2 extensions. */
|
||||||
|
.debug_weaknames BLOCK(__section_alignment__) (NOLOAD) :
|
||||||
|
{
|
||||||
|
*(.debug_weaknames)
|
||||||
|
}
|
||||||
|
.debug_funcnames BLOCK(__section_alignment__) (NOLOAD) :
|
||||||
|
{
|
||||||
|
*(.debug_funcnames)
|
||||||
|
}
|
||||||
|
.debug_typenames BLOCK(__section_alignment__) (NOLOAD) :
|
||||||
|
{
|
||||||
|
*(.debug_typenames)
|
||||||
|
}
|
||||||
|
.debug_varnames BLOCK(__section_alignment__) (NOLOAD) :
|
||||||
|
{
|
||||||
|
*(.debug_varnames)
|
||||||
|
}
|
||||||
|
.debug_macro BLOCK(__section_alignment__) (NOLOAD) :
|
||||||
|
{
|
||||||
|
*(.debug_macro)
|
||||||
|
}
|
||||||
|
/* DWARF 3. */
|
||||||
|
.debug_ranges BLOCK(__section_alignment__) (NOLOAD) :
|
||||||
|
{
|
||||||
|
*(.debug_ranges)
|
||||||
|
}
|
||||||
|
/* DWARF 4. */
|
||||||
|
.debug_types BLOCK(__section_alignment__) (NOLOAD) :
|
||||||
|
{
|
||||||
|
*(.debug_types) *(.gnu.linkonce.wt.*)
|
||||||
|
}
|
||||||
|
|
||||||
/DISCARD/ :
|
/DISCARD/ :
|
||||||
{
|
{
|
||||||
*(.drectve)
|
*(*)
|
||||||
}
|
}
|
||||||
.stab BLOCK(__section_alignment__) (NOLOAD) :
|
|
||||||
{
|
|
||||||
[ .stab ]
|
|
||||||
}
|
|
||||||
.stabstr BLOCK(__section_alignment__) (NOLOAD) :
|
|
||||||
{
|
|
||||||
[ .stabstr ]
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue