Xen Test Framework
link.lds.S
Go to the documentation of this file.
1 /*
2  * Common linker file for all architectures/environments
3  */
4 
5 #include <xtf/numbers.h>
6 #include <arch/page.h>
7 
8 /*
9  * Architecture must provide:
10  * - OUTPUT_FORMAT()
11  * - OUTPUT_ARCH()
12  * - ENTRY()
13  */
14 #define LINKER_HEADER
15 #include <arch/link.lds.h>
16 #undef LINKER_HEADER
17 
18 PHDRS
19 {
20  text PT_LOAD FLAGS(7); /* RWE */
21  note PT_NOTE FLAGS(4); /* R */
22 }
23 
24 SECTIONS
25 {
26  . = XTF_VIRT_START;
27 
28  _start = .;
29 
30  .text : {
31  *(.text.head)
32  *(.text)
33 
34  . = ALIGN(PAGE_SIZE);
35  __start_user_text = .;
36  *(.text.user)
37  . = ALIGN(PAGE_SIZE);
38  __end_user_text = .;
39 
40  } :text = 0
41 
42  .data : {
43  *(.data)
44  . = ALIGN(PAGE_SIZE);
45  *(.data.page_aligned)
46  . = ALIGN(PAGE_SIZE);
47 
48  __start_user_data = .;
49  *(.data.user)
50  . = ALIGN(PAGE_SIZE);
51  __end_user_data = .;
52 
53  }
54 
55  .note : {
56  *(.note)
57  *(.note.*)
58  } :note :text
59 
60  .rodata : {
61  *(.rodata)
62  *(.rodata.*)
63 
64  . = ALIGN(8);
65  __start_ex_table = .;
66  *(.ex_table)
67  __stop_ex_table = .;
68  } :text
69 
70  .bss : {
71  *(.bss)
72  . = ALIGN(PAGE_SIZE);
73  *(.bss.page_aligned)
74  . = ALIGN(PAGE_SIZE);
75 
76  __start_user_bss = .;
77  *(.bss.user.page_aligned)
78  . = ALIGN(PAGE_SIZE);
79  __end_user_bss = .;
80  }
81 
82  _end = .;
83 }
84 
85 /*
86  * Linker games to use virtual addresses at 0 without triggering NULL pointer
87  * "logic" and associated compiler optimisations.
88  */
89 zeroptr = 0;
90 
91 ASSERT(IS_ALIGNED(__start_user_text, PAGE_SIZE), "__start_user_text misaligned");
92 ASSERT(IS_ALIGNED(__end_user_text, PAGE_SIZE), "__end_user_text misaligned");
93 ASSERT(IS_ALIGNED(__start_user_data, PAGE_SIZE), "__start_user_data misaligned");
94 ASSERT(IS_ALIGNED(__end_user_data, PAGE_SIZE), "__end_user_data misaligned");
95 ASSERT(IS_ALIGNED(__start_user_bss, PAGE_SIZE), "__start_user_data misaligned");
96 ASSERT(IS_ALIGNED(__end_user_bss, PAGE_SIZE), "__end_user_data misaligned");
97 
98 /* Architecture may provide any extra asserts. */
99 #define LINKER_FOOTER
100 #include <arch/link.lds.h>
101 #undef LINKER_FOOTER
102 
103 /*
104  * Local variables:
105  * tab-width: 8
106  * indent-tabs-mode: nil
107  * End:
108  */