diff --git a/genprotimg/boot/.gitignore b/genprotimg/boot/.gitignore index 0a8eae62..837684ed 100644 --- a/genprotimg/boot/.gitignore +++ b/genprotimg/boot/.gitignore @@ -1,3 +1,4 @@ *.elf +*.lds *.bin *.d diff --git a/genprotimg/boot/Makefile b/genprotimg/boot/Makefile index 271a8078..5fd1e2cd 100644 --- a/genprotimg/boot/Makefile +++ b/genprotimg/boot/Makefile @@ -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 diff --git a/genprotimg/boot/stage3a.lds b/genprotimg/boot/stage3a.lds.S similarity index 81% rename from genprotimg/boot/stage3a.lds rename to genprotimg/boot/stage3a.lds.S index b6445cd2..eefb52c3 100644 --- a/genprotimg/boot/stage3a.lds +++ b/genprotimg/boot/stage3a.lds.S @@ -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) } diff --git a/genprotimg/boot/stage3b.h b/genprotimg/boot/stage3b.h index 6325d27e..421f0ea5 100644 --- a/genprotimg/boot/stage3b.h +++ b/genprotimg/boot/stage3b.h @@ -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__ diff --git a/genprotimg/boot/stage3b.lds b/genprotimg/boot/stage3b.lds.S similarity index 83% rename from genprotimg/boot/stage3b.lds rename to genprotimg/boot/stage3b.lds.S index 98122ea0..2711d84e 100644 --- a/genprotimg/boot/stage3b.lds +++ b/genprotimg/boot/stage3b.lds.S @@ -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 = .;