reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
  163
  164
  165
  166
  167
  168
  169
  170
  171
  172
  173
  174
  175
  176
  177
  178
  179
  180
  181
  182
  183
  184
  185
  186
  187
  188
  189
  190
  191
  192
  193
  194
  195
  196
  197
  198
  199
  200
  201
  202
  203
  204
  205
  206
  207
  208
  209
  210
# RUN: yaml2obj %s > %t.in.o
#
# RUN: llvm-objdump -section-headers %t.in.o | FileCheck %s --check-prefixes=SECTIONS-PRE
# RUN: llvm-objdump -t %t.in.o | FileCheck %s --check-prefixes=SYMBOLS-PRE
#
# RUN: llvm-objcopy -R .bss %t.in.o %t.remove-bss.o
# RUN: llvm-objdump -section-headers %t.remove-bss.o | FileCheck %s --check-prefix=SECTIONS-REMOVE-BSS
# RUN: llvm-objdump -t %t.remove-bss.o | FileCheck %s --check-prefix=SYMBOLS-REMOVE-BSS
#
# RUN: llvm-objcopy --remove-section .bss %t.in.o %t.cmp.o
# RUN: cmp %t.remove-bss.o %t.cmp.o
#
# RUN: llvm-objcopy -R .text %t.in.o %t.remove-text.o
# RUN: llvm-objdump -section-headers %t.remove-text.o | FileCheck %s --check-prefix=SECTIONS-REMOVE-TEXT
# RUN: llvm-objdump -t %t.remove-text.o | FileCheck %s --check-prefix=SYMBOLS-REMOVE-TEXT
#
# RUN: not llvm-objcopy -R .comdat %t.in.o %t.remove-comdat.o 2>&1 | FileCheck %s --check-prefix=ERROR-RELOC
#
# RUN: llvm-objcopy -R .text -R .comdat %t.in.o %t.remove-text-comdat.o
# RUN: llvm-objdump -section-headers %t.remove-text-comdat.o | FileCheck %s --check-prefix=SECTIONS-REMOVE-TEXT-COMDAT
# RUN: llvm-objdump -t %t.remove-text-comdat.o | FileCheck %s --check-prefix=SYMBOLS-REMOVE-TEXT-COMDAT
#
#
# SECTIONS-PRE: Sections:
# SECTIONS-PRE-NEXT: Idx Name
# SECTIONS-PRE-NEXT: 0 .text
# SECTIONS-PRE-NEXT: 1 .bss
# SECTIONS-PRE-NEXT: 2 .comdat
# SECTIONS-PRE-NEXT: 3 .associative
# SECTIONS-PRE-EMPTY:
#
# SYMBOLS-PRE: SYMBOL TABLE:
# SYMBOLS-PRE-NEXT: {{.*}}(sec -1){{.*}} @feat.00
# SYMBOLS-PRE-NEXT: {{.*}}(sec 1){{.*}} .text
# SYMBOLS-PRE-NEXT: AUX scnlen {{.*}} assoc 1 comdat 0
# SYMBOLS-PRE-NEXT: {{.*}}(sec 2){{.*}} .bss
# SYMBOLS-PRE-NEXT: AUX scnlen {{.*}} assoc 2 comdat 0
# SYMBOLS-PRE-NEXT: {{.*}}(sec 4){{.*}} .associative
# SYMBOLS-PRE-NEXT: AUX scnlen {{.*}} assoc 3 comdat 5
# SYMBOLS-PRE-NEXT: {{.*}}(sec 3){{.*}} .comdat
# SYMBOLS-PRE-NEXT: AUX scnlen {{.*}} assoc 3 comdat 2
# SYMBOLS-PRE-NEXT: {{.*}}(sec 3){{.*}} foo
# SYMBOLS-PRE-NEXT: {{.*}}(sec 1){{.*}} main
# SYMBOLS-PRE-EMPTY:
#
#
# Removing the .bss section removes one symbol and its aux symbol,
# and updates the section indices in symbols pointing to later
# symbols, including the aux section defintitions.
#
# Testing that the absolute symbol @feat.00 survives the section number
# mangling.
#
# SECTIONS-REMOVE-BSS: Sections:
# SECTIONS-REMOVE-BSS-NEXT: Idx Name
# SECTIONS-REMOVE-BSS-NEXT: 0 .text
# SECTIONS-REMOVE-BSS-NEXT: 1 .comdat
# SECTIONS-REMOVE-BSS-NEXT: 2 .associative
# SECTIONS-REMOVE-BSS-EMPTY:
#
# SYMBOLS-REMOVE-BSS: SYMBOL TABLE:
# SYMBOLS-REMOVE-BSS-NEXT: {{.*}}(sec -1){{.*}} @feat.00
# SYMBOLS-REMOVE-BSS-NEXT: {{.*}}(sec 1){{.*}} .text
# SYMBOLS-REMOVE-BSS-NEXT: AUX scnlen {{.*}} assoc 1 comdat 0
# SYMBOLS-REMOVE-BSS-NEXT: {{.*}}(sec 3){{.*}} .associative
# SYMBOLS-REMOVE-BSS-NEXT: AUX scnlen {{.*}} assoc 2 comdat 5
# SYMBOLS-REMOVE-BSS-NEXT: {{.*}}(sec 2){{.*}} .comdat
# SYMBOLS-REMOVE-BSS-NEXT: AUX scnlen {{.*}} assoc 2 comdat 2
# SYMBOLS-REMOVE-BSS-NEXT: {{.*}}(sec 2){{.*}} foo
# SYMBOLS-REMOVE-BSS-NEXT: {{.*}}(sec 1){{.*}} main
# SYMBOLS-REMOVE-BSS-EMPTY:
#
#
# Removing the .text section is ok and just removes the external symbol
# referring to it.
#
# SECTIONS-REMOVE-TEXT: Sections:
# SECTIONS-REMOVE-TEXT-NEXT: Idx Name
# SECTIONS-REMOVE-TEXT-NEXT: 0 .bss
# SECTIONS-REMOVE-TEXT-NEXT: 1 .comdat
# SECTIONS-REMOVE-TEXT-NEXT: 2 .associative
# SECTIONS-REMOVE-TEXT-EMPTY:
#
# SYMBOLS-REMOVE-TEXT: SYMBOL TABLE:
# SYMBOLS-REMOVE-TEXT-NEXT: {{.*}}(sec -1){{.*}} @feat.00
# SYMBOLS-REMOVE-TEXT-NEXT: {{.*}}(sec 1){{.*}} .bss
# SYMBOLS-REMOVE-TEXT-NEXT: AUX scnlen {{.*}} assoc 1 comdat 0
# SYMBOLS-REMOVE-TEXT-NEXT: {{.*}}(sec 3){{.*}} .associative
# SYMBOLS-REMOVE-TEXT-NEXT: AUX scnlen {{.*}} assoc 2 comdat 5
# SYMBOLS-REMOVE-TEXT-NEXT: {{.*}}(sec 2){{.*}} .comdat
# SYMBOLS-REMOVE-TEXT-NEXT: AUX scnlen {{.*}} assoc 2 comdat 2
# SYMBOLS-REMOVE-TEXT-NEXT: {{.*}}(sec 2){{.*}} foo
# SYMBOLS-REMOVE-TEXT-EMPTY:
#
#
# Removing the .comdat section fails, since the .text section has relocations
# against it.
#
# ERROR-RELOC: relocation target 'foo' ({{.*}}) not found
#
#
# Removing the .comdat section and .text (with a relocation against .comdat)
# works, as it also removes the .associative section transitively.
#
# SECTIONS-REMOVE-TEXT-COMDAT: Sections:
# SECTIONS-REMOVE-TEXT-COMDAT-NEXT: Idx Name
# SECTIONS-REMOVE-TEXT-COMDAT-NEXT: 0 .bss
# SECTIONS-REMOVE-TEXT-COMDAT-EMPTY:
#
# SYMBOLS-REMOVE-TEXT-COMDAT: SYMBOL TABLE:
# SYMBOLS-REMOVE-TEXT-COMDAT-NEXT: {{.*}}(sec -1){{.*}} @feat.00
# SYMBOLS-REMOVE-TEXT-COMDAT-NEXT: {{.*}}(sec 1){{.*}} .bss
# SYMBOLS-REMOVE-TEXT-COMDAT-NEXT: AUX scnlen {{.*}} assoc 1 comdat 0
# SYMBOLS-REMOVE-TEXT-COMDAT-EMPTY:

