From e9d42c5d66ff576b14f54f91609483cf99090ef7 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Fri, 28 Feb 2020 20:12:49 -0800 Subject: [PATCH] layout: Use .bss section and only use a single PHDR Adding a bss section reduces binary size by ~30%. We also only use a single Program Header. This better reflects the fact that the entire firmware is loaded as a single Read/Write/Execute blob. Right now, the hypervisor's loader does not read PHDR types: https://github.com/rust-vmm/linux-loader/blob/e5c6d66d3121421672c9b25b02e8954f0ed5f58d/src/loader/mod.rs#L248-L274 Signed-off-by: Joe Richey --- layout.ld | 14 +++++--------- src/asm/ram64.s | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/layout.ld b/layout.ld index 4a6bda51..5403d7d1 100644 --- a/layout.ld +++ b/layout.ld @@ -2,9 +2,7 @@ ENTRY(ram64_start) PHDRS { - rodata PT_LOAD FILEHDR PHDRS ; - data PT_LOAD ; - text PT_LOAD ; + program PT_LOAD FILEHDR PHDRS ; } /* Loaders like to put stuff in low memory (< 1M), so we don't use it. */ @@ -19,12 +17,10 @@ SECTIONS . = ram_min; . += SIZEOF_HEADERS; - .rodata : { *(.rodata .rodata.*) } :rodata - .data : { *(.data .data.*) *(.bss .bss.*) } :data - .text : { - *(.text .text.*) - *(.ram64) - } :text + .rodata : { *(.rodata .rodata.*) } :program + .text : { *(.text .text.*) } :program + .data : { *(.data .data.*) } :program + .bss : { *(.bss .bss.*) } :program firmware_ram_size = . - ram_min; diff --git a/src/asm/ram64.s b/src/asm/ram64.s index 0e94f98a..09bbb942 100644 --- a/src/asm/ram64.s +++ b/src/asm/ram64.s @@ -1,4 +1,4 @@ -.section .ram64, "ax" +.section .text, "ax" .global ram64_start .code64