1 ## This test shows that when symbol/section names are optimized in the string
2 ## table to share the same entry, due to tail merging, llvm-objcopy operations
3 ## function correctly without corrupting the names of unchanged sections/symbols.
5 # RUN: yaml2obj %s -o %t.o
6 ## Validate that the strings have been pooled.
7 # RUN: llvm-readobj %t.o --string-dump .strtab --string-dump .shstrtab \
8 # RUN: | FileCheck %s --check-prefix=VALIDATE --implicit-check-not='] bar' --implicit-check-not=.blag
10 # VALIDATE: String dump of section '.strtab':
11 # VALIDATE-NEXT: [ 1] bazfoobar
13 # VALIDATE-NEXT: String dump of section '.shstrtab':
14 # VALIDATE-NEXT: [ 1] .blam.blah.blag
16 ## Case 1: Basic copy.
17 # RUN: llvm-objcopy %t.o %t.copy
18 # RUN: llvm-readobj --section-headers --symbols %t.copy | FileCheck %s --check-prefix=COPY
21 # COPY: Name: .blam.blah.blag (
22 # COPY: Name: .blah.blag (
26 # COPY: Name: foobar (
27 # COPY: Name: bazfoobar (
29 ## Case 2: Rename section.
30 # RUN: llvm-objcopy %t.o %t.rename-section --rename-section .blah.blag=.blob.blab
31 # RUN: llvm-readobj --section-headers %t.rename-section \
32 # RUN: | FileCheck %s --check-prefix=RENAME-SECTION
34 # RENAME-SECTION: Sections [
35 # RENAME-SECTION: Name: .blam.blah.blag (
36 # RENAME-SECTION: Name: .blob.blab (
37 # RENAME-SECTION: Name: .blag (
39 ## Case 3: Rename symbol.
40 # RUN: llvm-objcopy %t.o %t.rename-symbol --redefine-sym foobar=raboof
41 # RUN: llvm-readobj --symbols %t.rename-symbol \
42 # RUN: | FileCheck %s --check-prefix=RENAME-SYMBOL
44 # RENAME-SYMBOL: Symbols [
45 # RENAME-SYMBOL: Name: bar (
46 # RENAME-SYMBOL: Name: raboof (
47 # RENAME-SYMBOL: Name: bazfoobar (
49 ## Case 4: Remove section.
50 # RUN: llvm-objcopy %t.o %t.remove-section -R .blah.blag
51 # RUN: llvm-readobj --section-headers %t.remove-section \
52 # RUN: | FileCheck %s --check-prefix=REMOVE-SECTION --implicit-check-not .blah.blag
54 # REMOVE-SECTION: Sections [
55 # REMOVE-SECTION: Name: .blam.blah.blag (
56 # REMOVE-SECTION: Name: .blag (
58 ## Case 5: Remove symbol.
59 # RUN: llvm-objcopy %t.o %t.remove-symbol -N foobar
60 # RUN: llvm-readobj --symbols %t.remove-symbol \
61 # RUN: | FileCheck %s --check-prefix=REMOVE-SYMBOL --implicit-check-not='Name: foobar'
63 # REMOVE-SYMBOL: Symbols [
64 # REMOVE-SYMBOL: Name: bar (
65 # REMOVE-SYMBOL: Name: bazfoobar (
74 - Name: .blam.blah.blag