1## Verify that llvm-readobj can dump files containing stabs symbols,
2## particularly symbols of type N_OSO which have repurposed the n_sect field
3## to store a non-section-index value.
4
5# RUN: yaml2obj %s -o %t
6# RUN: llvm-readobj --syms %t | FileCheck %s
7
8# CHECK:      Symbols [
9# CHECK-NEXT:   Symbol {
10# CHECK-NEXT:     Name: /Volumes/Sandbox/ (2)
11# CHECK-NEXT:     Type: SymDebugTable (0x64)
12# CHECK-NEXT:     Section:  (0x0)
13# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)
14# CHECK-NEXT:     Flags [ (0x0)
15# CHECK-NEXT:     ]
16# CHECK-NEXT:     Value: 0x0
17# CHECK-NEXT:   }
18# CHECK-NEXT:   Symbol {
19# CHECK-NEXT:     Name: /Volumes/Sandbox/test.o (20)
20# CHECK-NEXT:     Type: SymDebugTable (0x66)
21# CHECK-NEXT:     Section:  (0x3)
22# CHECK-NEXT:     RefType: ReferenceFlagUndefinedLazy (0x1)
23# CHECK-NEXT:     Flags [ (0x0)
24# CHECK-NEXT:     ]
25# CHECK-NEXT:     Value: 0x5F72D5E2
26# CHECK-NEXT:   }
27# CHECK-NEXT:   Symbol {
28# CHECK-NEXT:     Name:  (1)
29# CHECK-NEXT:     Type: SymDebugTable (0x2E)
30# CHECK-NEXT:     Section:  (0x1)
31# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)
32# CHECK-NEXT:     Flags [ (0x0)
33# CHECK-NEXT:     ]
34# CHECK-NEXT:     Value: 0x100000FA0
35# CHECK-NEXT:   }
36# CHECK-NEXT:   Symbol {
37# CHECK-NEXT:     Name: _foo (44)
38# CHECK-NEXT:     Type: SymDebugTable (0x24)
39# CHECK-NEXT:     Section:  (0x1)
40# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)
41# CHECK-NEXT:     Flags [ (0x0)
42# CHECK-NEXT:     ]
43# CHECK-NEXT:     Value: 0x100000FA0
44# CHECK-NEXT:   }
45# CHECK-NEXT:   Symbol {
46# CHECK-NEXT:     Name:  (1)
47# CHECK-NEXT:     Type: SymDebugTable (0x4E)
48# CHECK-NEXT:     Section:  (0x1)
49# CHECK-NEXT:     RefType: UndefinedNonLazy (0x0)
50# CHECK-NEXT:     Flags [ (0x0)
51# CHECK-NEXT:     ]
52# CHECK-NEXT:     Value: 0xF
53# CHECK-NEXT:   }
54# CHECK-NEXT: ]
55
56--- !mach-o
57FileHeader:
58  magic:           0xFEEDFACF
59  cputype:         0x01000007
60  cpusubtype:      0x00000003
61  filetype:        0x00000002
62  ncmds:           2
63  sizeofcmds:      744
64  flags:           0x00200085
65  reserved:        0x00000000
66LoadCommands:
67  - cmd:             LC_SEGMENT_64
68    cmdsize:         232
69    segname:         __TEXT
70    vmaddr:          4294967296
71    vmsize:          4096
72    fileoff:         0
73    filesize:        4096
74    maxprot:         5
75    initprot:        5
76    nsects:          1
77    flags:           0
78    Sections:
79      - sectname:        __text
80        segname:         __TEXT
81        addr:            0x00000000
82        size:            0
83        offset:          0x00000000
84        align:           4
85        reloff:          0x00000000
86        nreloc:          0
87        flags:           0x80000400
88        reserved1:       0x00000000
89        reserved2:       0x00000000
90        reserved3:       0x00000000
91  - cmd:             LC_SYMTAB
92    cmdsize:         24
93    symoff:          4152
94    nsyms:           5
95    stroff:          4328
96    strsize:         49
97LinkEditData:
98  NameList:
99    - n_strx:          2
100      n_type:          0x64 ## N_SO
101      n_sect:          0
102      n_desc:          0
103      n_value:         0
104    - n_strx:          20
105      n_type:          0x66 ## N_OSO
106      n_sect:          3
107      n_desc:          1
108      n_value:         1601361378
109    - n_strx:          1
110      n_type:          0x2E ## N_BNSYM
111      n_sect:          1
112      n_desc:          0
113      n_value:         4294971296
114    - n_strx:          44
115      n_type:          0x24 ## N_FUN
116      n_sect:          1
117      n_desc:          0
118      n_value:         4294971296
119    - n_strx:          1
120      n_type:          0x4E ## N_ENSYM
121      n_sect:          1
122      n_desc:          0
123      n_value:         15
124  StringTable:
125    - ' '
126    - '/Volumes/Sandbox/'
127    - '/Volumes/Sandbox/test.o'
128    - _foo
129...
130