Skip to content

Commit

Permalink
skiboot.lds.S: introduce PAGE_SIZE, use it to lay out sections
Browse files Browse the repository at this point in the history
Separate code, data, read-only data, and other significant sections
with PAGE_SIZE alignment. This enables memory protection for these
sections with a later patch.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
  • Loading branch information
npiggin authored and oohal committed Jun 11, 2020
1 parent e404411 commit ac08f4a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
3 changes: 3 additions & 0 deletions include/config.h
Expand Up @@ -4,6 +4,9 @@
#ifndef __CONFIG_H
#define __CONFIG_H

/* Alignment to which skiboot lays out memory. */
#define PAGE_SIZE 0x10000

#define HAVE_TYPEOF 1
#define HAVE_BUILTIN_TYPES_COMPATIBLE_P 1

Expand Down
22 changes: 14 additions & 8 deletions skiboot.lds.S
Expand Up @@ -75,6 +75,7 @@ SECTIONS
}

_head_end = .;
. = ALIGN(PAGE_SIZE);

/*
* The following sections are read-write at runtime. We need
Expand Down Expand Up @@ -107,14 +108,14 @@ SECTIONS
}

/* ...and back to RO */

. = ALIGN(0x10);
. = ALIGN(PAGE_SIZE);
_stext = .;
.text : {
*(.text*)
*(.sfpr .glink)
}
_etext = .;
. = ALIGN(PAGE_SIZE);

.rodata : {
__rodata_start = .;
Expand Down Expand Up @@ -177,6 +178,7 @@ SECTIONS
*(.rela*)
__rela_dyn_end = .;
}

.hash : { *(.hash) }
.gnu.hash : { *(.gnu.hash) }
.gnu.version : { *(.gnu.version) }
Expand All @@ -196,22 +198,26 @@ SECTIONS
*/
_romem_end = .;

. = ALIGN(PAGE_SIZE);

_sdata = .;
.data : {
/*
* A couple of things that need to be 4K aligned and
* to reside in their own pages for the sake of TCE
* mappings
* mappings, so use PAGE_SIZE alignment.
*/
. = ALIGN(0x1000);
. = ALIGN(PAGE_SIZE);
*(.data.memcons);
. = ALIGN(0x10000);
. = ALIGN(PAGE_SIZE);
*(.data.boot_trace);
. = ALIGN(0x10000);
. = ALIGN(PAGE_SIZE);
*(.data*)
*(.force.data)
*(.toc1)
*(.branch_lt)
}
_edata = .;

/* We locate the BSS at 4M to leave room for the symbol map */
. = 0x400000;
Expand All @@ -221,7 +227,7 @@ SECTIONS
*(.dynbss)
*(.bss*)
}
. = ALIGN(0x10000);
. = ALIGN(PAGE_SIZE);
_ebss = .;
_end = .;

Expand All @@ -230,7 +236,7 @@ SECTIONS
DEBUG_SECTIONS

/* Optional kernel image */
. = ALIGN(0x10000);
. = ALIGN(PAGE_SIZE);
.builtin_kernel : {
__builtin_kernel_start = .;
KEEP(*(.builtin_kernel))
Expand Down

0 comments on commit ac08f4a

Please sign in to comment.