mirror of
https://github.com/torvalds/linux.git
synced 2024-12-28 22:02:28 +00:00
22e6a2e14c
The objcopy only emits loadable sections when creating flat kernel Image. To have minimal possible size of flat kernel Image, we should have all non-loadable sections after loadable sections. Currently, execption table section (loadable section) is after BSS section (non-loadable section) in the RISC-V vmlinux.lds.S. This is not optimal for having minimal flat kernel Image size hence this patch makes BSS section as the last section in RISC-V vmlinux.lds.S. In addition, we make BSS section aligned to 16byte instead of PAGE aligned which further reduces flat kernel Image size by few KBs. The flat kernel Image size of Linux-4.20-rc4 using GCC 8.2.0 is 8819980 bytes with current RISC-V vmlinux.lds.S and it reduces to 7991740 bytes with this patch applied. In summary, this patch reduces Linux-4.20-rc4 flat kernel Image size by 809 KB. Signed-off-by: Anup Patel <anup@brainfault.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
97 lines
1.7 KiB
ArmAsm
97 lines
1.7 KiB
ArmAsm
/*
|
|
* Copyright (C) 2012 Regents of the University of California
|
|
* Copyright (C) 2017 SiFive
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation, version 2.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#define LOAD_OFFSET PAGE_OFFSET
|
|
#include <asm/vmlinux.lds.h>
|
|
#include <asm/page.h>
|
|
#include <asm/cache.h>
|
|
#include <asm/thread_info.h>
|
|
|
|
#define MAX_BYTES_PER_LONG 0x10
|
|
|
|
OUTPUT_ARCH(riscv)
|
|
ENTRY(_start)
|
|
|
|
jiffies = jiffies_64;
|
|
|
|
SECTIONS
|
|
{
|
|
/* Beginning of code and text segment */
|
|
. = LOAD_OFFSET;
|
|
_start = .;
|
|
__init_begin = .;
|
|
HEAD_TEXT_SECTION
|
|
INIT_TEXT_SECTION(PAGE_SIZE)
|
|
INIT_DATA_SECTION(16)
|
|
/* we have to discard exit text and such at runtime, not link time */
|
|
.exit.text :
|
|
{
|
|
EXIT_TEXT
|
|
}
|
|
.exit.data :
|
|
{
|
|
EXIT_DATA
|
|
}
|
|
PERCPU_SECTION(L1_CACHE_BYTES)
|
|
__init_end = .;
|
|
|
|
.text : {
|
|
_text = .;
|
|
_stext = .;
|
|
TEXT_TEXT
|
|
SCHED_TEXT
|
|
CPUIDLE_TEXT
|
|
LOCK_TEXT
|
|
KPROBES_TEXT
|
|
ENTRY_TEXT
|
|
IRQENTRY_TEXT
|
|
*(.fixup)
|
|
_etext = .;
|
|
}
|
|
|
|
/* Start of data section */
|
|
_sdata = .;
|
|
RO_DATA_SECTION(L1_CACHE_BYTES)
|
|
.srodata : {
|
|
*(.srodata*)
|
|
}
|
|
|
|
RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
|
|
.sdata : {
|
|
__global_pointer$ = . + 0x800;
|
|
*(.sdata*)
|
|
/* End of data section */
|
|
_edata = .;
|
|
*(.sbss*)
|
|
}
|
|
|
|
EXCEPTION_TABLE(0x10)
|
|
NOTES
|
|
|
|
.rel.dyn : {
|
|
*(.rel.dyn*)
|
|
}
|
|
|
|
BSS_SECTION(MAX_BYTES_PER_LONG,
|
|
MAX_BYTES_PER_LONG,
|
|
MAX_BYTES_PER_LONG)
|
|
|
|
_end = .;
|
|
|
|
STABS_DEBUG
|
|
DWARF_DEBUG
|
|
|
|
DISCARDS
|
|
}
|