genprotimg: boot: use C pre-processor for linker script generation

Use C pre-processor for linker script generation. This allows the
usage of constants in our "linker scripts" `*.lds.S` (actually, these
are assembler files, so we can make us of the C pre-processor and its
capabilities).

Suggested-by: Philipp Rudo <prudo@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Marc Hartmayer
2019-12-03 10:35:53 +01:00
committed by Jan Höppner
parent 3356d6f4fa
commit 2d600570df
5 changed files with 40 additions and 22 deletions

View File

@@ -1,3 +1,4 @@
*.elf
*.lds
*.bin
*.d

View File

@@ -39,6 +39,17 @@ all: $(FILES)
$(CC) $(ALL_CFLAGS) -c -o $@ $<
# Dependencies for the .lds generation
sources_lds_S = $(wildcard *.lds.S)
dependencies_lds_S = $(sources_lds_s:%.lds.S=.%.lds.d)
# Include all ".lds.d" dependency files for all make targets except for "clean"
ifneq ($(MAKECMDGOALS),clean)
-include $(dependencies_lds_S)
endif
%.lds: %.lds.S Makefile
$(CPP) -Wp,-MD,.$@.d,-MT,$@ $(INCLUDE_PARMS) -P -C -o $@ $<
# Special rules for zipl object files
$(ZIPL_OBJS_C): %.o : $(ZIPL_BOOT_DIR)/%.c
$(CC) $(ALL_CFLAGS) -c -o $@ $<
@@ -78,6 +89,6 @@ stage3b.elf: head.o stage3b.o stage3b.lds $(ZIPL_OBJS)
@chmod a-x $@
clean:
rm -f *.o *.elf *.bin *.map .*.d
rm -f *.o *.elf *.bin *.map .*.d *.lds
.PHONY: all clean

View File

@@ -13,37 +13,37 @@
* actual data: IPIB and UV header)
*/
#include "stage3a.h"
#include "common_memory_layout.h"
OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
OUTPUT_ARCH(s390:64-bit)
ENTRY(_init)
__heap_size__ = 0x4000;
__stack_size__ = 0x1000;
SECTIONS
{
. = 0x0;
. = 0x2000;
. = HEAP_ADDRESS;
__heap_start = .;
.heap : {
. = . + __heap_size__;
ASSERT(__heap_stop - __heap_start == __heap_size__,
. = . + HEAP_SIZE;
ASSERT(__heap_stop - __heap_start == HEAP_SIZE,
"Heap section doesn't conform to the described memory layout");
}
__heap_stop = .;
. = 0xf000;
. = STACK_ADDRESS;
__stack_start = .;
.stack : {
. = . + __stack_size__;
ASSERT(__stack_end - __stack_start == __stack_size__,
. = . + STACK_SIZE;
ASSERT(__stack_end - __stack_start == STACK_SIZE,
"Stack section doesn't conform to the described memory layout");
}
__stack_end = .;
. = 0x10000;
. = STAGE3A_INIT_ENTRY;
__text_init_start = .;
.text : {
stage3a_init.o(.text.init)
@@ -51,9 +51,11 @@ SECTIONS
/* Text size of text_init must be smaller than 'PARMAREA - IMAGE_ENTRY',
* otherwise the text data could be overwritten by the original zipl stage3
* boot loader */
ASSERT(__text_init_stop - __text_init_start < 0x400,
ASSERT(__text_init_stop - __text_init_start < PARMAREA - IMAGE_ENTRY,
"Text size must be smaller than 'PARMAREA - IMAGE_ENTRY'");
. = 0x1000;
ASSERT(ABSOLUTE(.) == STAGE3A_ENTRY,
"Text section doesn't conform to the described memory layout");
head.o(.text.start)
*(.text)
}

View File

@@ -11,6 +11,10 @@
#define STAGE3B_H
#include "lib/zt_common.h"
#include "boot/loaders_layout.h"
#define STAGE3B_ENTRY STAGE3_ENTRY
#define STAGE3B_LOAD_ADDRESS STAGE3B_ENTRY
#ifndef __ASSEMBLER__

View File

@@ -11,28 +11,28 @@
* 0x0f000 - 0x0ffff Stack
*/
#include "stage3b.h"
#include "common_memory_layout.h"
OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
OUTPUT_ARCH(s390:64-bit)
ENTRY(_start)
__heap_size__ = 0x4000;
__stack_size__ = 0x1000;
SECTIONS
{
. = 0x0;
. = 0x2000;
. = HEAP_ADDRESS;
__heap_start = .;
.heap : {
. = . + __heap_size__;
ASSERT(__heap_stop - __heap_start == __heap_size__,
. = . + HEAP_SIZE;
ASSERT(__heap_stop - __heap_start == HEAP_SIZE,
"Heap section doesn't conform to the described memory layout");
}
__heap_stop = .;
. = 0xa000;
. = STAGE3B_ENTRY;
.text : {
head.o(.text.start)
*(.text)
@@ -65,11 +65,11 @@ SECTIONS
"Data size must be equal to 'sizeof(struct stage3b_args)'");
}
. = 0xf000;
. = STACK_ADDRESS;
__stack_start = .;
.stack : {
. = . + __stack_size__;
ASSERT(__stack_end - __stack_start == __stack_size__,
. = . + STACK_SIZE;
ASSERT(__stack_end - __stack_start == STACK_SIZE,
"Stack section doesn't conform to the described memory layout");
}
__stack_end = .;