1 #ifndef __XEN_LDS_H__
2 #define __XEN_LDS_H__
3 
4 /*
5  * Common macros to be used in architecture specific linker scripts.
6  */
7 
8 #ifdef DECL_SECTION_WITH_LADDR
9 
10 /*
11  * Declare a section whose load address is based at PA 0 rather than
12  * Xen's virtual base address.
13  */
14 #ifdef CONFIG_LD_IS_GNU
15 # define DECL_SECTION(x) x : AT(ADDR(#x) - __XEN_VIRT_START)
16 #else
17 # define DECL_SECTION(x) x : AT(ADDR(x) - __XEN_VIRT_START)
18 #endif
19 
20 #else /* !DECL_SECTION_WITH_LADDR */
21 #define DECL_SECTION(x) x :
22 #endif
23 
24 /*
25  * To avoid any confusion, please note that the EFI macro does not correspond
26  * to EFI support and is used when linking a native EFI (i.e. PE/COFF) binary,
27  * hence its usage in this header.
28  */
29 
30 /* Macros to declare debug sections. */
31 #ifdef EFI
32 /*
33  * Use the NOLOAD directive, despite currently ignored by (at least) GNU ld
34  * for PE output, in order to record that we'd prefer these sections to not
35  * be loaded into memory.
36  */
37 #define DECL_DEBUG(x, a) x ALIGN(a) (NOLOAD) : { *(x) }
38 #define DECL_DEBUG2(x, y, a) x ALIGN(a) (NOLOAD) : { *(x) *(y) }
39 #else
40 #define DECL_DEBUG(x, a) x 0 : { *(x) }
41 #define DECL_DEBUG2(x, y, a) x 0 : { *(x) *(y) }
42 #endif
43 
44 /*
45  * DWARF2+ debug sections.
46  * Explicitly list debug sections, first of all to avoid these sections being
47  * viewed as "orphan" by the linker.
48  *
49  * For the PE output this is further necessary so that they don't end up at
50  * VA 0, which is below image base and thus invalid. Note that this macro is
51  * to be used after _end, so if these sections get loaded they'll be discarded
52  * at runtime anyway.
53  */
54 #define DWARF2_DEBUG_SECTIONS                     \
55   DECL_DEBUG(.debug_abbrev, 1)                    \
56   DECL_DEBUG2(.debug_info, .gnu.linkonce.wi.*, 1) \
57   DECL_DEBUG(.debug_types, 1)                     \
58   DECL_DEBUG(.debug_str, 1)                       \
59   DECL_DEBUG(.debug_str_offsets, 4)               \
60   DECL_DEBUG2(.debug_line, .debug_line.*, 1)      \
61   DECL_DEBUG(.debug_line_str, 1)                  \
62   DECL_DEBUG(.debug_names, 4)                     \
63   DECL_DEBUG(.debug_frame, 4)                     \
64   DECL_DEBUG(.debug_loc, 1)                       \
65   DECL_DEBUG(.debug_loclists, 4)                  \
66   DECL_DEBUG(.debug_macinfo, 1)                   \
67   DECL_DEBUG(.debug_macro, 1)                     \
68   DECL_DEBUG(.debug_ranges, POINTER_ALIGN)        \
69   DECL_DEBUG(.debug_rnglists, 4)                  \
70   DECL_DEBUG(.debug_addr, POINTER_ALIGN)          \
71   DECL_DEBUG(.debug_aranges, 1)                   \
72   DECL_DEBUG(.debug_pubnames, 1)                  \
73   DECL_DEBUG(.debug_pubtypes, 1)
74 
75 /* Stabs debug sections. */
76 #define STABS_DEBUG_SECTIONS                 \
77   .stab 0 : { *(.stab) }                     \
78   .stabstr 0 : { *(.stabstr) }               \
79   .stab.excl 0 : { *(.stab.excl) }           \
80   .stab.exclstr 0 : { *(.stab.exclstr) }     \
81   .stab.index 0 : { *(.stab.index) }         \
82   .stab.indexstr 0 : { *(.stab.indexstr) }
83 
84 /*
85  * ELF sections.
86  *
87  * LLVM ld also wants .symtab, .strtab, and .shstrtab placed. These look to
88  * be benign to GNU ld, so we can have them here unconditionally.
89  */
90 #define ELF_DETAILS_SECTIONS                 \
91   .comment 0 : { *(.comment) *(.comment.*) } \
92   .symtab 0 : { *(.symtab) }                 \
93   .strtab 0 : { *(.strtab) }                 \
94   .shstrtab 0 : { *(.shstrtab) }
95 
96 #ifdef EFI
97 #define DISCARD_EFI_SECTIONS \
98        *(.comment)   \
99        *(.comment.*) \
100        *(.note.*)
101 #else
102 #define DISCARD_EFI_SECTIONS
103 #endif
104 
105 /* Sections to be discarded. */
106 #define DISCARD_SECTIONS     \
107   /DISCARD/ : {              \
108        *(.text.exit)         \
109        *(.exit.text)         \
110        *(.exit.data)         \
111        *(.exitcall.exit)     \
112        *(.discard)           \
113        *(.discard.*)         \
114        *(.eh_frame)          \
115        *(.dtors)             \
116        *(.dtors.*)           \
117        *(.fini_array)        \
118        *(.fini_array.*)      \
119        DISCARD_EFI_SECTIONS  \
120   }
121 
122 /* List of constructs other than *_SECTIONS in alphabetical order. */
123 
124 #define ACPI_DEV_INFO        \
125   . = ALIGN(POINTER_ALIGN);  \
126   DECL_SECTION(.adev.info) { \
127       _asdevice = .;         \
128       *(.adev.info)          \
129       _aedevice = .;         \
130   } :text
131 
132 #define BUGFRAMES                               \
133     __start_bug_frames_0 = .;                   \
134     *(.bug_frames.0)                            \
135     __stop_bug_frames_0 = .;                    \
136                                                 \
137     __start_bug_frames_1 = .;                   \
138     *(.bug_frames.1)                            \
139     __stop_bug_frames_1 = .;                    \
140                                                 \
141     __start_bug_frames_2 = .;                   \
142     *(.bug_frames.2)                            \
143     __stop_bug_frames_2 = .;                    \
144                                                 \
145     __start_bug_frames_3 = .;                   \
146     *(.bug_frames.3)                            \
147     __stop_bug_frames_3 = .;
148 
149 #define DT_DEV_INFO         \
150   . = ALIGN(POINTER_ALIGN); \
151   DECL_SECTION(.dev.info) { \
152        _sdevice = .;        \
153        *(.dev.info)         \
154        _edevice = .;        \
155   } :text
156 
157 #ifdef CONFIG_HYPFS
158 #define HYPFS_PARAM              \
159        . = ALIGN(POINTER_ALIGN); \
160        __paramhypfs_start = .;   \
161        *(.data.paramhypfs)       \
162        __paramhypfs_end = .;
163 #else
164 #define HYPFS_PARAM
165 #endif
166 
167 #ifdef CONFIG_DEBUG_LOCK_PROFILE
168 #define LOCK_PROFILE_DATA        \
169        . = ALIGN(POINTER_ALIGN); \
170        __lock_profile_start = .; \
171        *(.lockprofile.data)      \
172        __lock_profile_end = .;
173 #else
174 #define LOCK_PROFILE_DATA
175 #endif
176 
177 #define PERCPU_BSS                 \
178        . = ALIGN(PAGE_SIZE);       \
179        __per_cpu_start = .;        \
180        *(.bss.percpu.page_aligned) \
181        *(.bss.percpu)              \
182        . = ALIGN(SMP_CACHE_BYTES); \
183        *(.bss.percpu.read_mostly)  \
184        . = ALIGN(SMP_CACHE_BYTES); \
185        __per_cpu_data_end = .;     \
186 
187 #ifdef CONFIG_HAS_VPCI
188 #define VPCI_ARRAY               \
189        . = ALIGN(POINTER_ALIGN); \
190        __start_vpci_array = .;   \
191        *(.data.rel.ro.vpci)      \
192        __end_vpci_array = .;
193 #else
194 #define VPCI_ARRAY
195 #endif
196 
197 #endif /* __XEN_LDS_H__ */
198