Skip to content

Instantly share code, notes, and snippets.

@alexshpilkin
Created August 9, 2013 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexshpilkin/6196039 to your computer and use it in GitHub Desktop.
Save alexshpilkin/6196039 to your computer and use it in GitHub Desktop.
Linking a higher half kernel
ENTRY(start)
OUTPUT_FORMAT(elf64-x86-64)
LD_FEATURE("SANE_EXPR")
SECTIONS
{
. = 0x0100000;
_init = .;
.header : {
/* LONG(0) */
*(.header)
}
.text32 : {
*.o32(.text.hot .text.hot.*)
*.o32(.text.unlikely .text.unlikely.*)
*.o32(.text .text.* .gnu.linkonce.t.*)
}
.data32 : {
*.o32(.rodata .rodata.* .gnu.linkonce.r.*) *.o32(.rodata1)
*.o32(.data .data.*) *.o32(.data1)
}
.bss32 (NOLOAD) : {
_bss32 = .;
*.o32(.bss .bss.* .gnu.linkonce.b.*) *.o32(COMMON)
_ebss32 = .;
}
_lbss32 = SIZEOF(.bss32);
.text64 : {
*.o64(.text.hot .text.hot.*)
*.o64(.text.unlikely .text.unlikely.*)
*.o64(.text .text.* .gnu.linkonce.t.*)
}
.data64 : {
*.o64(.rodata .rodata.* .gnu.linkonce.r.*) *.o64(.rodata1)
*.o64(.data .data.*) *.o64(.data1)
}
.bss64 (NOLOAD) : {
_bss64 = .;
*.o64(.bss .bss.* .gnu.linkonce.b.*) *.o64(COMMON)
_ebss64 = .;
}
_lbss64 = SIZEOF(.bss64);
. = ALIGN(0x200000);
_einit = .;
. = 0xFFFFFFFF00000000;
_vma = .;
.text : AT(ADDR(.text) - _vma + _einit) ALIGN(4096) {
_text = .;
*(.text.hot .text.hot.*)
*(.text.unlikely .text.unlikely.*)
*(.text .text.* .gnu.linkonce.t.*)
_etext = .;
}
.data : AT(ADDR(.data) - _vma + _einit) ALIGN(4096) {
_data = .;
*(.rodata .rodata.* .gnu.linkonce.r.*) *(.rodata1)
*(.data .data.*) *(.data1)
_edata = .;
}
.bss : AT(ADDR(.bss) - _vma + _einit) ALIGN(4096) {
_bss = .;
*(.bss .bss.* .gnu.linkonce.b.*) *(COMMON)
_ebss = .;
_end = .;
}
/DISCARD/ : {
*(.note.GNU-stack)
*(.eh_frame)
*(.gnu.lto_*)
}
}
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x100020
Start of program headers: 64 (bytes into file)
Start of section headers: 8736 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 2
Size of section headers: 64 (bytes)
Number of section headers: 13
Section header string table index: 10
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .header PROGBITS 0000000000100000 00002170
000000000000000c 0000000000000000 0 0 4
[ 2] .comment PROGBITS 0000000000000000 0000217c
0000000000000029 0000000000000001 MS 0 0 1
[ 3] .text32 PROGBITS 0000000000100000 00001000
00000000000005dc 0000000000000000 AX 0 0 16
[ 4] .data32 PROGBITS 00000000001005e0 000015e0
0000000000000404 0000000000000000 WA 0 0 32
[ 5] .bss32 NOBITS 00000000001009e4 000019e4
0000000000000012 0000000000000000 WA 0 0 4
[ 6] .text64 PROGBITS 0000000000100a00 00001a00
0000000000000577 0000000000000000 AX 0 0 16
[ 7] .data64 PROGBITS 0000000000100f80 00001f80
00000000000001f0 0000000000000000 WA 0 0 32
[ 8] .bss64 NOBITS 0000000000102000 00002170
0000000000041412 0000000000000000 WA 0 0 4096
[ 9] .gnu_debuglink PROGBITS 0000000000000000 000021a5
0000000000000010 0000000000000000 0 0 1
[10] .shstrtab STRTAB 0000000000000000 000021b5
0000000000000069 0000000000000000 0 0 1
[11] .symtab SYMTAB 0000000000000000 00002560
00000000000006c0 0000000000000018 12 46 8
[12] .strtab STRTAB 0000000000000000 00002c20
0000000000000130 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), l (large)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
There are no section groups in this file.
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000001000 0x0000000000100000 0x0000000000100000
0x00000000000009e4 0x00000000000009f6 RWE 1000
LOAD 0x0000000000001a00 0x0000000000100a00 0x0000000000100a00
0x0000000000000770 0x0000000000042a12 RWE 1000
Section to Segment mapping:
Segment Sections...
00 .text32 .data32 .bss32
01 .text64 .data64 .bss64
There is no dynamic section in this file.
There are no relocations in this file.
The decoding of unwind sections for machine type Advanced Micro Devices X86-64 is not currently supported.
Symbol table '.symtab' contains 72 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000003 0 NOTYPE LOCAL DEFAULT ABS flags
2: 00000000e4524ffb 0 NOTYPE LOCAL DEFAULT ABS checksum
3: 0000000000100000 23 FUNC LOCAL DEFAULT 3 newtab.part.0
4: 00000000001005e0 72 OBJECT LOCAL DEFAULT 4 ticks
5: 00000000001009e8 4 OBJECT LOCAL DEFAULT 5 tick
6: 00000000001009f0 4 OBJECT LOCAL DEFAULT 5 row
7: 00000000001009ec 4 OBJECT LOCAL DEFAULT 5 col
8: 00000000001009f4 2 OBJECT LOCAL DEFAULT 5 attr
9: 0000000000100940 68 OBJECT LOCAL DEFAULT 4 hidigs.1345
10: 00000000001009a0 68 OBJECT LOCAL DEFAULT 4 lodigs.1344
11: 00000000001009e4 4 OBJECT LOCAL DEFAULT 5 curtab
12: 0000000000100410 92 FUNC LOCAL DEFAULT 3 cocntl
13: 0000000000100530 172 FUNC LOCAL DEFAULT 3 fmtuptr
14: 00000000000b8000 0 NOTYPE LOCAL DEFAULT ABS screen
15: 0000000000100530 172 FUNC LOCAL DEFAULT 3 fmtu32
16: 0000000000100500 38 FUNC LOCAL DEFAULT 3 coputs
17: 00000000001003d0 62 FUNC LOCAL DEFAULT 3 cofini
18: 0000000000100530 172 FUNC LOCAL DEFAULT 3 fmtu8
19: 00000000001002f0 213 FUNC LOCAL DEFAULT 3 coinit
20: 0000000000000400 0 NOTYPE LOCAL DEFAULT ABS bda
21: 0000000000100530 172 FUNC LOCAL DEFAULT 3 fmtu16
22: 0000000000100530 172 FUNC LOCAL DEFAULT 3 fmtsize
23: 0000000000100530 172 FUNC LOCAL DEFAULT 3 fmtuint
24: 00000000001001d0 99 FUNC LOCAL DEFAULT 3 panic
25: 0000000000100050 36 FUNC LOCAL DEFAULT 3 newtab
26: 0000000000100080 307 FUNC LOCAL DEFAULT 3 mapmem
27: 0000000000100240 171 FUNC LOCAL DEFAULT 3 setup
28: 00000000001001c0 3 FUNC LOCAL DEFAULT 3 halt
29: 0000000000100530 172 FUNC LOCAL DEFAULT 3 fmtbyte
30: 0000000000100470 137 FUNC LOCAL DEFAULT 3 coputc
31: 0000000000100a00 33 FUNC LOCAL DEFAULT 6 newtab.part.0
32: 000000000014340c 4 OBJECT LOCAL DEFAULT 8 row
33: 0000000000143408 4 OBJECT LOCAL DEFAULT 8 col
34: 00000000001010e0 144 OBJECT LOCAL DEFAULT 7 ticks
35: 0000000000143400 8 OBJECT LOCAL DEFAULT 8 tick
36: 0000000000143410 2 OBJECT LOCAL DEFAULT 8 attr
37: 0000000000100000 0 SECTION LOCAL DEFAULT 1
38: 0000000000000000 0 SECTION LOCAL DEFAULT 2
39: 0000000000100000 0 SECTION LOCAL DEFAULT 3
40: 00000000001005e0 0 SECTION LOCAL DEFAULT 4
41: 00000000001009e4 0 SECTION LOCAL DEFAULT 5
42: 0000000000100a00 0 SECTION LOCAL DEFAULT 6
43: 0000000000100f80 0 SECTION LOCAL DEFAULT 7
44: 0000000000102000 0 SECTION LOCAL DEFAULT 8
45: 0000000000000000 0 SECTION LOCAL DEFAULT 9
46: 0000000000143412 0 NOTYPE GLOBAL DEFAULT 8 _ebss64
47: 0000000000102000 4 OBJECT GLOBAL DEFAULT 8 curtab
48: 0000000000100db0 133 FUNC GLOBAL DEFAULT 6 cocntl
49: 00000000000b8000 0 NOTYPE GLOBAL DEFAULT ABS screen
50: 0000000000200000 0 NOTYPE GLOBAL DEFAULT 8 _einit
51: 0000000000143400 0 NOTYPE GLOBAL DEFAULT 8 stack
52: 0000000000100000 0 NOTYPE GLOBAL DEFAULT ABS _init
53: 0000000000100f50 39 FUNC GLOBAL DEFAULT 6 coputs
54: ffffffff00000000 0 NOTYPE GLOBAL DEFAULT 8 _vma
55: 0000000000100d50 82 FUNC GLOBAL DEFAULT 6 cofini
56: 0000000000102000 0 NOTYPE GLOBAL DEFAULT 8 _bss64
57: 00000000001009e4 0 NOTYPE GLOBAL DEFAULT 5 _bss32
58: 0000000000100c30 284 FUNC GLOBAL DEFAULT 6 coinit
59: 0000000000000400 0 NOTYPE GLOBAL DEFAULT ABS bda
60: 0000000000100b80 123 FUNC GLOBAL DEFAULT 6 panic
61: 0000000000100c10 0 NOTYPE GLOBAL DEFAULT 6 longer
62: 0000000000100a30 64 FUNC GLOBAL DEFAULT 6 newtab
63: 0000000000100a70 251 FUNC GLOBAL DEFAULT 6 mapmem
64: 0000000000103000 0x40000 OBJECT GLOBAL DEFAULT 8 tables
65: 0000000000100c00 16 FUNC GLOBAL DEFAULT 6 setup
66: 0000000000100b70 3 FUNC GLOBAL DEFAULT 6 halt
67: 0000000000041412 0 NOTYPE GLOBAL DEFAULT ABS _lbss64
68: 0000000000100020 0 NOTYPE GLOBAL DEFAULT 3 start
69: 00000000001009f6 0 NOTYPE GLOBAL DEFAULT 5 _ebss32
70: 0000000000000012 0 NOTYPE GLOBAL DEFAULT ABS _lbss32
71: 0000000000100e40 257 FUNC GLOBAL DEFAULT 6 coputc
No version information found in this file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment