xv6

port of xv6 to x86-64
git clone http://frotz.net/git/xv6.git
Log | Files | Refs | README | LICENSE

kernel64.ld (1566B)


      1 /* Simple linker script for the JOS kernel.
      2    See the GNU ld 'info' manual ("info ld") to learn the syntax. */
      3 
      4 /* OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") */
      5 OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
      6 OUTPUT_ARCH(i386:x86-64)
      7 ENTRY(_start)
      8 
      9 mboot_load_addr = 0x00100000;
     10 
     11 SECTIONS
     12 {
     13 	/* Link the kernel at this address: "." means the current address */
     14         /* Must be equal to KERNLINK */
     15 	. = 0xFFFFFFFF80100000; 
     16 
     17 	PROVIDE(begin = .);
     18 
     19 	.text : AT(mboot_load_addr) {
     20 		*(.text .rela.text .stub .text.* .gnu.linkonce.t.*)
     21 	}
     22 
     23 	PROVIDE(etext = .);	/* Define the 'etext' symbol to this value */
     24 
     25 	.rodata : {
     26 		*(.rodata .rodata.* .gnu.linkonce.r.*)
     27 	}
     28 
     29 	/* Adjust the address for the data segment to the next page */
     30 	. = ALIGN(0x1000);
     31 
     32 	/* Conventionally, Unix linkers provide pseudo-symbols
     33 	 * etext, edata, and end, at the end of the text, data, and bss.
     34 	 * For the kernel mapping, we need the address at the beginning
     35 	 * of the data section, but that's not one of the conventional
     36 	 * symbols, because the convention started before there was a
     37 	 * read-only rodata section between text and data. */
     38 	PROVIDE(data = .);
     39 
     40 	/* The data segment */
     41 	.data : {
     42 		*(.data)
     43 	}
     44 
     45 	. = ALIGN(0x1000);
     46 
     47 	PROVIDE(edata = .);
     48 
     49 	.bss : {
     50 		*(.bss)
     51 		*(COMMON)
     52 	}
     53 
     54 	. = ALIGN(0x1000);
     55 
     56 	PROVIDE(end = .);
     57 
     58 	/DISCARD/ : {
     59 		*(.eh_frame .rela.eh_frame .note.GNU-stack)
     60 	}
     61 }
     62 
     63 mboot_load_end = mboot_load_addr + (edata - begin);
     64 mboot_bss_end = mboot_load_addr + (end - begin);
     65 mboot_entry_addr = mboot_load_addr + (mboot_entry - begin);