blob: cacd7898ba7f97562a29c5cd3912d549f0d06e55 [file] [log] [blame]
Thomas Gleixner50acfb22019-05-29 07:18:00 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -07002/*
3 * Copyright (C) 2012 Regents of the University of California
4 * Copyright (C) 2017 SiFive
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -07005 */
6
7#define LOAD_OFFSET PAGE_OFFSET
8#include <asm/vmlinux.lds.h>
9#include <asm/page.h>
10#include <asm/cache.h>
11#include <asm/thread_info.h>
Zong Li00cb41d2020-03-10 00:55:40 +080012#include <asm/set_memory.h>
Atish Patracb7d2dd2020-09-17 15:37:13 -070013#include "image-vars.h"
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070014
Atish Patrae0119952020-03-17 18:11:39 -070015#include <linux/sizes.h>
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070016OUTPUT_ARCH(riscv)
17ENTRY(_start)
18
19jiffies = jiffies_64;
20
Atish Patracb7d2dd2020-09-17 15:37:13 -070021PECOFF_SECTION_ALIGNMENT = 0x1000;
22PECOFF_FILE_ALIGNMENT = 0x200;
23
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070024SECTIONS
25{
26 /* Beginning of code and text segment */
27 . = LOAD_OFFSET;
28 _start = .;
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070029 HEAD_TEXT_SECTION
Atish Patrae0119952020-03-17 18:11:39 -070030 . = ALIGN(PAGE_SIZE);
31
32 __init_begin = .;
Atish Patrab6566dc2020-11-04 16:04:37 -080033 __init_text_begin = .;
34 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) ALIGN(SECTION_ALIGN) { \
35 _sinittext = .; \
36 INIT_TEXT \
37 _einittext = .; \
38 }
39
Damien Le Moal335b1392020-03-16 09:47:38 +090040 . = ALIGN(8);
41 __soc_early_init_table : {
42 __soc_early_init_table_start = .;
43 KEEP(*(__soc_early_init_table))
44 __soc_early_init_table_end = .;
45 }
Palmer Dabbelt2d268252020-04-14 13:43:24 +090046 __soc_builtin_dtb_table : {
47 __soc_builtin_dtb_table_start = .;
48 KEEP(*(__soc_builtin_dtb_table))
49 __soc_builtin_dtb_table_end = .;
50 }
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070051 /* we have to discard exit text and such at runtime, not link time */
52 .exit.text :
53 {
54 EXIT_TEXT
55 }
56 .exit.data :
57 {
58 EXIT_DATA
59 }
60 PERCPU_SECTION(L1_CACHE_BYTES)
61 __init_end = .;
62
Zong Li00cb41d2020-03-10 00:55:40 +080063 . = ALIGN(SECTION_ALIGN);
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070064 .text : {
65 _text = .;
Guo Ren84814462020-10-06 16:49:33 +000066 _stext = .;
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070067 TEXT_TEXT
68 SCHED_TEXT
69 CPUIDLE_TEXT
70 LOCK_TEXT
71 KPROBES_TEXT
72 ENTRY_TEXT
73 IRQENTRY_TEXT
Nick Hu8ad8b722020-01-06 10:38:32 -080074 SOFTIRQENTRY_TEXT
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070075 *(.fixup)
76 _etext = .;
77 }
78
Atish Patracb7d2dd2020-09-17 15:37:13 -070079#ifdef CONFIG_EFI
80 . = ALIGN(PECOFF_SECTION_ALIGNMENT);
81 __pecoff_text_end = .;
82#endif
83
Guo Ren84814462020-10-06 16:49:33 +000084 INIT_DATA_SECTION(16)
85
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070086 /* Start of data section */
87 _sdata = .;
Zong Li00cb41d2020-03-10 00:55:40 +080088 RO_DATA(SECTION_ALIGN)
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070089 .srodata : {
90 *(.srodata*)
91 }
92
Zong Libd3d9142020-03-10 00:55:39 +080093 EXCEPTION_TABLE(0x10)
94
Zong Li00cb41d2020-03-10 00:55:40 +080095 . = ALIGN(SECTION_ALIGN);
Zong Libd3d9142020-03-10 00:55:39 +080096 _data = .;
97
Kees Cookc9174042019-10-29 14:13:35 -070098 RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -070099 .sdata : {
100 __global_pointer$ = . + 0x800;
101 *(.sdata*)
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700102 }
103
Atish Patracb7d2dd2020-09-17 15:37:13 -0700104#ifdef CONFIG_EFI
105 .pecoff_edata_padding : { BYTE(0); . = ALIGN(PECOFF_FILE_ALIGNMENT); }
106 __pecoff_data_raw_size = ABSOLUTE(. - __pecoff_text_end);
107#endif
108
109 /* End of data section */
110 _edata = .;
111
Palmer Dabbelt41fb9d52019-02-08 09:11:08 -0800112 BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0)
113
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700114 .rel.dyn : {
115 *(.rel.dyn*)
116 }
117
Atish Patracb7d2dd2020-09-17 15:37:13 -0700118#ifdef CONFIG_EFI
119 . = ALIGN(PECOFF_SECTION_ALIGNMENT);
120 __pecoff_data_virt_size = ABSOLUTE(. - __pecoff_text_end);
121#endif
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700122 _end = .;
123
124 STABS_DEBUG
125 DWARF_DEBUG
Kees Cookc604abc2020-08-21 12:42:45 -0700126 ELF_DETAILS
Palmer Dabbeltfbe934d2017-07-10 18:08:08 -0700127
128 DISCARDS
129}