llvm/llvm/test/tools/yaml2obj/ELF/shstrtab.yaml

## A user should be able to specify any arbitrary string table as the section
## header string table, including the symbol string table. This test covers
## various cases to do with this.

## Case 1: custom name specified for string table.
# RUN: yaml2obj --docnum=1 %s -o %t1 -DSHSTRTAB=.strings
# RUN: llvm-readelf -S -p .strings %t1 | FileCheck %s --check-prefix=CASE1

# CASE1:      There are 5 section headers
# CASE1-EMPTY:
# CASE1-NEXT: Section Headers:
# CASE1-NEXT:   [Nr] Name         Type   Address          Off      Size   ES Flg  Lk Inf Al
# CASE1-NEXT:   [ 0]              NULL
# CASE1-NEXT:   [ 1] .foo{{ }}
# CASE1-NEXT:   [ 2] .bar{{ }}
# CASE1-NEXT:   [ 3] .strtab{{ }}
# CASE1-NEXT:   [ 4] .strings     STRTAB 0000000000000000 [[#%x,]] 00001c 00       0   0  1

# CASE1:      String dump of section '.strings':
# CASE1-NEXT: [     1] .strings{{$}}
# CASE1-NEXT: [     a] .bar{{$}}
# CASE1-NEXT: [     f] .foo{{$}}
# CASE1-NEXT: [    14] .strtab{{$}}
# CASE1-EMPTY:

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: [[SHSTRTAB=<none>]]
Sections:
  - Name: .foo
    Type: SHT_PROGBITS
  - Name: [[OTHER=.bar]]
    Type: SHT_PROGBITS

## Case 2: reuse symbol string table.
# RUN: yaml2obj --docnum=2 %s -o %t2 -DSHSTRTAB=.strtab
# RUN: llvm-readelf -S -s -p .strtab %t2 | FileCheck %s --check-prefix=CASE2

# CASE2: There are 5 section headers
# CASE2-EMPTY:
# CASE2-NEXT: Section Headers:
# CASE2-NEXT:   [Nr] Name         Type   Address          Off      Size   ES Flg Lk Inf Al
# CASE2-NEXT:   [ 0]              NULL
# CASE2-NEXT:   [ 1] .foo{{ }}
# CASE2-NEXT:   [ 2] .bar{{ }}
# CASE2-NEXT:   [ 3] .symtab{{ }}
# CASE2-NEXT:   [ 4] .strtab      STRTAB 0000000000000000 [[#%x,]] 000023 00      0   0  1

# CASE2:      Symbol table '.symtab' contains 3 entries:
# CASE2-NEXT:    Num: {{.*}} Ndx Name
# CASE2-NEXT:      0: {{.*}} UND {{$}}
# CASE2-NEXT:      1: {{.*}}     baz{{$}}
# CASE2-NEXT:      2: {{.*}}     bob{{$}}

# CASE2:      String dump of section '.strtab':
# CASE2-NEXT: [     1] baz{{$}}
# CASE2-NEXT: [     5] .bar{{$}}
# CASE2-NEXT: [     a] .foo{{$}}
# CASE2-NEXT: [     f] bob{{$}}
# CASE2-NEXT: [    13] .strtab{{$}}
# CASE2-NEXT: [    1b] .symtab{{$}}
# CASE2-EMPTY:

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: [[SHSTRTAB]]
Sections:
  - Name: .foo
    Type: SHT_PROGBITS
  - Name: .bar
    Type: SHT_PROGBITS
Symbols:
  - Name: baz
  - Name: bob

## Case 3: reuse dynamic string table.
# RUN: yaml2obj --docnum=3 %s -o %t3 -DSHSTRTAB=.dynstr
# RUN: llvm-readelf -S --dyn-syms -p .dynstr %t3 | FileCheck %s --check-prefix=CASE3

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: [[SHSTRTAB]]
Sections:
  - Name: .foo
    Type: SHT_PROGBITS
  - Name: .bar
    Type: SHT_PROGBITS
DynamicSymbols:
  - Name: baz
  - Name: bob

