16
16
#include " llvm/ADT/SmallVector.h"
17
17
#include " llvm/ADT/StringSet.h"
18
18
#include " llvm/BinaryFormat/MachO.h"
19
- #include " llvm/DebugInfo/DWARF/DWARFContext.h"
20
- #include " llvm/DebugInfo/DWARF/DWARFDebugLine.h"
21
-
22
- #include < chrono>
23
19
24
20
#define DEBUG_TYPE " orc"
25
21
@@ -101,6 +97,8 @@ class MachODebugObjectSynthesizer : public MachODebugObjectSynthesizerBase {
101
97
<< " \n " ;
102
98
});
103
99
100
+ auto &SDOSec = G.createSection (SynthDebugSectionName, MemProt::Read);
101
+
104
102
for (auto &Sec : G.sections ()) {
105
103
if (Sec.blocks ().empty ())
106
104
continue ;
@@ -116,10 +114,6 @@ class MachODebugObjectSynthesizer : public MachODebugObjectSynthesizerBase {
116
114
NonDebugSections.push_back ({&Sec, nullptr });
117
115
}
118
116
119
- // Bail out early if no debug sections.
120
- if (DebugSections.empty ())
121
- return Error::success ();
122
-
123
117
// Write MachO header and debug section load commands.
124
118
Builder.Header .filetype = MachO::MH_OBJECT;
125
119
switch (G.getTargetTriple ().getArch ()) {
@@ -137,51 +131,15 @@ class MachODebugObjectSynthesizer : public MachODebugObjectSynthesizerBase {
137
131
138
132
Seg = &Builder.addSegment (" " );
139
133
140
- StringMap<std::unique_ptr<MemoryBuffer>> DebugSectionMap;
141
- StringRef DebugLineSectionData;
142
134
for (auto &DSec : DebugSections) {
143
135
auto [SegName, SecName] = DSec.GraphSec ->getName ().split (' ,' );
144
136
DSec.BuilderSec = &Seg->addSection (SecName, SegName);
145
137
146
138
SectionRange SR (*DSec.GraphSec );
147
139
DSec.BuilderSec ->Content .Size = SR.getSize ();
148
- if (!SR.empty ()) {
140
+ if (!SR.empty ())
149
141
DSec.BuilderSec ->align = Log2_64 (SR.getFirstBlock ()->getAlignment ());
150
- StringRef SectionData (SR.getFirstBlock ()->getContent ().data (),
151
- SR.getFirstBlock ()->getSize ());
152
- DebugSectionMap[SecName] =
153
- MemoryBuffer::getMemBuffer (SectionData, G.getName (), false );
154
- if (SecName == " __debug_line" )
155
- DebugLineSectionData = SectionData;
156
- }
157
- }
158
-
159
- if (DebugLineSectionData.empty ())
160
- return make_error<StringError>(G.getName () +
161
- " has debug info but no line table" ,
162
- inconvertibleErrorCode ());
163
-
164
- // Add Stabs.
165
- auto DWARFCtx = DWARFContext::create (DebugSectionMap, G.getPointerSize (),
166
- G.getEndianness ());
167
- DWARFDataExtractor DebugLineData (
168
- DebugLineSectionData, G.getEndianness () == support::endianness::little,
169
- G.getPointerSize ());
170
- uint64_t Offset = 0 ;
171
- DWARFDebugLine::LineTable LineTable;
172
- if (auto Err = LineTable.parse (DebugLineData, &Offset, *DWARFCtx, nullptr ,
173
- consumeError))
174
- return Err;
175
-
176
- Builder.addSymbol (" " , MachO::N_SO, 0 , 0 , 0 );
177
- for (auto &FN : LineTable.Prologue .FileNames ) {
178
- if (auto Name = dwarf::toString (FN.Name ))
179
- Builder.addSymbol (*Name, MachO::N_SO, 0 , 0 , 0 );
180
142
}
181
- auto TimeStamp = std::chrono::duration_cast<std::chrono::seconds>(
182
- std::chrono::system_clock::now ().time_since_epoch ())
183
- .count ();
184
- Builder.addSymbol (" " , MachO::N_OSO, 3 , 1 , TimeStamp);
185
143
186
144
for (auto &NDSP : NonDebugSections) {
187
145
auto [SegName, SecName] = NDSP.GraphSec ->getName ().split (' ,' );
@@ -206,12 +164,8 @@ class MachODebugObjectSynthesizer : public MachODebugObjectSynthesizerBase {
206
164
}
207
165
}
208
166
209
- Builder.addSymbol (" " , MachO::N_SO, 1 , 0 , 0 );
210
-
211
- // Lay out the debug object, create a section and block for it.
212
167
size_t DebugObjectSize = Builder.layout ();
213
168
214
- auto &SDOSec = G.createSection (SynthDebugSectionName, MemProt::Read);
215
169
MachOContainerBlock = &G.createMutableContentBlock (
216
170
SDOSec, G.allocateBuffer (DebugObjectSize), orc::ExecutorAddr (), 8 , 0 );
217
171
0 commit comments