Skip to content

Commit 5b779b3

Browse files
committed
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 <[email protected]>
1 parent eefe2c8 commit 5b779b3

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

layout.ld

+5-9
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ ENTRY(ram64_start)
22

33
PHDRS
44
{
5-
rodata PT_LOAD FILEHDR PHDRS ;
6-
data PT_LOAD ;
7-
text PT_LOAD ;
5+
program PT_LOAD FILEHDR PHDRS ;
86
}
97

108
/* Loaders like to put stuff in low memory (< 1M), so we don't use it. */
@@ -19,12 +17,10 @@ SECTIONS
1917
. = ram_min;
2018
. += SIZEOF_HEADERS;
2119

22-
.rodata : { *(.rodata .rodata.*) } :rodata
23-
.data : { *(.data .data.*) *(.bss .bss.*) } :data
24-
.text : {
25-
*(.text .text.*)
26-
*(.ram64)
27-
} :text
20+
.rodata : { *(.rodata .rodata.*) } :program
21+
.text : { *(.text .text.*) } :program
22+
.data : { *(.data .data.*) } :program
23+
.bss : { *(.bss .bss.*) } :program
2824

2925
firmware_ram_size = . - ram_min;
3026

src/asm/ram64.s

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.section .ram64, "ax"
1+
.section .text, "ax"
22
.global ram64_start
33
.code64
44

0 commit comments

Comments
 (0)