[FREELDR]
authorDmitry Gorbachev <gorbachev@reactos.org>
Thu, 22 Sep 2011 06:06:51 +0000 (06:06 +0000)
committerDmitry Gorbachev <gorbachev@reactos.org>
Thu, 22 Sep 2011 06:06:51 +0000 (06:06 +0000)
Put uninitialized/zero-initialized data into .bss. Fill it with 0s at startup.

svn path=/trunk/; revision=53798

reactos/boot/freeldr/freeldr/CMakeLists.txt
reactos/boot/freeldr/freeldr/arch/i386/entry.S
reactos/boot/freeldr/freeldr/arch/i386/multiboot.S
reactos/boot/freeldr/freeldr/freeldr_i386.lnk

index 57a86a9..7851e56 100644 (file)
@@ -203,10 +203,6 @@ if(ARCH MATCHES i386 OR ARCH MATCHES amd64)
     list(APPEND SETUPLDR_SOURCE windows/setupldr.c)
 endif()
 
     list(APPEND SETUPLDR_SOURCE windows/setupldr.c)
 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})
 
 if(NOT MSVC)
 add_executable(setupldr_pe ${FREELDR_BASE_SOURCE} ${SETUPLDR_SOURCE})
 
 if(NOT MSVC)
index 61d44b0..d352f10 100644 (file)
@@ -70,11 +70,19 @@ _FrldrStartup:
     /* Initialize the idt */
     call _InitIdt
 
     /* Initialize the idt */
     call _InitIdt
 
-    /* Pass the command line to BootMain */
-#ifdef _USE_ML
+#ifndef _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
 
        /* GO! */
 #endif
 
        /* GO! */
index 72a40c4..d00333e 100644 (file)
@@ -58,7 +58,7 @@ MultibootHeader:
     /* load_addr */
     .long INITIAL_BASE
     /* load_end_addr */
     /* load_addr */
     .long INITIAL_BASE
     /* load_end_addr */
-    .long INITIAL_BASE + __bss_start__ - FREELDR_BASE
+    .long 0
     /* bss_end_addr */
     .long 0
     /* entry_addr */
     /* bss_end_addr */
     .long 0
     /* entry_addr */
@@ -98,17 +98,10 @@ mb3:
     /* Relocate itself to lower address */
     mov esi, INITIAL_BASE
     mov edi, FREELDR_BASE
     /* Relocate itself to lower address */
     mov esi, INITIAL_BASE
     mov edi, FREELDR_BASE
-    mov ecx, (offset __bss_start__ - FREELDR_BASE + 3)
+    mov ecx, offset __bss_start__ - FREELDR_BASE
     shr ecx, 2
     rep movsd
 
     shr ecx, 2
     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 */
     lgdt gdtptr
     mov ax, HEX(10)
     /* Load segment registers for real-address mode */
     lgdt gdtptr
     mov ax, HEX(10)
index 41a6da0..29997a4 100644 (file)
-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$*))
-    *(.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__ = . ;
+    *(SORT(.text*))
     *(.data)
     *(.data)
-    *(.data2)
-    *(SORT(.data$*))
+    *(SORT(.data*))
     *(.rdata)
     *(.rdata)
-    *(SORT(.rdata$*))
-    *(.eh_frame)
-    __data_end__ = . ;
+    *(SORT(.rdata*))
+  }
+
+  .bss :
+  {
     __bss_start__ = . ;
     *(.bss)
     *(COMMON)
     __bss_end__ = . ;
   }
     __bss_start__ = . ;
     *(.bss)
     *(COMMON)
     __bss_end__ = . ;
   }
-  /DISCARD/ :
+
+  /* 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) :
   {
   {
-    *(.drectve)
+    *(.debug_str)
   }
   }
-  .stab BLOCK(__section_alignment__) (NOLOAD) :
+  .debug_loc BLOCK(__section_alignment__) (NOLOAD) :
   {
   {
-    [ .stab ]
+    *(.debug_loc)
   }
   }
-  .stabstr BLOCK(__section_alignment__) (NOLOAD) :
+  .debug_macinfo BLOCK(__section_alignment__) (NOLOAD) :
   {
   {
-    [ .stabstr ]
+    *(.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/ :
+  {
+    *(*)
+  }
 }
 }
-