llvm.org GIT mirror llvm / e8d332f
[llvm-objcopy] Add additional testing for various cases This patch adds a number of tests to test various cases not covered by existing tests. All of them work correctly, with no need to change llvm-objcopy itself, although some do indicate possible areas for improvement. Reviewed by: MaskRay Differential Revision: https://reviews.llvm.org/D61727 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360422 91177308-0d34-0410-b5e6-96231b3b80d8 James Henderson 5 months ago
10 changed file(s) with 497 addition(s) and 41 deletion(s). Raw diff Collapse all Expand all
0 ## If the e_phoff field is set to a value either past the end of the file, or
1 ## such that e_phoff + e_phnum * sizeof(Elf_Phdr) is past the end of the file,
2 ## we should emit an error. This test checks that the emitted error is sensible.
3
4 # RUN: yaml2obj %s -o %t.o
5 ## Remove the default section headers so that the section header table is not invalid.
6 # RUN: llvm-objcopy --strip-sections %t.o
7 # RUN: cp %t.o %t2.o
8
9 ## Sanity check that the phdr table is at offset 64:
10 # RUN: llvm-readobj --file-headers %t.o | FileCheck %s --check-prefix=VALIDATE
11 # VALIDATE: ProgramHeaderOffset: 0x40{{$}}
12
13 ## Truncate the file to end before the program header table ends.
14 # RUN: %python -c "with open('%/t.o', 'r+b') as input: input.truncate(65)"
15 # RUN: not llvm-objcopy %t.o 2>&1 | FileCheck %s
16
17 ## Set the e_phoff field to a value much larger than the object file size.
18 # RUN: %python -c "with open('%/t2.o', 'r+b') as input: import struct; bytes = struct.pack('
19 # RUN: not llvm-objcopy %t2.o 2>&1 | FileCheck %s
20
21 --- !ELF
22 FileHeader:
23 Class: ELFCLASS64
24 Data: ELFDATA2LSB
25 Type: ET_EXEC
26 Machine: EM_X86_64
27 ProgramHeaders:
28 - Type: PT_LOAD
29
30 # CHECK: error: program headers longer than binary
0 ## If the e_shoff field is set to a value either past the end of the file, or
1 ## such that e_shoff + e_shnum * sizeof(Elf_Shdr) is past the end of the file,
2 ## we should emit an error. This test checks that the emitted error is sensible.
3
4 # RUN: yaml2obj %s -o %t.o
5 # RUN: cp %t.o %t2.o
6
7 ## Sanity check that the section header table is at offset 64:
8 # RUN: llvm-readobj --file-headers %t.o | FileCheck %s --check-prefix=VALIDATE
9 # VALIDATE: SectionHeaderOffset: 0x40{{$}}
10
11 ## Truncate the file to end before the section header table ends.
12 # RUN: %python -c "with open('%/t.o', 'r+b') as input: input.truncate(65)"
13 # RUN: not llvm-objcopy %t.o 2>&1 | FileCheck %s -DINPUT=%t.o
14
15 ## Set the e_shoff field to a value much larger than the object file size.
16 # RUN: %python -c "with open('%/t2.o', 'r+b') as input: import struct; bytes = struct.pack('
17 # RUN: not llvm-objcopy %t2.o 2>&1 | FileCheck %s -DINPUT=%t2.o
18
19 --- !ELF
20 FileHeader:
21 Class: ELFCLASS64
22 Data: ELFDATA2LSB
23 Type: ET_EXEC
24 Machine: EM_X86_64
25 Sections:
26 - Name: .foo
27 Type: SHT_PROGBITS
28
29 # CHECK: error: '[[INPUT]]': section header table goes past the end of the file
0 ## This test checks that if a section has a sh_link field, and one or more
1 ## sections are removed such that the target section index changes, then
2 ## llvm-objcopy correctly updates the sh_link field.
3
4 # RUN: yaml2obj %s -o %t.o
5 # RUN: llvm-objcopy --remove-section .foo %t.o %t2.o
6 # RUN: llvm-readobj --section-headers %t2.o | FileCheck %s
7
8 --- !ELF
9 FileHeader:
10 Class: ELFCLASS64
11 Data: ELFDATA2LSB
12 Type: ET_EXEC
13 Machine: EM_X86_64
14 Sections:
15 - Name: .foo
16 Type: SHT_PROGBITS
17 - Name: .bar
18 Type: SHT_PROGBITS
19 - Name: .baz
20 Type: SHT_PROGBITS
21 Link: .bar
22
23 # CHECK: Index: 1
24 # CHECK-NEXT: Name: .bar
25 # CHECK: Name: .baz
26 ## Find the next "Link" line, then check the value is exactly the index of .bar.
27 # CHECK: Link
28 # CHECK-SAME: : 1{{$}}
0 ## This test shows that llvm-objcopy does not baulk at overlapping sections
1 ## where such sections are within segments.
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 ## First, check that the section header table appears immediately after the program
7 ## header table.
8 # RUN: llvm-readobj --file-headers %t.o | FileCheck %s --check-prefix=SHDRS-OFFSET
9 # SHDRS-OFFSET: SectionHeaderOffset: 0x78{{$}}
10
11 ## Binary edit the section header sh_offset field of the second section to
12 ## overlap the first one.
13 # RUN: %python -c "with open('%/t.o', 'r+b') as input: import struct; bytes = struct.pack('
14
15 ## Sanity check that the binary editing modified the correct field.
16 # RUN: llvm-readobj --section-headers %t.o | FileCheck %s
17
18 ## Check that the contents are as expected before the copy.
19 # RUN: llvm-readobj -x .first -x .second %t.o | FileCheck %s --check-prefix=CONTENTS
20
21 ## Now check that the section contents are still correct after the copy and show that
22 ## llvm-objcopy hasn't "unoverlapped" these sections because they are in segments.
23 # RUN: llvm-objcopy %t.o %t2.o
24 # RUN: llvm-readobj --section-headers %t2.o | FileCheck %s
25 # RUN: llvm-readobj -x .first -x .second %t2.o | FileCheck %s --check-prefix=CONTENTS
26
27 # CHECK: Name: .first
28 # CHECK: Offset: 0x1000
29 # CHECK: Name: .second
30 # CHECK: Offset: 0x1001
31
32 # CONTENTS: Hex dump of section '.first':
33 # CONTENTS-NEXT: 0x00000000 01234567
34 # CONTENTS-NEXT: Hex dump of section '.second':
35 # CONTENTS-NEXT: 0x00000000 23456789
36
37 --- !ELF
38 FileHeader:
39 Class: ELFCLASS64
40 Data: ELFDATA2LSB
41 Type: ET_EXEC
42 Machine: EM_X86_64
43 Sections:
44 - Name: .first
45 Type: SHT_PROGBITS
46 Content: '01234567'
47 AddressAlign: 0x1000
48 - Name: .second
49 Type: SHT_PROGBITS
50 Content: '89abcdef'
51 ProgramHeaders:
52 - Type: PT_LOAD
53 FileSize: 5
54 Offset: 0x1000
55 Align: 0x1000
0 ## This test shows that llvm-objcopy does not baulk at overlapping sections.
1 ## These don't really make sense, but the tool should still handle invalid
2 ## inputs somehow.
3 # RUN: yaml2obj %s -o %t.o
4
5 ## First, check that the section header table appears immediately after the ELF
6 ## header.
7 # RUN: llvm-readobj --file-headers %t.o | FileCheck %s --check-prefix=SHDRS-OFFSET
8 # SHDRS-OFFSET: SectionHeaderOffset: 0x40{{$}}
9
10 ## Binary edit the section header sh_offset field of the second section to
11 ## overlap the first one.
12 # RUN: %python -c "with open('%/t.o', 'r+b') as input: import struct; bytes = struct.pack('
13
14 ## Sanity check that the binary editing modified the correct field.
15 # RUN: llvm-readobj --section-headers %t.o | FileCheck %s --check-prefix=VALIDATE
16
17 # VALIDATE: Name: .first
18 # VALIDATE: Offset: 0x1000
19 # VALIDATE: Name: .second
20 # VALIDATE: Offset: 0x1001
21
22 ## Check that the contents are as expected before the copy.
23 # RUN: llvm-readobj -x .first -x .second %t.o | FileCheck %s --check-prefix=CONTENTS
24
25 ## Now check that the section contents are still correct after the copy.
26 ## Also characterize the behavior of llvm-objcopy in that it "unoverlaps" the
27 ## two sections.
28 # RUN: llvm-objcopy %t.o %t2.o
29 # RUN: llvm-readobj --section-headers %t2.o | FileCheck %s
30 # RUN: llvm-readobj -x .first -x .second %t2.o | FileCheck %s --check-prefix=CONTENTS
31
32 # CHECK: Name: .first
33 # CHECK: Offset: 0x1000
34 # CHECK: Name: .second
35 # CHECK: Offset: 0x1004
36
37 # CONTENTS: Hex dump of section '.first':
38 # CONTENTS-NEXT: 0x00000000 01234567
39 # CONTENTS-NEXT: Hex dump of section '.second':
40 # CONTENTS-NEXT: 0x00000000 23456789
41
42 --- !ELF
43 FileHeader:
44 Class: ELFCLASS64
45 Data: ELFDATA2LSB
46 Type: ET_EXEC
47 Machine: EM_X86_64
48 Sections:
49 - Name: .first
50 Type: SHT_PROGBITS
51 Content: '01234567'
52 AddressAlign: 0x1000
53 - Name: .second
54 Type: SHT_PROGBITS
55 Content: '89abcdef'
0 ## When multiple sections have the same name, and --rename-section is specified,
1 ## GNU objcopy renames all these sections. This test shows that llvm-objcopy
2 ## does the same.
3
4 ## Note: we have to do this test in two stages because yaml2obj cannot handle
5 ## multiple sections with the same name. This has the benefit of showing that
6 ## we can rename to an already existing name.
7 # RUN: yaml2obj %s -o %t.o
8
9 ## First make two sections with the same name...
10 # RUN: llvm-objcopy --rename-section=.foo=.bar %t.o %t2.o
11 ## ... then rename them both.
12 # RUN: llvm-objcopy --rename-section=.bar=.baz %t2.o %t3.o
13 # RUN: llvm-readobj --sections %t3.o | FileCheck %s
14
15 --- !ELF
16 FileHeader:
17 Class: ELFCLASS64
18 Data: ELFDATA2LSB
19 Type: ET_REL
20 Machine: EM_X86_64
21 Sections:
22 - Name: .foo
23 Type: SHT_PROGBITS
24 Flags: [ SHF_ALLOC ]
25 - Name: .bar
26 Type: SHT_PROGBITS
27
28 # CHECK: Name: .baz
29 # CHECK: Name: .baz
0 ## This test verifies that llvm-objcopy can handle renaming a section to and
1 ## from an empty string.
2 # RUN: yaml2obj %s -o %t.o
3
4 # RUN: llvm-objcopy %t.o %t2.o --rename-section=.foo=
5 # RUN: llvm-readobj --sections %t2.o | FileCheck %s --check-prefix=TO
6
7 # RUN: llvm-objcopy %t2.o %t3.o --rename-section==.bar
8 # RUN: llvm-readobj --sections %t3.o | FileCheck %s --check-prefix=FROM
9
10 --- !ELF
11 FileHeader:
12 Class: ELFCLASS64
13 Data: ELFDATA2LSB
14 Type: ET_REL
15 Machine: EM_X86_64
16 Sections:
17 - Name: .foo
18 Type: SHT_PROGBITS
19
20 # TO: Index: 1
21 # TO-NEXT: Name: (0)
22 # FROM: Index: 1
23 # FROM-NEXT: Name: .bar (
0 # REQUIRES: x86-registered-target
1
2 ## It is possible for the section header table and symbol table to share the
3 ## same string table for storing section and symbol names. This test shows that
4 ## under various circumstances, the names are still correct after llvm-objcopy
5 ## has copied such an object file, and that the name table is still shared.
6 ## This test uses the assembler rather than yaml2obj because yaml2obj generates
7 ## separate string tables, whereas the assembler shares them.
8
9 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t.o
10 ## Sanity check that the string tables are shared:
11 # RUN: llvm-readobj --section-headers %t.o \
12 # RUN: | FileCheck %s --check-prefix=VALIDATE --implicit-check-not=.shstrtab
13
14 # VALIDATE: Name: .strtab
15
16 ## Case 1: basic copy.
17 # RUN: llvm-objcopy %t.o %t.basic
18 # RUN: llvm-readobj --section-headers --symbols %t.basic \
19 # RUN: | FileCheck %s --check-prefix=BASIC --implicit-check-not=.shstrtab
20
21 # BASIC: Sections [
22 # BASIC: Name: .foo (
23 # BASIC: Name: .strtab (
24 # BASIC: Symbols [
25 # BASIC: Name: foo (
26
27 ## Case 2: renaming a section.
28 # RUN: llvm-objcopy %t.o %t.rename-section --rename-section .foo=.oof
29 # RUN: llvm-readobj --section-headers --symbols %t.rename-section \
30 # RUN: | FileCheck %s --check-prefix=SECTION-RENAME --implicit-check-not=.shstrtab
31
32 # SECTION-RENAME: Sections [
33 # SECTION-RENAME: Name: .oof (
34 # SECTION-RENAME: Name: .strtab (
35 # SECTION-RENAME: Symbols [
36 # SECTION-RENAME: Name: foo (
37
38 ## Case 3: renaming a symbol.
39 # RUN: llvm-objcopy %t.o %t.redefine-symbol --redefine-sym foo=oof
40 # RUN: llvm-readobj --section-headers --symbols %t.redefine-symbol \
41 # RUN: | FileCheck %s --check-prefix=SYMBOL-RENAME --implicit-check-not=.shstrtab
42
43 # SYMBOL-RENAME: Sections [
44 # SYMBOL-RENAME: Name: .foo (
45 # SYMBOL-RENAME: Name: .strtab (
46 # SYMBOL-RENAME: Symbols [
47 # SYMBOL-RENAME: Name: oof (
48
49 ## Case 4: removing a section.
50 # RUN: llvm-objcopy %t.o %t.remove-section -R .foo
51 # RUN: llvm-readobj --section-headers --symbols %t.remove-section \
52 # RUN: | FileCheck %s --check-prefix=SECTION-REMOVE --implicit-check-not=.shstrtab --implicit-check-not=.foo
53
54 # SECTION-REMOVE: Sections [
55 # SECTION-REMOVE: Name: .strtab (
56 # SECTION-REMOVE: Symbols [
57 # SECTION-REMOVE: Name: foo (
58
59 ## Case 5: removing a symbol.
60 # RUN: llvm-objcopy %t.o %t.remove-symbol -N foo
61 # RUN: llvm-readobj --section-headers --symbols %t.remove-symbol \
62 # RUN: | FileCheck %s --check-prefix=SYMBOL-REMOVE --implicit-check-not=.shstrtab --implicit-check-not=foo
63
64 # SYMBOL-REMOVE: Sections [
65 # SYMBOL-REMOVE: Name: .foo (
66 # SYMBOL-REMOVE: Name: .strtab (
67 # SYMBOL-REMOVE: Symbols [
68
69 ## Case 6: adding a section.
70 # RUN: llvm-objcopy %t.o %t.add-section --add-section .bar=%s
71 # RUN: llvm-readobj --section-headers --symbols %t.add-section \
72 # RUN: | FileCheck %s --check-prefix=SECTION-ADD --implicit-check-not=.shstrtab
73
74 # SECTION-ADD: Sections [
75 # SECTION-ADD: Name: .foo (
76 # SECTION-ADD: Name: .strtab (
77 # SECTION-ADD: Name: .bar (
78 # SECTION-ADD: Symbols [
79 # SECTION-ADD: Name: foo (
80
81 ## Case 7: adding a symbol.
82 # RUN: llvm-objcopy %t.o %t.add-symbol --add-symbol bar=0x1234
83 # RUN: llvm-readobj --section-headers --symbols %t.add-symbol \
84 # RUN: | FileCheck %s --check-prefix=SYMBOL-ADD --implicit-check-not=.shstrtab
85
86 # SYMBOL-ADD: Sections [
87 # SYMBOL-ADD: Name: .foo (
88 # SYMBOL-ADD: Name: .strtab (
89 # SYMBOL-ADD: Symbols [
90 # SYMBOL-ADD: Name: foo (
91 # SYMBOL-ADD: Name: bar (
92
93 ## Case 8: removing all symbols.
94 # RUN: llvm-objcopy %t.o %t.strip-all --strip-all
95 # RUN: llvm-readobj --section-headers --symbols %t.strip-all \
96 # RUN: | FileCheck %s --check-prefix=STRIP-ALL --implicit-check-not=.shstrtab
97
98 # STRIP-ALL: Sections [
99 # STRIP-ALL: Name: .foo (
100 # STRIP-ALL: Name: .strtab (
101 # STRIP-ALL: Symbols [
102 # STRIP-ALL-NEXT: ]
103
104 .section .foo,"a",@progbits
105 foo = 0x4321
11 # RUN: llvm-objcopy --strip-sections %t %t2
22 # RUN: llvm-readobj --file-headers --program-headers %t2 | FileCheck %s
33 # RUN: od -t x1 -j 4096 %t2 | FileCheck %s --check-prefix=DATA
4
5 ## Sanity check the DATA-NOT line by showing that "fe ed fa ce" appears
6 ## if --strip-sections is not specified.
7 # RUN: llvm-objcopy %t %t3
8 # RUN: od -t x1 -j 4096 %t3 | FileCheck %s --check-prefix=VALIDATE
49
510 !ELF
611 FileHeader:
1823 Type: SHT_PROGBITS
1924 Flags: [ ]
2025 Content: "CAFEBABE"
26 - Name: .non_alloc_not_in_segment
27 Type: SHT_PROGBITS
28 Flags: [ ]
29 Content: "FEEDFACE"
2130 ProgramHeaders:
2231 - Type: PT_LOAD
2332 Flags: [ PF_X, PF_R ]
2534 - Section: .text
2635 - Section: .non_alloc_in_segment
2736
28 #DATA: 0010000 de ad be ef ca fe ba be
37 # DATA: 0010000 de ad be ef ca fe ba be
38 # DATA-NOT: fe ed fa ce
2939
30 #CHECK: ElfHeader {
31 #CHECK-NEXT: Ident {
32 #CHECK-NEXT: Magic: (7F 45 4C 46)
33 #CHECK-NEXT: Class: 64-bit (0x2)
34 #CHECK-NEXT: DataEncoding: LittleEndian (0x1)
35 #CHECK-NEXT: FileVersion: 1
36 #CHECK-NEXT: OS/ABI: SystemV (0x0)
37 #CHECK-NEXT: ABIVersion: 0
38 #CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
39 #CHECK-NEXT: }
40 #CHECK-NEXT: Type: Executable (0x2)
41 #CHECK-NEXT: Machine: EM_X86_64 (0x3E)
42 #CHECK-NEXT: Version: 1
43 #CHECK-NEXT: Entry: 0x0
44 #CHECK-NEXT: ProgramHeaderOffset: 0x40
45 #CHECK-NEXT: SectionHeaderOffset: 0x0
46 #CHECK-NEXT: Flags [ (0x0)
47 #CHECK-NEXT: ]
48 #CHECK-NEXT: HeaderSize: 64
49 #CHECK-NEXT: ProgramHeaderEntrySize: 56
50 #CHECK-NEXT: ProgramHeaderCount: 1
51 #CHECK-NEXT: SectionHeaderEntrySize: 0
52 #CHECK-NEXT: SectionHeaderCount: 0
53 #CHECK-NEXT: StringTableSectionIndex: 0
54 #CHECK-NEXT: }
40 # VALIDATE: 0010000 de ad be ef ca fe ba be fe ed fa ce
5541
56 #CHECK: ProgramHeaders [
57 #CHECK-NEXT: ProgramHeader {
58 #CHECK-NEXT: Type: PT_LOAD (0x1)
59 #CHECK-NEXT: Offset: 0x1000
60 #CHECK-NEXT: VirtualAddress: 0x0
61 #CHECK-NEXT: PhysicalAddress: 0x0
62 #CHECK-NEXT: FileSize: 8
63 #CHECK-NEXT: MemSize: 8
64 #CHECK-NEXT: Flags [ (0x5)
65 #CHECK-NEXT: PF_R (0x4)
66 #CHECK-NEXT: PF_X (0x1)
67 #CHECK-NEXT: ]
68 #CHECK-NEXT: Alignment: 4096
69 #CHECK-NEXT: }
70 #CHECK-NEXT:]
42 # CHECK: ElfHeader {
43 # CHECK-NEXT: Ident {
44 # CHECK-NEXT: Magic: (7F 45 4C 46)
45 # CHECK-NEXT: Class: 64-bit (0x2)
46 # CHECK-NEXT: DataEncoding: LittleEndian (0x1)
47 # CHECK-NEXT: FileVersion: 1
48 # CHECK-NEXT: OS/ABI: SystemV (0x0)
49 # CHECK-NEXT: ABIVersion: 0
50 # CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
51 # CHECK-NEXT: }
52 # CHECK-NEXT: Type: Executable (0x2)
53 # CHECK-NEXT: Machine: EM_X86_64 (0x3E)
54 # CHECK-NEXT: Version: 1
55 # CHECK-NEXT: Entry: 0x0
56 # CHECK-NEXT: ProgramHeaderOffset: 0x40
57 # CHECK-NEXT: SectionHeaderOffset: 0x0
58 # CHECK-NEXT: Flags [ (0x0)
59 # CHECK-NEXT: ]
60 # CHECK-NEXT: HeaderSize: 64
61 # CHECK-NEXT: ProgramHeaderEntrySize: 56
62 # CHECK-NEXT: ProgramHeaderCount: 1
63 # CHECK-NEXT: SectionHeaderEntrySize: 0
64 # CHECK-NEXT: SectionHeaderCount: 0
65 # CHECK-NEXT: StringTableSectionIndex: 0
66 # CHECK-NEXT: }
67
68 # CHECK: ProgramHeaders [
69 # CHECK-NEXT: ProgramHeader {
70 # CHECK-NEXT: Type: PT_LOAD (0x1)
71 # CHECK-NEXT: Offset: 0x1000
72 # CHECK-NEXT: VirtualAddress: 0x0
73 # CHECK-NEXT: PhysicalAddress: 0x0
74 # CHECK-NEXT: FileSize: 8
75 # CHECK-NEXT: MemSize: 8
76 # CHECK-NEXT: Flags [ (0x5)
77 # CHECK-NEXT: PF_R (0x4)
78 # CHECK-NEXT: PF_X (0x1)
79 # CHECK-NEXT: ]
80 # CHECK-NEXT: Alignment: 4096
81 # CHECK-NEXT: }
82 # CHECK-NEXT: ]
0 ## This test shows that when symbol/section names are optimized in the string
1 ## table to share the same entry, due to tail merging, llvm-objcopy operations
2 ## function correctly without corrupting the names of unchanged sections/symbols.
3
4 # RUN: yaml2obj %s -o %t.o
5 ## Sanity check that the strings have been pooled.
6 # RUN: llvm-readobj %t.o --string-dump .strtab --string-dump .shstrtab \
7 # RUN: | FileCheck %s --check-prefix=VALIDATE --implicit-check-not=bar --implicit-check-not=.blag
8
9 # VALIDATE: String dump of section '.strtab':
10 # VALIDATE: bazfoobar
11 # VALIDATE: String dump of section '.shstrtab':
12 # VALIDATE: .blam.blah.blag
13
14 ## Case 1: Basic copy.
15 # RUN: llvm-objcopy %t.o %t.copy
16 # RUN: llvm-readobj --section-headers --symbols %t.copy | FileCheck %s --check-prefix=COPY
17
18 # COPY: Sections [
19 # COPY: Name: .blam.blah.blag (
20 # COPY: Name: .blah.blag (
21 # COPY: Name: .blag (
22 # COPY: Symbols [
23 # COPY: Name: bar (
24 # COPY: Name: foobar (
25 # COPY: Name: bazfoobar (
26
27 ## Case 2: Rename section.
28 # RUN: llvm-objcopy %t.o %t.rename-section --rename-section .blah.blag=.blob.blab
29 # RUN: llvm-readobj --section-headers %t.rename-section \
30 # RUN: | FileCheck %s --check-prefix=RENAME-SECTION
31
32 # RENAME-SECTION: Sections [
33 # RENAME-SECTION: Name: .blam.blah.blag (
34 # RENAME-SECTION: Name: .blob.blab (
35 # RENAME-SECTION: Name: .blag (
36
37 ## Case 3: Rename symbol.
38 # RUN: llvm-objcopy %t.o %t.rename-symbol --redefine-sym foobar=raboof
39 # RUN: llvm-readobj --symbols %t.rename-symbol \
40 # RUN: | FileCheck %s --check-prefix=RENAME-SYMBOL
41
42 # RENAME-SYMBOL: Symbols [
43 # RENAME-SYMBOL: Name: bar (
44 # RENAME-SYMBOL: Name: raboof (
45 # RENAME-SYMBOL: Name: bazfoobar (
46
47 ## Case 4: Remove section.
48 # RUN: llvm-objcopy %t.o %t.remove-section -R .blah.blag
49 # RUN: llvm-readobj --section-headers %t.remove-section \
50 # RUN: | FileCheck %s --check-prefix=REMOVE-SECTION --implicit-check-not .blah.blag
51
52 # REMOVE-SECTION: Sections [
53 # REMOVE-SECTION: Name: .blam.blah.blag (
54 # REMOVE-SECTION: Name: .blag (
55
56 ## Case 5: Remove symbol.
57 # RUN: llvm-objcopy %t.o %t.remove-symbol -N foobar
58 # RUN: llvm-readobj --symbols %t.remove-symbol \
59 # RUN: | FileCheck %s --check-prefix=REMOVE-SYMBOL --implicit-check-not foobar
60
61 # REMOVE-SYMBOL: Symbols [
62 # REMOVE-SYMBOL: Name: bar (
63 # REMOVE-SYMBOL: Name: bazfoobar (
64
65 --- !ELF
66 FileHeader:
67 Class: ELFCLASS64
68 Data: ELFDATA2LSB
69 Type: ET_EXEC
70 Machine: EM_X86_64
71 Sections:
72 - Name: .blam.blah.blag
73 Type: SHT_PROGBITS
74 - Name: .blah.blag
75 Type: SHT_PROGBITS
76 - Name: .blag
77 Type: SHT_PROGBITS
78 Symbols:
79 - Name: bar
80 - Name: foobar
81 - Name: bazfoobar