-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlinker.ld
62 lines (60 loc) · 1.62 KB
/
linker.ld
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
/*
** File: boot_linker.ld
**
** Author: Schuyler Martin <[email protected]>
**
** Based on code from:
** http://dc0d32.blogspot.com/2010/06/real-mode-in-c-with-gcc-writing.html
**
** Description: Linker script to configure organization of boot sector using
** the compiled ELF files
*/
ENTRY(main)
/* Link to a flat binary format */
OUTPUT_FORMAT(binary)
SECTIONS
{
/*
** This is where the bootsector lives which has 510 bytes to play with.
** Initially this script placed the 2-byte boot loader signature at 0x7DFE
** (making the full 512 byte boot sector). But for whatever reason when I
** converted from the ELF format to a "flat" binary the boot signature
** would be placed in the first two bytes of the sector (0x0) and thus
** create an invalid boot sector (as well as pushing back the rest of the
** instructions back by 2 bytes)
*/
. = 0x7C00;
.text : AT(0x7C00)
{
_TEXT_BEGIN = .;
/* boot loader loads other sections of the OS into memory */
bin/boot.o (.text);
/*
** 0x7C00 + 512 = 0x7E00
** This is where we can work before the 1mb barrier (and where ever
** video memory starts for CGA systems)
*/
*(.text);
_TEXT_END = .;
}
.data : {
_DATA_BEGIN = .;
*(.data);
*(.rodata);
_DATA_END = .;
}
.bss : {
_BSS_BEGIN = .;
*(.bss);
_BSS_END = .;
}
/* Save space. Memory is expensive in 1984. */
/DISCARD/ :
{
*(.note*);
*(.iplt*);
*(.igot*);
*(.rel*);
*(.comment);
}
}