xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/overlapping-sections.test (revision a5dfa70806be78c5e07f14b14c758a4223935024)
1## This test shows that llvm-objcopy does not baulk at overlapping sections.
2## These don't really make sense, but the tool should still handle invalid
3## inputs somehow.
4# RUN: yaml2obj %s -o %t.o
5
6## Check that the contents are as expected before the copy.
7# RUN: llvm-readobj -x .first -x .second %t.o | FileCheck %s --check-prefix=CONTENTS
8
9## Now check that the section contents are still correct after the copy.
10## Also characterize the behavior of llvm-objcopy in that it "unoverlaps" the
11## two sections.
12# RUN: llvm-objcopy %t.o %t2.o
13# RUN: llvm-readobj --section-headers %t2.o | FileCheck %s
14# RUN: llvm-readobj -x .first -x .second %t2.o | FileCheck %s --check-prefix=CONTENTS
15
16# CHECK: Name: .first
17# CHECK: Offset: 0x1000
18# CHECK: Name: .second
19# CHECK: Offset: 0x1004
20
21# CONTENTS:      Hex dump of section '.first':
22# CONTENTS-NEXT: 0x00000000 01234567
23# CONTENTS-EMPTY:
24# CONTENTS-NEXT: Hex dump of section '.second':
25# CONTENTS-NEXT: 0x00000000 23456789
26
27--- !ELF
28FileHeader:
29  Class:   ELFCLASS64
30  Data:    ELFDATA2LSB
31  Type:    ET_EXEC
32  Machine: EM_X86_64
33Sections:
34  - Name: .first
35    Type: SHT_PROGBITS
36    Content: '01234567'
37    AddressAlign: 0x1000
38  - Name: .second
39    Type: SHT_PROGBITS
40    Content: '89abcdef'
41    ShOffset: 0x1001
42