Add method to query segments for specified output section name. Return error if the section is assigned to unknown segment. Check matching of sections to segments during layout on the subject of correctness. NOTE: no actual functionality of using custom segments is implemented. Differential Revision: http://reviews.llvm.org/D10359 llvm-svn: 239719
83 lines
2.3 KiB
Plaintext
83 lines
2.3 KiB
Plaintext
/*
|
|
This group of tests checks usage of default headers during linking,
|
|
when PHDRS command is not defined or defined empty in linker scripts.
|
|
|
|
This test uses a single X86-64 input object, simple.o, created with the
|
|
following X86-64 assembly code:
|
|
|
|
*** simple.S:
|
|
|
|
(command line clang -c simple.S -o simple.o)
|
|
|
|
.text
|
|
main:
|
|
mov $1, %eax
|
|
movq $1, %rdi
|
|
movq $msg, %rsi
|
|
movq $14, %rdx
|
|
syscall
|
|
ret
|
|
|
|
.globl _start
|
|
_start:
|
|
call main
|
|
mov $60, %eax
|
|
syscall
|
|
ret
|
|
|
|
.data
|
|
msg: .asciz "Hello, World!\n"
|
|
*/
|
|
|
|
/*
|
|
Prepare the object file to test on.
|
|
|
|
RUN: yaml2obj -format=elf %p/Inputs/simple.o.yaml -o=%t.o
|
|
*/
|
|
|
|
/*
|
|
Test when no linker script passed.
|
|
|
|
RUN: lld -flavor gnu -target x86_64 %t.o -static -o %t1
|
|
RUN: llvm-objdump -section-headers %t1 | FileCheck -check-prefix SECTIONS %s
|
|
RUN: llvm-readobj -program-headers %t1 | FileCheck -check-prefix HEADERS %s
|
|
|
|
SECTIONS: .text {{[0-9a-f]+}} 00000000004000b0
|
|
SECTIONS: .data {{[0-9a-f]+}} 0000000000401000
|
|
|
|
HEADERS: ProgramHeader {
|
|
HEADERS: Type: PT_LOAD (0x1)
|
|
HEADERS: VirtualAddress: 0x400000
|
|
HEADERS: }
|
|
HEADERS: ProgramHeader {
|
|
HEADERS: Type: PT_LOAD (0x1)
|
|
HEADERS: VirtualAddress: 0x401000
|
|
HEADERS: }
|
|
*/
|
|
|
|
/*
|
|
Test when linker script doesn't contain PHDRS and sections are not assigned to any segments.
|
|
|
|
RUN: lld -flavor gnu -target x86_64 -T %p/phdrs/sections-no-phdrs.script %t.o -static -o %t2
|
|
RUN: llvm-objdump -section-headers %t2 | FileCheck -check-prefix SECTIONS %s
|
|
RUN: llvm-readobj -program-headers %t2 | FileCheck -check-prefix HEADERS %s
|
|
*/
|
|
|
|
/*
|
|
Test when linker script contains empty PHDRS and sections are not assigned to any segments.
|
|
|
|
RUN: lld -flavor gnu -target x86_64 -T %p/phdrs/sections-empty-phdrs.script %t.o -static -o %t3
|
|
RUN: llvm-objdump -section-headers %t3 | FileCheck -check-prefix SECTIONS %s
|
|
RUN: llvm-readobj -program-headers %t3 | FileCheck -check-prefix HEADERS %s
|
|
*/
|
|
|
|
/*
|
|
Test when linker script contains empty PHDRS and sections are only assigned to NONE segments
|
|
or not assigned at all.
|
|
NOTE: Segments with the name NONE are ignored in such a case.
|
|
|
|
RUN: lld -flavor gnu -target x86_64 -T %p/phdrs/sections-none-phdrs.script %t.o -static -o %t4
|
|
RUN: llvm-objdump -section-headers %t4 | FileCheck -check-prefix SECTIONS %s
|
|
RUN: llvm-readobj -program-headers %t4 | FileCheck -check-prefix HEADERS %s
|
|
*/
|