mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zipl/boot: use C pre-processor for linker script generation
Use C pre-processor for linker script generation and refactor some constants. This allows the usage of the 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). While at it, enforce the described memory layout in the generated linker script. Reviewed-by: Stefan Haberland <sth@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:
committed by
Jan Höppner
parent
ce65c39e18
commit
19f747847f
@@ -14,19 +14,29 @@
|
||||
#include "lib/zt_common.h"
|
||||
#include "linux_layout.h"
|
||||
|
||||
#define STAGE2_DESC _AC(0x78, UL)
|
||||
#define STAGE2_ENTRY _AC(0x2018, UL)
|
||||
#define STAGE2_HEAP_ADDRESS _AC(0x6000, UL)
|
||||
#define STAGE2_HEAP_SIZE _AC(0x3000, UL)
|
||||
#define STAGE2_STACK_ADDRESS _AC(0xe400, UL)
|
||||
#define STAGE2_STACK_SIZE _AC(0x1c00, UL)
|
||||
|
||||
#define STAGE3_ENTRY _AC(0xa000, UL)
|
||||
|
||||
#define STAGE2_LOAD_ADDRESS _AC(0x2000, UL)
|
||||
#define STAGE3_LOAD_ADDRESS STAGE3_ENTRY
|
||||
#define IMAGE_LOAD_ADDRESS IMAGE_ENTRY
|
||||
|
||||
#define STAGE3_MAXIMUM_SIZE _AC(0x3000, UL)
|
||||
#define STAGE3_HEAP_SIZE _AC(0x4000, UL)
|
||||
#define STAGE3_HEAP_ADDRESS _AC(0x2000, UL)
|
||||
#define STAGE3_STACK_SIZE _AC(0x1000, UL)
|
||||
#define STAGE3_STACK_ADDRESS _AC(0xF000, UL)
|
||||
#define STAGE3_PARAMS_ADDRESS _AC(0x9000, UL)
|
||||
#define STAGE3_PARAMS_MAXIMUM_SIZE _AC(0x1000, UL)
|
||||
|
||||
#define COMMAND_LINE_EXTRA _AC(0xE000, UL)
|
||||
#define COMMAND_LINE_EXTRA_SIZE _AC(0x0400, UL)
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
#endif /* __ASSEMBLER__ */
|
||||
|
||||
2
zipl/boot/.gitignore
vendored
Normal file
2
zipl/boot/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.lds
|
||||
*.lds.d
|
||||
@@ -1,8 +1,11 @@
|
||||
# Common definitions
|
||||
include ../../common.mak
|
||||
|
||||
ALL_CFLAGS = $(NO_PIE_CFLAGS) -Os -g -I $(rootdir)/zipl/include \
|
||||
-I $(rootdir)/include -DS390_TOOLS_RELEASE=$(S390_TOOLS_RELEASE) \
|
||||
INCLUDE_PATHS := $(rootdir)/zipl/include $(rootdir)/include
|
||||
INCLUDE_PARMS := $(addprefix -I,$(INCLUDE_PATHS))
|
||||
|
||||
ALL_CFLAGS = $(NO_PIE_CFLAGS) -Os -g $(INCLUDE_PARMS) \
|
||||
-DS390_TOOLS_RELEASE=$(S390_TOOLS_RELEASE) \
|
||||
-fno-builtin -ffreestanding -fno-asynchronous-unwind-tables \
|
||||
-fno-delete-null-pointer-checks \
|
||||
-fexec-charset=IBM1047 -m64 -mpacked-stack \
|
||||
@@ -26,6 +29,17 @@ all: data.o data.h tape0.bin stage3.bin
|
||||
%.o: %.c
|
||||
$(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
|
||||
$(CPP) -Wp,-MD,.$@.d,-MT,$@ $(INCLUDE_PARMS) -P -C -o $@ $<
|
||||
|
||||
eckd2dump_sv.exec: \
|
||||
head.o stage2dump.o cio.o eckd2dump.o eckd2dump_sv.o \
|
||||
libc.o ebcdic.o sclp.o entry.o stage2.lds
|
||||
@@ -104,6 +118,6 @@ data.h: data.o
|
||||
|
||||
clean:
|
||||
rm -f *.o *.exec *.bin $(FILES) data.o data.h tape0.bin *.xxx *.yyy \
|
||||
stage3.bin
|
||||
stage3.bin *.lds *.lds.d
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "libc.h"
|
||||
#include "menu.h"
|
||||
#include "boot/s390.h"
|
||||
#include "boot/loaders_layout.h"
|
||||
#include "stage2.h"
|
||||
|
||||
static int is_null_descriptor(disk_blockptr_t *address)
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
#define DESCR_PER_BLOCK _AC(16, U)
|
||||
|
||||
/* ADRESS */
|
||||
#define STAGE2_DESC _AC(0x78, UL)
|
||||
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
|
||||
@@ -25,15 +25,19 @@
|
||||
* 0x5000-0x51ff eckd2dump_mv parameter block (426 bytes)
|
||||
*/
|
||||
|
||||
#include "boot/loaders_layout.h"
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x78;
|
||||
. = STAGE2_DESC;
|
||||
__stage2_desc = .;
|
||||
|
||||
. = 0x2000;
|
||||
. = STAGE2_LOAD_ADDRESS;
|
||||
.stage2.head : { *(.stage2.head) }
|
||||
. = 0x2018;
|
||||
.text.start : { *(.text.start) }
|
||||
. = STAGE2_ENTRY;
|
||||
.text.start : {
|
||||
*(.text.start)
|
||||
}
|
||||
.text : { *(.text) }
|
||||
__ex_table_start = .;
|
||||
.ex_table : { *(.ex_table) }
|
||||
@@ -52,12 +56,38 @@ SECTIONS
|
||||
.bss : { *(.bss) }
|
||||
__bss_stop = .;
|
||||
|
||||
. = 0x6000;
|
||||
. = STAGE2_HEAP_ADDRESS;
|
||||
__heap_start = .;
|
||||
. = 0x9000;
|
||||
.heap : {
|
||||
. += STAGE2_HEAP_SIZE;
|
||||
ASSERT(__heap_stop - __heap_start == STAGE2_HEAP_SIZE,
|
||||
"Heap section doesn't conform to the described memory layout");
|
||||
}
|
||||
__heap_stop = .;
|
||||
|
||||
. = 0xf000;
|
||||
/* Memory reserved for stage3. Use a dummy section to check if changes
|
||||
* in stage3 memory layout work with stage2 and vice versa.
|
||||
*/
|
||||
. = STAGE3_PARAMS_ADDRESS;
|
||||
.stage3 : {
|
||||
. += STAGE3_PARAMS_MAXIMUM_SIZE;
|
||||
|
||||
. = STAGE3_LOAD_ADDRESS - STAGE3_PARAMS_ADDRESS;
|
||||
. += STAGE3_MAXIMUM_SIZE;
|
||||
|
||||
. = COMMAND_LINE_EXTRA - STAGE3_PARAMS_ADDRESS;
|
||||
. += COMMAND_LINE_EXTRA_SIZE;
|
||||
}
|
||||
|
||||
. = STAGE2_STACK_ADDRESS;
|
||||
__stack_start = .;
|
||||
.stack : {
|
||||
. += STAGE2_STACK_SIZE;
|
||||
ASSERT(__stack_end - __stack_start == STAGE2_STACK_SIZE,
|
||||
"Stack section doesn't conform to the described memory layout");
|
||||
}
|
||||
__stack_end = .;
|
||||
|
||||
.eh_frame : { *(.eh_frame) }
|
||||
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
||||
}
|
||||
@@ -13,21 +13,26 @@
|
||||
* 0xf000-0xffff Stack
|
||||
*/
|
||||
|
||||
#include "boot/loaders_layout.h"
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x0;
|
||||
|
||||
. = 0x2000;
|
||||
. = STAGE3_HEAP_ADDRESS;
|
||||
__heap_start = .;
|
||||
. = 0x6000;
|
||||
.heap : {
|
||||
. += STAGE3_HEAP_SIZE;
|
||||
ASSERT(__heap_stop - __heap_start == STAGE3_HEAP_SIZE,
|
||||
"Heap section doesn't conform to the described memory layout");
|
||||
}
|
||||
__heap_stop = .;
|
||||
|
||||
|
||||
/* stage 3 parameter */
|
||||
. = 0x9000;
|
||||
. = STAGE3_PARAMS_ADDRESS;
|
||||
_stage3_parms = .;
|
||||
|
||||
. = 0xa000;
|
||||
. = STAGE3_ENTRY;
|
||||
.text.start : { *(.text.start) }
|
||||
.text : { *(.text) }
|
||||
__ex_table_start = .;
|
||||
@@ -40,4 +45,18 @@ SECTIONS
|
||||
__bss_stop = .;
|
||||
.rodata : {*(.rodata) }
|
||||
.data : { *(.data) }
|
||||
|
||||
. = COMMAND_LINE_EXTRA;
|
||||
.cmdline_extra : {
|
||||
. += COMMAND_LINE_EXTRA_SIZE;
|
||||
}
|
||||
|
||||
. = STAGE3_STACK_ADDRESS;
|
||||
__stack_start = .;
|
||||
.stack : {
|
||||
. += STAGE3_STACK_SIZE;
|
||||
ASSERT(__stack_end - __stack_start == STAGE3_STACK_SIZE,
|
||||
"Stack section doesn't conform to the described memory layout");
|
||||
}
|
||||
__stack_end = .;
|
||||
}
|
||||
Reference in New Issue
Block a user