From: Andrew Cooper Date: Wed, 4 Jan 2023 23:19:26 +0000 (+0000) Subject: link: Move the linker script to being common X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c0f454c68329301447fd258e47824f7d402f19e9;p=people%2Fandrewcoop%2Fxen-test-framework.git link: Move the linker script to being common ... now that all x86-ism have been removed. Fix some style bugs. Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/link.lds.S b/arch/x86/link.lds.S deleted file mode 100644 index 3a0907d..0000000 --- a/arch/x86/link.lds.S +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Common linker file for all architectures/environments - */ - -#include -#include - -/* - * Architecture must provide: - * - OUTPUT_FORMAT() - * - OUTPUT_ARCH() - * - ENTRY() - */ -#define LINKER_HEADER -#include -#undef LINKER_HEADER - -PHDRS -{ - text PT_LOAD FLAGS(7); /* RWE */ - note PT_NOTE FLAGS(4); /* R */ -} - -SECTIONS -{ - . = XTF_VIRT_START; - - _start = .; - - .text : { - *(.text.head) - *(.text) - - . = ALIGN(PAGE_SIZE); - __start_user_text = .; - *(.text.user) - . = ALIGN(PAGE_SIZE); - __end_user_text = .; - - } :text = 0 - - .data : { - *(.data) - . = ALIGN(PAGE_SIZE); - *(.data.page_aligned) - . = ALIGN(PAGE_SIZE); - - __start_user_data = .; - *(.data.user) - . = ALIGN(PAGE_SIZE); - __end_user_data = .; - - } - - .note : { - *(.note) - *(.note.*) - } :note :text - - .rodata : { - *(.rodata) - *(.rodata.*) - - . = ALIGN(8); - __start_ex_table = .; - *(.ex_table) - __stop_ex_table = .; - } :text - - .bss : { - *(.bss) - . = ALIGN(PAGE_SIZE); - *(.bss.page_aligned) - . = ALIGN(PAGE_SIZE); - - __start_user_bss = .; - *(.bss.user.page_aligned) - . = ALIGN(PAGE_SIZE); - __end_user_bss = .; - } - - _end = .; -} - -/* - * Linker games to use virtual addresses at 0 without triggering NULL pointer - * "logic" and associated compiler optimisations. - */ -zeroptr = 0; - -ASSERT(IS_ALIGNED(__start_user_text, PAGE_SIZE), "__start_user_text misaligned"); -ASSERT(IS_ALIGNED(__end_user_text, PAGE_SIZE), "__end_user_text misaligned"); -ASSERT(IS_ALIGNED(__start_user_data, PAGE_SIZE), "__start_user_data misaligned"); -ASSERT(IS_ALIGNED(__end_user_data, PAGE_SIZE), "__end_user_data misaligned") -ASSERT(IS_ALIGNED(__start_user_bss, PAGE_SIZE), "__start_user_data misaligned"); -ASSERT(IS_ALIGNED(__end_user_bss, PAGE_SIZE), "__end_user_data misaligned") - -/* Architecture may provide any extra asserts. */ -#define LINKER_FOOTER -#include -#undef LINKER_FOOTER - -/* - * Local variables: - * tab-width: 8 - * indent-tabs-mode: nil - * End: - */ diff --git a/build/common.mk b/build/common.mk index 42d4c77..644961c 100644 --- a/build/common.mk +++ b/build/common.mk @@ -72,8 +72,8 @@ DEPS-$(1) = \ $$(obj-$(1):%.o=%-$(1).o) $$(obj-perenv:%.o=%-$(1).o) # Generate .lds with appropriate flags -%/link-$(1).lds: %/link.lds.S - $$(CPP) $$(AFLAGS_$(1)) -P -C $$< -o $$@ +%/link-$(1).lds: $(ROOT)/common/link.lds.S + $$(CPP) $$(AFLAGS_$(1)) -P $$< -o $$@ # Generate a per-arch .o from .S %-$($(1)_arch).o: %.S diff --git a/common/link.lds.S b/common/link.lds.S new file mode 100644 index 0000000..f5836b6 --- /dev/null +++ b/common/link.lds.S @@ -0,0 +1,108 @@ +/* + * Common linker file for all architectures/environments + */ + +#include +#include + +/* + * Architecture must provide: + * - OUTPUT_FORMAT() + * - OUTPUT_ARCH() + * - ENTRY() + */ +#define LINKER_HEADER +#include +#undef LINKER_HEADER + +PHDRS +{ + text PT_LOAD FLAGS(7); /* RWE */ + note PT_NOTE FLAGS(4); /* R */ +} + +SECTIONS +{ + . = XTF_VIRT_START; + + _start = .; + + .text : { + *(.text.head) + *(.text) + + . = ALIGN(PAGE_SIZE); + __start_user_text = .; + *(.text.user) + . = ALIGN(PAGE_SIZE); + __end_user_text = .; + + } :text = 0 + + .data : { + *(.data) + . = ALIGN(PAGE_SIZE); + *(.data.page_aligned) + . = ALIGN(PAGE_SIZE); + + __start_user_data = .; + *(.data.user) + . = ALIGN(PAGE_SIZE); + __end_user_data = .; + + } + + .note : { + *(.note) + *(.note.*) + } :note :text + + .rodata : { + *(.rodata) + *(.rodata.*) + + . = ALIGN(8); + __start_ex_table = .; + *(.ex_table) + __stop_ex_table = .; + } :text + + .bss : { + *(.bss) + . = ALIGN(PAGE_SIZE); + *(.bss.page_aligned) + . = ALIGN(PAGE_SIZE); + + __start_user_bss = .; + *(.bss.user.page_aligned) + . = ALIGN(PAGE_SIZE); + __end_user_bss = .; + } + + _end = .; +} + +/* + * Linker games to use virtual addresses at 0 without triggering NULL pointer + * "logic" and associated compiler optimisations. + */ +zeroptr = 0; + +ASSERT(IS_ALIGNED(__start_user_text, PAGE_SIZE), "__start_user_text misaligned"); +ASSERT(IS_ALIGNED(__end_user_text, PAGE_SIZE), "__end_user_text misaligned"); +ASSERT(IS_ALIGNED(__start_user_data, PAGE_SIZE), "__start_user_data misaligned"); +ASSERT(IS_ALIGNED(__end_user_data, PAGE_SIZE), "__end_user_data misaligned"); +ASSERT(IS_ALIGNED(__start_user_bss, PAGE_SIZE), "__start_user_data misaligned"); +ASSERT(IS_ALIGNED(__end_user_bss, PAGE_SIZE), "__end_user_data misaligned"); + +/* Architecture may provide any extra asserts. */ +#define LINKER_FOOTER +#include +#undef LINKER_FOOTER + +/* + * Local variables: + * tab-width: 8 + * indent-tabs-mode: nil + * End: + */