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
# REQUIRES: x86
# RUN: yaml2obj %s -o %t.obj
# RUN: llvm-mc %S/Inputs/pdb-global-gc.s -triple x86_64-windows-msvc -filetype=obj -o %t2.obj
# RUN: lld-link %t.obj %t2.obj -debug -entry:main \
# RUN:          -nodefaultlib -opt:ref -out:%t.exe -pdb:%t.pdb -verbose
# RUN: llvm-pdbutil dump -symbols -globals %t.pdb | FileCheck %s

# This tests the case where an __imp_ chunk is discarded by linker GC. The debug
# info may refer to the __imp_ symbol still.

# Compile this code with MSVC to regenerate the test case:
#   extern char __declspec(dllimport) __wc_mb_cur;
#   int discarded() { return __wc_mb_cur; }
#   int main() { return g2; }

# CHECK:                             Global Symbols
# CHECK-NEXT: ============================================================
# CHECK-NEXT:   Records
# CHECK-NEXT:       20 | S_GDATA32 [size = 28] `__wc_mb_cur`
# CHECK-NEXT:            type = 0x0070 (char), addr = 0000:0000

# CHECK:                                Symbols
# CHECK:      ============================================================
# CHECK-NEXT:   Mod 0000 | `{{.*}}pdb-global-gc.yaml.tmp.obj`:
# CHECK-NEXT:   Mod 0001 | `{{.*}}pdb-global-gc.yaml.tmp2.obj`:
# CHECK-NEXT:   Error loading module stream 1.  The specified stream could not be loaded. Module stream not present
# CHECK-NEXT:   Mod 0002 | `* Linker *`:

--- !COFF
header:
  Machine:         IMAGE_FILE_MACHINE_AMD64
  Characteristics: [  ]
sections:
  - Name:            '.debug$S'
    Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
    Alignment:       1
    Subsections:
      - !Symbols
        Records:
          - Kind:            S_GDATA32
            DataSym:
              Type:            112
              DisplayName:     __wc_mb_cur
      - !StringTable
        Strings:
    Relocations:
      - VirtualAddress:  20
        SymbolName:      __wc_mb_cur
        Type:            IMAGE_REL_AMD64_SECREL
      - VirtualAddress:  24
        SymbolName:      __wc_mb_cur
        Type:            IMAGE_REL_AMD64_SECTION
  - Name:            '.text$mn'
    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
    Alignment:       16
    SectionData:     0FBE0500000000C3
    Relocations:
      - VirtualAddress:  3
        SymbolName:      __wc_mb_cur
        Type:            IMAGE_REL_AMD64_REL32
  - Name:            '.text$mn'
    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
    Alignment:       16
    SectionData:     B82A000000C3
symbols:
  - Name:            '.debug$S'
    Value:           0
    SectionNumber:   1
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_STATIC
    SectionDefinition:
      Length:          240
      NumberOfRelocations: 2
      NumberOfLinenumbers: 0
      CheckSum:        0
      Number:          0
  - Name:            '.text$mn'
    Value:           0
    SectionNumber:   2
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_STATIC
    SectionDefinition:
      Length:          11
      NumberOfRelocations: 1
      NumberOfLinenumbers: 0
      CheckSum:        2906070869
      Number:          0
      Selection:       IMAGE_COMDAT_SELECT_NODUPLICATES
  - Name:            '.text$mn'
    Value:           0
    SectionNumber:   3
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_STATIC
    SectionDefinition:
      Length:          6
      NumberOfRelocations: 0
      NumberOfLinenumbers: 0
      CheckSum:        2139436471
      Number:          0
      Selection:       IMAGE_COMDAT_SELECT_NODUPLICATES
  - Name:            discarded
    Value:           0
    SectionNumber:   2
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_FUNCTION
    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
  - Name:            main
    Value:           0
    SectionNumber:   3
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_FUNCTION
    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
  - Name:            __wc_mb_cur
    Value:           0
    SectionNumber:   0
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
...