Delete the old script parser.

It was ELF specific.

llvm-svn: 262163
This commit is contained in:
Rafael Espindola 2016-02-28 02:14:48 +00:00
parent 80d4b898d1
commit d3926f940a
29 changed files with 1 additions and 4166 deletions

View File

@ -8,7 +8,6 @@ endif()
add_lld_library(lldReaderWriter
CoreLinkingContext.cpp
FileArchive.cpp
LinkerScript.cpp
ADDITIONAL_HEADER_DIRS
${LLD_INCLUDE_DIR}/lld/ReaderWriter

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@ configure_lit_site_cfg(
set(LLD_TEST_DEPS
FileCheck not llvm-ar llvm-as llvm-nm llc
lld llvm-config llvm-objdump llvm-readobj yaml2obj obj2yaml
linker-script-test llvm-mc llvm-nm llvm-lib
llvm-mc llvm-nm llvm-lib
)
if (LLVM_INCLUDE_TESTS)
set(LLD_TEST_DEPS ${LLD_TEST_DEPS} LLDUnitTests)

View File

@ -1,34 +0,0 @@
/*
RUN: linker-script-test %s | FileCheck %s
*/
SECTIONS {
. = foo >= bar + 1 ? bar : 1- - - -1;
}
/*
CHECK: kw_sections: SECTIONS
CHECK: l_brace: {
CHECK: identifier: .
CHECK: equal: =
CHECK: identifier: foo
CHECK: greaterequal: >=
CHECK: identifier: bar
CHECK: plus: +
CHECK: number: 1
CHECK: question: ?
CHECK: identifier: bar
CHECK: colon: :
CHECK: number: 1
CHECK: minus: -
CHECK: minus: -
CHECK: minus: -
CHECK: minus: -
CHECK: number: 1
CHECK: semicolon: ;
CHECK: r_brace: }
CHECK: eof:
CHECK: SECTIONS
CHECK: {
CHECK: . = (foo >= (bar + 1)) ? bar : (1 - (-(-(-1))))
CHECK: }
*/

View File

@ -1,22 +0,0 @@
/*
RUN: linker-script-test %s 2> %t | FileCheck %s
RUN: FileCheck -input-file %t -check-prefix=CHECK-ERR %s
*/
EXTERN(a b 3)
/*
CHECK-ERR: [[@LINE-2]]:12: error: expected symbol in EXTERN.
CHECK-ERR-NEXT: {{^EXTERN\(a b 3\)}}
CHECK-ERR-NEXT: {{^ \^}}
*/
/*
CHECK: kw_extern: EXTERN
CHECK: l_paren: (
CHECK: identifier: a
CHECK: identifier: b
CHECK: number: 3
CHECK: r_paren: )
CHECK: eof:
*/

View File

@ -1,19 +0,0 @@
/*
RUN: linker-script-test %s 2> %t | FileCheck %s
RUN: FileCheck -input-file %t -check-prefix=CHECK-ERR %s
*/
EXTERN()
/*
CHECK-ERR: [[@LINE-2]]:8: error: expected one or more symbols in EXTERN.
CHECK-ERR-NEXT: {{^EXTERN()}}
CHECK-ERR-NEXT: {{^ \^}}
*/
/*
CHECK: kw_extern: EXTERN
CHECK: l_paren: (
CHECK: r_paren: )
CHECK: eof:
*/

View File

@ -1,29 +0,0 @@
/*
RUN: linker-script-test %s | FileCheck %s
*/
EXTERN(a)
EXTERN(a b)
EXTERN(_foo _bar _baz)
/*
CHECK: kw_extern: EXTERN
CHECK: l_paren: (
CHECK: identifier: a
CHECK: r_paren: )
CHECK: kw_extern: EXTERN
CHECK: l_paren: (
CHECK: identifier: a
CHECK: identifier: b
CHECK: r_paren: )
CHECK: kw_extern: EXTERN
CHECK: l_paren: (
CHECK: identifier: _foo
CHECK: identifier: _bar
CHECK: identifier: _baz
CHECK: r_paren: )
CHECK: eof:
CHECK: EXTERN(a)
CHECK: EXTERN(a b)
CHECK: EXTERN(_foo _bar _baz)
*/

View File

@ -1,25 +0,0 @@
/*
RUN: linker-script-test %s 2> %t | FileCheck %s
RUN: FileCheck -input-file %t -check-prefix=CHECK-ERR %s
*/
SECTIONS {
. = foo ? bar;
/*
CHECK-ERR: [[@LINE-2]]:18: error: expected :
CHECK-ERR-NEXT: {{^ \. = foo \? bar;}}
CHECK-ERR-NEXT: {{^ \^}}
*/
}
/*
CHECK: kw_sections: SECTIONS
CHECK: l_brace: {
CHECK: identifier: .
CHECK: equal: =
CHECK: identifier: foo
CHECK: question: ?
CHECK: identifier: bar
CHECK: semicolon: ;
CHECK: r_brace: }
CHECK: eof:
*/

View File

@ -1,11 +0,0 @@
/* RUN: linker-script-test %s 2>&1 | FileCheck %s
*/
OUTPUT_ARCH(i386:x86_64)
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
GROUP( -l### )
ENTRY(init)
/*
CHECK: libname-err-1.test:6:10: error: expected )
*/

View File

@ -1,11 +0,0 @@
/* RUN: linker-script-test %s 2>&1 | FileCheck %s
*/
OUTPUT_ARCH(i386:x86_64)
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
GROUP( -l )
ENTRY(init)
/*
CHECK: libname-err-2.test:6:10: error: expected )
*/

View File

@ -1,12 +0,0 @@
/* RUN: linker-script-test %s | FileCheck %s
*/
OUTPUT_FORMAT(elf64-x86-64)
/*
CHECK: kw_output_format: OUTPUT_FORMAT
CHECK: l_paren: (
CHECK: identifier: elf64-x86-64
CHECK: r_paren: )
CHECK: OUTPUT_FORMAT("elf64-x86-64")
*/

View File

@ -1,46 +0,0 @@
/* RUN: linker-script-test %s | FileCheck %s
*/
OUTPUT_ARCH(i386:x86_64)
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
OUTPUT("/out/foo")
GROUP ( /lib/x86_64-linux-gnu/libc.so.6 /usr/lib/x86_64-linux-gnu/libc_nonshared.a AS_NEEDED ( /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ) -lm -l:libgcc.a )
ENTRY(init)
/*
CHECK: kw_output_arch: OUTPUT_ARCH
CHECK: l_paren: (
CHECK: identifier: i386:x86_64
CHECK: r_paren: )
CHECK: kw_output_format: OUTPUT_FORMAT
CHECK: l_paren: (
CHECK: identifier: elf64-x86-64
CHECK: comma: ,
CHECK: identifier: elf64-x86-64
CHECK: comma: ,
CHECK: identifier: elf64-x86-64
CHECK: r_paren: )
CHECK: kw_output: OUTPUT
CHECK: l_paren: (
CHECK: identifier: /out/foo
CHECK: r_paren: )
CHECK: kw_group: GROUP
CHECK: l_paren: (
CHECK: identifier: /lib/x86_64-linux-gnu/libc.so.6
CHECK: identifier: /usr/lib/x86_64-linux-gnu/libc_nonshared.a
CHECK: kw_as_needed: AS_NEEDED
CHECK: l_paren: (
CHECK: identifier: /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
CHECK: r_paren: )
CHECK: libname: m
CHECK: libname: :libgcc.a
CHECK: r_paren: )
CHECK: kw_entry: ENTRY
CHECK: l_paren: (
CHECK: identifier: init
CHECK: r_paren: )
CHECK: eof:
CHECK: OUTPUT_FORMAT("elf64-x86-64","elf64-x86-64","elf64-x86-64")
CHECK: GROUP(/lib/x86_64-linux-gnu/libc.so.6 /usr/lib/x86_64-linux-gnu/libc_nonshared.a AS_NEEDED(/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2) -lm -l:libgcc.a)
CHECK: ENTRY(init)
*/

View File

@ -1,17 +0,0 @@
/*
RUN: linker-script-test %s | FileCheck %s
*/
MEMORY
{
}
/*
CHECK: kw_memory: MEMORY
CHECK: l_brace: {
CHECK: r_brace: }
CHECK: eof:
CHECK: MEMORY
CHECK: {
CHECK: }
*/

View File

@ -1,32 +0,0 @@
/*
RUN: linker-script-test %s 2> %t | FileCheck %s
RUN: FileCheck -input-file %t -check-prefix=CHECK-ERR %s
*/
MEMORY
{
ram () : ORIGIN = 0x20000000, LENGTH = 128M
/*
CHECK-ERR: [[@LINE-2]]:8: error: Expected memory attribute string.
CHECK-ERR-NEXT: {{^ ram \(\) : ORIGIN = 0x20000000, LENGTH = 128M}}
CHECK-ERR-NEXT: {{^ \^}}
*/
}
/*
CHECK: kw_memory: MEMORY
CHECK: l_brace: {
CHECK: identifier: ram
CHECK: l_paren: (
CHECK: r_paren: )
CHECK: colon: :
CHECK: kw_origin: ORIGIN
CHECK: equal: =
CHECK: number: 0x20000000
CHECK: comma: ,
CHECK: kw_length: LENGTH
CHECK: equal: =
CHECK: number: 128M
CHECK: r_brace: }
CHECK: eof:
*/

View File

@ -1,29 +0,0 @@
/*
RUN: linker-script-test %s 2> %t | FileCheck %s
RUN: FileCheck -input-file %t -check-prefix=CHECK-ERR %s
*/
MEMORY
{
ram (rwx) : ORIGIN = 0x20000000,
}
/*
CHECK-ERR: [[@LINE-2]]:1: error: expected LENGTH
CHECK-ERR-NEXT: {{^}}}
CHECK-ERR-NEXT: {{^\^}}
*/
/*
CHECK: kw_memory: MEMORY
CHECK: l_brace: {
CHECK: identifier: ram
CHECK: l_paren: (
CHECK: identifier: rwx
CHECK: r_paren: )
CHECK: colon: :
CHECK: kw_origin: ORIGIN
CHECK: equal: =
CHECK: number: 0x20000000
CHECK: r_brace: }
CHECK: eof:
*/

View File

@ -1,31 +0,0 @@
/*
RUN: linker-script-test %s 2> %t | FileCheck %s
RUN: FileCheck -input-file %t -check-prefix=CHECK-ERR %s
*/
MEMORY
{
(rwx) : ORIGIN = 0x20000000, LENGTH = 128M
/*
CHECK-ERR: [[@LINE-2]]:3: error: expected memory block definition.
CHECK-ERR-NEXT: {{^ \(rwx\) : ORIGIN = 0x20000000, LENGTH = 128M}}
CHECK-ERR-NEXT: {{^ \^}}
*/
}
/*
CHECK: kw_memory: MEMORY
CHECK: l_brace: {
CHECK: l_paren: (
CHECK: r_paren: )
CHECK: colon: :
CHECK: kw_origin: ORIGIN
CHECK: equal: =
CHECK: number: 0x20000000
CHECK: comma: ,
CHECK: kw_length: LENGTH
CHECK: equal: =
CHECK: number: 128M
CHECK: r_brace: }
CHECK: eof:
*/

View File

@ -1,30 +0,0 @@
/*
RUN: linker-script-test %s 2> %t | FileCheck %s
RUN: FileCheck -input-file %t -check-prefix=CHECK-ERR %s
*/
MEMORY
{
ram (rwx) : LENGTH = 128M
/*
CHECK-ERR: [[@LINE-2]]:15: error: expected ORIGIN
CHECK-ERR-NEXT: {{^ ram \(rwx\) : LENGTH = 128M}}
CHECK-ERR-NEXT: {{^ \^}}
*/
}
/*
CHECK: kw_memory: MEMORY
CHECK: l_brace: {
CHECK: identifier: ram
CHECK: l_paren: (
CHECK: identifier: rwx
CHECK: r_paren: )
CHECK: colon: :
CHECK: kw_length: LENGTH
CHECK: equal: =
CHECK: number: 128M
CHECK: r_brace: }
CHECK: eof:
*/

View File

@ -1,56 +0,0 @@
/*
RUN: linker-script-test %s | FileCheck %s
*/
MEMORY
{
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 96K
rom (rx) : org = 0x0, len = 256K
boot : o = 0x1000000, l = 0x5f00
}
/*
CHECK: kw_memory: MEMORY
CHECK: l_brace: {
CHECK: identifier: ram
CHECK: l_paren: (
CHECK: identifier: rwx
CHECK: r_paren: )
CHECK: colon: :
CHECK: kw_origin: ORIGIN
CHECK: equal: =
CHECK: number: 0x20000000
CHECK: comma: ,
CHECK: kw_length: LENGTH
CHECK: equal: =
CHECK: number: 96K
CHECK: identifier: rom
CHECK: l_paren: (
CHECK: identifier: rx
CHECK: r_paren: )
CHECK: colon: :
CHECK: kw_origin: org
CHECK: equal: =
CHECK: number: 0x0
CHECK: comma: ,
CHECK: kw_length: len
CHECK: equal: =
CHECK: number: 256K
CHECK: identifier: boot
CHECK: colon: :
CHECK: kw_origin: o
CHECK: equal: =
CHECK: number: 0x1000000
CHECK: comma: ,
CHECK: kw_length: l
CHECK: equal: =
CHECK: number: 0x5f00
CHECK: r_brace: }
CHECK: eof:
CHECK: MEMORY
CHECK: {
CHECK: ram (rwx) : ORIGIN = 536870912, LENGTH = 98304
CHECK: rom (rx) : ORIGIN = 0, LENGTH = 262144
CHECK: boot : ORIGIN = 16777216, LENGTH = 24320
CHECK: }
*/

View File

@ -1,21 +0,0 @@
/*
RUN: linker-script-test %s 2> %t | FileCheck %s
RUN: FileCheck -input-file %t -check-prefix=CHECK-ERR %s
*/
SECTIONS {
ENTRY()
/*
CHECK-ERR: [[@LINE-2]]:11: error: expected identifier in ENTRY
CHECK-ERR-NEXT: {{^ ENTRY()}}
CHECK-ERR-NEXT: {{^ \^}}
*/
}
/*
CHECK: l_brace: {
CHECK: kw_entry: ENTRY
CHECK: l_paren: (
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: eof:
*/

View File

@ -1,25 +0,0 @@
/*
RUN: linker-script-test %s 2> %t | FileCheck %s
RUN: FileCheck -input-file %t -check-prefix=CHECK-ERR %s
*/
SECTIONS {
.text : { ()}
/*
CHECK-ERR: [[@LINE-2]]:15: error: expected symbol assignment or input file name.
CHECK-ERR-NEXT: {{^ \.text : { \(\)}}}
CHECK-ERR-NEXT: {{^ \^}}
*/
}
/*
CHECK: kw_sections: SECTIONS
CHECK: l_brace: {
CHECK: identifier: .text
CHECK: colon: :
CHECK: l_brace: {
CHECK: l_paren: (
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: r_brace: }
CHECK: eof:
*/

View File

@ -1,27 +0,0 @@
/*
RUN: linker-script-test %s 2> %t | FileCheck %s
RUN: FileCheck -input-file %t -check-prefix=CHECK-ERR %s
*/
SECTIONS {
.text : { *(+)}
/*
CHECK-ERR: [[@LINE-2]]:16: error: expected )
CHECK-ERR-NEXT: {{^ \.text : { \*\(\+\)}}}
CHECK-ERR-NEXT: {{^ \^}}
*/
}
/*
CHECK: kw_sections: SECTIONS
CHECK: l_brace: {
CHECK: identifier: .text
CHECK: colon: :
CHECK: l_brace: {
CHECK: star: *
CHECK: l_paren: (
CHECK: plus: +
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: r_brace: }
CHECK: eof:
*/

View File

@ -1,24 +0,0 @@
/*
RUN: linker-script-test %s 2> %t | FileCheck %s
RUN: FileCheck -check-prefix=CHECK-ERR -input-file %t %s
*/
SECTIONS {
. = foo / ;
/*
CHECK-ERR: [[@LINE-2]]:15: error: expected symbol, number, minus, tilde or left parenthesis.
CHECK-ERR-NEXT: {{^ . = foo / ;}}
CHECK-ERR-NEXT: {{^ \^}}
*/
}
/*
CHECK: kw_sections: SECTIONS
CHECK: l_brace: {
CHECK: identifier: .
CHECK: equal: =
CHECK: identifier: foo
CHECK: slash: /
CHECK: semicolon: ;
CHECK: r_brace: }
CHECK: eof:
*/

View File

@ -1,25 +0,0 @@
/*
RUN: linker-script-test %s 2> %t | FileCheck %s
RUN: FileCheck -input-file %t -check-prefix=CHECK-ERR %s
*/
SECTIONS {
: { *()}
/*
CHECK-ERR: [[@LINE-2]]:5: error: expected symbol assignment, entry, overlay or output section name
CHECK-ERR-NEXT: {{^ : { \*\(\)}}}
CHECK-ERR-NEXT: {{^ \^}}
*/
}
/*
CHECK: kw_sections: SECTIONS
CHECK: l_brace: {
CHECK: colon: :
CHECK: l_brace: {
CHECK: star: *
CHECK: l_paren: (
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: r_brace: }
CHECK: eof:
*/

View File

@ -1,24 +0,0 @@
/*
RUN: linker-script-test %s 2> %t | FileCheck %s
RUN: FileCheck -input-file %t -check-prefix=CHECK-ERR %s
*/
SECTIONS {
= foo + bar;
/*
CHECK-ERR: [[@LINE-2]]:5: error: expected symbol assignment, entry, overlay or output section name.
CHECK-ERR-NEXT: {{^ = foo \+ bar;}}
CHECK-ERR-NEXT: {{^ \^}}
*/
}
/*
CHECK: kw_sections: SECTIONS
CHECK: l_brace: {
CHECK: equal: =
CHECK: identifier: foo
CHECK: plus: +
CHECK: identifier: bar
CHECK: semicolon: ;
CHECK: r_brace: }
CHECK: eof:
*/

View File

@ -1,29 +0,0 @@
/*
Test PHDR parsing and section -> phdr mapping.
RUN: linker-script-test %s | FileCheck %s
*/
PHDRS
{
ph_text PT_LOAD FLAGS (0x1 | 0x4);
ph_data PT_LOAD FLAGS (0x2 | 0x4);
}
SECTIONS
{
.init : {} : ph_text
}
/*
CHECK: PHDRS
CHECK: {
CHECK: ph_text 1 FLAGS (5);
CHECK: ph_data 1 FLAGS (6);
CHECK: }
CHECK: SECTIONS
CHECK: {
CHECK: .init :
CHECK: {
CHECK: } : ph_text
CHECK: }
*/

View File

@ -1,624 +0,0 @@
/*
This test exercises parsing typical commands found in GNU ld linker scripts.
RUN: linker-script-test %s | FileCheck %s
*/
SEARCH_DIR("/usr/x86_64-linux-gnu/lib64"); SEARCH_DIR("=/usr/local/lib/x86_64-linux-gnu");
SECTIONS
{
PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x400000)); . = SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS;
.interp : { *(.interp) }
.note.gnu.build-id : { *(.note.gnu.build-id) }
.hash : { *(.hash) }
.rela.dyn :
{
*(.rela.init)
*(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
*(.rela.fini)
*(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
}
.rela.plt :
{
*(.rela.plt)
PROVIDE_HIDDEN (__rela_iplt_start = .);
*(.rela.iplt)
PROVIDE_HIDDEN (__rela_iplt_end = .);
}
.init :
{
FILL (0x90909090)
KEEP (*(SORT_NONE(.init)))
} =0x909090909090909090909090
PROVIDE (__etext = .);
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
.exception_ranges : ONLY_IF_RO { *(.exception_ranges
.exception_ranges*) }
. = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
/* Exception handling */
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
.ctors :
{
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
. = DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >= 24 ? 24 : 0, .);
.got.plt : { *(.got.plt) *(.igot.plt) }
.lrodata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
{
*(.lrodata .lrodata.* .gnu.linkonce.lr.*)
}
.ldata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
{
*(.ldata .ldata.* .gnu.linkonce.l.*)
. = ALIGN(. != 0 ? 64 / 8 : 1);
}
. = ALIGN(64 / 8);
_end = .; PROVIDE (end = .);
. = DATA_SEGMENT_END (.);
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
}
/*
CHECK: kw_search_dir: SEARCH_DIR
CHECK: l_paren: (
CHECK: identifier: /usr/x86_64-linux-gnu/lib64
CHECK: r_paren: )
CHECK: semicolon: ;
CHECK: kw_search_dir: SEARCH_DIR
CHECK: l_paren: (
CHECK: identifier: =/usr/local/lib/x86_64-linux-gnu
CHECK: r_paren: )
CHECK: semicolon: ;
CHECK: kw_sections: SECTIONS
CHECK: l_brace: {
CHECK: kw_provide: PROVIDE
CHECK: l_paren: (
CHECK: identifier: __executable_start
CHECK: equal: =
CHECK: identifier: SEGMENT_START
CHECK: l_paren: (
CHECK: identifier: text-segment
CHECK: comma: ,
CHECK: number: 0x400000
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: semicolon: ;
CHECK: identifier: .
CHECK: equal: =
CHECK: identifier: SEGMENT_START
CHECK: l_paren: (
CHECK: identifier: text-segment
CHECK: comma: ,
CHECK: number: 0x400000
CHECK: r_paren: )
CHECK: plus: +
CHECK: identifier: SIZEOF_HEADERS
CHECK: semicolon: ;
CHECK: identifier: .interp
CHECK: colon: :
CHECK: l_brace: {
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .interp
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: identifier: .note.gnu.build-id
CHECK: colon: :
CHECK: l_brace: {
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .note.gnu.build-id
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: identifier: .hash
CHECK: colon: :
CHECK: l_brace: {
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .hash
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: identifier: .rela.dyn
CHECK: colon: :
CHECK: l_brace: {
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .rela.init
CHECK: r_paren: )
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .rela.text
CHECK: identifier: .rela.text.*
CHECK: identifier: .rela.gnu.linkonce.t.*
CHECK: r_paren: )
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .rela.fini
CHECK: r_paren: )
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .rela.rodata
CHECK: identifier: .rela.rodata.*
CHECK: identifier: .rela.gnu.linkonce.r.*
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: identifier: .rela.plt
CHECK: colon: :
CHECK: l_brace: {
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .rela.plt
CHECK: r_paren: )
CHECK: kw_provide_hidden: PROVIDE_HIDDEN
CHECK: l_paren: (
CHECK: identifier: __rela_iplt_start
CHECK: equal: =
CHECK: identifier: .
CHECK: r_paren: )
CHECK: semicolon: ;
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .rela.iplt
CHECK: r_paren: )
CHECK: kw_provide_hidden: PROVIDE_HIDDEN
CHECK: l_paren: (
CHECK: identifier: __rela_iplt_end
CHECK: equal: =
CHECK: identifier: .
CHECK: r_paren: )
CHECK: semicolon: ;
CHECK: r_brace: }
CHECK: identifier: .init
CHECK: colon: :
CHECK: l_brace: {
CHECK: kw_fill: FILL
CHECK: l_paren: (
CHECK: number: 0x90909090
CHECK: r_paren: )
CHECK: kw_keep: KEEP
CHECK: l_paren: (
CHECK: star: *
CHECK: l_paren: (
CHECK: kw_sort_none: SORT_NONE
CHECK: l_paren: (
CHECK: identifier: .init
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: kw_provide: PROVIDE
CHECK: l_paren: (
CHECK: identifier: __etext
CHECK: equal: =
CHECK: identifier: .
CHECK: r_paren: )
CHECK: semicolon: ;
CHECK: identifier: .eh_frame
CHECK: colon: :
CHECK: kw_only_if_ro: ONLY_IF_RO
CHECK: l_brace: {
CHECK: kw_keep: KEEP
CHECK: l_paren: (
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .eh_frame
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: identifier: .exception_ranges
CHECK: colon: :
CHECK: kw_only_if_ro: ONLY_IF_RO
CHECK: l_brace: {
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .exception_ranges
CHECK: identifier: .exception_ranges*
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: identifier: .
CHECK: equal: =
CHECK: kw_align: ALIGN
CHECK: l_paren: (
CHECK: identifier: CONSTANT
CHECK: l_paren: (
CHECK: identifier: MAXPAGESIZE
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: minus: -
CHECK: l_paren: (
CHECK: l_paren: (
CHECK: identifier: CONSTANT
CHECK: l_paren: (
CHECK: identifier: MAXPAGESIZE
CHECK: r_paren: )
CHECK: minus: -
CHECK: identifier: .
CHECK: r_paren: )
CHECK: amp: &
CHECK: l_paren: (
CHECK: identifier: CONSTANT
CHECK: l_paren: (
CHECK: identifier: MAXPAGESIZE
CHECK: r_paren: )
CHECK: minus: -
CHECK: number: 1
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: semicolon: ;
CHECK: identifier: .
CHECK: equal: =
CHECK: identifier: DATA_SEGMENT_ALIGN
CHECK: l_paren: (
CHECK: identifier: CONSTANT
CHECK: l_paren: (
CHECK: identifier: MAXPAGESIZE
CHECK: r_paren: )
CHECK: comma: ,
CHECK: identifier: CONSTANT
CHECK: l_paren: (
CHECK: identifier: COMMONPAGESIZE
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: semicolon: ;
CHECK: identifier: .eh_frame
CHECK: colon: :
CHECK: kw_only_if_rw: ONLY_IF_RW
CHECK: l_brace: {
CHECK: kw_keep: KEEP
CHECK: l_paren: (
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .eh_frame
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: identifier: .ctors
CHECK: colon: :
CHECK: l_brace: {
CHECK: kw_keep: KEEP
CHECK: l_paren: (
CHECK: identifier: *crtbegin.o
CHECK: l_paren: (
CHECK: identifier: .ctors
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: kw_keep: KEEP
CHECK: l_paren: (
CHECK: identifier: *crtbegin?.o
CHECK: l_paren: (
CHECK: identifier: .ctors
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: kw_keep: KEEP
CHECK: l_paren: (
CHECK: star: *
CHECK: l_paren: (
CHECK: kw_exclude_file: EXCLUDE_FILE
CHECK: l_paren: (
CHECK: identifier: *crtend.o
CHECK: identifier: *crtend?.o
CHECK: r_paren: )
CHECK: identifier: .ctors
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: kw_keep: KEEP
CHECK: l_paren: (
CHECK: star: *
CHECK: l_paren: (
CHECK: kw_sort_by_name: SORT
CHECK: l_paren: (
CHECK: identifier: .ctors.*
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: kw_keep: KEEP
CHECK: l_paren: (
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .ctors
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: identifier: .dtors
CHECK: colon: :
CHECK: l_brace: {
CHECK: kw_keep: KEEP
CHECK: l_paren: (
CHECK: identifier: *crtbegin.o
CHECK: l_paren: (
CHECK: identifier: .dtors
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: kw_keep: KEEP
CHECK: l_paren: (
CHECK: identifier: *crtbegin?.o
CHECK: l_paren: (
CHECK: identifier: .dtors
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: kw_keep: KEEP
CHECK: l_paren: (
CHECK: star: *
CHECK: l_paren: (
CHECK: kw_exclude_file: EXCLUDE_FILE
CHECK: l_paren: (
CHECK: identifier: *crtend.o
CHECK: identifier: *crtend?.o
CHECK: r_paren: )
CHECK: identifier: .dtors
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: kw_keep: KEEP
CHECK: l_paren: (
CHECK: star: *
CHECK: l_paren: (
CHECK: kw_sort_by_name: SORT
CHECK: l_paren: (
CHECK: identifier: .dtors.*
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: kw_keep: KEEP
CHECK: l_paren: (
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .dtors
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: identifier: .
CHECK: equal: =
CHECK: identifier: DATA_SEGMENT_RELRO_END
CHECK: l_paren: (
CHECK: identifier: SIZEOF
CHECK: l_paren: (
CHECK: identifier: .got.plt
CHECK: r_paren: )
CHECK: greaterequal: >=
CHECK: number: 24
CHECK: question: ?
CHECK: number: 24
CHECK: colon: :
CHECK: number: 0
CHECK: comma: ,
CHECK: identifier: .
CHECK: r_paren: )
CHECK: semicolon: ;
CHECK: identifier: .got.plt
CHECK: colon: :
CHECK: l_brace: {
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .got.plt
CHECK: r_paren: )
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .igot.plt
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: identifier: .lrodata
CHECK: kw_align: ALIGN
CHECK: l_paren: (
CHECK: identifier: CONSTANT
CHECK: l_paren: (
CHECK: identifier: MAXPAGESIZE
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: plus: +
CHECK: l_paren: (
CHECK: identifier: .
CHECK: amp: &
CHECK: l_paren: (
CHECK: identifier: CONSTANT
CHECK: l_paren: (
CHECK: identifier: MAXPAGESIZE
CHECK: r_paren: )
CHECK: minus: -
CHECK: number: 1
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: colon: :
CHECK: l_brace: {
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .lrodata
CHECK: identifier: .lrodata.*
CHECK: identifier: .gnu.linkonce.lr.*
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: identifier: .ldata
CHECK: kw_align: ALIGN
CHECK: l_paren: (
CHECK: identifier: CONSTANT
CHECK: l_paren: (
CHECK: identifier: MAXPAGESIZE
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: plus: +
CHECK: l_paren: (
CHECK: identifier: .
CHECK: amp: &
CHECK: l_paren: (
CHECK: identifier: CONSTANT
CHECK: l_paren: (
CHECK: identifier: MAXPAGESIZE
CHECK: r_paren: )
CHECK: minus: -
CHECK: number: 1
CHECK: r_paren: )
CHECK: r_paren: )
CHECK: colon: :
CHECK: l_brace: {
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .ldata
CHECK: identifier: .ldata.*
CHECK: identifier: .gnu.linkonce.l.*
CHECK: r_paren: )
CHECK: identifier: .
CHECK: equal: =
CHECK: kw_align: ALIGN
CHECK: l_paren: (
CHECK: identifier: .
CHECK: exclaimequal: !=
CHECK: number: 0
CHECK: question: ?
CHECK: number: 64
CHECK: slash: /
CHECK: number: 8
CHECK: colon: :
CHECK: number: 1
CHECK: r_paren: )
CHECK: semicolon: ;
CHECK: r_brace: }
CHECK: identifier: .
CHECK: equal: =
CHECK: kw_align: ALIGN
CHECK: l_paren: (
CHECK: number: 64
CHECK: slash: /
CHECK: number: 8
CHECK: r_paren: )
CHECK: semicolon: ;
CHECK: identifier: _end
CHECK: equal: =
CHECK: identifier: .
CHECK: semicolon: ;
CHECK: kw_provide: PROVIDE
CHECK: l_paren: (
CHECK: identifier: end
CHECK: equal: =
CHECK: identifier: .
CHECK: r_paren: )
CHECK: semicolon: ;
CHECK: identifier: .
CHECK: equal: =
CHECK: identifier: DATA_SEGMENT_END
CHECK: l_paren: (
CHECK: identifier: .
CHECK: r_paren: )
CHECK: semicolon: ;
CHECK: kw_discard: /DISCARD/
CHECK: colon: :
CHECK: l_brace: {
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .note.GNU-stack
CHECK: r_paren: )
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .gnu_debuglink
CHECK: r_paren: )
CHECK: star: *
CHECK: l_paren: (
CHECK: identifier: .gnu.lto_*
CHECK: r_paren: )
CHECK: r_brace: }
CHECK: r_brace: }
CHECK: eof:
CHECK: SEARCH_DIR("/usr/x86_64-linux-gnu/lib64")
CHECK: SEARCH_DIR("=/usr/local/lib/x86_64-linux-gnu")
CHECK: SECTIONS
CHECK: {
CHECK: PROVIDE(__executable_start = SEGMENT_START(text-segment, 4194304))
CHECK: . = (SEGMENT_START(text-segment, 4194304) + SIZEOF_HEADERS)
CHECK: .interp :
CHECK: {
CHECK: *(.interp)
CHECK: }
CHECK: .note.gnu.build-id :
CHECK: {
CHECK: *(.note.gnu.build-id)
CHECK: }
CHECK: .hash :
CHECK: {
CHECK: *(.hash)
CHECK: }
CHECK: .rela.dyn :
CHECK: {
CHECK: *(.rela.init)
CHECK: *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
CHECK: *(.rela.fini)
CHECK: *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
CHECK: }
CHECK: .rela.plt :
CHECK: {
CHECK: *(.rela.plt)
CHECK: PROVIDE_HIDDEN(__rela_iplt_start = .)
CHECK: *(.rela.iplt)
CHECK: PROVIDE_HIDDEN(__rela_iplt_end = .)
CHECK: }
CHECK: .init :
CHECK: {
CHECK: FILL(0x90909090)
CHECK: KEEP(*(SORT_NONE(.init)))
CHECK: } =0x909090909090909090909090
CHECK: PROVIDE(__etext = .)
CHECK: .eh_frame :
CHECK: ONLY_IF_RO {
CHECK: KEEP(*(.eh_frame))
CHECK: }
CHECK: .exception_ranges :
CHECK: ONLY_IF_RO {
CHECK: *(.exception_ranges .exception_ranges*)
CHECK: }
CHECK: . = (ALIGN(CONSTANT(MAXPAGESIZE)) - ((CONSTANT(MAXPAGESIZE) - .) & (CONSTANT(MAXPAGESIZE) - 1)))
CHECK: . = DATA_SEGMENT_ALIGN(CONSTANT(MAXPAGESIZE), CONSTANT(COMMONPAGESIZE))
CHECK: .eh_frame :
CHECK: ONLY_IF_RW {
CHECK: KEEP(*(.eh_frame))
CHECK: }
CHECK: .ctors :
CHECK: {
CHECK: KEEP(*crtbegin.o(.ctors))
CHECK: KEEP(*crtbegin?.o(.ctors))
CHECK: KEEP(*(EXCLUDE_FILE(*crtend.o *crtend?.o ) .ctors))
CHECK: KEEP(*(SORT_BY_NAME(.ctors.*)))
CHECK: KEEP(*(.ctors))
CHECK: }
CHECK: .dtors :
CHECK: {
CHECK: KEEP(*crtbegin.o(.dtors))
CHECK: KEEP(*crtbegin?.o(.dtors))
CHECK: KEEP(*(EXCLUDE_FILE(*crtend.o *crtend?.o ) .dtors))
CHECK: KEEP(*(SORT_BY_NAME(.dtors.*)))
CHECK: KEEP(*(.dtors))
CHECK: }
CHECK: . = DATA_SEGMENT_RELRO_END((SIZEOF(.got.plt) >= 24) ? 24 : 0, .)
CHECK: .got.plt :
CHECK: {
CHECK: *(.got.plt)
CHECK: *(.igot.plt)
CHECK: }
CHECK: .lrodata (ALIGN(CONSTANT(MAXPAGESIZE)) + (. & (CONSTANT(MAXPAGESIZE) - 1))) :
CHECK: {
CHECK: *(.lrodata .lrodata.* .gnu.linkonce.lr.*)
CHECK: }
CHECK: .ldata (ALIGN(CONSTANT(MAXPAGESIZE)) + (. & (CONSTANT(MAXPAGESIZE) - 1))) :
CHECK: {
CHECK: *(.ldata .ldata.* .gnu.linkonce.l.*)
CHECK: . = ALIGN((. != 0) ? (64 / 8) : 1)
CHECK: }
CHECK: . = ALIGN((64 / 8))
CHECK: _end = .
CHECK: PROVIDE(end = .)
CHECK: . = DATA_SEGMENT_END(.)
CHECK: :
CHECK: {
CHECK: *(.note.GNU-stack)
CHECK: *(.gnu_debuglink)
CHECK: *(.gnu.lto_*)
CHECK: }
CHECK: }
*/

View File

@ -1,2 +1 @@
add_subdirectory(linker-script-test)
add_subdirectory(lld)

View File

@ -1,8 +0,0 @@
add_llvm_executable(linker-script-test
linker-script-test.cpp
)
target_link_libraries(linker-script-test
LLVMSupport
lldReaderWriter
)

View File

@ -1,57 +0,0 @@
//===- utils/linker-script-test/linker-script-test.cpp --------------------===//
//
// The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// \brief Tool for testing linker script parsing.
///
//===----------------------------------------------------------------------===//
#include "lld/ReaderWriter/LinkerScript.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Signals.h"
using namespace llvm;
using namespace lld;
using namespace script;
int main(int argc, const char **argv) {
llvm::sys::PrintStackTraceOnErrorSignal();
llvm::PrettyStackTraceProgram X(argc, argv);
{
ErrorOr<std::unique_ptr<MemoryBuffer>> mb =
MemoryBuffer::getFileOrSTDIN(argv[1]);
if (std::error_code ec = mb.getError()) {
llvm::errs() << ec.message() << "\n";
return 1;
}
Lexer l(std::move(mb.get()));
Token tok;
while (true) {
l.lex(tok);
tok.dump(llvm::outs());
if (tok._kind == Token::eof || tok._kind == Token::unknown)
break;
}
}
{
ErrorOr<std::unique_ptr<MemoryBuffer>> mb =
MemoryBuffer::getFileOrSTDIN(argv[1]);
if (std::error_code ec = mb.getError()) {
llvm::errs() << ec.message() << "\n";
return 1;
}
Parser p(std::move(mb.get()));
if (!p.parse()) {
LinkerScript *ls = p.get();
ls->dump(llvm::outs());
}
}
}