Skip to content

Commit d4d9a55

Browse files
lzufalconralfbaechle
authored andcommitted
MIPS: Cleanup and Fixup of compressed kernel support
o Remove the .initrd section. The initrd section was already handled when vmlinux was linked. o Discard .MIPS.options, .options, .pdr, .reginfo, .comment and .note sections. If .MIPS.options is not removed, kernels compiled with gcc 3.4.6 will not boot. o Clean up the file format. o Remove several other unneeded sections. Tested with GCC 3.4.6 and 4.4.1 with and without initrd. Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com> Cc: linux-mips@linux-mips.org Patchwork: http://patchwork.linux-mips.org/patch/785/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent abbdc3d commit d4d9a55

3 files changed

Lines changed: 59 additions & 155 deletions

File tree

‎arch/mips/boot/compressed/Makefile‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ $(obj)/piggy.o: $(obj)/vmlinux.$(suffix_y) $(obj)/dummy.o
5656
LDFLAGS_vmlinuz := $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T
5757
vmlinuz: $(src)/ld.script $(obj-y) $(obj)/piggy.o
5858
$(call if_changed,ld)
59-
$(Q)$(OBJCOPY) $(OBJCOPYFLAGS) -R .comment -R .stab -R .stabstr -R .initrd -R .sysmap $@
59+
$(Q)$(OBJCOPY) $(OBJCOPYFLAGS) $@
6060

6161
#
6262
# Some DECstations need all possible sections of an ECOFF executable
@@ -84,14 +84,11 @@ vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ)
8484
$(obj)/../elf2ecoff: $(src)/../elf2ecoff.c
8585
$(Q)$(HOSTCC) -o $@ $^
8686

87-
drop-sections = .reginfo .mdebug .comment .note .pdr .options .MIPS.options
88-
strip-flags = $(addprefix --remove-section=,$(drop-sections))
89-
90-
OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary $(strip-flags)
87+
OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary
9188
vmlinuz.bin: vmlinuz
9289
$(call if_changed,objcopy)
9390

94-
OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec $(strip-flags)
91+
OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec
9592
vmlinuz.srec: vmlinuz
9693
$(call if_changed,objcopy)
9794

‎arch/mips/boot/compressed/decompress.c‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ char *zimage_start;
2828

2929
/* The linker tells us where the image is. */
3030
extern unsigned char __image_begin, __image_end;
31-
extern unsigned char __ramdisk_begin, __ramdisk_end;
32-
unsigned long initrd_size;
3331

3432
/* debug interfaces */
3533
extern void puts(const char *s);
@@ -102,14 +100,6 @@ void decompress_kernel(unsigned long boot_heap_start)
102100
puthex((unsigned long)(zimage_size + zimage_start));
103101
puts("\n");
104102

