Some archs use the C preprocessor to adapt their vmlinux.lds script.
Introduce a common rule for these arch/*/Makefile's to use.
prepare: include/linux/version.h include/asm include/config/MARKER
@echo ' Starting the build. KBUILD_BUILTIN=$(KBUILD_BUILTIN) KBUILD_MODULES=$(KBUILD_MODULES)'
+# This can be used by arch/$ARCH/Makefile to preprocess
+# their vmlinux.lds.S file
+
+arch/$ARCH/vmlinux.lds.s: arch/$ARCH/vmlinux.lds.S
+ $(CPP) $(CPPFLAGS) $(CPPFLAGS_$@) -P -C -U$(ARCH) $< -o $@
+
# Single targets
# ---------------------------------------------------------------------------
NM := $(NM) -B
-LDFLAGS_vmlinux = -static -T arch/alpha/vmlinux.lds -N #-relax
+LDFLAGS_vmlinux = -static -T arch/alpha/vmlinux.lds.s -N #-relax
CFLAGS := $(CFLAGS) -pipe -mno-fp-regs -ffixed-8
# Determine if we can use the BWX instructions with GAS.
@$(MAKEBOOT) clean
archmrproper:
- rm -f arch/alpha/vmlinux.lds
rm -f include/asm-alpha/asm_offsets.h
-vmlinux: arch/alpha/vmlinux.lds
-
-arch/alpha/vmlinux.lds: arch/alpha/vmlinux.lds.in
- $(CPP) $(CPPFLAGS) -xc -P arch/alpha/vmlinux.lds.in -o arch/alpha/vmlinux.lds
+vmlinux: arch/alpha/vmlinux.lds.s
bootpfile:
@$(MAKEBOOT) bootpfile
--- /dev/null
+#include <linux/config.h>
+
+OUTPUT_FORMAT("elf64-alpha")
+ENTRY(__start)
+PHDRS { kernel PT_LOAD ; }
+jiffies = jiffies_64;
+SECTIONS
+{
+#ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
+ . = 0xfffffc0000310000;
+#else
+ . = 0xfffffc0000810000;
+#endif
+
+ .text : {
+ _text = .;
+ *(.text)
+ _etext = .;
+ } :kernel
+
+ /* Exception table */
+ __ex_table ALIGN(16) : {
+ __start___ex_table = .;
+ *(__ex_table)
+ __stop___ex_table = .;
+ }
+
+ /* Kernel symbol table */
+ __ksymtab ALIGN(8) : {
+ __start___ksymtab = .;
+ *(__ksymtab)
+ __stop___ksymtab = .;
+ }
+ .kstrtab : { *(.kstrtab) }
+
+ /* Startup code */
+ .text.init ALIGN(8192) : {
+ __init_begin = .;
+ *(.text.init)
+ }
+ .data.init : { *(.data.init) }
+
+ .setup.init ALIGN(16): {
+ __setup_start = .;
+ *(.setup.init)
+ __setup_end = .;
+ }
+
+ .initcall.init ALIGN(8): {
+ __initcall_start = .;
+ *(.initcall1.init)
+ *(.initcall2.init)
+ *(.initcall3.init)
+ *(.initcall4.init)
+ *(.initcall5.init)
+ *(.initcall6.init)
+ *(.initcall7.init)
+ __initcall_end = .;
+ }
+
+ . = ALIGN(64);
+ __per_cpu_start = .;
+ .data.percpu : { *(.data.percpu) }
+ __per_cpu_end = .;
+
+ /* The initial task and kernel stack */
+ .data.init_thread ALIGN(2*8192) : {
+ __init_end = .;
+ *(.data.init_thread)
+ }
+
+ /* Global data */
+ .data.cacheline_aligned : {
+ _data = .;
+ *(.data.cacheline_aligned)
+ }
+ .rodata : { *(.rodata) *(.rodata.*) }
+ .data : { *(.data) CONSTRUCTORS }
+ .got : { *(.got) }
+ .sdata : {
+ *(.sdata)
+ _edata = .;
+ }
+
+ .sbss : {
+ __bss_start = .;
+ *(.sbss) *(.scommon)
+ }
+ .bss : {
+ *(.bss) *(COMMON)
+ __bss_stop = .;
+ _end = .;
+ }
+
+ .mdebug 0 : { *(.mdebug) }
+ .note 0 : { *(.note) }
+ .comment 0 : { *(.comment) }
+
+ /* DWARF 1 */
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ /* GNU DWARF 1 extensions */
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ /* DWARF 1.1 and DWARF 2 */
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ /* DWARF 2 */
+ .debug_info 0 : { *(.debug_info) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ /* SGI/MIPS DWARF 2 extensions */
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+
+ /DISCARD/ : { *(.text.exit) *(.data.exit) *(.exitcall.exit) }
+}
+++ /dev/null
-#include <linux/config.h>
-
-OUTPUT_FORMAT("elf64-alpha")
-ENTRY(__start)
-PHDRS { kernel PT_LOAD ; }
-jiffies = jiffies_64;
-SECTIONS
-{
-#ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
- . = 0xfffffc0000310000;
-#else
- . = 0xfffffc0000810000;
-#endif
-
- .text : {
- _text = .;
- *(.text)
- _etext = .;
- } :kernel
-
- /* Exception table */
- __ex_table ALIGN(16) : {
- __start___ex_table = .;
- *(__ex_table)
- __stop___ex_table = .;
- }
-
- /* Kernel symbol table */
- __ksymtab ALIGN(8) : {
- __start___ksymtab = .;
- *(__ksymtab)
- __stop___ksymtab = .;
- }
- .kstrtab : { *(.kstrtab) }
-
- /* Startup code */
- .text.init ALIGN(8192) : {
- __init_begin = .;
- *(.text.init)
- }
- .data.init : { *(.data.init) }
-
- .setup.init ALIGN(16): {
- __setup_start = .;
- *(.setup.init)
- __setup_end = .;
- }
-
- .initcall.init ALIGN(8): {
- __initcall_start = .;
- *(.initcall1.init)
- *(.initcall2.init)
- *(.initcall3.init)
- *(.initcall4.init)
- *(.initcall5.init)
- *(.initcall6.init)
- *(.initcall7.init)
- __initcall_end = .;
- }
-
- . = ALIGN(64);
- __per_cpu_start = .;
- .data.percpu : { *(.data.percpu) }
- __per_cpu_end = .;
-
- /* The initial task and kernel stack */
- .data.init_thread ALIGN(2*8192) : {
- __init_end = .;
- *(.data.init_thread)
- }
-
- /* Global data */
- .data.cacheline_aligned : {
- _data = .;
- *(.data.cacheline_aligned)
- }
- .rodata : { *(.rodata) *(.rodata.*) }
- .data : { *(.data) CONSTRUCTORS }
- .got : { *(.got) }
- .sdata : {
- *(.sdata)
- _edata = .;
- }
-
- .sbss : {
- __bss_start = .;
- *(.sbss) *(.scommon)
- }
- .bss : {
- *(.bss) *(COMMON)
- __bss_stop = .;
- _end = .;
- }
-
- .mdebug 0 : { *(.mdebug) }
- .note 0 : { *(.note) }
- .comment 0 : { *(.comment) }
-
- /* DWARF 1 */
- .debug 0 : { *(.debug) }
- .line 0 : { *(.line) }
- /* GNU DWARF 1 extensions */
- .debug_srcinfo 0 : { *(.debug_srcinfo) }
- .debug_sfnames 0 : { *(.debug_sfnames) }
- /* DWARF 1.1 and DWARF 2 */
- .debug_aranges 0 : { *(.debug_aranges) }
- .debug_pubnames 0 : { *(.debug_pubnames) }
- /* DWARF 2 */
- .debug_info 0 : { *(.debug_info) }
- .debug_abbrev 0 : { *(.debug_abbrev) }
- .debug_line 0 : { *(.debug_line) }
- .debug_frame 0 : { *(.debug_frame) }
- .debug_str 0 : { *(.debug_str) }
- .debug_loc 0 : { *(.debug_loc) }
- .debug_macinfo 0 : { *(.debug_macinfo) }
- /* SGI/MIPS DWARF 2 extensions */
- .debug_weaknames 0 : { *(.debug_weaknames) }
- .debug_funcnames 0 : { *(.debug_funcnames) }
- .debug_typenames 0 : { *(.debug_typenames) }
- .debug_varnames 0 : { *(.debug_varnames) }
-
- /DISCARD/ : { *(.text.exit) *(.data.exit) *(.exitcall.exit) }
-}
export AWK
OBJCOPYFLAGS := --strip-all
-LDFLAGS_vmlinux := -static -T arch/$(ARCH)/vmlinux.lds
+LDFLAGS_vmlinux := -static -T arch/$(ARCH)/vmlinux.lds.s
AFLAGS_KERNEL := -mconstant-gp
EXTRA =
MAKEBOOT = $(MAKE) -C arch/$(ARCH)/boot
-vmlinux: arch/$(ARCH)/vmlinux.lds
+vmlinux: arch/$(ARCH)/vmlinux.lds.s
-arch/$(ARCH)/vmlinux.lds: arch/$(ARCH)/vmlinux.lds.S FORCE
- $(CPP) $(AFLAGS) -C -P -traditional $< > $@
+CPPFLAGS_arch/ia64/vmlinux.lds.s := -traditional
compressed: vmlinux
$(OBJCOPY) $(OBJCOPYFLAGS) vmlinux vmlinux-tmp
@$(MAKEBOOT) clean
archmrproper:
- rm -f arch/$(ARCH)/vmlinux.lds
@$(MAKE) -C arch/$(ARCH)/tools mrproper
bootpfile:
#
ifdef CONFIG_BOOT_ELF32
CFLAGS += -Wa,-32
-LDFLAGS_vmlinux += -T arch/mips64/ld.script.elf32
+LDFLAGS_vmlinux += -T arch/mips64/vmlinux.lds.s
endif
#
# The 64-bit ELF tools are pretty broken so at this time we generate 64-bit
#
ifdef CONFIG_BOOT_ELF64
CFLAGS += -Wa,-32
-LDFLAGS_vmlinux += -T arch/mips64/ld.script.elf32
+LDFLAGS_vmlinux += -T arch/mips64/vmlinux.lds.s
#AS += -64
#LDFLAGS += -m elf64bmip
#LDFLAGS_vmlinux += -T arch/mips64/ld.script.elf64
64bit-bfd = elf64-bigmips
endif
-vmlinux: arch/mips64/ld.script.elf32
-arch/mips64/ld.script.elf32: arch/mips64/ld.script.elf32.S
- $(CPP) $(CPPFLAGS) -C -P -imacros $(srctree)/include/asm-mips64/sn/mapped_kernel.h -Umips $< > $@
+vmlinux: arch/mips64/vmlinux.lds.s
+
+CPPFLAGS_arch/mips64/vmlinux.lds.s := -imacros $(srctree)/include/asm-mips64/sn/mapped_kernel.h
ifdef CONFIG_MAPPED_KERNEL
vmlinux.64: vmlinux
archclean:
@$(MAKEBOOT) clean
$(MAKE) -C arch/$(ARCH)/tools clean
- rm -f vmlinux.64 arch/$(ARCH)/ld.script.elf32
archmrproper:
@$(MAKEBOOT) mrproper
+++ /dev/null
-OUTPUT_ARCH(mips)
-ENTRY(kernel_entry)
-SECTIONS
-{
- /* Read-only sections, merged into text segment: */
- .init : { *(.init) } =0
- .text :
- {
- *(.text)
- *(.rodata)
- *(.rodata.*)
- *(.rodata1)
- /* .gnu.warning sections are handled specially by elf32.em. */
- *(.gnu.warning)
- } =0
- .kstrtab : { *(.kstrtab) }
-
- . = ALIGN(16); /* Exception table */
- __start___ex_table = .;
- __ex_table : { *(__ex_table) }
- __stop___ex_table = .;
-
- __start___dbe_table = .; /* Exception table for data bus errors */
- __dbe_table : { *(__dbe_table) }
- __stop___dbe_table = .;
-
- _etext = .;
-
- . = ALIGN(16384);
- . = . + MAPPED_OFFSET; /* for CONFIG_MAPPED_KERNEL */
- .data.init_task : { *(.data.init_task) }
-
- /* Startup code */
- . = ALIGN(4096);
- __init_begin = .;
- .text.init : { *(.text.init) }
- .data.init : { *(.data.init) }
- . = ALIGN(16);
- __setup_start = .;
- .setup.init : { *(.setup.init) }
- __setup_end = .;
- __initcall_start = .;
- .initcall.init : {
- *(.initcall1.init)
- *(.initcall2.init)
- *(.initcall3.init)
- *(.initcall4.init)
- *(.initcall5.init)
- *(.initcall6.init)
- *(.initcall7.init)
- }
- __initcall_end = .;
- . = ALIGN(4096); /* Align double page for init_task_union */
- __init_end = .;
-
- . = ALIGN(4096);
- .data.page_aligned : { *(.data.idt) }
-
- . = ALIGN(32);
- .data.cacheline_aligned : { *(.data.cacheline_aligned) }
-
- .fini : { *(.fini) } =0
- .reginfo : { *(.reginfo) }
- /* Adjust the address for the data segment. We want to adjust up to
- the same address within the page on the next page up. It would
- be more correct to do this:
- . = .;
- The current expression does not correctly handle the case of a
- text segment ending precisely at the end of a page; it causes the
- data segment to skip a page. The above expression does not have
- this problem, but it will currently (2/95) cause BFD to allocate
- a single segment, combining both text and data, for this case.
- This will prevent the text segment from being shared among
- multiple executions of the program; I think that is more
- important than losing a page of the virtual address space (note
- that no actual memory is lost; the page which is skipped can not
- be referenced). */
- . = .;
- .data :
- {
- _fdata = . ;
- *(.data)
- CONSTRUCTORS
- }
- .data1 : { *(.data1) }
- .lit8 : { *(.lit8) }
- .lit4 : { *(.lit4) }
- .ctors : { *(.ctors) }
- .dtors : { *(.dtors) }
- .got : { *(.got.plt) *(.got) }
- .dynamic : { *(.dynamic) }
- /* We want the small data sections together, so single-instruction offsets
- can access them all, and initialized data all before uninitialized, so
- we can shorten the on-disk segment size. */
- .sdata : { *(.sdata) }
- _edata = .;
-
- .sbss : { *(.sbss) *(.scommon) }
- .bss :
- {
- *(.dynbss)
- *(.bss)
- *(COMMON)
- _end = . ;
- }
-
- /* Sections to be discarded */
- /DISCARD/ :
- {
- *(.text.exit)
- *(.data.exit)
- *(.exitcall.exit)
- }
-
- /* These are needed for ELF backends which have not yet been
- converted to the new style linker. */
- .stab 0 : { *(.stab) }
- .stabstr 0 : { *(.stabstr) }
- /* DWARF debug sections.
- Symbols in the .debug DWARF section are relative to the beginning of the
- section so we begin .debug at 0. It's not clear yet what needs to happen
- for the others. */
- .debug 0 : { *(.debug) }
- .debug_srcinfo 0 : { *(.debug_srcinfo) }
- .debug_aranges 0 : { *(.debug_aranges) }
- .debug_pubnames 0 : { *(.debug_pubnames) }
- .debug_sfnames 0 : { *(.debug_sfnames) }
- .line 0 : { *(.line) }
- /* These must appear regardless of . */
- .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
- .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
-}
--- /dev/null
+OUTPUT_ARCH(mips)
+ENTRY(kernel_entry)
+SECTIONS
+{
+ /* Read-only sections, merged into text segment: */
+ .init : { *(.init) } =0
+ .text :
+ {
+ *(.text)
+ *(.rodata)
+ *(.rodata.*)
+ *(.rodata1)
+ /* .gnu.warning sections are handled specially by elf32.em. */
+ *(.gnu.warning)
+ } =0
+ .kstrtab : { *(.kstrtab) }
+
+ . = ALIGN(16); /* Exception table */
+ __start___ex_table = .;
+ __ex_table : { *(__ex_table) }
+ __stop___ex_table = .;
+
+ __start___dbe_table = .; /* Exception table for data bus errors */
+ __dbe_table : { *(__dbe_table) }
+ __stop___dbe_table = .;
+
+ _etext = .;
+
+ . = ALIGN(16384);
+ . = . + MAPPED_OFFSET; /* for CONFIG_MAPPED_KERNEL */
+ .data.init_task : { *(.data.init_task) }
+
+ /* Startup code */
+ . = ALIGN(4096);
+ __init_begin = .;
+ .text.init : { *(.text.init) }
+ .data.init : { *(.data.init) }
+ . = ALIGN(16);
+ __setup_start = .;
+ .setup.init : { *(.setup.init) }
+ __setup_end = .;
+ __initcall_start = .;
+ .initcall.init : {
+ *(.initcall1.init)
+ *(.initcall2.init)
+ *(.initcall3.init)
+ *(.initcall4.init)
+ *(.initcall5.init)
+ *(.initcall6.init)
+ *(.initcall7.init)
+ }
+ __initcall_end = .;
+ . = ALIGN(4096); /* Align double page for init_task_union */
+ __init_end = .;
+
+ . = ALIGN(4096);
+ .data.page_aligned : { *(.data.idt) }
+
+ . = ALIGN(32);
+ .data.cacheline_aligned : { *(.data.cacheline_aligned) }
+
+ .fini : { *(.fini) } =0
+ .reginfo : { *(.reginfo) }
+ /* Adjust the address for the data segment. We want to adjust up to
+ the same address within the page on the next page up. It would
+ be more correct to do this:
+ . = .;
+ The current expression does not correctly handle the case of a
+ text segment ending precisely at the end of a page; it causes the
+ data segment to skip a page. The above expression does not have
+ this problem, but it will currently (2/95) cause BFD to allocate
+ a single segment, combining both text and data, for this case.
+ This will prevent the text segment from being shared among
+ multiple executions of the program; I think that is more
+ important than losing a page of the virtual address space (note
+ that no actual memory is lost; the page which is skipped can not
+ be referenced). */
+ . = .;
+ .data :
+ {
+ _fdata = . ;
+ *(.data)
+ CONSTRUCTORS
+ }
+ .data1 : { *(.data1) }
+ .lit8 : { *(.lit8) }
+ .lit4 : { *(.lit4) }
+ .ctors : { *(.ctors) }
+ .dtors : { *(.dtors) }
+ .got : { *(.got.plt) *(.got) }
+ .dynamic : { *(.dynamic) }
+ /* We want the small data sections together, so single-instruction offsets
+ can access them all, and initialized data all before uninitialized, so
+ we can shorten the on-disk segment size. */
+ .sdata : { *(.sdata) }
+ _edata = .;
+
+ .sbss : { *(.sbss) *(.scommon) }
+ .bss :
+ {
+ *(.dynbss)
+ *(.bss)
+ *(COMMON)
+ _end = . ;
+ }
+
+ /* Sections to be discarded */
+ /DISCARD/ :
+ {
+ *(.text.exit)
+ *(.data.exit)
+ *(.exitcall.exit)
+ }
+
+ /* These are needed for ELF backends which have not yet been
+ converted to the new style linker. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ /* DWARF debug sections.
+ Symbols in the .debug DWARF section are relative to the beginning of the
+ section so we begin .debug at 0. It's not clear yet what needs to happen
+ for the others. */
+ .debug 0 : { *(.debug) }
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ .line 0 : { *(.line) }
+ /* These must appear regardless of . */
+ .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
+ .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
+}
FINAL_LD=$(CROSS_COMPILE)ld --warn-common --warn-section-align
-CPP=$(CC) -E
OBJCOPY_FLAGS =-O binary -R .note -R .comment -S
LDFLAGS_vmlinux =-T arch/parisc/vmlinux.lds
#
LDFLAGS := -m elf64_s390
-CPP=$(CC) -E
OBJCOPYFLAGS := -O binary
ifeq ($(CONFIG_SHARED_KERNEL),y)
LINKSCRIPT := arch/s390x/vmlinux-shared.lds
# error messages during linking. Select a default linkscript if
# none has been choosen above.
#
-LINKSCRIPT = arch/sh/vmlinux.lds
+LINKSCRIPT = arch/sh/vmlinux.lds.s
LDFLAGS_vmlinux += -T $(word 1,$(LINKSCRIPT)) -e _stext
ifdef LOADADDR
CORE_FILES += arch/sh/stboards/stboards.o
endif
-vmlinux: arch/sh/vmlinux.lds
+vmlinux: arch/sh/vmlinux.lds.s
-arch/sh/vmlinux.lds: arch/sh/vmlinux.lds.S FORCE
- $(CPP) $(CPPFLAGS) -traditional -C -P -Ush $< > $@
+CPPFLAGS_arch/sh/vmlinux.lds.s := -traditional
FORCE: ;
# $(MAKE) -C arch/$(ARCH)/tools clean
archmrproper:
- rm -f arch/sh/vmlinux.lds
+