# CASE3:      There are 6 section headers
# CASE3-EMPTY:
# CASE3-NEXT: Section Headers:
# CASE3-NEXT:   [Nr] Name         Type   Address          Off      Size   ES Flg Lk Inf Al
# CASE3-NEXT:   [ 0]              NULL
# CASE3-NEXT:   [ 1] .foo{{ }}
# CASE3-NEXT:   [ 2] .bar{{ }}
# CASE3-NEXT:   [ 3] .dynsym{{ }}
# CASE3-NEXT:   [ 4] .dynstr      STRTAB 0000000000000048 [[#%x,]] 00002b 00   A  0   0  1
# CASE3-NEXT:   [ 5] .strtab{{ }}

# CASE3:      Symbol table '.dynsym' contains 3 entries:
# CASE3-NEXT:    Num: {{.*}} Ndx Name
# CASE3-NEXT:      0: {{.*}} UND {{$}}
# CASE3-NEXT:      1: {{.*}}     baz{{$}}
# CASE3-NEXT:      2: {{.*}}     bob{{$}}

# CASE3:      String dump of section '.dynstr':
# CASE3-NEXT: [     1] baz{{$}}
# CASE3-NEXT: [     5] .dynstr{{$}}
# CASE3-NEXT: [     d] .bar{{$}}
# CASE3-NEXT: [    12] .foo{{$}}
# CASE3-NEXT: [    17] .dynsym{{$}}
# CASE3-NEXT: [    1f] bob{{$}}
# CASE3-NEXT: [    23] .strtab{{$}}
# CASE3-EMPTY:

## Case 4: shstrtab specified to be otherwise ungenerated non-strtab implicit
##         section.
# RUN: yaml2obj --docnum=1 %s -o %t4 -DSHSTRTAB=.symtab
# RUN: llvm-readelf -S -p .symtab %t4 | FileCheck %s --check-prefix=CASE4

# CASE4:      There are 5 section headers
# CASE4-EMPTY:
# CASE4-NEXT: Section Headers:
# CASE4-NEXT:   [Nr] Name         Type   Address          Off      Size   ES Flg Lk Inf Al
# CASE4-NEXT:   [ 0]              NULL
# CASE4-NEXT:   [ 1] .foo{{ }}
# CASE4-NEXT:   [ 2] .bar{{ }}
# CASE4-NEXT:   [ 3] .strtab{{ }}
# CASE4-NEXT:   [ 4] .symtab      STRTAB 0000000000000000 [[#%x,]] 00001b 00      0   0  1

# CASE4:      String dump of section '.symtab':
# CASE4-NEXT: [     1] .bar{{$}}
# CASE4-NEXT: [     6] .foo{{$}}
# CASE4-NEXT: [     b] .strtab{{$}}
# CASE4-NEXT: [    13] .symtab{{$}}

## Case 5: shstrtab specified to be otherwise ungenerated .dynstr section. In
##         this case, the SHF_ALLOC flag will be set.
# RUN: yaml2obj --docnum=1 %s -o %t5 -DSHSTRTAB=.dynstr
# RUN: llvm-readelf -S -p .dynstr %t5 | FileCheck %s --check-prefix=CASE5

# CASE5:      There are 5 section headers
# CASE5-EMPTY:
# CASE5-NEXT: Section Headers:
# CASE5-NEXT:   [Nr] Name         Type   Address          Off      Size   ES Flg Lk Inf Al
# CASE5-NEXT:   [ 0]              NULL
# CASE5-NEXT:   [ 1] .foo{{ }}
# CASE5-NEXT:   [ 2] .bar{{ }}
# CASE5-NEXT:   [ 3] .strtab{{ }}
# CASE5-NEXT:   [ 4] .dynstr      STRTAB 0000000000000001 [[#%x,]] 00001b 00   A  0   0  1

# CASE5:      String dump of section '.dynstr':
# CASE5-NEXT: [     1] .dynstr{{$}}
# CASE5-NEXT: [     9] .bar{{$}}
# CASE5-NEXT: [     e] .foo{{$}}
# CASE5-NEXT: [    13] .strtab{{$}}

## Case 6: shstrtab specified to be otherwise ungenerated .debug_str section. In
##         this case, the sh_entsize will be set to 1.
# RUN: yaml2obj --docnum=1 %s -o %t6 -DSHSTRTAB=.debug_str
# RUN: llvm-readelf -S -p .debug_str %t6 | FileCheck %s --check-prefix=CASE6

