aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2009-07-08 22:27:40 -0400
committerTejun Heo <tj@kernel.org>2009-07-08 22:27:40 -0400
commit023bf6f1b8bf58dc4da7f0dc1cf4787b0d5297c1 (patch)
tree780331cadf207ced67dfcdf36a6479dc0e3d3c04
parent1dcdd0911b5553f0282ce8525773955b59a56919 (diff)
linker script: unify usage of discard definition
Discarded sections in different archs share some commonality but have considerable differences. This led to linker script for each arch implementing its own /DISCARD/ definition, which makes maintaining tedious and adding new entries error-prone. This patch makes all linker scripts to move discard definitions to the end of the linker script and use the common DISCARDS macro. As ld uses the first matching section definition, archs can include default discarded sections by including them earlier in the linker script. ia64 is notable because it first throws away some ia64 specific subsections and then include the rest of the sections into the final image, so those sections must be discarded before the inclusion. defconfig compile tested for x86, x86-64, powerpc, powerpc64, ia64, alpha, sparc, sparc64 and s390. Michal Simek tested microblaze. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Paul Mundt <lethal@linux-sh.org> Acked-by: Mike Frysinger <vapier@gentoo.org> Tested-by: Michal Simek <monstr@monstr.eu> Cc: linux-arch@vger.kernel.org Cc: Michal Simek <monstr@monstr.eu> Cc: microblaze-uclinux@itee.uq.edu.au Cc: Sam Ravnborg <sam@ravnborg.org> Cc: Tony Luck <tony.luck@intel.com>
-rw-r--r--arch/alpha/kernel/vmlinux.lds.S10
-rw-r--r--arch/avr32/kernel/vmlinux.lds.S10
-rw-r--r--arch/blackfin/kernel/vmlinux.lds.S6
-rw-r--r--arch/cris/kernel/vmlinux.lds.S10
-rw-r--r--arch/frv/kernel/vmlinux.lds.S2
-rw-r--r--arch/h8300/kernel/vmlinux.lds.S6
-rw-r--r--arch/ia64/kernel/vmlinux.lds.S17
-rw-r--r--arch/m32r/kernel/vmlinux.lds.S11
-rw-r--r--arch/m68k/kernel/vmlinux-std.lds11
-rw-r--r--arch/m68k/kernel/vmlinux-sun3.lds10
-rw-r--r--arch/m68knommu/kernel/vmlinux.lds.S8
-rw-r--r--arch/microblaze/kernel/vmlinux.lds.S2
-rw-r--r--arch/mips/kernel/vmlinux.lds.S22
-rw-r--r--arch/mn10300/kernel/vmlinux.lds.S9
-rw-r--r--arch/parisc/kernel/vmlinux.lds.S9
-rw-r--r--arch/powerpc/kernel/vmlinux.lds.S10
-rw-r--r--arch/s390/kernel/vmlinux.lds.S10
-rw-r--r--arch/sh/kernel/vmlinux.lds.S11
-rw-r--r--arch/sparc/kernel/vmlinux.lds.S9
-rw-r--r--arch/um/include/asm/common.lds.S5
-rw-r--r--arch/um/kernel/dyn.lds.S2
-rw-r--r--arch/um/kernel/uml.lds.S2
-rw-r--r--arch/x86/kernel/vmlinux.lds.S11
-rw-r--r--arch/xtensa/kernel/vmlinux.lds.S14
-rw-r--r--include/asm-generic/vmlinux.lds.h18
25 files changed, 80 insertions, 155 deletions
diff --git a/arch/alpha/kernel/vmlinux.lds.S b/arch/alpha/kernel/vmlinux.lds.S
index 75fe1d6877e9..6dc03c35caa0 100644
--- a/arch/alpha/kernel/vmlinux.lds.S
+++ b/arch/alpha/kernel/vmlinux.lds.S
@@ -134,14 +134,6 @@ SECTIONS
134 __bss_stop = .; 134 __bss_stop = .;
135 _end = .; 135 _end = .;
136 136
137 /* Sections to be discarded */
138 /DISCARD/ : {
139 EXIT_TEXT
140 EXIT_DATA
141 *(.exitcall.exit)
142 *(.discard)
143 }
144
145 .mdebug 0 : { 137 .mdebug 0 : {
146 *(.mdebug) 138 *(.mdebug)
147 } 139 }
@@ -151,4 +143,6 @@ SECTIONS
151 143
152 STABS_DEBUG 144 STABS_DEBUG
153 DWARF_DEBUG 145 DWARF_DEBUG
146
147 DISCARDS
154} 148}
diff --git a/arch/avr32/kernel/vmlinux.lds.S b/arch/avr32/kernel/vmlinux.lds.S
index b8324608ec0c..c4b56654349a 100644
--- a/arch/avr32/kernel/vmlinux.lds.S
+++ b/arch/avr32/kernel/vmlinux.lds.S
@@ -124,15 +124,11 @@ SECTIONS
124 _end = .; 124 _end = .;
125 } 125 }
126 126
127 DWARF_DEBUG
128
127 /* When something in the kernel is NOT compiled as a module, the module 129 /* When something in the kernel is NOT compiled as a module, the module
128 * cleanup code and data are put into these segments. Both can then be 130 * cleanup code and data are put into these segments. Both can then be
129 * thrown away, as cleanup code is never called unless it's a module. 131 * thrown away, as cleanup code is never called unless it's a module.
130 */ 132 */
131 /DISCARD/ : { 133 DISCARDS
132 EXIT_DATA
133 *(.exitcall.exit)
134 *(.discard)
135 }
136
137 DWARF_DEBUG
138} 134}
diff --git a/arch/blackfin/kernel/vmlinux.lds.S b/arch/blackfin/kernel/vmlinux.lds.S
index 6e8eabd8f0a6..d7ffe299b979 100644
--- a/arch/blackfin/kernel/vmlinux.lds.S
+++ b/arch/blackfin/kernel/vmlinux.lds.S
@@ -277,9 +277,5 @@ SECTIONS
277 277
278 DWARF_DEBUG 278 DWARF_DEBUG
279 279
280 /DISCARD/ : 280 DISCARDS
281 {
282 *(.exitcall.exit)
283 *(.discard)
284 }
285} 281}
diff --git a/arch/cris/kernel/vmlinux.lds.S b/arch/cris/kernel/vmlinux.lds.S
index a3175ebb38cc..6c81836b9229 100644
--- a/arch/cris/kernel/vmlinux.lds.S
+++ b/arch/cris/kernel/vmlinux.lds.S
@@ -140,13 +140,7 @@ SECTIONS
140 _end = .; 140 _end = .;
141 __end = .; 141 __end = .;
142 142
143 /* Sections to be discarded */
144 /DISCARD/ : {
145 EXIT_TEXT
146 EXIT_DATA
147 *(.exitcall.exit)
148 *(.discard)
149 }
150
151 dram_end = dram_start + (CONFIG_ETRAX_DRAM_SIZE - __CONFIG_ETRAX_VMEM_SIZE)*1024*1024; 143 dram_end = dram_start + (CONFIG_ETRAX_DRAM_SIZE - __CONFIG_ETRAX_VMEM_SIZE)*1024*1024;
144
145 DISCARDS
152} 146}
diff --git a/arch/frv/kernel/vmlinux.lds.S b/arch/frv/kernel/vmlinux.lds.S
index 64b5a5e4d35e..7dbf41f68b52 100644
--- a/arch/frv/kernel/vmlinux.lds.S
+++ b/arch/frv/kernel/vmlinux.lds.S
@@ -178,7 +178,7 @@ SECTIONS
178 178
179 .comment 0 : { *(.comment) } 179 .comment 0 : { *(.comment) }
180 180
181 /DISCARD/ : { *(.discard) } 181 DISCARDS
182} 182}
183 183
184__kernel_image_size_no_bss = __bss_start - __kernel_image_start; 184__kernel_image_size_no_bss = __bss_start - __kernel_image_start;
diff --git a/arch/h8300/kernel/vmlinux.lds.S b/arch/h8300/kernel/vmlinux.lds.S
index 03d6c0df33db..662b02ecb86e 100644
--- a/arch/h8300/kernel/vmlinux.lds.S
+++ b/arch/h8300/kernel/vmlinux.lds.S
@@ -152,10 +152,6 @@ SECTIONS
152 __end = . ; 152 __end = . ;
153 __ramstart = .; 153 __ramstart = .;
154 } 154 }
155 /DISCARD/ : {
156 *(.exitcall.exit)
157 *(.discard)
158 }
159 .romfs : 155 .romfs :
160 { 156 {
161 *(.romfs*) 157 *(.romfs*)
@@ -166,4 +162,6 @@ SECTIONS
166 COMMAND_START = . - 0x200 ; 162 COMMAND_START = . - 0x200 ;
167 __ramend = . ; 163 __ramend = . ;
168 } 164 }
165
166 DISCARDS
169} 167}
diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
index 13d958975874..eb4214d1c5af 100644
--- a/arch/ia64/kernel/vmlinux.lds.S
+++ b/arch/ia64/kernel/vmlinux.lds.S
@@ -24,15 +24,14 @@ PHDRS {
24} 24}
25SECTIONS 25SECTIONS
26{ 26{
27 /* Sections to be discarded */ 27 /* unwind exit sections must be discarded before the rest of the
28 sections get included. */
28 /DISCARD/ : { 29 /DISCARD/ : {
29 EXIT_TEXT
30 EXIT_DATA
31 *(.exitcall.exit)
32 *(.discard)
33 *(.IA_64.unwind.exit.text) 30 *(.IA_64.unwind.exit.text)
34 *(.IA_64.unwind_info.exit.text) 31 *(.IA_64.unwind_info.exit.text)
35 } 32 *(.comment)
33 *(.note)
34 }
36 35
37 v = PAGE_OFFSET; /* this symbol is here to make debugging easier... */ 36 v = PAGE_OFFSET; /* this symbol is here to make debugging easier... */
38 phys_start = _start - LOAD_OFFSET; 37 phys_start = _start - LOAD_OFFSET;
@@ -317,7 +316,7 @@ SECTIONS
317 .debug_funcnames 0 : { *(.debug_funcnames) } 316 .debug_funcnames 0 : { *(.debug_funcnames) }
318 .debug_typenames 0 : { *(.debug_typenames) } 317 .debug_typenames 0 : { *(.debug_typenames) }
319 .debug_varnames 0 : { *(.debug_varnames) } 318 .debug_varnames 0 : { *(.debug_varnames) }
320 /* These must appear regardless of . */ 319
321 /DISCARD/ : { *(.comment) } 320 /* Default discards */
322 /DISCARD/ : { *(.note) } 321 DISCARDS
323} 322}
diff --git a/arch/m32r/kernel/vmlinux.lds.S b/arch/m32r/kernel/vmlinux.lds.S
index 480a49944cfd..de5e21cca6a5 100644
--- a/arch/m32r/kernel/vmlinux.lds.S
+++ b/arch/m32r/kernel/vmlinux.lds.S
@@ -120,14 +120,6 @@ SECTIONS
120 120
121 _end = . ; 121 _end = . ;
122 122
123 /* Sections to be discarded */
124 /DISCARD/ : {
125 EXIT_TEXT
126 EXIT_DATA
127 *(.exitcall.exit)
128 *(.discard)
129 }
130
131 /* Stabs debugging sections. */ 123 /* Stabs debugging sections. */
132 .stab 0 : { *(.stab) } 124 .stab 0 : { *(.stab) }
133 .stabstr 0 : { *(.stabstr) } 125 .stabstr 0 : { *(.stabstr) }
@@ -136,4 +128,7 @@ SECTIONS
136 .stab.index 0 : { *(.stab.index) } 128 .stab.index 0 : { *(.stab.index) }
137 .stab.indexstr 0 : { *(.stab.indexstr) } 129 .stab.indexstr 0 : { *(.stab.indexstr) }
138 .comment 0 : { *(.comment) } 130 .comment 0 : { *(.comment) }
131
132 /* Sections to be discarded */
133 DISCARDS
139} 134}
diff --git a/arch/m68k/kernel/vmlinux-std.lds b/arch/m68k/kernel/vmlinux-std.lds
index 905a797ada93..47eac19e8f61 100644
--- a/arch/m68k/kernel/vmlinux-std.lds
+++ b/arch/m68k/kernel/vmlinux-std.lds
@@ -82,14 +82,6 @@ SECTIONS
82 82
83 _end = . ; 83 _end = . ;
84 84
85 /* Sections to be discarded */
86 /DISCARD/ : {
87 EXIT_TEXT
88 EXIT_DATA
89 *(.exitcall.exit)
90 *(.discard)
91 }
92
93 /* Stabs debugging sections. */ 85 /* Stabs debugging sections. */
94 .stab 0 : { *(.stab) } 86 .stab 0 : { *(.stab) }
95 .stabstr 0 : { *(.stabstr) } 87 .stabstr 0 : { *(.stabstr) }
@@ -98,4 +90,7 @@ SECTIONS
98 .stab.index 0 : { *(.stab.index) } 90 .stab.index 0 : { *(.stab.index) }
99 .stab.indexstr 0 : { *(.stab.indexstr) } 91 .stab.indexstr 0 : { *(.stab.indexstr) }
100 .comment 0 : { *(.comment) } 92 .comment 0 : { *(.comment) }
93
94 /* Sections to be discarded */
95 DISCARDS
101} 96}
diff --git a/arch/m68k/kernel/vmlinux-sun3.lds b/arch/m68k/kernel/vmlinux-sun3.lds
index 47d04be322aa..03efaf04d7d7 100644
--- a/arch/m68k/kernel/vmlinux-sun3.lds
+++ b/arch/m68k/kernel/vmlinux-sun3.lds
@@ -77,14 +77,6 @@ __init_begin = .;
77 77
78 _end = . ; 78 _end = . ;
79 79
80 /* Sections to be discarded */
81 /DISCARD/ : {
82 EXIT_TEXT
83 EXIT_DATA
84 *(.exitcall.exit)
85 *(.discard)
86 }
87
88 .crap : { 80 .crap : {
89 /* Stabs debugging sections. */ 81 /* Stabs debugging sections. */
90 *(.stab) 82 *(.stab)
@@ -97,4 +89,6 @@ __init_begin = .;
97 *(.note) 89 *(.note)
98 } 90 }
99 91
92 /* Sections to be discarded */
93 DISCARDS
100} 94}
diff --git a/arch/m68knommu/kernel/vmlinux.lds.S b/arch/m68knommu/kernel/vmlinux.lds.S
index 68111a61a77f..2736a5e309c0 100644
--- a/arch/m68knommu/kernel/vmlinux.lds.S
+++ b/arch/m68knommu/kernel/vmlinux.lds.S
@@ -184,13 +184,6 @@ SECTIONS {
184 __init_end = .; 184 __init_end = .;
185 } > INIT 185 } > INIT
186 186
187 /DISCARD/ : {
188 EXIT_TEXT
189 EXIT_DATA
190 *(.exitcall.exit)
191 *(.discard)
192 }
193
194 .bss : { 187 .bss : {
195 . = ALIGN(4); 188 . = ALIGN(4);
196 _sbss = . ; 189 _sbss = . ;
@@ -201,5 +194,6 @@ SECTIONS {
201 _end = . ; 194 _end = . ;
202 } > BSS 195 } > BSS
203 196
197 DISCARDS
204} 198}
205 199
diff --git a/arch/microblaze/kernel/vmlinux.lds.S b/arch/microblaze/kernel/vmlinux.lds.S
index 81bebdcb18fe..ec5fa91a48d8 100644
--- a/arch/microblaze/kernel/vmlinux.lds.S
+++ b/arch/microblaze/kernel/vmlinux.lds.S
@@ -163,5 +163,5 @@ SECTIONS {
163 . = ALIGN(4096); 163 . = ALIGN(4096);
164 _end = .; 164 _end = .;
165 165
166 /DISCARD/ : { *(.discard) } 166 DISCARDS
167} 167}
diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index 45901609b741..1474c18fb777 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -176,18 +176,6 @@ SECTIONS
176 176
177 _end = . ; 177 _end = . ;
178 178
179 /* Sections to be discarded */
180 /DISCARD/ : {
181 *(.exitcall.exit)
182 *(.discard)
183
184 /* ABI crap starts here */
185 *(.MIPS.options)
186 *(.options)
187 *(.pdr)
188 *(.reginfo)
189 }
190
191 /* These mark the ABI of the kernel for debuggers. */ 179 /* These mark the ABI of the kernel for debuggers. */
192 .mdebug.abi32 : { 180 .mdebug.abi32 : {
193 KEEP(*(.mdebug.abi32)) 181 KEEP(*(.mdebug.abi32))
@@ -213,4 +201,14 @@ SECTIONS
213 *(.gptab.bss) 201 *(.gptab.bss)
214 *(.gptab.sbss) 202 *(.gptab.sbss)
215 } 203 }
204
205 /* Sections to be discarded */
206 DISCARDS
207 /DISCARD/ : {
208 /* ABI crap starts here */
209 *(.MIPS.options)
210 *(.options)
211 *(.pdr)
212 *(.reginfo)
213 }
216} 214}
diff --git a/arch/mn10300/kernel/vmlinux.lds.S b/arch/mn10300/kernel/vmlinux.lds.S
index 5609d4962a55..8fcd0f1e21de 100644
--- a/arch/mn10300/kernel/vmlinux.lds.S
+++ b/arch/mn10300/kernel/vmlinux.lds.S
@@ -115,13 +115,10 @@ SECTIONS
115 . = ALIGN(PAGE_SIZE); 115 . = ALIGN(PAGE_SIZE);
116 pg0 = .; 116 pg0 = .;
117 117
118 /* Sections to be discarded */
119 /DISCARD/ : {
120 EXIT_CALL
121 *(.discard)
122 }
123
124 STABS_DEBUG 118 STABS_DEBUG
125 119
126 DWARF_DEBUG 120 DWARF_DEBUG
121
122 /* Sections to be discarded */
123 DISCARDS
127} 124}
diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S
index ccf58341845a..aea1784edbd1 100644
--- a/arch/parisc/kernel/vmlinux.lds.S
+++ b/arch/parisc/kernel/vmlinux.lds.S
@@ -237,10 +237,12 @@ SECTIONS
237 /* freed after init ends here */ 237 /* freed after init ends here */
238 _end = . ; 238 _end = . ;
239 239
240 STABS_DEBUG
241 .note 0 : { *(.note) }
242
240 /* Sections to be discarded */ 243 /* Sections to be discarded */
244 DISCARDS
241 /DISCARD/ : { 245 /DISCARD/ : {
242 *(.exitcall.exit)
243 *(.discard)
244#ifdef CONFIG_64BIT 246#ifdef CONFIG_64BIT
245 /* temporary hack until binutils is fixed to not emit these 247 /* temporary hack until binutils is fixed to not emit these
246 * for static binaries 248 * for static binaries
@@ -253,7 +255,4 @@ SECTIONS
253 *(.gnu.hash) 255 *(.gnu.hash)
254#endif 256#endif
255 } 257 }
256
257 STABS_DEBUG
258 .note 0 : { *(.note) }
259} 258}
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index 7fca9355fd3d..244e3658983c 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -37,13 +37,6 @@ jiffies = jiffies_64 + 4;
37#endif 37#endif
38SECTIONS 38SECTIONS
39{ 39{
40 /* Sections to be discarded. */
41 /DISCARD/ : {
42 *(.exitcall.exit)
43 *(.discard)
44 EXIT_DATA
45 }
46
47 . = KERNELBASE; 40 . = KERNELBASE;
48 41
49/* 42/*
@@ -299,4 +292,7 @@ SECTIONS
299 . = ALIGN(PAGE_SIZE); 292 . = ALIGN(PAGE_SIZE);
300 _end = . ; 293 _end = . ;
301 PROVIDE32 (end = .); 294 PROVIDE32 (end = .);
295
296 /* Sections to be discarded. */
297 DISCARDS
302} 298}
diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S
index 98867dfea469..82415c75b996 100644
--- a/arch/s390/kernel/vmlinux.lds.S
+++ b/arch/s390/kernel/vmlinux.lds.S
@@ -157,14 +157,10 @@ SECTIONS
157 157
158 _end = . ; 158 _end = . ;
159 159
160 /* Sections to be discarded */
161 /DISCARD/ : {
162 EXIT_DATA
163 *(.exitcall.exit)
164 *(.discard)
165 }
166
167 /* Debugging sections. */ 160 /* Debugging sections. */
168 STABS_DEBUG 161 STABS_DEBUG
169 DWARF_DEBUG 162 DWARF_DEBUG
163
164 /* Sections to be discarded */
165 DISCARDS
170} 166}
diff --git a/arch/sh/kernel/vmlinux.lds.S b/arch/sh/kernel/vmlinux.lds.S
index 766976d27b21..0ce254bca92f 100644
--- a/arch/sh/kernel/vmlinux.lds.S
+++ b/arch/sh/kernel/vmlinux.lds.S
@@ -163,17 +163,14 @@ SECTIONS
163 _end = . ; 163 _end = . ;
164 } 164 }
165 165
166 STABS_DEBUG
167 DWARF_DEBUG
168
166 /* 169 /*
167 * When something in the kernel is NOT compiled as a module, the 170 * When something in the kernel is NOT compiled as a module, the
168 * module cleanup code and data are put into these segments. Both 171 * module cleanup code and data are put into these segments. Both
169 * can then be thrown away, as cleanup code is never called unless 172 * can then be thrown away, as cleanup code is never called unless
170 * it's a module. 173 * it's a module.
171 */ 174 */
172 /DISCARD/ : { 175 DISCARDS
173 *(.exitcall.exit)
174 *(.discard)
175 }
176
177 STABS_DEBUG
178 DWARF_DEBUG
179} 176}
diff --git a/arch/sparc/kernel/vmlinux.lds.S b/arch/sparc/kernel/vmlinux.lds.S
index d63cf914667d..866390feb683 100644
--- a/arch/sparc/kernel/vmlinux.lds.S
+++ b/arch/sparc/kernel/vmlinux.lds.S
@@ -171,13 +171,8 @@ SECTIONS
171 } 171 }
172 _end = . ; 172 _end = . ;
173 173
174 /DISCARD/ : {
175 EXIT_TEXT
176 EXIT_DATA
177 *(.exitcall.exit)
178 *(.discard)
179 }
180
181 STABS_DEBUG 174 STABS_DEBUG
182 DWARF_DEBUG 175 DWARF_DEBUG
176
177 DISCARDS
183} 178}
diff --git a/arch/um/include/asm/common.lds.S b/arch/um/include/asm/common.lds.S
index cb0248616d49..37ecc5577a9a 100644
--- a/arch/um/include/asm/common.lds.S
+++ b/arch/um/include/asm/common.lds.S
@@ -123,8 +123,3 @@
123 __initramfs_end = .; 123 __initramfs_end = .;
124 } 124 }
125 125
126 /* Sections to be discarded */
127 /DISCARD/ : {
128 *(.exitcall.exit)
129 }
130
diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S
index 2916d6eadffd..715a188c0472 100644
--- a/arch/um/kernel/dyn.lds.S
+++ b/arch/um/kernel/dyn.lds.S
@@ -157,5 +157,5 @@ SECTIONS
157 157
158 DWARF_DEBUG 158 DWARF_DEBUG
159 159
160 /DISCARD/ : { *(.discard) } 160 DISCARDS
161} 161}
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
index 1f8a622cabe1..2ebd39765db8 100644
--- a/arch/um/kernel/uml.lds.S
+++ b/arch/um/kernel/uml.lds.S
@@ -101,5 +101,5 @@ SECTIONS
101 101
102 DWARF_DEBUG 102 DWARF_DEBUG
103 103
104 /DISCARD/ : { *(.discard) } 104 DISCARDS
105} 105}
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 367e87882041..b600c843710b 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -387,15 +387,12 @@ SECTIONS
387 _end = .; 387 _end = .;
388 } 388 }
389 389
390 /* Sections to be discarded */
391 /DISCARD/ : {
392 *(.exitcall.exit)
393 *(.eh_frame)
394 *(.discard)
395 }
396
397 STABS_DEBUG 390 STABS_DEBUG
398 DWARF_DEBUG 391 DWARF_DEBUG
392
393 /* Sections to be discarded */
394 DISCARDS
395 /DISCARD/ : { *(.eh_frame) }
399} 396}
400 397
401 398
diff --git a/arch/xtensa/kernel/vmlinux.lds.S b/arch/xtensa/kernel/vmlinux.lds.S
index b1e24638acd7..921b6ff3b645 100644
--- a/arch/xtensa/kernel/vmlinux.lds.S
+++ b/arch/xtensa/kernel/vmlinux.lds.S
@@ -280,16 +280,6 @@ SECTIONS
280 *(.ResetVector.text) 280 *(.ResetVector.text)
281 } 281 }
282 282
283 /* Sections to be discarded */
284 /DISCARD/ :
285 {
286 *(.exit.literal)
287 EXIT_TEXT
288 EXIT_DATA
289 *(.exitcall.exit)
290 *(.discard)
291 }
292
293 .xt.lit : { *(.xt.lit) } 283 .xt.lit : { *(.xt.lit) }
294 .xt.prop : { *(.xt.prop) } 284 .xt.prop : { *(.xt.prop) }
295 285
@@ -322,4 +312,8 @@ SECTIONS
322 *(.xt.lit) 312 *(.xt.lit)
323 *(.gnu.linkonce.p*) 313 *(.gnu.linkonce.p*)
324 } 314 }
315
316 /* Sections to be discarded */
317 DISCARDS
318 /DISCARD/ : { *(.exit.literal) }
325} 319}
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index c5c18ac878ab..ab8ea9b7741e 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -35,13 +35,10 @@
35 * __bss_stop = .; 35 * __bss_stop = .;
36 * _end = .; 36 * _end = .;
37 * 37 *
38 * /DISCARD/ : {
39 * EXIT_TEXT
40 * EXIT_DATA
41 * EXIT_CALL
42 * }
43 * STABS_DEBUG 38 * STABS_DEBUG
44 * DWARF_DEBUG 39 * DWARF_DEBUG
40 *
41 * DISCARDS // must be the last
45 * } 42 * }
46 * 43 *
47 * [__init_begin, __init_end] is the init section that may be freed after init 44 * [__init_begin, __init_end] is the init section that may be freed after init
@@ -629,11 +626,20 @@
629#define INIT_RAM_FS 626#define INIT_RAM_FS
630#endif 627#endif
631 628
629/*
630 * Default discarded sections.
631 *
632 * Some archs want to discard exit text/data at runtime rather than
633 * link time due to cross-section references such as alt instructions,
634 * bug table, eh_frame, etc. DISCARDS must be the last of output
635 * section definitions so that such archs put those in earlier section
636 * definitions.
637 */
632#define DISCARDS \ 638#define DISCARDS \
633 /DISCARD/ : { \ 639 /DISCARD/ : { \
634 EXIT_TEXT \ 640 EXIT_TEXT \
635 EXIT_DATA \ 641 EXIT_DATA \
636 *(.exitcall.exit) \ 642 EXIT_CALL \
637 *(.discard) \ 643 *(.discard) \
638 } 644 }
639 645