]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/lldb/source/Symbol/ObjectFile.cpp
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / lldb / source / Symbol / ObjectFile.cpp
1 //===-- ObjectFile.cpp ------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "lldb/lldb-private.h"
11 #include "lldb/lldb-private-log.h"
12 #include "lldb/Core/DataBuffer.h"
13 #include "lldb/Core/DataBufferHeap.h"
14 #include "lldb/Core/Log.h"
15 #include "lldb/Core/Module.h"
16 #include "lldb/Core/ModuleSpec.h"
17 #include "lldb/Core/PluginManager.h"
18 #include "lldb/Core/RegularExpression.h"
19 #include "lldb/Core/Section.h"
20 #include "lldb/Core/Timer.h"
21 #include "lldb/Symbol/ObjectFile.h"
22 #include "lldb/Symbol/ObjectContainer.h"
23 #include "lldb/Symbol/SymbolFile.h"
24 #include "lldb/Target/Process.h"
25 #include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
26
27 using namespace lldb;
28 using namespace lldb_private;
29
30 ObjectFileSP
31 ObjectFile::FindPlugin (const lldb::ModuleSP &module_sp,
32                         const FileSpec* file,
33                         lldb::offset_t file_offset,
34                         lldb::offset_t file_size,
35                         DataBufferSP &data_sp,
36                         lldb::offset_t &data_offset)
37 {
38     ObjectFileSP object_file_sp;
39
40     if (module_sp)
41     {
42         Timer scoped_timer (__PRETTY_FUNCTION__,
43                             "ObjectFile::FindPlugin (module = %s, file = %p, file_offset = 0x%8.8" PRIx64 ", file_size = 0x%8.8" PRIx64 ")",
44                             module_sp->GetFileSpec().GetPath().c_str(),
45                             file, (uint64_t) file_offset, (uint64_t) file_size);
46         if (file)
47         {
48             FileSpec archive_file;
49             ObjectContainerCreateInstance create_object_container_callback;
50
51             const bool file_exists = file->Exists();
52             if (!data_sp)
53             {
54                 // We have an object name which most likely means we have
55                 // a .o file in a static archive (.a file). Try and see if
56                 // we have a cached archive first without reading any data
57                 // first
58                 if (file_exists && module_sp->GetObjectName())
59                 {
60                     for (uint32_t idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != NULL; ++idx)
61                     {
62                         std::unique_ptr<ObjectContainer> object_container_ap(create_object_container_callback(module_sp, data_sp, data_offset, file, file_offset, file_size));
63                         
64                         if (object_container_ap.get())
65                             object_file_sp = object_container_ap->GetObjectFile(file);
66                         
67                         if (object_file_sp.get())
68                             return object_file_sp;
69                     }
70                 }
71                 // Ok, we didn't find any containers that have a named object, now
72                 // lets read the first 512 bytes from the file so the object file
73                 // and object container plug-ins can use these bytes to see if they
74                 // can parse this file.
75                 if (file_size > 0)
76                 {
77                     data_sp = file->ReadFileContents(file_offset, std::min<size_t>(512, file_size));
78                     data_offset = 0;
79                 }
80             }
81
82             if (!data_sp || data_sp->GetByteSize() == 0)
83             {
84                 // Check for archive file with format "/path/to/archive.a(object.o)"
85                 char path_with_object[PATH_MAX*2];
86                 module_sp->GetFileSpec().GetPath(path_with_object, sizeof(path_with_object));
87
88                 ConstString archive_object;
89                 const bool must_exist = true;
90                 if (ObjectFile::SplitArchivePathWithObject (path_with_object, archive_file, archive_object, must_exist))
91                 {
92                     file_size = archive_file.GetByteSize();
93                     if (file_size > 0)
94                     {
95                         file = &archive_file;
96                         module_sp->SetFileSpecAndObjectName (archive_file, archive_object);
97                         // Check if this is a object container by iterating through all object
98                         // container plugin instances and then trying to get an object file
99                         // from the container plugins since we had a name. Also, don't read
100                         // ANY data in case there is data cached in the container plug-ins
101                         // (like BSD archives caching the contained objects within an file).
102                         for (uint32_t idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != NULL; ++idx)
103                         {
104                             std::unique_ptr<ObjectContainer> object_container_ap(create_object_container_callback(module_sp, data_sp, data_offset, file, file_offset, file_size));
105                             
106                             if (object_container_ap.get())
107                                 object_file_sp = object_container_ap->GetObjectFile(file);
108                             
109                             if (object_file_sp.get())
110                                 return object_file_sp;
111                         }
112                         // We failed to find any cached object files in the container
113                         // plug-ins, so lets read the first 512 bytes and try again below...
114                         data_sp = archive_file.ReadFileContents(file_offset, 512);
115                     }
116                 }
117             }
118
119             if (data_sp && data_sp->GetByteSize() > 0)
120             {
121                 // Check if this is a normal object file by iterating through
122                 // all object file plugin instances.
123                 ObjectFileCreateInstance create_object_file_callback;
124                 for (uint32_t idx = 0; (create_object_file_callback = PluginManager::GetObjectFileCreateCallbackAtIndex(idx)) != NULL; ++idx)
125                 {
126                     object_file_sp.reset (create_object_file_callback(module_sp, data_sp, data_offset, file, file_offset, file_size));
127                     if (object_file_sp.get())
128                         return object_file_sp;
129                 }
130
131                 // Check if this is a object container by iterating through
132                 // all object container plugin instances and then trying to get
133                 // an object file from the container.
134                 for (uint32_t idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != NULL; ++idx)
135                 {
136                     std::unique_ptr<ObjectContainer> object_container_ap(create_object_container_callback(module_sp, data_sp, data_offset, file, file_offset, file_size));
137
138                     if (object_container_ap.get())
139                         object_file_sp = object_container_ap->GetObjectFile(file);
140
141                     if (object_file_sp.get())
142                         return object_file_sp;
143                 }
144             }
145         }
146     }
147     // We didn't find it, so clear our shared pointer in case it
148     // contains anything and return an empty shared pointer
149     object_file_sp.reset();
150     return object_file_sp;
151 }
152
153 ObjectFileSP
154 ObjectFile::FindPlugin (const lldb::ModuleSP &module_sp, 
155                         const ProcessSP &process_sp,
156                         lldb::addr_t header_addr,
157                         DataBufferSP &data_sp)
158 {
159     ObjectFileSP object_file_sp;
160     
161     if (module_sp)
162     {
163         Timer scoped_timer (__PRETTY_FUNCTION__,
164                             "ObjectFile::FindPlugin (module = %s, process = %p, header_addr = 0x%" PRIx64 ")",
165                             module_sp->GetFileSpec().GetPath().c_str(),
166                             process_sp.get(), header_addr);
167         uint32_t idx;
168         
169         // Check if this is a normal object file by iterating through
170         // all object file plugin instances.
171         ObjectFileCreateMemoryInstance create_callback;
172         for (idx = 0; (create_callback = PluginManager::GetObjectFileCreateMemoryCallbackAtIndex(idx)) != NULL; ++idx)
173         {
174             object_file_sp.reset (create_callback(module_sp, data_sp, process_sp, header_addr));
175             if (object_file_sp.get())
176                 return object_file_sp;
177         }
178         
179     }
180     // We didn't find it, so clear our shared pointer in case it
181     // contains anything and return an empty shared pointer
182     object_file_sp.reset();
183     return object_file_sp;
184 }
185
186 size_t
187 ObjectFile::GetModuleSpecifications (const FileSpec &file,
188                                      lldb::offset_t file_offset,
189                                      lldb::offset_t file_size,
190                                      ModuleSpecList &specs)
191 {
192     DataBufferSP data_sp (file.ReadFileContents(file_offset, 512));
193     if (data_sp)
194     {
195         if (file_size == 0)
196         {
197             const lldb::offset_t actual_file_size = file.GetByteSize();
198             if (actual_file_size > file_offset)
199                 file_size = actual_file_size - file_offset;
200         }
201         return ObjectFile::GetModuleSpecifications (file,       // file spec
202                                                     data_sp,    // data bytes
203                                                     0,          // data offset
204                                                     file_offset,// file offset
205                                                     file_size,  // file length
206                                                     specs);
207     }
208     return 0;
209 }
210
211 size_t
212 ObjectFile::GetModuleSpecifications (const lldb_private::FileSpec& file,
213                                      lldb::DataBufferSP& data_sp,
214                                      lldb::offset_t data_offset,
215                                      lldb::offset_t file_offset,
216                                      lldb::offset_t file_size,
217                                      lldb_private::ModuleSpecList &specs)
218 {
219     const size_t initial_count = specs.GetSize();
220     ObjectFileGetModuleSpecifications callback;
221     uint32_t i;
222     // Try the ObjectFile plug-ins
223     for (i = 0; (callback = PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex(i)) != NULL; ++i)
224     {
225         if (callback (file, data_sp, data_offset, file_offset, file_size, specs) > 0)
226             return specs.GetSize() - initial_count;
227     }
228
229     // Try the ObjectContainer plug-ins
230     for (i = 0; (callback = PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex(i)) != NULL; ++i)
231     {
232         if (callback (file, data_sp, data_offset, file_offset, file_size, specs) > 0)
233             return specs.GetSize() - initial_count;
234     }
235     return 0;
236 }
237
238 ObjectFile::ObjectFile (const lldb::ModuleSP &module_sp,
239                         const FileSpec *file_spec_ptr,
240                         lldb::offset_t file_offset,
241                         lldb::offset_t length,
242                         lldb::DataBufferSP& data_sp,
243                         lldb::offset_t data_offset
244 ) :
245     ModuleChild (module_sp),
246     m_file (),  // This file could be different from the original module's file
247     m_type (eTypeInvalid),
248     m_strata (eStrataInvalid),
249     m_file_offset (file_offset),
250     m_length (length),
251     m_data (),
252     m_unwind_table (*this),
253     m_process_wp(),
254     m_memory_addr (LLDB_INVALID_ADDRESS),
255     m_sections_ap(),
256     m_symtab_ap ()
257 {
258     if (file_spec_ptr)
259         m_file = *file_spec_ptr;
260     if (data_sp)
261         m_data.SetData (data_sp, data_offset, length);
262     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
263     if (log)
264     {
265         if (m_file)
266         {
267             log->Printf ("%p ObjectFile::ObjectFile() module = %p (%s), file = %s, file_offset = 0x%8.8" PRIx64 ", size = %" PRIu64,
268                          this,
269                          module_sp.get(),
270                          module_sp->GetSpecificationDescription().c_str(),
271                          m_file.GetPath().c_str(),
272                          m_file_offset,
273                          m_length);
274         }
275         else
276         {
277             log->Printf ("%p ObjectFile::ObjectFile() module = %p (%s), file = <NULL>, file_offset = 0x%8.8" PRIx64 ", size = %" PRIu64,
278                          this,
279                          module_sp.get(),
280                          module_sp->GetSpecificationDescription().c_str(),
281                          m_file_offset,
282                          m_length);
283         }
284     }
285 }
286
287
288 ObjectFile::ObjectFile (const lldb::ModuleSP &module_sp, 
289                         const ProcessSP &process_sp,
290                         lldb::addr_t header_addr, 
291                         DataBufferSP& header_data_sp) :
292     ModuleChild (module_sp),
293     m_file (),
294     m_type (eTypeInvalid),
295     m_strata (eStrataInvalid),
296     m_file_offset (0),
297     m_length (0),
298     m_data (),
299     m_unwind_table (*this),
300     m_process_wp (process_sp),
301     m_memory_addr (header_addr),
302     m_sections_ap(),
303     m_symtab_ap ()
304 {
305     if (header_data_sp)
306         m_data.SetData (header_data_sp, 0, header_data_sp->GetByteSize());
307     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
308     if (log)
309     {
310         log->Printf ("%p ObjectFile::ObjectFile() module = %p (%s), process = %p, header_addr = 0x%" PRIx64,
311                      this,
312                      module_sp.get(),
313                      module_sp->GetSpecificationDescription().c_str(),
314                      process_sp.get(),
315                      m_memory_addr);
316     }
317 }
318
319
320 ObjectFile::~ObjectFile()
321 {
322     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
323     if (log)
324         log->Printf ("%p ObjectFile::~ObjectFile ()\n", this);
325 }
326
327 bool 
328 ObjectFile::SetModulesArchitecture (const ArchSpec &new_arch)
329 {
330     ModuleSP module_sp (GetModule());
331     if (module_sp)
332         return module_sp->SetArchitecture (new_arch);
333     return false;
334 }
335
336 AddressClass
337 ObjectFile::GetAddressClass (addr_t file_addr)
338 {
339     Symtab *symtab = GetSymtab();
340     if (symtab)
341     {
342         Symbol *symbol = symtab->FindSymbolContainingFileAddress(file_addr);
343         if (symbol)
344         {
345             if (symbol->ValueIsAddress())
346             {
347                 const SectionSP section_sp (symbol->GetAddress().GetSection());
348                 if (section_sp)
349                 {
350                     const SectionType section_type = section_sp->GetType();
351                     switch (section_type)
352                     {
353                     case eSectionTypeInvalid:               return eAddressClassUnknown;
354                     case eSectionTypeCode:                  return eAddressClassCode;
355                     case eSectionTypeContainer:             return eAddressClassUnknown;
356                     case eSectionTypeData:
357                     case eSectionTypeDataCString:
358                     case eSectionTypeDataCStringPointers:
359                     case eSectionTypeDataSymbolAddress:
360                     case eSectionTypeData4:
361                     case eSectionTypeData8:
362                     case eSectionTypeData16:
363                     case eSectionTypeDataPointers:
364                     case eSectionTypeZeroFill:
365                     case eSectionTypeDataObjCMessageRefs:
366                     case eSectionTypeDataObjCCFStrings:
367                         return eAddressClassData;
368                     case eSectionTypeDebug:
369                     case eSectionTypeDWARFDebugAbbrev:
370                     case eSectionTypeDWARFDebugAranges:
371                     case eSectionTypeDWARFDebugFrame:
372                     case eSectionTypeDWARFDebugInfo:
373                     case eSectionTypeDWARFDebugLine:
374                     case eSectionTypeDWARFDebugLoc:
375                     case eSectionTypeDWARFDebugMacInfo:
376                     case eSectionTypeDWARFDebugPubNames:
377                     case eSectionTypeDWARFDebugPubTypes:
378                     case eSectionTypeDWARFDebugRanges:
379                     case eSectionTypeDWARFDebugStr:
380                     case eSectionTypeDWARFAppleNames:
381                     case eSectionTypeDWARFAppleTypes:
382                     case eSectionTypeDWARFAppleNamespaces:
383                     case eSectionTypeDWARFAppleObjC:
384                         return eAddressClassDebug;
385                     case eSectionTypeEHFrame:               return eAddressClassRuntime;
386                     case eSectionTypeELFSymbolTable:
387                     case eSectionTypeELFDynamicSymbols:
388                     case eSectionTypeELFRelocationEntries:
389                     case eSectionTypeELFDynamicLinkInfo:
390                     case eSectionTypeOther:                 return eAddressClassUnknown;
391                     }
392                 }
393             }
394             
395             const SymbolType symbol_type = symbol->GetType();
396             switch (symbol_type)
397             {
398             case eSymbolTypeAny:            return eAddressClassUnknown;
399             case eSymbolTypeAbsolute:       return eAddressClassUnknown;
400             case eSymbolTypeCode:           return eAddressClassCode;
401             case eSymbolTypeTrampoline:     return eAddressClassCode;
402             case eSymbolTypeResolver:       return eAddressClassCode;
403             case eSymbolTypeData:           return eAddressClassData;
404             case eSymbolTypeRuntime:        return eAddressClassRuntime;
405             case eSymbolTypeException:      return eAddressClassRuntime;
406             case eSymbolTypeSourceFile:     return eAddressClassDebug;
407             case eSymbolTypeHeaderFile:     return eAddressClassDebug;
408             case eSymbolTypeObjectFile:     return eAddressClassDebug;
409             case eSymbolTypeCommonBlock:    return eAddressClassDebug;
410             case eSymbolTypeBlock:          return eAddressClassDebug;
411             case eSymbolTypeLocal:          return eAddressClassData;
412             case eSymbolTypeParam:          return eAddressClassData;
413             case eSymbolTypeVariable:       return eAddressClassData;
414             case eSymbolTypeVariableType:   return eAddressClassDebug;
415             case eSymbolTypeLineEntry:      return eAddressClassDebug;
416             case eSymbolTypeLineHeader:     return eAddressClassDebug;
417             case eSymbolTypeScopeBegin:     return eAddressClassDebug;
418             case eSymbolTypeScopeEnd:       return eAddressClassDebug;
419             case eSymbolTypeAdditional:     return eAddressClassUnknown;
420             case eSymbolTypeCompiler:       return eAddressClassDebug;
421             case eSymbolTypeInstrumentation:return eAddressClassDebug;
422             case eSymbolTypeUndefined:      return eAddressClassUnknown;
423             case eSymbolTypeObjCClass:      return eAddressClassRuntime;
424             case eSymbolTypeObjCMetaClass:  return eAddressClassRuntime;
425             case eSymbolTypeObjCIVar:       return eAddressClassRuntime;
426             case eSymbolTypeReExported:     return eAddressClassRuntime;
427             }
428         }
429     }
430     return eAddressClassUnknown;
431 }
432
433 DataBufferSP
434 ObjectFile::ReadMemory (const ProcessSP &process_sp, lldb::addr_t addr, size_t byte_size)
435 {
436     DataBufferSP data_sp;
437     if (process_sp)
438     {
439         std::unique_ptr<DataBufferHeap> data_ap (new DataBufferHeap (byte_size, 0));
440         Error error;
441         const size_t bytes_read = process_sp->ReadMemory (addr, 
442                                                           data_ap->GetBytes(), 
443                                                           data_ap->GetByteSize(), 
444                                                           error);
445         if (bytes_read == byte_size)
446             data_sp.reset (data_ap.release());
447     }
448     return data_sp;
449 }
450
451 size_t
452 ObjectFile::GetData (off_t offset, size_t length, DataExtractor &data) const
453 {
454     // The entire file has already been mmap'ed into m_data, so just copy from there
455     // as the back mmap buffer will be shared with shared pointers.
456     return data.SetData (m_data, offset, length);
457 }
458
459 size_t
460 ObjectFile::CopyData (off_t offset, size_t length, void *dst) const
461 {
462     // The entire file has already been mmap'ed into m_data, so just copy from there
463     // Note that the data remains in target byte order.
464     return m_data.CopyData (offset, length, dst);
465 }
466
467
468 size_t
469 ObjectFile::ReadSectionData (const Section *section, off_t section_offset, void *dst, size_t dst_len) const
470 {
471     // If some other objectfile owns this data, pass this to them.
472     if (section->GetObjectFile() != this)
473         return section->GetObjectFile()->ReadSectionData (section, section_offset, dst, dst_len);
474
475     if (IsInMemory())
476     {
477         ProcessSP process_sp (m_process_wp.lock());
478         if (process_sp)
479         {
480             Error error;
481             const addr_t base_load_addr = section->GetLoadBaseAddress (&process_sp->GetTarget());
482             if (base_load_addr != LLDB_INVALID_ADDRESS)
483                 return process_sp->ReadMemory (base_load_addr + section_offset, dst, dst_len, error);
484         }
485     }
486     else
487     {
488         const uint64_t section_file_size = section->GetFileSize();
489         if (section_offset < section_file_size)
490         {
491             const uint64_t section_bytes_left = section_file_size - section_offset;
492             uint64_t section_dst_len = dst_len;
493             if (section_dst_len > section_bytes_left)
494                 section_dst_len = section_bytes_left;
495             return CopyData (section->GetFileOffset() + section_offset, section_dst_len, dst);
496         }
497         else
498         {
499             if (section->GetType() == eSectionTypeZeroFill)
500             {
501                 const uint64_t section_size = section->GetByteSize();
502                 const uint64_t section_bytes_left = section_size - section_offset;
503                 uint64_t section_dst_len = dst_len;
504                 if (section_dst_len > section_bytes_left)
505                     section_dst_len = section_bytes_left;
506                 memset(dst, 0, section_dst_len);
507                 return section_dst_len;
508             }
509         }
510     }
511     return 0;
512 }
513
514 //----------------------------------------------------------------------
515 // Get the section data the file on disk
516 //----------------------------------------------------------------------
517 size_t
518 ObjectFile::ReadSectionData (const Section *section, DataExtractor& section_data) const
519 {
520     // If some other objectfile owns this data, pass this to them.
521     if (section->GetObjectFile() != this)
522         return section->GetObjectFile()->ReadSectionData (section, section_data);
523
524     if (IsInMemory())
525     {
526         ProcessSP process_sp (m_process_wp.lock());
527         if (process_sp)
528         {
529             const addr_t base_load_addr = section->GetLoadBaseAddress (&process_sp->GetTarget());
530             if (base_load_addr != LLDB_INVALID_ADDRESS)
531             {
532                 DataBufferSP data_sp (ReadMemory (process_sp, base_load_addr, section->GetByteSize()));
533                 if (data_sp)
534                 {
535                     section_data.SetData (data_sp, 0, data_sp->GetByteSize());
536                     section_data.SetByteOrder (process_sp->GetByteOrder());
537                     section_data.SetAddressByteSize (process_sp->GetAddressByteSize());
538                     return section_data.GetByteSize();
539                 }
540             }
541         }
542     }
543     else
544     {
545         // The object file now contains a full mmap'ed copy of the object file data, so just use this
546         return MemoryMapSectionData (section, section_data);
547     }
548     section_data.Clear();
549     return 0;
550 }
551
552 size_t
553 ObjectFile::MemoryMapSectionData (const Section *section, DataExtractor& section_data) const
554 {
555     // If some other objectfile owns this data, pass this to them.
556     if (section->GetObjectFile() != this)
557         return section->GetObjectFile()->MemoryMapSectionData (section, section_data);
558
559     if (IsInMemory())
560     {
561         return ReadSectionData (section, section_data);
562     }
563     else
564     {
565         // The object file now contains a full mmap'ed copy of the object file data, so just use this
566         return GetData(section->GetFileOffset(), section->GetFileSize(), section_data);
567     }
568     section_data.Clear();
569     return 0;
570 }
571
572
573 bool
574 ObjectFile::SplitArchivePathWithObject (const char *path_with_object, FileSpec &archive_file, ConstString &archive_object, bool must_exist)
575 {
576     RegularExpression g_object_regex("(.*)\\(([^\\)]+)\\)$");
577     RegularExpression::Match regex_match(2);
578     if (g_object_regex.Execute (path_with_object, &regex_match))
579     {
580         std::string path;
581         std::string obj;
582         if (regex_match.GetMatchAtIndex (path_with_object, 1, path) &&
583             regex_match.GetMatchAtIndex (path_with_object, 2, obj))
584         {
585             archive_file.SetFile (path.c_str(), false);
586             archive_object.SetCString(obj.c_str());
587             if (must_exist && !archive_file.Exists())
588                 return false;
589             return true;
590         }
591     }
592     return false;
593 }
594
595 void
596 ObjectFile::ClearSymtab ()
597 {
598     ModuleSP module_sp(GetModule());
599     if (module_sp)
600     {
601         lldb_private::Mutex::Locker locker(module_sp->GetMutex());
602         Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
603         if (log)
604         {
605             log->Printf ("%p ObjectFile::ClearSymtab () symtab = %p",
606                          this,
607                          m_symtab_ap.get());
608         }
609         m_symtab_ap.reset();
610     }
611 }
612
613 SectionList *
614 ObjectFile::GetSectionList()
615 {
616     if (m_sections_ap.get() == NULL)
617     {
618         ModuleSP module_sp(GetModule());
619         if (module_sp)
620             CreateSections(*module_sp->GetUnifiedSectionList());
621     }
622     return m_sections_ap.get();
623 }