# CASE6:      There are 5 section headers
# CASE6-EMPTY:
# CASE6-NEXT: Section Headers:
# CASE6-NEXT:   [Nr] Name         Type   Address          Off      Size   ES Flg Lk Inf Al
# CASE6-NEXT:   [ 0]              NULL
# CASE6-NEXT:   [ 1] .foo{{ }}
# CASE6-NEXT:   [ 2] .bar{{ }}
# CASE6-NEXT:   [ 3] .strtab{{ }}
# CASE6-NEXT:   [ 4] .debug_str   STRTAB 0000000000000000 [[#%x,]] 00001e 01      0   0  1

# CASE6:      String dump of section '.debug_str':
# CASE6-NEXT: [     1] .debug_str{{$}}
# CASE6-NEXT: [     c] .bar{{$}}
# CASE6-NEXT: [    11] .foo{{$}}
# CASE6-NEXT: [    16] .strtab{{$}}

## Case 7: shstrtab specified to be the .symtab section, when there are symbols.
## This triggers an error (since the symbols cannot be represented in the
## section as section names).
# RUN: not yaml2obj --docnum=2 %s -o %t7 -DSHSTRTAB=.symtab 2>&1 | FileCheck %s --check-prefix=ERR1

# ERR1: error: cannot use '.symtab' as the section header name table when there are symbols

## Case 8: shstrtab specified to be the .dynsym section, when there are dynamic
## symbols. This triggers an error (since the symbols cannot be represented in
## the section as section names).
# RUN: not yaml2obj --docnum=3 %s -o %t8 -DSHSTRTAB=.dynsym 2>&1 | FileCheck %s --check-prefix=ERR2

# ERR2: error: cannot use '.dynsym' as the section header name table when there are dynamic symbols

## Case 9: shstrtab specified to be the .debug_str section, when there are DWARF
## debug strings. This triggers an error.
# RUN: not yaml2obj --docnum=4 %s -o %t9 2>&1 | FileCheck %s --check-prefix=ERR3

# ERR3: error: cannot use '.debug_str' as the section header name table when it is needed for DWARF output

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: .debug_str
DWARF:
  debug_str:
    - a

## Case 10: can explicitly specifiy ".shstrtab" as shstrtab. Output will be the
##         same as if it wasn't sepcified at all.
# RUN: yaml2obj --docnum=1 %s -o %t10 -DSHSTRTAB=.shstrtab
# RUN: llvm-readelf -S -p .shstrtab %t10 | FileCheck %s --check-prefix=CASE10
# RUN: yaml2obj --docnum=1 %s -o %t10.default
# RUN: cmp %t10 %t10.default

# CASE10:      There are 5 section headers
# CASE10-EMPTY:
# CASE10-NEXT: Section Headers:
# CASE10-NEXT:   [Nr] Name         Type   Address          Off      Size   ES Flg  Lk Inf Al
# CASE10-NEXT:   [ 0]              NULL
# CASE10-NEXT:   [ 1] .foo{{ }}
# CASE10-NEXT:   [ 2] .bar{{ }}
# CASE10-NEXT:   [ 3] .strtab{{ }}
# CASE10-NEXT:   [ 4] .shstrtab    STRTAB 0000000000000000 [[#%x,]] 00001d 00       0   0  1

# CASE10:      String dump of section '.shstrtab':
# CASE10-NEXT: [     1] .bar{{$}}
# CASE10-NEXT: [     6] .foo{{$}}
# CASE10-NEXT: [     b] .shstrtab{{$}}
# CASE10-NEXT: [    15] .strtab{{$}}
# CASE10-EMPTY:

## Case 11: can specify custom shstrtab properties.
## FIXME: when the section is listed explicitly, the sh_addralign value is 0 if
##        not overwritten, which is inconsistent with when the section is not
##        specified at all.
# RUN: yaml2obj --docnum=5 %s -o %t11 -DENTSIZE=2
# RUN: llvm-readelf -S -p .strings %t11 | FileCheck %s --check-prefix=CASE11

# CASE11:      There are 5 section headers
# CASE11-EMPTY:
# CASE11-NEXT: Section Headers:
# CASE11-NEXT:   [Nr] Name         Type   Address          Off      Size   ES Flg  Lk Inf Al
# CASE11-NEXT:   [ 0]              NULL
# CASE11-NEXT:   [ 1] .foo{{ }}
# CASE11-NEXT:   [ 2] .strings     STRTAB 0000000000000000 [[#%x,]] 00001c 02       0   0  0
# CASE11-NEXT:   [ 3] .bar{{ }}
# CASE11-NEXT:   [ 4] .strtab{{ }}

