summaryrefslogtreecommitdiff
path: root/sos-code-article5/support/sos.lds
blob: 63aac701a8eaa6de3cff470ebc269acbfdd3dd1b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* Copyright (C) 2003, Thomas Petazzoni

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
   USA. 
*/

/* We generate binary in the ELF format */
OUTPUT_FORMAT("elf32-i386","elf32-i386","elf32-i386");

/* The entry point is _start (defined in boot.S) */
ENTRY(_start)

/* The architecture is i386 */
OUTPUT_ARCH("i386")

SECTIONS
{
    /* our kernel is loaded at 0x200000 */
    . = 0x200000;
    __b_load   = .;

    /* the multiboot header MUST come early enough in the output
       object file */
    .multiboot :
    {
        /* The multiboot section (containing the multiboot header)
           goes here */
	*(.multiboot);
	
	/*
	 * With the following line, we force this section to be
	 * allocated in the output file as soon as possible, no matter
	 * when the file containing the multiboot header (multiboot.S)
	 * is compiled. This is to conform to the multiboot spec, which
	 * says "The Multiboot header must be contained completely
	 * within the first 8192 bytes of the OS image, and must be
	 * longword (32-bit) aligned."
	 */
	LONG(0);
    }

    /* Defines a symbol '__b_kernel to mark the start of the kernel
       code/data */
    . = ALIGN(4096);
    __b_kernel = .;
  
    /* Beginning of the text section */
    .text ALIGN(4096) :
    {   
	/* This section includes the code */
        *(.text*)
	/* Defines the 'etext' and '_etext' at the end */
        PROVIDE(etext = .);
        PROVIDE(_etext = .);
    }

    /* Beginning of the data section */
    .data . :
    {   *(.data*) 
        PROVIDE(edata = .);
	PROVIDE(_edata = .);
    }

    /* Beginning of the read-only data section */
    .rodata . :
    {   *(.rodata*)
        PROVIDE(erodata = .);
        PROVIDE(_erodata = .);
    }
    /* We take note of the end of the data to load */
    __e_load = .;

    /* Beginning of the BSS section (global uninitialized data) */
    .bss SIZEOF(.rodata) + ADDR(.rodata) :
    {   *(.bss)
        *(COMMON)

	/* We put the stack of the bootstrap thread on a page
           boundary, because it can be un-allocated later */
	. = ALIGN(4096);
	*(.init_stack)

        PROVIDE(ebss = .);
	PROVIDE(_ebss = .);
    }

    /* We take note of the end of the kernel: this is where the GPFM
       will begin */
    __e_kernel = .;

    /* We don't care of the note, indent, comment, etc.. sections
       generated by gcc */
        /DISCARD/ :{
                *(.note*)
                *(.indent)
                *(.comment)
                *(.stab)
                *(.stabstr)
        }

}