2 This test exercises parsing typical commands found in GNU ld linker scripts.
3 RUN: linker-script-test %s | FileCheck %s
6 SEARCH_DIR("/usr/x86_64-linux-gnu/lib64"); SEARCH_DIR("=/usr/local/lib/x86_64-linux-gnu");
9 PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x400000)); . = SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS;
10 .interp : { *(.interp) }
11 .note.gnu.build-id : { *(.note.gnu.build-id) }
16 *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
18 *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
23 PROVIDE_HIDDEN (__rela_iplt_start = .);
25 PROVIDE_HIDDEN (__rela_iplt_end = .);
29 KEEP (*(SORT_NONE(.init)))
30 } =0x909090909090909090909090
31 PROVIDE (__etext = .);
32 .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
33 .exception_ranges : ONLY_IF_RO { *(.exception_ranges
35 . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
36 /* Exception handling */
37 .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
40 KEEP (*crtbegin.o(.ctors))
41 KEEP (*crtbegin?.o(.ctors))
42 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
43 KEEP (*(SORT(.ctors.*)))
48 KEEP (*crtbegin.o(.dtors))
49 KEEP (*crtbegin?.o(.dtors))
50 KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
51 KEEP (*(SORT(.dtors.*)))
54 . = DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >= 24 ? 24 : 0, .);
55 .got.plt : { *(.got.plt) *(.igot.plt) }
56 .lrodata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
58 *(.lrodata .lrodata.* .gnu.linkonce.lr.*)
60 .ldata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
62 *(.ldata .ldata.* .gnu.linkonce.l.*)
63 . = ALIGN(. != 0 ? 64 / 8 : 1);
66 _end = .; PROVIDE (end = .);
67 . = DATA_SEGMENT_END (.);
68 /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
72 CHECK: kw_search_dir: SEARCH_DIR
74 CHECK: identifier: /usr/x86_64-linux-gnu/lib64
77 CHECK: kw_search_dir: SEARCH_DIR
79 CHECK: identifier: =/usr/local/lib/x86_64-linux-gnu
82 CHECK: kw_sections: SECTIONS
84 CHECK: kw_provide: PROVIDE
86 CHECK: identifier: __executable_start
88 CHECK: identifier: SEGMENT_START
90 CHECK: identifier: text-segment
92 CHECK: number: 0x400000
98 CHECK: identifier: SEGMENT_START
100 CHECK: identifier: text-segment
102 CHECK: number: 0x400000
105 CHECK: identifier: SIZEOF_HEADERS
107 CHECK: identifier: .interp
112 CHECK: identifier: .interp
115 CHECK: identifier: .note.gnu.build-id
120 CHECK: identifier: .note.gnu.build-id
123 CHECK: identifier: .hash
128 CHECK: identifier: .hash
131 CHECK: identifier: .rela.dyn
136 CHECK: identifier: .rela.init
140 CHECK: identifier: .rela.text
141 CHECK: identifier: .rela.text.*
142 CHECK: identifier: .rela.gnu.linkonce.t.*
146 CHECK: identifier: .rela.fini
150 CHECK: identifier: .rela.rodata
151 CHECK: identifier: .rela.rodata.*
152 CHECK: identifier: .rela.gnu.linkonce.r.*
155 CHECK: identifier: .rela.plt
160 CHECK: identifier: .rela.plt
162 CHECK: kw_provide_hidden: PROVIDE_HIDDEN
164 CHECK: identifier: __rela_iplt_start
171 CHECK: identifier: .rela.iplt
173 CHECK: kw_provide_hidden: PROVIDE_HIDDEN
175 CHECK: identifier: __rela_iplt_end
181 CHECK: identifier: .init
188 CHECK: kw_sort_none: SORT_NONE
190 CHECK: identifier: .init
195 CHECK: kw_provide: PROVIDE
197 CHECK: identifier: __etext
202 CHECK: identifier: .eh_frame
204 CHECK: kw_only_if_ro: ONLY_IF_RO
210 CHECK: identifier: .eh_frame
214 CHECK: identifier: .exception_ranges
216 CHECK: kw_only_if_ro: ONLY_IF_RO
220 CHECK: identifier: .exception_ranges
221 CHECK: identifier: .exception_ranges*
226 CHECK: kw_align: ALIGN
228 CHECK: identifier: CONSTANT
230 CHECK: identifier: MAXPAGESIZE
236 CHECK: identifier: CONSTANT
238 CHECK: identifier: MAXPAGESIZE
245 CHECK: identifier: CONSTANT
247 CHECK: identifier: MAXPAGESIZE
256 CHECK: identifier: DATA_SEGMENT_ALIGN
258 CHECK: identifier: CONSTANT
260 CHECK: identifier: MAXPAGESIZE
263 CHECK: identifier: CONSTANT
265 CHECK: identifier: COMMONPAGESIZE
269 CHECK: identifier: .eh_frame
271 CHECK: kw_only_if_rw: ONLY_IF_RW
277 CHECK: identifier: .eh_frame
281 CHECK: identifier: .ctors
286 CHECK: identifier: *crtbegin.o
288 CHECK: identifier: .ctors
293 CHECK: identifier: *crtbegin?.o
295 CHECK: identifier: .ctors
302 CHECK: kw_exclude_file: EXCLUDE_FILE
304 CHECK: identifier: *crtend.o
305 CHECK: identifier: *crtend?.o
307 CHECK: identifier: .ctors
314 CHECK: kw_sort_by_name: SORT
316 CHECK: identifier: .ctors.*
324 CHECK: identifier: .ctors
328 CHECK: identifier: .dtors
333 CHECK: identifier: *crtbegin.o
335 CHECK: identifier: .dtors
340 CHECK: identifier: *crtbegin?.o
342 CHECK: identifier: .dtors
349 CHECK: kw_exclude_file: EXCLUDE_FILE
351 CHECK: identifier: *crtend.o
352 CHECK: identifier: *crtend?.o
354 CHECK: identifier: .dtors
361 CHECK: kw_sort_by_name: SORT
363 CHECK: identifier: .dtors.*
371 CHECK: identifier: .dtors
377 CHECK: identifier: DATA_SEGMENT_RELRO_END
379 CHECK: identifier: SIZEOF
381 CHECK: identifier: .got.plt
383 CHECK: greaterequal: >=
393 CHECK: identifier: .got.plt
398 CHECK: identifier: .got.plt
402 CHECK: identifier: .igot.plt
405 CHECK: identifier: .lrodata
406 CHECK: kw_align: ALIGN
408 CHECK: identifier: CONSTANT
410 CHECK: identifier: MAXPAGESIZE
418 CHECK: identifier: CONSTANT
420 CHECK: identifier: MAXPAGESIZE
430 CHECK: identifier: .lrodata
431 CHECK: identifier: .lrodata.*
432 CHECK: identifier: .gnu.linkonce.lr.*
435 CHECK: identifier: .ldata
436 CHECK: kw_align: ALIGN
438 CHECK: identifier: CONSTANT
440 CHECK: identifier: MAXPAGESIZE
448 CHECK: identifier: CONSTANT
450 CHECK: identifier: MAXPAGESIZE
460 CHECK: identifier: .ldata
461 CHECK: identifier: .ldata.*
462 CHECK: identifier: .gnu.linkonce.l.*
466 CHECK: kw_align: ALIGN
469 CHECK: exclaimequal: !=
482 CHECK: kw_align: ALIGN
489 CHECK: identifier: _end
493 CHECK: kw_provide: PROVIDE
495 CHECK: identifier: end
502 CHECK: identifier: DATA_SEGMENT_END
507 CHECK: kw_discard: /DISCARD/
512 CHECK: identifier: .note.GNU-stack
516 CHECK: identifier: .gnu_debuglink
520 CHECK: identifier: .gnu.lto_*
525 CHECK: SEARCH_DIR("/usr/x86_64-linux-gnu/lib64")
526 CHECK: SEARCH_DIR("=/usr/local/lib/x86_64-linux-gnu")
529 CHECK: PROVIDE(__executable_start = SEGMENT_START(text-segment, 4194304))
530 CHECK: . = (SEGMENT_START(text-segment, 4194304) + SIZEOF_HEADERS)
535 CHECK: .note.gnu.build-id :
537 CHECK: *(.note.gnu.build-id)
546 CHECK: *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
548 CHECK: *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
553 CHECK: PROVIDE_HIDDEN(__rela_iplt_start = .)
555 CHECK: PROVIDE_HIDDEN(__rela_iplt_end = .)
559 CHECK: KEEP(*(SORT_NONE(.init)))
560 CHECK: } =0x909090909090909090909090
561 CHECK: PROVIDE(__etext = .)
564 CHECK: KEEP(*(.eh_frame))
566 CHECK: .exception_ranges :
568 CHECK: *(.exception_ranges .exception_ranges*)
570 CHECK: . = (ALIGN(CONSTANT(MAXPAGESIZE)) - ((CONSTANT(MAXPAGESIZE) - .) & (CONSTANT(MAXPAGESIZE) - 1)))
571 CHECK: . = DATA_SEGMENT_ALIGN(CONSTANT(MAXPAGESIZE), CONSTANT(COMMONPAGESIZE))
574 CHECK: KEEP(*(.eh_frame))
578 CHECK: KEEP(*crtbegin.o(.ctors))
579 CHECK: KEEP(*crtbegin?.o(.ctors))
580 CHECK: KEEP(*(EXCLUDE_FILE(*crtend.o *crtend?.o ) .ctors))
581 CHECK: KEEP(*(SORT_BY_NAME(.ctors.*)))
582 CHECK: KEEP(*(.ctors))
586 CHECK: KEEP(*crtbegin.o(.dtors))
587 CHECK: KEEP(*crtbegin?.o(.dtors))
588 CHECK: KEEP(*(EXCLUDE_FILE(*crtend.o *crtend?.o ) .dtors))
589 CHECK: KEEP(*(SORT_BY_NAME(.dtors.*)))
590 CHECK: KEEP(*(.dtors))
592 CHECK: . = DATA_SEGMENT_RELRO_END((SIZEOF(.got.plt) >= 24) ? 24 : 0, .)
598 CHECK: .lrodata (ALIGN(CONSTANT(MAXPAGESIZE)) + (. & (CONSTANT(MAXPAGESIZE) - 1))) :
600 CHECK: *(.lrodata .lrodata.* .gnu.linkonce.lr.*)
602 CHECK: .ldata (ALIGN(CONSTANT(MAXPAGESIZE)) + (. & (CONSTANT(MAXPAGESIZE) - 1))) :
604 CHECK: *(.ldata .ldata.* .gnu.linkonce.l.*)
605 CHECK: . = ALIGN((. != 0) ? (64 / 8) : 1)
607 CHECK: . = ALIGN((64 / 8))
609 CHECK: PROVIDE(end = .)
610 CHECK: . = DATA_SEGMENT_END(.)
613 CHECK: *(.note.GNU-stack)
614 CHECK: *(.gnu_debuglink)