# CASE11:      String dump of section '.strings':
# CASE11-NEXT: [     1] .strings{{$}}
# CASE11-NEXT: [     a] .bar{{$}}
# CASE11-NEXT: [     f] .foo{{$}}
# CASE11-NEXT: [    14] .strtab{{$}}
# CASE11-EMPTY:

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: .strings
Sections:
  - Name:         .foo
    Type:         SHT_PROGBITS
  - Name:         .strings
    Type:         [[TYPE=SHT_STRTAB]]
    EntSize:      [[ENTSIZE=<none>]]
    Size:         [[SIZE=<none>]]
    Content:      [[CONTENT=<none>]]
  - Name:         .bar
    Type:         SHT_PROGBITS

## Case 12: shstrtab does not have SHT_STRTAB type. Default properties will be
##          derived from the specified section type.
# RUN: yaml2obj --docnum=5 %s -o %t12 -DTYPE=SHT_RELA
# RUN: llvm-readelf -S %t12 | FileCheck %s --check-prefix=CASE12

# CASE12:      There are 5 section headers
# CASE12-EMPTY:
# CASE12-NEXT: Section Headers:
# CASE12-NEXT:   [Nr] Name         Type Address          Off      Size   ES Flg  Lk Inf Al
# CASE12-NEXT:   [ 0]              NULL
# CASE12-NEXT:   [ 1] .foo{{ }}
# CASE12-NEXT:   [ 2] .strings     RELA 0000000000000000 [[#%x,]] 00001c 18       0   0  0
# CASE12-NEXT:   [ 3] .bar{{ }}
# CASE12-NEXT:   [ 4] .strtab{{ }}

## Case 13: shstrtab has specified Content. The specified content overrides the
##          implicitly generated content.
# RUN: yaml2obj --docnum=5 %s -o %t13 -DCONTENT="00616263646566676800696a6b6c006d6e6f70007172737475767700787a7b7c00"
# RUN: llvm-readelf -S %t13 | FileCheck %s --check-prefix=CASE13

# CASE13:      There are 5 section headers
# CASE13-EMPTY:
# CASE13-NEXT: Section Headers:
# CASE13-NEXT:   [Nr] Name         Type   Address          Off      Size   ES Flg  Lk Inf Al
# CASE13-NEXT:   [ 0]              NULL
# CASE13-NEXT:   [ 1] mnop{{ }}
# CASE13-NEXT:   [ 2] abcdefgh     STRTAB 0000000000000000 [[#%x,]] 000021 00       0   0  0
# CASE13-NEXT:   [ 3] ijkl{{ }}
# CASE13-NEXT:   [ 4] qrstuvw{{ }}

## Case 14: shstrtab has specified Size. The section will be filled with zeros
##          to the requested size.
# RUN: yaml2obj --docnum=5 %s -o %t14 -DSIZE=32
# RUN: llvm-readelf -S -p 2 %t14 | FileCheck %s --check-prefix=CASE14

# CASE14:      There are 5 section headers
# CASE14-EMPTY:
# CASE14-NEXT: Section Headers:
# CASE14-NEXT:   [Nr] Name Type     Address          Off      Size   ES Flg  Lk Inf Al
# CASE14-NEXT:   [ 0]      NULL
# CASE14-NEXT:   [ 1]      PROGBITS
# CASE14-NEXT:   [ 2]      STRTAB   0000000000000000 [[#%x,]] 000020 00       0   0  0
# CASE14-NEXT:   [ 3]      PROGBITS
# CASE14-NEXT:   [ 4]      STRTAB

# CASE14:      String dump of section '':
# CASE14-EMPTY:

## Case 15: custom shstrtab and no section header table. The section header
##          names shouldn't appear anywhere in the output file.
# RUN: yaml2obj --docnum=6 %s -o %t15
# RUN: FileCheck %s --input-file=%t15 \
# RUN:   --implicit-check-not=.strings --implicit-check-not=.foo \
# RUN:   --implicit-check-not=.bar

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: .strings
Sections:
  - Name:      .foo
    Type:      SHT_PROGBITS
  - Name:      .bar
    Type:      SHT_PROGBITS
  - Type:      SectionHeaderTable
    NoHeaders: true

## Case 16: custom shstrtab can be reordered in the section header table.
# RUN: yaml2obj --docnum=7 %s -o %t16
# RUN: llvm-readelf -S %t16 | FileCheck %s --check-prefix=CASE16