--- !COFF
header:          
  Machine:         IMAGE_FILE_MACHINE_AMD64
  Characteristics: [  ]
sections:        
  - Name:            .text
    Characteristics: [  ]
    Alignment:       4
    SectionData:     488B0500000000C3
    Relocations:     
      - VirtualAddress:  3
        SymbolName:      foo
        Type:            IMAGE_REL_AMD64_REL32
  - Name:            .bss
    Characteristics: [  ]
    Alignment:       4
    SectionData:     ''
  - Name:            .comdat
    Characteristics: [ IMAGE_SCN_LNK_COMDAT ]
    Alignment:       1
    SectionData:     '2A000000'
  - Name:            .associative
    Characteristics: [ IMAGE_SCN_LNK_COMDAT ]
    Alignment:       1
    SectionData:     '0000000000000000'
symbols:         
  - Name:            '@feat.00'
    Value:           0
    SectionNumber:   -1
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_STATIC
  - Name:            .text
    Value:           0
    SectionNumber:   1
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_STATIC
    SectionDefinition: 
      Length:          8
      NumberOfRelocations: 1
      NumberOfLinenumbers: 0
      CheckSum:        583624169
      Number:          1
  - Name:            .bss
    Value:           0
    SectionNumber:   2
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_STATIC
    SectionDefinition: 
      Length:          0
      NumberOfRelocations: 0
      NumberOfLinenumbers: 0
      CheckSum:        0
      Number:          2
  - Name:            .associative
    Value:           0
    SectionNumber:   4
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_STATIC
    SectionDefinition: 
      Length:          8
      NumberOfRelocations: 0
      NumberOfLinenumbers: 0
      CheckSum:        0
      Number:          3
      Selection:       IMAGE_COMDAT_SELECT_ASSOCIATIVE
  - Name:            .comdat
    Value:           0
    SectionNumber:   3
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_STATIC
    SectionDefinition: 
      Length:          4
      NumberOfRelocations: 0
      NumberOfLinenumbers: 0
      CheckSum:        3482275674
      Number:          3
      Selection:       IMAGE_COMDAT_SELECT_ANY
  - Name:            foo
    Value:           0
    SectionNumber:   3
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
  - Name:            main
    Value:           0
    SectionNumber:   1
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
...