Handout
This commit is contained in:
		
							
								
								
									
										107
									
								
								compiler/sections.ld
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										107
									
								
								compiler/sections.ld
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,107 @@
 | 
			
		||||
/* Entry in our OS -- label 'startup_bsp' in file boot/startup.asm */
 | 
			
		||||
ENTRY(startup_bsp)
 | 
			
		||||
 | 
			
		||||
SECTIONS
 | 
			
		||||
 {
 | 
			
		||||
	/* start address of our kernel */
 | 
			
		||||
	. = 16M;
 | 
			
		||||
 | 
			
		||||
	___KERNEL_START___ = .;
 | 
			
		||||
 | 
			
		||||
	.boot :
 | 
			
		||||
	{
 | 
			
		||||
		/* Multiboot Header should be at the very beginning */
 | 
			
		||||
		*(.multiboot_header)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	___KERNEL_TEXT_START___ = .;
 | 
			
		||||
 | 
			
		||||
	.text :
 | 
			
		||||
	{
 | 
			
		||||
		*(".text")
 | 
			
		||||
		*(".text$")
 | 
			
		||||
		*(".init")
 | 
			
		||||
		*(".fini")
 | 
			
		||||
		*(".gnu.linkonce.*")
 | 
			
		||||
		KEEP(*(.note.gnu.build-id))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* lists containing the start address of global constructors and destructors (generated by the compiler) */
 | 
			
		||||
	.preinit_array :
 | 
			
		||||
	{
 | 
			
		||||
		PROVIDE_HIDDEN (__preinit_array_start = .);
 | 
			
		||||
		KEEP (*(.preinit_array))
 | 
			
		||||
		PROVIDE_HIDDEN (__preinit_array_end = .);
 | 
			
		||||
	}
 | 
			
		||||
	.init_array :
 | 
			
		||||
	{
 | 
			
		||||
		PROVIDE_HIDDEN (__init_array_start = .);
 | 
			
		||||
		KEEP (*(SORT(.init_array.*)))
 | 
			
		||||
		KEEP (*(.init_array))
 | 
			
		||||
		PROVIDE_HIDDEN (__init_array_end = .);
 | 
			
		||||
	}
 | 
			
		||||
	.fini_array :
 | 
			
		||||
	{
 | 
			
		||||
		PROVIDE_HIDDEN (__fini_array_start = .);
 | 
			
		||||
		KEEP (*(SORT(.fini_array.*)))
 | 
			
		||||
		KEEP (*(.fini_array))
 | 
			
		||||
		PROVIDE_HIDDEN (__fini_array_end = .);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	___KERNEL_TEXT_END___ = .;
 | 
			
		||||
 | 
			
		||||
	.data :
 | 
			
		||||
	{
 | 
			
		||||
		*(".data")
 | 
			
		||||
		*(".data$")
 | 
			
		||||
		*(".rodata")
 | 
			
		||||
		___CTOR_LIST__ = .;
 | 
			
		||||
		*(".ctors")
 | 
			
		||||
		*(".ctor")
 | 
			
		||||
		___CTOR_LIST_END__ = .;
 | 
			
		||||
		___DTOR_LIST__ = .;
 | 
			
		||||
		*(".dtors")
 | 
			
		||||
		*(".dtor")
 | 
			
		||||
		___DTOR_LIST_END__ = .;
 | 
			
		||||
		*(".got")
 | 
			
		||||
		*(".got.plt")
 | 
			
		||||
		*(".eh_frame")
 | 
			
		||||
		*(".eh_fram")
 | 
			
		||||
		*(".jcr")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Start for application processors, relocated by APIC::init()
 | 
			
		||||
	 * to a below 1 MB address to boot from real mode.
 | 
			
		||||
	 * It is possible to let the linker place it at a below 1 MB address,
 | 
			
		||||
	 * while all the rest starts at 16 MB. This will work for multiboot
 | 
			
		||||
	 * compliant boot loader like GRUB and PXELINUX, however,
 | 
			
		||||
	 * the qemu boot loader cannot handle such ELF files (yet)...
 | 
			
		||||
	 * That's why we have to do it in our software */
 | 
			
		||||
	.setup_ap_seg ALIGN(0x10) :
 | 
			
		||||
	{
 | 
			
		||||
		___SETUP_AP_START__ = .;
 | 
			
		||||
		*(".setup_ap_seg")
 | 
			
		||||
		*(".setup_ap_seg$")
 | 
			
		||||
	}
 | 
			
		||||
	___SETUP_AP_END__ = .;
 | 
			
		||||
 | 
			
		||||
	.bss :
 | 
			
		||||
	{
 | 
			
		||||
		*(".bss")
 | 
			
		||||
		*(".bss.*")
 | 
			
		||||
		*(COMMON)
 | 
			
		||||
	}
 | 
			
		||||
	___KERNEL_END___ = .;
 | 
			
		||||
 | 
			
		||||
	/DISCARD/ :
 | 
			
		||||
	{
 | 
			
		||||
		*(".note")
 | 
			
		||||
		*(".comment")
 | 
			
		||||
/* Keep debug information
 | 
			
		||||
		*(".debug_line")
 | 
			
		||||
		*(".debug_info")
 | 
			
		||||
		*(".debug_abbrev")
 | 
			
		||||
		*(".debug_aranges")
 | 
			
		||||
*/
 | 
			
		||||
	}
 | 
			
		||||
 }
 | 
			
		||||
		Reference in New Issue
	
	Block a user