Browse Source

[linux] Add linux platform skeleton

Add makefiles, ld scripts and default config for linux platform for
both i386 and x86_64.

Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Piotr Jaroszyński 14 years ago
parent
commit
e84db1121b

+ 6
- 0
src/arch/i386/Makefile.linux View File

@@ -0,0 +1,6 @@
1
+LDSCRIPT = arch/i386/scripts/linux.lds
2
+
3
+SRCDIRS += arch/i386/core/linux
4
+
5
+MAKEDEPS += arch/x86/Makefile.linux
6
+include arch/x86/Makefile.linux

+ 101
- 0
src/arch/i386/scripts/linux.lds View File

@@ -0,0 +1,101 @@
1
+/* -*- sh -*- */
2
+
3
+/*
4
+ * Linker script for i386 Linux images
5
+ *
6
+ */
7
+
8
+OUTPUT_FORMAT ( "elf32-i386", "elf32-i386", "elf32-i386" )
9
+OUTPUT_ARCH ( i386 )
10
+
11
+ENTRY ( _start )
12
+
13
+SECTIONS {
14
+	_max_align = 32;
15
+
16
+	. = 0x08048000;
17
+
18
+	/*
19
+	 * The text section
20
+	 *
21
+	 */
22
+
23
+	. = ALIGN ( _max_align );
24
+	.text : {
25
+		_text = .;
26
+		*(.text)
27
+		*(.text.*)
28
+		_etext = .;
29
+	}
30
+
31
+	/*
32
+	 * The rodata section
33
+	 *
34
+	 */
35
+
36
+	. = ALIGN ( _max_align );
37
+	.rodata : {
38
+		_rodata = .;
39
+		*(.rodata)
40
+		*(.rodata.*)
41
+		_erodata = .;
42
+	}
43
+
44
+	/*
45
+	 * The data section
46
+	 *
47
+	 */
48
+
49
+	. = ALIGN ( _max_align );
50
+	.data : {
51
+		_data = .;
52
+		*(.data)
53
+		*(.data.*)
54
+		*(SORT(.tbl.*))		/* Various tables.  See include/tables.h */
55
+		_edata = .;
56
+	}
57
+
58
+	/*
59
+	 * The bss section
60
+	 *
61
+	 */
62
+
63
+	. = ALIGN ( _max_align );
64
+	.bss : {
65
+		_bss = .;
66
+		*(.bss)
67
+		*(.bss.*)
68
+		*(COMMON)
69
+		_ebss = .;
70
+	}
71
+
72
+	/*
73
+	 * Weak symbols that need zero values if not otherwise defined
74
+	 *
75
+	 */
76
+
77
+	.weak 0x0 : {
78
+		_weak = .;
79
+		*(.weak)
80
+		_eweak = .;
81
+	}
82
+	_assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" );
83
+
84
+	/*
85
+	 * Dispose of the comment and note sections to make the link map
86
+	 * easier to read
87
+	 *
88
+	 */
89
+
90
+	/DISCARD/ : {
91
+		*(.comment)
92
+		*(.comment.*)
93
+		*(.note)
94
+		*(.note.*)
95
+		*(.eh_frame)
96
+		*(.eh_frame.*)
97
+		*(.rel)
98
+		*(.rel.*)
99
+		*(.discard)
100
+	}
101
+}

+ 5
- 2
src/arch/x86/Makefile View File

@@ -5,5 +5,8 @@ INCDIRS		+= arch/x86/include
5 5
 # x86-specific directories containing source files
6 6
 #
7 7
 SRCDIRS		+= arch/x86/core
8
-SRCDIRS 	+= arch/x86/interface/efi
9
-SRCDIRS 	+= arch/x86/prefix
8
+SRCDIRS		+= arch/x86/interface/efi
9
+SRCDIRS		+= arch/x86/prefix
10
+
11
+# breaks building some of the linux-related objects
12
+CFLAGS		+= -Ulinux

+ 8
- 0
src/arch/x86/Makefile.linux View File