# CASE16:      There are 5 section headers
# CASE16-EMPTY:
# CASE16-NEXT: Section Headers:
# CASE16-NEXT:   [Nr] Name         Type   Address          Off      Size   ES Flg  Lk Inf Al
# CASE16-NEXT:   [ 0]              NULL
# CASE16-NEXT:   [ 1] .foo{{ }}
# CASE16-NEXT:   [ 2] .strings     STRTAB 0000000000000000 [[#%x,]] 00001c 00       0   0  1
# CASE16-NEXT:   [ 3] .bar{{ }}
# CASE16-NEXT:   [ 4] .strtab{{ }}

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: .strings
Sections:
  - Name:      .foo
    Type:      SHT_PROGBITS
  - Name:      .bar
    Type:      SHT_PROGBITS
  - Type:      SectionHeaderTable
    Sections:
      - Name: .foo
      - Name: .strings
      - Name: .bar
      - Name: .strtab

## Case 17: custom shstrtab section header can be excluded.
# RUN: yaml2obj --docnum=8 %s -o %t17
# RUN: llvm-readelf -h -S %t17 | FileCheck %s --check-prefix=CASE17

# CASE17:      Section header string table index: 0
# CASE17:      There are 4 section headers
# CASE17-EMPTY:
# CASE17-NEXT: Section Headers:
# CASE17-NEXT:   [Nr] Name         Type
# CASE17-NEXT:   [ 0] <no-strings> NULL
# CASE17-NEXT:   [ 1] <no-strings> PROGBITS
# CASE17-NEXT:   [ 2] <no-strings> PROGBITS
# CASE17-NEXT:   [ 3] <no-strings> STRTAB

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: .strings
Sections:
  - Name:      .foo
    Type:      SHT_PROGBITS
  - Name:      .bar
    Type:      SHT_PROGBITS
  - Type:      SectionHeaderTable
    Sections:
      - Name: .foo
      - Name: .bar
      - Name: .strtab
    Excluded:
      - Name: .strings

## Case 18: section name for excluded section does not appear in custom
##          shstrtab.
# RUN: yaml2obj --docnum=9 %s -o %t18
# RUN: llvm-readelf -S -p .strings %t18 | FileCheck %s --check-prefix=CASE18

# CASE18:      There are 4 section headers
# CASE18-EMPTY:
# CASE18-NEXT: Section Headers:
# CASE18-NEXT:   [Nr] Name         Type   Address          Off      Size   ES Flg  Lk Inf Al
# CASE18-NEXT:   [ 0]              NULL
# CASE18-NEXT:   [ 1] .foo{{ }}
# CASE18-NEXT:   [ 2] .strings     STRTAB 0000000000000000 [[#%x,]] 000017 00       0   0  1
# CASE18-NEXT:   [ 3] .strtab{{ }}

# CASE18:      String dump of section '.strings':
# CASE18-NEXT: [     1] .strings
# CASE18-NEXT: [     a] .foo
# CASE18-NEXT: [     f] .strtab
# CASE18-EMPTY:

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
  SectionHeaderStringTable: .strings
Sections:
  - Name:      .foo
    Type:      SHT_PROGBITS
  - Name:      .bar
    Type:      SHT_PROGBITS
  - Type:      SectionHeaderTable
    Sections:
      - Name: .foo
      - Name: .strings
      - Name: .strtab
    Excluded:
      - Name: .bar

## Case 19: custom shstrtab can have a uniqued name.
# RUN: yaml2obj --docnum=1 %s -o %t19 '-DSHSTRTAB=.strings (1)' '-DOTHER=.strings (0)'
# RUN: llvm-readelf -S -p 4 %t19 | FileCheck %s --check-prefix=CASE19

# CASE19:      There are 5 section headers
# CASE19-EMPTY:
# CASE19-NEXT: Section Headers:
# CASE19-NEXT:   [Nr] Name         Type     Address          Off      Size   ES Flg  Lk Inf Al
# CASE19-NEXT:   [ 0]              NULL
# CASE19-NEXT:   [ 1] .foo{{ }}
# CASE19-NEXT:   [ 2] .strings     PROGBITS
# CASE19-NEXT:   [ 3] .strtab{{ }}
# CASE19-NEXT:   [ 4] .strings     STRTAB   0000000000000000 [[#%x,]] 000017 00       0   0  1

