001 /* Copyright (C) 2003, Thomas Petazzoni
002
003 This program is free software; you can redistribute it and/or
004 modify it under the terms of the GNU General Public License
005 as published by the Free Software Foundation; either version 2
006 of the License, or (at your option) any later version.
007
008 This program is distributed in the hope that it will be useful,
009 but WITHOUT ANY WARRANTY; without even the implied warranty of
010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
011 GNU General Public License for more details.
012
013 You should have received a copy of the GNU General Public License
014 along with this program; if not, write to the Free Software
015 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
016 USA.
017 */
018
019 /* We generate binary in the ELF format */
020 OUTPUT_FORMAT("elf32-i386","elf32-i386","elf32-i386");
021
022 /* The entry point is _start (defined in boot.S) */
023 ENTRY(_start)
024
025 /* The architecture is i386 */
026 OUTPUT_ARCH("i386")
027
028 SECTIONS
029 {
030 /* our kernel is loaded at 0x200000 */
031 . = 0x200000;
032 __b_load = .;
033
034 /* the multiboot header MUST come early enough in the output
035 object file */
036 .multiboot :
037 {
038 /* The multiboot section (containing the multiboot header)
039 goes here */
040 *(.multiboot);
041
042 /*
043 * With the following line, we force this section to be
044 * allocated in the output file as soon as possible, no matter
045 * when the file containing the multiboot header (multiboot.S)
046 * is compiled. This is to conform to the multiboot spec, which
047 * says "The Multiboot header must be contained completely
048 * within the first 8192 bytes of the OS image, and must be
049 * longword (32-bit) aligned."
050 */
051 LONG(0);
052 }
053
054 /* Defines a symbol '__b_kernel to mark the start of the kernel
055 code/data */
056 . = ALIGN(4096);
057 __b_kernel = .;
058
059 /* Beginning of the text section */
060 .text ALIGN(4096) :
061 {
062 /* This section includes the code */
063 *(.text*)
064 /* Defines the 'etext' and '_etext' at the end */
065 PROVIDE(etext = .);
066 PROVIDE(_etext = .);
067 }
068
069 /* Beginning of the data section */
070 .data . :
071 { *(.data*)
072 PROVIDE(edata = .);
073 PROVIDE(_edata = .);
074 }
075
076 /* Beginning of the read-only data section */
077 .rodata . :
078 { *(.rodata*)
079 *(.eh_frame*)
080
081 /* For articles 7.5 and later, it is better if the program
082 "files" are located on a 4kB boundary: this allows
083 binfmt_elf32 to share program pages between kernel and
084 user, alleviating the need to allocate new pages to copy the
085 user code */
086 . = ALIGN(4096);
087 *(.userprogs)
088
089 PROVIDE(erodata = .);
090 PROVIDE(_erodata = .);
091 }
092
093 /* We take note of the end of the data to load */
094 __e_load = .;
095
096 /* Beginning of the BSS section (global uninitialized data) */
097 .bss SIZEOF(.rodata) + ADDR(.rodata) :
098 { *(.bss)
099 *(COMMON)
100
101 /* We put the stack of the bootstrap thread on a page
102 boundary, because it can be un-allocated later */
103 . = ALIGN(4096);
104 *(.init_stack)
105
106 PROVIDE(ebss = .);
107 PROVIDE(_ebss = .);
108 }
109
110 /* We take note of the end of the kernel: this is where the GPFM
111 will begin */
112 __e_kernel = .;
113 }