1b2441318SGreg Kroah-Hartman/* SPDX-License-Identifier: GPL-2.0 */ 2dbee90b7SRalf Baechle#include <asm/asm-offsets.h> 37b1c0d26SDavid Daney#include <asm/thread_info.h> 4485172b3SDavid Daney 5bef9ae3dSRalf Baechle#define PAGE_SIZE _PAGE_SIZE 6bef9ae3dSRalf Baechle 7485172b3SDavid Daney/* 8485172b3SDavid Daney * Put .bss..swapper_pg_dir as the first thing in .bss. This will 9485172b3SDavid Daney * ensure that it has .bss alignment (64K). 10485172b3SDavid Daney */ 11485172b3SDavid Daney#define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir) 12485172b3SDavid Daney 13441110a5SKees Cook/* Cavium Octeon should not have a separate PT_NOTE Program Header. */ 14441110a5SKees Cook#ifndef CONFIG_CAVIUM_OCTEON_SOC 15441110a5SKees Cook#define EMITS_PT_NOTE 16441110a5SKees Cook#endif 17441110a5SKees Cook 186dcbd0a6SJiaxun Yang#define RUNTIME_DISCARD_EXIT 196dcbd0a6SJiaxun Yang 201da177e4SLinus Torvalds#include <asm-generic/vmlinux.lds.h> 211da177e4SLinus Torvalds 2241c594abSRalf Baechle#undef mips 231da177e4SLinus Torvalds#define mips mips 241da177e4SLinus TorvaldsOUTPUT_ARCH(mips) 251da177e4SLinus TorvaldsENTRY(kernel_entry) 26603bb99cSRalf BaechlePHDRS { 27603bb99cSRalf Baechle text PT_LOAD FLAGS(7); /* RWX */ 283bfb7224SDavid Daney#ifndef CONFIG_CAVIUM_OCTEON_SOC 29603bb99cSRalf Baechle note PT_NOTE FLAGS(4); /* R__ */ 303bfb7224SDavid Daney#endif /* CAVIUM_OCTEON_SOC */ 31603bb99cSRalf Baechle} 3251b563fcSSam Ravnborg 33d71789b6SManuel Lauss#ifdef CONFIG_32BIT 34d71789b6SManuel Lauss #ifdef CONFIG_CPU_LITTLE_ENDIAN 3551b563fcSSam Ravnborg jiffies = jiffies_64; 36d71789b6SManuel Lauss #else 3751b563fcSSam Ravnborg jiffies = jiffies_64 + 4; 38d71789b6SManuel Lauss #endif 39d71789b6SManuel Lauss#else 4051b563fcSSam Ravnborg jiffies = jiffies_64; 41d71789b6SManuel Lauss#endif 420f5c9064SSam Ravnborg 431da177e4SLinus TorvaldsSECTIONS 441da177e4SLinus Torvalds{ 451da177e4SLinus Torvalds#ifdef CONFIG_BOOT_ELF64 461da177e4SLinus Torvalds /* Read-only sections, merged into text segment: */ 471da177e4SLinus Torvalds /* . = 0xc000000000000000; */ 481da177e4SLinus Torvalds 491da177e4SLinus Torvalds /* This is the value for an Origin kernel, taken from an IRIX kernel. */ 501da177e4SLinus Torvalds /* . = 0xc00000000001c000; */ 511da177e4SLinus Torvalds 521da177e4SLinus Torvalds /* Set the vaddr for the text segment to a value 530f5c9064SSam Ravnborg * >= 0xa800 0000 0001 9000 if no symmon is going to configured 540f5c9064SSam Ravnborg * >= 0xa800 0000 0030 0000 otherwise 550f5c9064SSam Ravnborg */ 561da177e4SLinus Torvalds 571da177e4SLinus Torvalds /* . = 0xa800000000300000; */ 581da177e4SLinus Torvalds . = 0xffffffff80300000; 591da177e4SLinus Torvalds#endif 60ff487d41SJiaxun Yang . = LINKER_LOAD_ADDRESS; 611da177e4SLinus Torvalds /* read-only */ 621da177e4SLinus Torvalds _text = .; /* Text and read-only data */ 631da177e4SLinus Torvalds .text : { 64*52892ed6SRong Xu HEAD_TEXT 657664709bSSam Ravnborg TEXT_TEXT 661da177e4SLinus Torvalds SCHED_TEXT 671da177e4SLinus Torvalds LOCK_TEXT 68f70fd1b5SRalf Baechle KPROBES_TEXT 698f99a162SWu Zhangjin IRQENTRY_TEXT 70be7635e7SAlexander Potapenko SOFTIRQENTRY_TEXT 711da177e4SLinus Torvalds *(.fixup) 721da177e4SLinus Torvalds *(.gnu.warning) 73795b3a36SAlexander Lobakin . = ALIGN(16); 74795b3a36SAlexander Lobakin *(.got) /* Global offset table */ 75603bb99cSRalf Baechle } :text = 0 761da177e4SLinus Torvalds _etext = .; /* End of text section */ 771da177e4SLinus Torvalds 786eb10bc9SNelson Elhage EXCEPTION_TABLE(16) 791da177e4SLinus Torvalds 800f5c9064SSam Ravnborg /* Exception table for data bus errors */ 810f5c9064SSam Ravnborg __dbe_table : { 820f5c9064SSam Ravnborg __start___dbe_table = .; 83c0436b50SPaul Burton KEEP(*(__dbe_table)) 841da177e4SLinus Torvalds __stop___dbe_table = .; 850f5c9064SSam Ravnborg } 86603bb99cSRalf Baechle 87a2d063acSSteven Rostedt _sdata = .; /* Start of data section */ 88c8231825SKees Cook RO_DATA(4096) 891da177e4SLinus Torvalds 901da177e4SLinus Torvalds /* writeable */ 911da177e4SLinus Torvalds .data : { /* Data */ 921da177e4SLinus Torvalds . = . + DATAOFFSET; /* for CONFIG_MAPPED_KERNEL */ 931da177e4SLinus Torvalds 947b1c0d26SDavid Daney INIT_TASK_DATA(THREAD_SIZE) 956eb10bc9SNelson Elhage NOSAVE_DATA 968ac7c87aSAlexander Lobakin PAGE_ALIGNED_DATA(PAGE_SIZE) 976eb10bc9SNelson Elhage CACHELINE_ALIGNED_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) 98f8bec75aSCatalin Marinas READ_MOSTLY_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) 99ca967258SSam Ravnborg DATA_DATA 1001da177e4SLinus Torvalds CONSTRUCTORS 1011da177e4SLinus Torvalds } 102b5effd38SPeter Zijlstra BUG_TABLE 1031da177e4SLinus Torvalds _gp = . + 0x8000; 1040f5c9064SSam Ravnborg .lit8 : { 1050f5c9064SSam Ravnborg *(.lit8) 1060f5c9064SSam Ravnborg } 1070f5c9064SSam Ravnborg .lit4 : { 1080f5c9064SSam Ravnborg *(.lit4) 1090f5c9064SSam Ravnborg } 1101da177e4SLinus Torvalds /* We want the small data sections together, so single-instruction offsets 1111da177e4SLinus Torvalds can access them all, and initialized data all before uninitialized, so 1121da177e4SLinus Torvalds we can shorten the on-disk segment size. */ 1130f5c9064SSam Ravnborg .sdata : { 1140f5c9064SSam Ravnborg *(.sdata) 1150f5c9064SSam Ravnborg } 1161da177e4SLinus Torvalds _edata = .; /* End of data section */ 1171da177e4SLinus Torvalds 1181da177e4SLinus Torvalds /* will be freed after init */ 119a0b54e25SNelson Elhage . = ALIGN(PAGE_SIZE); /* Init code and data */ 1201da177e4SLinus Torvalds __init_begin = .; 1216eb10bc9SNelson Elhage INIT_TEXT_SECTION(PAGE_SIZE) 1226eb10bc9SNelson Elhage INIT_DATA_SECTION(16) 1230f5c9064SSam Ravnborg 124487d70d0SGabor Juhos . = ALIGN(4); 125487d70d0SGabor Juhos .mips.machines.init : AT(ADDR(.mips.machines.init) - LOAD_OFFSET) { 126487d70d0SGabor Juhos __mips_machines_start = .; 127c0436b50SPaul Burton KEEP(*(.mips.machines.init)) 128487d70d0SGabor Juhos __mips_machines_end = .; 129487d70d0SGabor Juhos } 130487d70d0SGabor Juhos 1312efac77eSRalf Baechle /* .exit.text is discarded at runtime, not link time, to deal with 1320f5c9064SSam Ravnborg * references from .rodata 1330f5c9064SSam Ravnborg */ 1340f5c9064SSam Ravnborg .exit.text : { 13501ba2bdcSSam Ravnborg EXIT_TEXT 1360f5c9064SSam Ravnborg } 1370f5c9064SSam Ravnborg .exit.data : { 13801ba2bdcSSam Ravnborg EXIT_DATA 1390f5c9064SSam Ravnborg } 1401da8f179SJonas Gorski#ifdef CONFIG_SMP 1410415b00dSTejun Heo PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT) 1421da8f179SJonas Gorski#endif 143069fd766SMatt Redfearn 144008c3cbdSAlexander Lobakin .rel.dyn : ALIGN(8) { 145008c3cbdSAlexander Lobakin *(.rel) 146008c3cbdSAlexander Lobakin *(.rel*) 147008c3cbdSAlexander Lobakin } 148008c3cbdSAlexander Lobakin 1493f0a53bcSYasha Cherikovsky#ifdef CONFIG_MIPS_ELF_APPENDED_DTB 1507a05293aSPaul Cercueil STRUCT_ALIGN(); 1513f0a53bcSYasha Cherikovsky .appended_dtb : AT(ADDR(.appended_dtb) - LOAD_OFFSET) { 1523f0a53bcSYasha Cherikovsky *(.appended_dtb) 1533f0a53bcSYasha Cherikovsky KEEP(*(.appended_dtb)) 1543f0a53bcSYasha Cherikovsky } 1553f0a53bcSYasha Cherikovsky#endif 1563f0a53bcSYasha Cherikovsky 157069fd766SMatt Redfearn#ifdef CONFIG_RELOCATABLE 158069fd766SMatt Redfearn . = ALIGN(4); 159069fd766SMatt Redfearn 160069fd766SMatt Redfearn .data.reloc : { 161069fd766SMatt Redfearn _relocation_start = .; 162069fd766SMatt Redfearn /* 163069fd766SMatt Redfearn * Space for relocation table 164069fd766SMatt Redfearn * This needs to be filled so that the 165069fd766SMatt Redfearn * relocs tool can overwrite the content. 166069fd766SMatt Redfearn * An invalid value is left at the start of the 167069fd766SMatt Redfearn * section to abort relocation if the table 168069fd766SMatt Redfearn * has not been filled in. 169069fd766SMatt Redfearn */ 170069fd766SMatt Redfearn LONG(0xFFFFFFFF); 171069fd766SMatt Redfearn FILL(0); 172069fd766SMatt Redfearn . += CONFIG_RELOCATION_TABLE_SIZE - 4; 173069fd766SMatt Redfearn _relocation_end = .; 174069fd766SMatt Redfearn } 175069fd766SMatt Redfearn#endif 176069fd766SMatt Redfearn 1771da8f179SJonas Gorski#ifdef CONFIG_MIPS_RAW_APPENDED_DTB 1786654111cSBjørn Mork .fill : { 1796654111cSBjørn Mork FILL(0); 1806654111cSBjørn Mork BYTE(0); 1813f6c515dSPaul Cercueil STRUCT_ALIGN(); 1826654111cSBjørn Mork } 1831da8f179SJonas Gorski __appended_dtb = .; 1841da8f179SJonas Gorski /* leave space for appended DTB */ 1851da8f179SJonas Gorski . += 0x100000; 1861da8f179SJonas Gorski#endif 187485172b3SDavid Daney /* 188485172b3SDavid Daney * Align to 64K in attempt to eliminate holes before the 189485172b3SDavid Daney * .bss..swapper_pg_dir section at the start of .bss. This 190485172b3SDavid Daney * also satisfies PAGE_SIZE alignment as the largest page size 191485172b3SDavid Daney * allowed is 64K. 192485172b3SDavid Daney */ 193485172b3SDavid Daney . = ALIGN(0x10000); 1941da177e4SLinus Torvalds __init_end = .; 1951da177e4SLinus Torvalds /* freed after init ends here */ 1961da177e4SLinus Torvalds 197485172b3SDavid Daney /* 198485172b3SDavid Daney * Force .bss to 64K alignment so that .bss..swapper_pg_dir 199485172b3SDavid Daney * gets that alignment. .sbss should be empty, so there will be 200485172b3SDavid Daney * no holes after __init_end. */ 2013f00f4d8SPaul Burton BSS_SECTION(0, 0x10000, 8) 2021da177e4SLinus Torvalds 2031da177e4SLinus Torvalds _end = . ; 2041da177e4SLinus Torvalds 2056c76988bSDaniel Jacobowitz /* These mark the ABI of the kernel for debuggers. */ 2060f5c9064SSam Ravnborg .mdebug.abi32 : { 2070f5c9064SSam Ravnborg KEEP(*(.mdebug.abi32)) 2080f5c9064SSam Ravnborg } 2090f5c9064SSam Ravnborg .mdebug.abi64 : { 2100f5c9064SSam Ravnborg KEEP(*(.mdebug.abi64)) 2110f5c9064SSam Ravnborg } 2126c76988bSDaniel Jacobowitz 2131da177e4SLinus Torvalds /* This is the MIPS specific mdebug section. */ 2140f5c9064SSam Ravnborg .mdebug : { 2150f5c9064SSam Ravnborg *(.mdebug) 2160f5c9064SSam Ravnborg } 21778665aaaSAtsushi Nemoto 21878665aaaSAtsushi Nemoto STABS_DEBUG 21904b6b3b6SAtsushi Nemoto DWARF_DEBUG 220c604abc3SKees Cook ELF_DETAILS 22104b6b3b6SAtsushi Nemoto 2221da177e4SLinus Torvalds /* These must appear regardless of . */ 2230f5c9064SSam Ravnborg .gptab.sdata : { 2240f5c9064SSam Ravnborg *(.gptab.data) 2250f5c9064SSam Ravnborg *(.gptab.sdata) 2260f5c9064SSam Ravnborg } 2270f5c9064SSam Ravnborg .gptab.sbss : { 2280f5c9064SSam Ravnborg *(.gptab.bss) 2290f5c9064SSam Ravnborg *(.gptab.sbss) 2300f5c9064SSam Ravnborg } 231023bf6f1STejun Heo 232023bf6f1STejun Heo /* Sections to be discarded */ 233023bf6f1STejun Heo DISCARDS 234023bf6f1STejun Heo /DISCARD/ : { 235023bf6f1STejun Heo /* ABI crap starts here */ 23661379878SAaro Koskinen *(.MIPS.abiflags) 237023bf6f1STejun Heo *(.MIPS.options) 2385629d418SAlexander Lobakin *(.gnu.attributes) 239023bf6f1STejun Heo *(.options) 240023bf6f1STejun Heo *(.pdr) 241023bf6f1STejun Heo *(.reginfo) 242023bf6f1STejun Heo } 2431da177e4SLinus Torvalds} 244