RISC-V: Make BSS section as the last section in vmlinux.lds.S
authorAnup Patel <anup@brainfault.org>
Wed, 19 Dec 2018 12:36:57 +0000 (18:06 +0530)
committerPalmer Dabbelt <palmer@sifive.com>
Mon, 7 Jan 2019 15:59:25 +0000 (07:59 -0800)
commit22e6a2e14cb8ebcae059488cf24e778e4058c2bf
tree8729b81a6648275b3ca4ff049b106f0c010c7e23
parentbfeffd155283772bbe78c6a05dec7c0128ee500c
RISC-V: Make BSS section as the last section in vmlinux.lds.S

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>
arch/riscv/kernel/vmlinux.lds.S