# CASE19:      String dump of section '.strings':
# CASE19-NEXT: [     1] .strings{{$}}
# CASE19-NEXT: [     a] .foo{{$}}
# CASE19-NEXT: [     f] .strtab{{$}}
# CASE19-EMPTY:

## Case 20: custom shstrtab named ".strtab" with uniquifying ID.
# RUN: yaml2obj --docnum=2 %s -o %t20 '-DSHSTRTAB=.strtab (1)'
# RUN: llvm-readelf -S -s -p 4 -p 5 %t20 | FileCheck %s --check-prefix=CASE20

# CASE20: There are 6 section headers
# CASE20-EMPTY:
# CASE20-NEXT: Section Headers:
# CASE20-NEXT:   [Nr] Name         Type   Address          Off      Size   ES Flg Lk Inf Al
# CASE20-NEXT:   [ 0]              NULL
# CASE20-NEXT:   [ 1] .foo{{ }}
# CASE20-NEXT:   [ 2] .bar{{ }}
# CASE20-NEXT:   [ 3] .symtab{{ }}
# CASE20-NEXT:   [ 4] .strtab      STRTAB [[#%x,]]         [[#%x,]] 000009 00      0   0  1
# CASE20-NEXT:   [ 5] .strtab      STRTAB 0000000000000000 [[#%x,]] 00001b 00      0   0  1

# CASE20:      Symbol table '.symtab' contains 3 entries:
# CASE20-NEXT:    Num: {{.*}} Ndx Name
# CASE20-NEXT:      0: {{.*}} UND {{$}}
# CASE20-NEXT:      1: {{.*}}     baz{{$}}
# CASE20-NEXT:      2: {{.*}}     bob{{$}}

# CASE20:      String dump of section '.strtab':
# CASE20-NEXT: [     1] baz
# CASE20-NEXT: [     5] bob
# CASE20-EMPTY:

# CASE20:      String dump of section '.strtab':
# CASE20-NEXT: [     1] .bar{{$}}
# CASE20-NEXT: [     6] .foo{{$}}
# CASE20-NEXT: [     b] .strtab{{$}}
# CASE20-NEXT: [    13] .symtab{{$}}
# CASE20-EMPTY:

## Case 21: custom shstrtab named ".dynstr" with uniquifying ID.
# RUN: yaml2obj --docnum=3 %s -o %t21 '-DSHSTRTAB=.dynstr (1)'
# RUN: llvm-readelf -S --dyn-syms -p 4 -p 6 %t21 | FileCheck %s --check-prefix=CASE21

# CASE21: There are 7 section headers
# CASE21-EMPTY:
# CASE21-NEXT: Section Headers:
# CASE21-NEXT:   [Nr] Name         Type   Address          Off      Size   ES Flg Lk Inf Al
# CASE21-NEXT:   [ 0]              NULL
# CASE21-NEXT:   [ 1] .foo{{ }}
# CASE21-NEXT:   [ 2] .bar{{ }}
# CASE21-NEXT:   [ 3] .dynsym{{ }}
# CASE21-NEXT:   [ 4] .dynstr      STRTAB [[#%x,]]         [[#%x,]] 000009 00   A  0   0  1
# CASE21-NEXT:   [ 5] .strtab{{ }}
# CASE21-NEXT:   [ 6] .dynstr      STRTAB 0000000000000000 [[#%x,]] 000023 00      0   0  1

# CASE21:      Symbol table '.dynsym' contains 3 entries:
# CASE21-NEXT:    Num: {{.*}} Ndx Name
# CASE21-NEXT:      0: {{.*}} UND {{$}}
# CASE21-NEXT:      1: {{.*}}     baz{{$}}
# CASE21-NEXT:      2: {{.*}}     bob{{$}}

# CASE21:      String dump of section '.dynstr':
# CASE21-NEXT: [     1] baz
# CASE21-NEXT: [     5] bob
# CASE21-EMPTY:

# CASE21:      String dump of section '.dynstr':
# CASE21-NEXT: [     1] .dynstr{{$}}
# CASE21-NEXT: [     9] .bar{{$}}
# CASE21-NEXT: [     e] .foo{{$}}
# CASE21-NEXT: [    13] .dynsym{{$}}
# CASE21-NEXT: [    1b] .strtab{{$}}
# CASE21-EMPTY: