Skip to content

Commit

Permalink
layout: Use .bss section and only use a single PHDR
Browse files Browse the repository at this point in the history
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
  • Loading branch information
josephlr committed Feb 29, 2020
1 parent 48e46d1 commit 1c54703
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
14 changes: 5 additions & 9 deletions layout.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/asm/ram64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.section .ram64, "ax"
.section .text, "ax"
.global ram64_start
.code64

Expand Down

0 comments on commit 1c54703

Please sign in to comment.