105-
if (initrd_size) {
106-
puts("initrd at: ");
107-
puthex((unsigned long)(&__ramdisk_begin));
108-
puts(" ");
109-
puthex((unsigned long)(&__ramdisk_end));
110-
puts("\n");
111-
}
112-
113103
/* this area are prepared for mallocing when decompressing */
114104
free_mem_ptr = boot_heap_start;
115105
free_mem_end_ptr = boot_heap_start + BOOT_HEAP_SIZE;
Lines changed: 56 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,150 +1,67 @@
1+
/*
2+
* ld.script for compressed kernel support of MIPS
3+
*
4+
* Copyright (C) 2009 Lemote Inc.
5+
* Author: Wu Zhangjin <wuzj@lemote.com>
6+
*/
7+
18
OUTPUT_ARCH(mips)
29
ENTRY(start)
310
SECTIONS
411
{
5-
/* Read-only sections, merged into text segment: */
6-
.init : { *(.init) } =0
7-
.text :
8-
{
9-
_ftext = . ;
10-
*(.text)
11-
*(.rodata)
12-
*(.rodata1)
13-
/* .gnu.warning sections are handled specially by elf32.em. */
14-
*(.gnu.warning)
15-
} =0
16-
.kstrtab : { *(.kstrtab) }
17-
18-
. = ALIGN(16); /* Exception table */
19-
__start___ex_table = .;
20-
__ex_table : { *(__ex_table) }
21-
__stop___ex_table = .;
22-
23-
__start___dbe_table = .; /* Exception table for data bus errors */
24-
__dbe_table : { *(__dbe_table) }
25-
__stop___dbe_table = .;
26-
27-
__start___ksymtab = .; /* Kernel symbol table */
28-
__ksymtab : { *(__ksymtab) }
29-
__stop___ksymtab = .;
30-
31-
_etext = .;
32-
33-
. = ALIGN(8192);
34-
.data.init_task : { *(.data.init_task) }
35-
36-
/* Startup code */
37-
. = ALIGN(4096);
38-
__init_begin = .;
39-
.text.init : { *(.text.init) }
40-
.data.init : { *(.data.init) }
41-
. = ALIGN(16);
42-
__setup_start = .;
43-
.setup.init : { *(.setup.init) }
44-
__setup_end = .;
45-
__initcall_start = .;
46-
.initcall.init : { *(.initcall.init) }
47-
__initcall_end = .;
48-
. = ALIGN(4096); /* Align double page for init_task_union */
49-
__init_end = .;
50-
51-
. = ALIGN(4096);
52-
.data.page_aligned : { *(.data.idt) }
53-
54-
. = ALIGN(32);
55-
.data.cacheline_aligned : { *(.data.cacheline_aligned) }
12+
/* . = VMLINUZ_LOAD_ADDRESS */
13+
/* read-only */
14+
_text = .; /* Text and read-only data */
15+
.text : {
16+
_ftext = . ;
17+
*(.text)
18+
*(.rodata)
19+
} = 0
20+
_etext = .; /* End of text section */
5621

57-
.fini : { *(.fini) } =0
58-
.reginfo : { *(.reginfo) }
59-
/* Adjust the address for the data segment. We want to adjust up to
60-
the same address within the page on the next page up. It would
61-
be more correct to do this:
62-
. = .;
63-
The current expression does not correctly handle the case of a
64-
text segment ending precisely at the end of a page; it causes the
65-
data segment to skip a page. The above expression does not have
66-
this problem, but it will currently (2/95) cause BFD to allocate
67-
a single segment, combining both text and data, for this case.
68-
This will prevent the text segment from being shared among
69-
multiple executions of the program; I think that is more
70-
important than losing a page of the virtual address space (note
71-
that no actual memory is lost; the page which is skipped can not
72-
be referenced). */
73-
. = .;
74-
.data :
75-
{
76-
_fdata = . ;
77-
*(.data)
22+
/* writable */
23+
.data : { /* Data */
24+
_fdata = . ;
25+
*(.data)
26+
/* Put the compressed image here, so bss is on the end. */
27+
__image_begin = .;
28+
*(.image)
29+
__image_end = .;
30+
CONSTRUCTORS
31+
}
32+
.sdata : { *(.sdata) }
33+
. = ALIGN(4);
34+
_edata = .; /* End of data section */
7835

79-
/* Put the compressed image here, so bss is on the end. */
80-
__image_begin = .;
81-
*(.image)
82-
__image_end = .;
83-
/* Align the initial ramdisk image (INITRD) on page boundaries. */
84-
. = ALIGN(4096);
85-
__ramdisk_begin = .;
86-
*(.initrd)
87-
__ramdisk_end = .;
88-
. = ALIGN(4096);
36+
/* BSS */
37+
__bss_start = .;
38+
_fbss = .;
39+
.sbss : { *(.sbss) *(.scommon) }
40+
.bss : {
41+
*(.dynbss)
42+
*(.bss)
43+
*(COMMON)
44+
}
45+
. = ALIGN(4);
46+
_end = . ;
8947

90-
CONSTRUCTORS
91-
}
92-
.data1 : { *(.data1) }
93-
_gp = . + 0x8000;
94-
.lit8 : { *(.lit8) }
95-
.lit4 : { *(.lit4) }
96-
.ctors : { *(.ctors) }
97-
.dtors : { *(.dtors) }
98-
.got : { *(.got.plt) *(.got) }
99-
.dynamic : { *(.dynamic) }
100-
/* We want the small data sections together, so single-instruction offsets
101-
can access them all, and initialized data all before uninitialized, so
102-
we can shorten the on-disk segment size. */
103-
.sdata : { *(.sdata) }
104-
. = ALIGN(4);
105-
_edata = .;
106-
PROVIDE (edata = .);
48+
/* These are needed for ELF backends which have not yet been converted
49+
* to the new style linker. */
10750

108-
__bss_start = .;
109-
_fbss = .;
110-
.sbss : { *(.sbss) *(.scommon) }
111-
.bss :
112-
{
113-
*(.dynbss)
114-
*(.bss)
115-
*(COMMON)
116-
. = ALIGN(4);
117-
_end = . ;
118-
PROVIDE (end = .);
119-
}
51+
.stab 0 : { *(.stab) }
52+
.stabstr 0 : { *(.stabstr) }
12053

121-
/* Sections to be discarded */
122-
/DISCARD/ :
123-
{
124-
*(.text.exit)
125-
*(.data.exit)
126-
*(.exitcall.exit)
127-
}
54+
/* These must appear regardless of . */
55+
.gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
56+
.gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
12857

129-
/* This is the MIPS specific mdebug section. */
130-
.mdebug : { *(.mdebug) }
131-
/* These are needed for ELF backends which have not yet been
132-
converted to the new style linker. */
133-
.stab 0 : { *(.stab) }
134-
.stabstr 0 : { *(.stabstr) }
135-
/* DWARF debug sections.
136-
Symbols in the .debug DWARF section are relative to the beginning of the
137-
section so we begin .debug at 0. It's not clear yet what needs to happen
138-
for the others. */
139-
.debug 0 : { *(.debug) }
140-
.debug_srcinfo 0 : { *(.debug_srcinfo) }
141-
.debug_aranges 0 : { *(.debug_aranges) }
142-
.debug_pubnames 0 : { *(.debug_pubnames) }
143-
.debug_sfnames 0 : { *(.debug_sfnames) }
144-
.line 0 : { *(.line) }
145-
/* These must appear regardless of . */
146-
.gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
147-
.gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
148-
.comment : { *(.comment) }
149-
.note : { *(.note) }
58+
/* Sections to be discarded */
59+
/DISCARD/ : {
60+
*(.MIPS.options)
61+
*(.options)
62+
*(.pdr)
63+
*(.reginfo)
64+
*(.comment)
65+
*(.note)
66+
}
15067
}

0 commit comments

Comments
 (0)