@@ -0,0 +1,8 @@
1
+MEDIA = linux
2
+
3
+INCDIRS += arch/x86/include/linux
4
+SRCDIRS += arch/x86/core/linux
5
+
6
+$(BIN)/%.linux : $(BIN)/%.linux.tmp
7
+	$(QM)$(ECHO) "  [FINISH] $@"
8
+	$(Q)cp -p $< $@

+ 6
- 0
src/arch/x86_64/Makefile.linux View File

@@ -0,0 +1,6 @@
1
+LDSCRIPT = arch/x86_64/scripts/linux.lds
2
+
3
+SRCDIRS += arch/x86_64/core/linux
4
+
5
+MAKEDEPS += arch/x86/Makefile.linux
6
+include arch/x86/Makefile.linux

+ 101
- 0
src/arch/x86_64/scripts/linux.lds View File

@@ -0,0 +1,101 @@
1
+/* -*- sh -*- */
2
+
3
+/*
4
+ * Linker script for x86_64 Linux images
5
+ *
6
+ */
7
+
8
+OUTPUT_FORMAT ( "elf64-x86-64", "elf64-x86-64", "elf64-x86-64" )
9
+OUTPUT_ARCH ( i386:x86-64 )
10
+
11
+ENTRY ( _start )
12
+
13
+SECTIONS {
14
+	_max_align = 32;
15
+
16
+	. = 0x400000;
17
+
18
+	/*
19
+	 * The text section
20
+	 *
21
+	 */
22
+
23
+	. = ALIGN ( _max_align );
24
+	.text : {
25
+		_text = .;
26
+		*(.text)
27
+		*(.text.*)
28
+		_etext = .;
29
+	}
30
+
31
+	/*
32
+	 * The rodata section
33
+	 *
34
+	 */
35
+
36
+	. = ALIGN ( _max_align );
37
+	.rodata : {
38
+		_rodata = .;
39
+		*(.rodata)
40
+		*(.rodata.*)
41
+		_erodata = .;
42
+	}
43
+
44
+	/*
45
+	 * The data section
46
+	 *
47
+	 */
48
+
49
+	. = ALIGN ( _max_align );
50
+	.data : {
51
+		_data = .;
52
+		*(.data)
53
+		*(.data.*)
54
+		*(SORT(.tbl.*))		/* Various tables.  See include/tables.h */
55
+		_edata = .;
56
+	}
57
+
58
+	/*
59
+	 * The bss section
60
+	 *
61
+	 */
62
+
63
+	. = ALIGN ( _max_align );
64
+	.bss : {
65
+		_bss = .;
66
+		*(.bss)
67
+		*(.bss.*)
68
+		*(COMMON)
69
+		_ebss = .;
70
+	}
71
+
72
+	/*
73
+	 * Weak symbols that need zero values if not otherwise defined
74
+	 *
75
+	 */
76
+
77
+	.weak 0x0 : {
78
+		_weak = .;
79
+		*(.weak)
80
+		_eweak = .;
81
+	}
82
+	_assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" );
83
+
84
+	/*
85
+	 * Dispose of the comment and note sections to make the link map
86
+	 * easier to read
87
+	 *
88
+	 */
89
+
90
+	/DISCARD/ : {
91
+		*(.comment)
92
+		*(.comment.*)
93
+		*(.note)
94
+		*(.note.*)
95
+		*(.eh_frame)
96
+		*(.eh_frame.*)
97
+		*(.rel)
98
+		*(.rel.*)
99
+		*(.discard)
100
+	}
101
+}

+ 12
- 0
src/config/defaults/linux.h View File

@@ -0,0 +1,12 @@
1
+#ifndef CONFIG_DEFAULTS_LINUX_H
2
+#define CONFIG_DEFAULTS_LINUX_H
3
+
4
+/** @file
5
+ *
6
+ * Configuration defaults for linux
7
+ *
8
+ */
9
+
10
+#define IMAGE_SCRIPT
11
+
12
+#endif /* CONFIG_DEFAULTS_LINUX_H */

Loading…
Cancel
Save