LLDB  mainline
ObjectFile.cpp
Go to the documentation of this file.
1 //===-- ObjectFile.cpp ------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 #include "lldb/Core/Module.h"
11 #include "lldb/Core/ModuleSpec.h"
13 #include "lldb/Core/Section.h"
15 #include "lldb/Symbol/SymbolFile.h"
16 #include "lldb/Target/Process.h"
18 #include "lldb/Target/Target.h"
21 #include "lldb/Utility/Log.h"
23 #include "lldb/Utility/Timer.h"
24 #include "lldb/lldb-private.h"
25 
26 using namespace lldb;
27 using namespace lldb_private;
28 
29 ObjectFileSP
30 ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file,
31  lldb::offset_t file_offset, lldb::offset_t file_size,
32  DataBufferSP &data_sp, lldb::offset_t &data_offset) {
33  ObjectFileSP object_file_sp;
34 
35  if (module_sp) {
36  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
37  Timer scoped_timer(
38  func_cat,
39  "ObjectFile::FindPlugin (module = %s, file = %p, file_offset = "
40  "0x%8.8" PRIx64 ", file_size = 0x%8.8" PRIx64 ")",
41  module_sp->GetFileSpec().GetPath().c_str(),
42  static_cast<const void *>(file), static_cast<uint64_t>(file_offset),
43  static_cast<uint64_t>(file_size));
44  if (file) {
45  FileSpec archive_file;
46  ObjectContainerCreateInstance create_object_container_callback;
47 
48  const bool file_exists = FileSystem::Instance().Exists(*file);
49  if (!data_sp) {
50  // We have an object name which most likely means we have a .o file in
51  // a static archive (.a file). Try and see if we have a cached archive
52  // first without reading any data first
53  if (file_exists && module_sp->GetObjectName()) {
54  for (uint32_t idx = 0;
55  (create_object_container_callback =
56  PluginManager::GetObjectContainerCreateCallbackAtIndex(
57  idx)) != nullptr;
58  ++idx) {
59  std::unique_ptr<ObjectContainer> object_container_up(
60  create_object_container_callback(module_sp, data_sp,
61  data_offset, file, file_offset,
62  file_size));
63 
64  if (object_container_up)
65  object_file_sp = object_container_up->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 lets
72  // read the first 512 bytes from the file so the object file and object
73  // container plug-ins can use these bytes to see if they can parse this
74  // file.
75  if (file_size > 0) {
76  data_sp = FileSystem::Instance().CreateDataBuffer(file->GetPath(),
77  512, file_offset);
78  data_offset = 0;
79  }
80  }
81 
82  if (!data_sp || data_sp->GetByteSize() == 0) {
83  // Check for archive file with format "/path/to/archive.a(object.o)"
84  char path_with_object[PATH_MAX * 2];
85  module_sp->GetFileSpec().GetPath(path_with_object,
86  sizeof(path_with_object));
87 
88  ConstString archive_object;
89  const bool must_exist = true;
90  if (ObjectFile::SplitArchivePathWithObject(
91  path_with_object, archive_file, archive_object, must_exist)) {
92  file_size = FileSystem::Instance().GetByteSize(archive_file);
93  if (file_size > 0) {
94  file = &archive_file;
95  module_sp->SetFileSpecAndObjectName(archive_file, archive_object);
96  // Check if this is a object container by iterating through all
97  // object container plugin instances and then trying to get an
98  // object file from the container plugins since we had a name.
99  // 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
102  // file).
103  for (uint32_t idx = 0;
104  (create_object_container_callback =
105  PluginManager::GetObjectContainerCreateCallbackAtIndex(
106  idx)) != nullptr;
107  ++idx) {
108  std::unique_ptr<ObjectContainer> object_container_up(
109  create_object_container_callback(module_sp, data_sp,
110  data_offset, file,
111  file_offset, file_size));
112 
113  if (object_container_up)
114  object_file_sp = object_container_up->GetObjectFile(file);
115 
116  if (object_file_sp.get())
117  return object_file_sp;
118  }
119  // We failed to find any cached object files in the container plug-
120  // ins, so lets read the first 512 bytes and try again below...
121  data_sp = FileSystem::Instance().CreateDataBuffer(
122  archive_file.GetPath(), 512, file_offset);
123  }
124  }
125  }
126 
127  if (data_sp && data_sp->GetByteSize() > 0) {
128  // Check if this is a normal object file by iterating through all
129  // object file plugin instances.
130  ObjectFileCreateInstance create_object_file_callback;
131  for (uint32_t idx = 0;
132  (create_object_file_callback =
133  PluginManager::GetObjectFileCreateCallbackAtIndex(idx)) !=
134  nullptr;
135  ++idx) {
136  object_file_sp.reset(create_object_file_callback(
137  module_sp, data_sp, data_offset, file, file_offset, file_size));
138  if (object_file_sp.get())
139  return object_file_sp;
140  }
141 
142  // Check if this is a object container by iterating through all object
143  // container plugin instances and then trying to get an object file
144  // from the container.
145  for (uint32_t idx = 0;
146  (create_object_container_callback =
147  PluginManager::GetObjectContainerCreateCallbackAtIndex(
148  idx)) != nullptr;
149  ++idx) {
150  std::unique_ptr<ObjectContainer> object_container_up(
151  create_object_container_callback(module_sp, data_sp, data_offset,
152  file, file_offset, file_size));
153 
154  if (object_container_up)
155  object_file_sp = object_container_up->GetObjectFile(file);
156 
157  if (object_file_sp.get())
158  return object_file_sp;
159  }
160  }
161  }
162  }
163  // We didn't find it, so clear our shared pointer in case it contains
164  // anything and return an empty shared pointer
165  object_file_sp.reset();
166  return object_file_sp;
167 }
168 
169 ObjectFileSP ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp,
170  const ProcessSP &process_sp,
171  lldb::addr_t header_addr,
172  DataBufferSP &data_sp) {
173  ObjectFileSP object_file_sp;
174 
175  if (module_sp) {
176  static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
177  Timer scoped_timer(func_cat,
178  "ObjectFile::FindPlugin (module = "
179  "%s, process = %p, header_addr = "
180  "0x%" PRIx64 ")",
181  module_sp->GetFileSpec().GetPath().c_str(),
182  static_cast<void *>(process_sp.get()), header_addr);
183  uint32_t idx;
184 
185  // Check if this is a normal object file by iterating through all object
186  // file plugin instances.
187  ObjectFileCreateMemoryInstance create_callback;
188  for (idx = 0;
189  (create_callback =
190  PluginManager::GetObjectFileCreateMemoryCallbackAtIndex(idx)) !=
191  nullptr;
192  ++idx) {
193  object_file_sp.reset(
194  create_callback(module_sp, data_sp, process_sp, header_addr));
195  if (object_file_sp.get())
196  return object_file_sp;
197  }
198  }
199 
200  // We didn't find it, so clear our shared pointer in case it contains
201  // anything and return an empty shared pointer
202  object_file_sp.reset();
203  return object_file_sp;
204 }
205 
206 size_t ObjectFile::GetModuleSpecifications(const FileSpec &file,
207  lldb::offset_t file_offset,
208  lldb::offset_t file_size,
209  ModuleSpecList &specs) {
210  DataBufferSP data_sp =
211  FileSystem::Instance().CreateDataBuffer(file.GetPath(), 512, file_offset);
212  if (data_sp) {
213  if (file_size == 0) {
214  const lldb::offset_t actual_file_size =
215  FileSystem::Instance().GetByteSize(file);
216  if (actual_file_size > file_offset)
217  file_size = actual_file_size - file_offset;
218  }
219  return ObjectFile::GetModuleSpecifications(file, // file spec
220  data_sp, // data bytes
221  0, // data offset
222  file_offset, // file offset
223  file_size, // file length
224  specs);
225  }
226  return 0;
227 }
228 
229 size_t ObjectFile::GetModuleSpecifications(
230  const lldb_private::FileSpec &file, lldb::DataBufferSP &data_sp,
231  lldb::offset_t data_offset, lldb::offset_t file_offset,
232  lldb::offset_t file_size, lldb_private::ModuleSpecList &specs) {
233  const size_t initial_count = specs.GetSize();
234  ObjectFileGetModuleSpecifications callback;
235  uint32_t i;
236  // Try the ObjectFile plug-ins
237  for (i = 0;
238  (callback =
239  PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex(
240  i)) != nullptr;
241  ++i) {
242  if (callback(file, data_sp, data_offset, file_offset, file_size, specs) > 0)
243  return specs.GetSize() - initial_count;
244  }
245 
246  // Try the ObjectContainer plug-ins
247  for (i = 0;
248  (callback = PluginManager::
249  GetObjectContainerGetModuleSpecificationsCallbackAtIndex(i)) !=
250  nullptr;
251  ++i) {
252  if (callback(file, data_sp, data_offset, file_offset, file_size, specs) > 0)
253  return specs.GetSize() - initial_count;
254  }
255  return 0;
256 }
257 
258 ObjectFile::ObjectFile(const lldb::ModuleSP &module_sp,
259  const FileSpec *file_spec_ptr,
260  lldb::offset_t file_offset, lldb::offset_t length,
261  const lldb::DataBufferSP &data_sp,
262  lldb::offset_t data_offset)
263  : ModuleChild(module_sp),
264  m_file(), // This file could be different from the original module's file
265  m_type(eTypeInvalid), m_strata(eStrataInvalid),
266  m_file_offset(file_offset), m_length(length), m_data(), m_process_wp(),
267  m_memory_addr(LLDB_INVALID_ADDRESS), m_sections_up(), m_symtab_up(),
268  m_synthetic_symbol_idx(0) {
269  if (file_spec_ptr)
270  m_file = *file_spec_ptr;
271  if (data_sp)
272  m_data.SetData(data_sp, data_offset, length);
274  if (log)
275  log->Printf("%p ObjectFile::ObjectFile() module = %p (%s), file = %s, "
276  "file_offset = 0x%8.8" PRIx64 ", size = %" PRIu64,
277  static_cast<void *>(this), static_cast<void *>(module_sp.get()),
278  module_sp->GetSpecificationDescription().c_str(),
279  m_file ? m_file.GetPath().c_str() : "<NULL>", m_file_offset,
280  m_length);
281 }
282 
283 ObjectFile::ObjectFile(const lldb::ModuleSP &module_sp,
284  const ProcessSP &process_sp, lldb::addr_t header_addr,
285  DataBufferSP &header_data_sp)
286  : ModuleChild(module_sp), m_file(), m_type(eTypeInvalid),
288  m_process_wp(process_sp), m_memory_addr(header_addr), m_sections_up(),
290  if (header_data_sp)
291  m_data.SetData(header_data_sp, 0, header_data_sp->GetByteSize());
293  if (log)
294  log->Printf("%p ObjectFile::ObjectFile() module = %p (%s), process = %p, "
295  "header_addr = 0x%" PRIx64,
296  static_cast<void *>(this), static_cast<void *>(module_sp.get()),
297  module_sp->GetSpecificationDescription().c_str(),
298  static_cast<void *>(process_sp.get()), m_memory_addr);
299 }
300 
303  if (log)
304  log->Printf("%p ObjectFile::~ObjectFile ()\n", static_cast<void *>(this));
305 }
306 
308  ModuleSP module_sp(GetModule());
309  if (module_sp)
310  return module_sp->SetArchitecture(new_arch);
311  return false;
312 }
313 
315  Symtab *symtab = GetSymtab();
316  if (symtab) {
317  Symbol *symbol = symtab->FindSymbolContainingFileAddress(file_addr);
318  if (symbol) {
319  if (symbol->ValueIsAddress()) {
320  const SectionSP section_sp(symbol->GetAddressRef().GetSection());
321  if (section_sp) {
322  const SectionType section_type = section_sp->GetType();
323  switch (section_type) {
324  case eSectionTypeInvalid:
325  return AddressClass::eUnknown;
326  case eSectionTypeCode:
327  return AddressClass::eCode;
329  return AddressClass::eUnknown;
330  case eSectionTypeData:
334  case eSectionTypeData4:
335  case eSectionTypeData8:
336  case eSectionTypeData16:
342  return AddressClass::eData;
343  case eSectionTypeDebug:
373  return AddressClass::eDebug;
374  case eSectionTypeEHFrame:
378  return AddressClass::eRuntime;
383  case eSectionTypeOther:
384  return AddressClass::eUnknown;
386  // In case of absolute sections decide the address class based on
387  // the symbol type because the section type isn't specify if it is
388  // a code or a data section.
389  break;
390  }
391  }
392  }
393 
394  const SymbolType symbol_type = symbol->GetType();
395  switch (symbol_type) {
396  case eSymbolTypeAny:
397  return AddressClass::eUnknown;
398  case eSymbolTypeAbsolute:
399  return AddressClass::eUnknown;
400  case eSymbolTypeCode:
401  return AddressClass::eCode;
403  return AddressClass::eCode;
404  case eSymbolTypeResolver:
405  return AddressClass::eCode;
406  case eSymbolTypeData:
407  return AddressClass::eData;
408  case eSymbolTypeRuntime:
409  return AddressClass::eRuntime;
411  return AddressClass::eRuntime;
413  return AddressClass::eDebug;
415  return AddressClass::eDebug;
417  return AddressClass::eDebug;
419  return AddressClass::eDebug;
420  case eSymbolTypeBlock:
421  return AddressClass::eDebug;
422  case eSymbolTypeLocal:
423  return AddressClass::eData;
424  case eSymbolTypeParam:
425  return AddressClass::eData;
426  case eSymbolTypeVariable:
427  return AddressClass::eData;
429  return AddressClass::eDebug;
431  return AddressClass::eDebug;
433  return AddressClass::eDebug;
435  return AddressClass::eDebug;
436  case eSymbolTypeScopeEnd:
437  return AddressClass::eDebug;
439  return AddressClass::eUnknown;
440  case eSymbolTypeCompiler:
441  return AddressClass::eDebug;
443  return AddressClass::eDebug;
445  return AddressClass::eUnknown;
447  return AddressClass::eRuntime;
449  return AddressClass::eRuntime;
450  case eSymbolTypeObjCIVar:
451  return AddressClass::eRuntime;
453  return AddressClass::eRuntime;
454  }
455  }
456  }
457  return AddressClass::eUnknown;
458 }
459 
460 DataBufferSP ObjectFile::ReadMemory(const ProcessSP &process_sp,
461  lldb::addr_t addr, size_t byte_size) {
462  DataBufferSP data_sp;
463  if (process_sp) {
464  std::unique_ptr<DataBufferHeap> data_up(new DataBufferHeap(byte_size, 0));
465  Status error;
466  const size_t bytes_read = process_sp->ReadMemory(
467  addr, data_up->GetBytes(), data_up->GetByteSize(), error);
468  if (bytes_read == byte_size)
469  data_sp.reset(data_up.release());
470  }
471  return data_sp;
472 }
473 
474 size_t ObjectFile::GetData(lldb::offset_t offset, size_t length,
475  DataExtractor &data) const {
476  // The entire file has already been mmap'ed into m_data, so just copy from
477  // there as the back mmap buffer will be shared with shared pointers.
478  return data.SetData(m_data, offset, length);
479 }
480 
481 size_t ObjectFile::CopyData(lldb::offset_t offset, size_t length,
482  void *dst) const {
483  // The entire file has already been mmap'ed into m_data, so just copy from
484  // there Note that the data remains in target byte order.
485  return m_data.CopyData(offset, length, dst);
486 }
487 
489  lldb::offset_t section_offset, void *dst,
490  size_t dst_len) {
491  assert(section);
492  section_offset *= section->GetTargetByteSize();
493 
494  // If some other objectfile owns this data, pass this to them.
495  if (section->GetObjectFile() != this)
496  return section->GetObjectFile()->ReadSectionData(section, section_offset,
497  dst, dst_len);
498 
499  if (IsInMemory()) {
500  ProcessSP process_sp(m_process_wp.lock());
501  if (process_sp) {
502  Status error;
503  const addr_t base_load_addr =
504  section->GetLoadBaseAddress(&process_sp->GetTarget());
505  if (base_load_addr != LLDB_INVALID_ADDRESS)
506  return process_sp->ReadMemory(base_load_addr + section_offset, dst,
507  dst_len, error);
508  }
509  } else {
510  if (!section->IsRelocated())
511  RelocateSection(section);
512 
513  const lldb::offset_t section_file_size = section->GetFileSize();
514  if (section_offset < section_file_size) {
515  const size_t section_bytes_left = section_file_size - section_offset;
516  size_t section_dst_len = dst_len;
517  if (section_dst_len > section_bytes_left)
518  section_dst_len = section_bytes_left;
519  return CopyData(section->GetFileOffset() + section_offset,
520  section_dst_len, dst);
521  } else {
522  if (section->GetType() == eSectionTypeZeroFill) {
523  const uint64_t section_size = section->GetByteSize();
524  const uint64_t section_bytes_left = section_size - section_offset;
525  uint64_t section_dst_len = dst_len;
526  if (section_dst_len > section_bytes_left)
527  section_dst_len = section_bytes_left;
528  memset(dst, 0, section_dst_len);
529  return section_dst_len;
530  }
531  }
532  }
533  return 0;
534 }
535 
536 // Get the section data the file on disk
538  DataExtractor &section_data) {
539  // If some other objectfile owns this data, pass this to them.
540  if (section->GetObjectFile() != this)
541  return section->GetObjectFile()->ReadSectionData(section, section_data);
542 
543  if (IsInMemory()) {
544  ProcessSP process_sp(m_process_wp.lock());
545  if (process_sp) {
546  const addr_t base_load_addr =
547  section->GetLoadBaseAddress(&process_sp->GetTarget());
548  if (base_load_addr != LLDB_INVALID_ADDRESS) {
549  DataBufferSP data_sp(
550  ReadMemory(process_sp, base_load_addr, section->GetByteSize()));
551  if (data_sp) {
552  section_data.SetData(data_sp, 0, data_sp->GetByteSize());
553  section_data.SetByteOrder(process_sp->GetByteOrder());
554  section_data.SetAddressByteSize(process_sp->GetAddressByteSize());
555  return section_data.GetByteSize();
556  }
557  }
558  }
559  return GetData(section->GetFileOffset(), section->GetFileSize(),
560  section_data);
561  } else {
562  // The object file now contains a full mmap'ed copy of the object file
563  // data, so just use this
564  if (!section->IsRelocated())
565  RelocateSection(section);
566 
567  return GetData(section->GetFileOffset(), section->GetFileSize(),
568  section_data);
569  }
570 }
571 
572 bool ObjectFile::SplitArchivePathWithObject(const char *path_with_object,
573  FileSpec &archive_file,
574  ConstString &archive_object,
575  bool must_exist) {
576  RegularExpression g_object_regex(llvm::StringRef("(.*)\\(([^\\)]+)\\)$"));
577  RegularExpression::Match regex_match(2);
578  if (g_object_regex.Execute(llvm::StringRef::withNullAsEmpty(path_with_object),
579  &regex_match)) {
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  archive_file.SetFile(path, FileSpec::Style::native);
585  archive_object.SetCString(obj.c_str());
586  return !(must_exist && !FileSystem::Instance().Exists(archive_file));
587  }
588  }
589  return false;
590 }
591 
593  ModuleSP module_sp(GetModule());
594  if (module_sp) {
595  std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
597  if (log)
598  log->Printf("%p ObjectFile::ClearSymtab () symtab = %p",
599  static_cast<void *>(this),
600  static_cast<void *>(m_symtab_up.get()));
601  m_symtab_up.reset();
602  }
603 }
604 
605 SectionList *ObjectFile::GetSectionList(bool update_module_section_list) {
606  if (m_sections_up == nullptr) {
607  if (update_module_section_list) {
608  ModuleSP module_sp(GetModule());
609  if (module_sp) {
610  std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
611  CreateSections(*module_sp->GetUnifiedSectionList());
612  }
613  } else {
614  SectionList unified_section_list;
615  CreateSections(unified_section_list);
616  }
617  }
618  return m_sections_up.get();
619 }
620 
623  lldb::SymbolType symbol_type_hint) {
624  if (!name.empty()) {
625  if (name.startswith("_OBJC_")) {
626  // ObjC
627  if (name.startswith("_OBJC_CLASS_$_"))
629  if (name.startswith("_OBJC_METACLASS_$_"))
631  if (name.startswith("_OBJC_IVAR_$_"))
633  } else if (name.startswith(".objc_class_name_")) {
634  // ObjC v1
636  }
637  }
638  return symbol_type_hint;
639 }
640 
642  StreamString ss;
643  ConstString file_name = GetModule()->GetFileSpec().GetFilename();
644  ss.Printf("___lldb_unnamed_symbol%u$$%s", ++m_synthetic_symbol_idx,
645  file_name.GetCString());
646  return ConstString(ss.GetString());
647 }
648 
649 std::vector<ObjectFile::LoadableData>
651  std::vector<LoadableData> loadables;
652  SectionList *section_list = GetSectionList();
653  if (!section_list)
654  return loadables;
655  // Create a list of loadable data from loadable sections
656  size_t section_count = section_list->GetNumSections(0);
657  for (size_t i = 0; i < section_count; ++i) {
658  LoadableData loadable;
659  SectionSP section_sp = section_list->GetSectionAtIndex(i);
660  loadable.Dest =
661  target.GetSectionLoadList().GetSectionLoadAddress(section_sp);
662  if (loadable.Dest == LLDB_INVALID_ADDRESS)
663  continue;
664  // We can skip sections like bss
665  if (section_sp->GetFileSize() == 0)
666  continue;
667  DataExtractor section_data;
668  section_sp->GetSectionData(section_data);
669  loadable.Contents = llvm::ArrayRef<uint8_t>(section_data.GetDataStart(),
670  section_data.GetByteSize());
671  loadables.push_back(loadable);
672  }
673  return loadables;
674 }
675 
677 {
678 }
679 
680 DataBufferSP ObjectFile::MapFileData(const FileSpec &file, uint64_t Size,
681  uint64_t Offset) {
682  return FileSystem::Instance().CreateDataBuffer(file.GetPath(), Size, Offset);
683 }
684 
685 void llvm::format_provider<ObjectFile::Type>::format(
686  const ObjectFile::Type &type, raw_ostream &OS, StringRef Style) {
687  switch (type) {
689  OS << "invalid";
690  break;
692  OS << "core file";
693  break;
695  OS << "executable";
696  break;
698  OS << "debug info";
699  break;
701  OS << "dynamic linker";
702  break;
704  OS << "object file";
705  break;
707  OS << "shared library";
708  break;
710  OS << "stub library";
711  break;
713  OS << "jit";
714  break;
716  OS << "unknown";
717  break;
718  }
719 }
720 
721 void llvm::format_provider<ObjectFile::Strata>::format(
722  const ObjectFile::Strata &strata, raw_ostream &OS, StringRef Style) {
723  switch (strata) {
725  OS << "invalid";
726  break;
728  OS << "unknown";
729  break;
731  OS << "user";
732  break;
734  OS << "kernel";
735  break;
737  OS << "raw image";
738  break;
740  OS << "jit";
741  break;
742  }
743 }
Address & GetAddressRef()
Definition: Symbol.h:56
virtual std::vector< LoadableData > GetLoadableData(Target &target)
Loads this objfile to memory.
Definition: ObjectFile.cpp:650
An data extractor class.
Definition: DataExtractor.h:47
#define LIBLLDB_LOG_OBJECT
Definition: Logging.h:25
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
virtual void ClearSymtab()
Frees the symbol table.
Definition: ObjectFile.cpp:592
bool IsRelocated() const
Definition: Section.h:243
lldb::offset_t GetFileOffset() const
Definition: Section.h:148
bool SetModulesArchitecture(const ArchSpec &new_arch)
Sets the architecture for a module.
Definition: ObjectFile.cpp:307
ObjectFile * GetObjectFile()
Definition: Section.h:198
virtual AddressClass GetAddressClass(lldb::addr_t file_addr)
Get the address type given a file address in an object file.
Definition: ObjectFile.cpp:314
std::shared_ptr< DataBufferLLVM > CreateDataBuffer(const llvm::Twine &path, uint64_t size=0, uint64_t offset=0)
Create memory buffer from path.
A shared library that can be used during execution.
Definition: ObjectFile.h:73
lldb::addr_t GetLoadBaseAddress(Target *target) const
Definition: Section.cpp:229
A file utility class.
Definition: FileSpec.h:55
"lldb/Utility/RegularExpression.h" A C++ wrapper class for regex.
An architecture specification class.
Definition: ArchSpec.h:32
size_t GetData(lldb::offset_t offset, size_t length, DataExtractor &data) const
Definition: ObjectFile.cpp:474
A library that can be linked against but not used for execution.
Definition: ObjectFile.h:75
virtual void RelocateSection(lldb_private::Section *section)
Perform relocations on the section if necessary.
Definition: ObjectFile.cpp:676
A timer class that simplifies common timing metrics.
Definition: Timer.h:23
std::unique_ptr< lldb_private::Symtab > m_symtab_up
Definition: ObjectFile.h:679
static bool SplitArchivePathWithObject(const char *path_with_object, lldb_private::FileSpec &archive_file, lldb_private::ConstString &archive_object, bool must_exist)
Split a path into a file path with object name.
Definition: ObjectFile.cpp:572
void SetAddressByteSize(uint32_t addr_size)
Set the address byte size.
The platform&#39;s dynamic linker executable.
Definition: ObjectFile.h:71
static FileSystem & Instance()
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:27
A subclass of DataBuffer that stores a data buffer on the heap.
lldb::offset_t GetFileSize() const
Definition: Section.h:154
size_t CopyData(lldb::offset_t offset, size_t length, void *dst) const
Definition: ObjectFile.cpp:481
std::unique_ptr< lldb_private::SectionList > m_sections_up
Definition: ObjectFile.h:678
lldb::SymbolType GetType() const
Definition: Symbol.h:136
virtual size_t ReadSectionData(Section *section, lldb::offset_t section_offset, void *dst, size_t dst_len)
Definition: ObjectFile.cpp:488
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
Definition: lldb-defines.h:85
bool GetMatchAtIndex(llvm::StringRef s, uint32_t idx, std::string &match_str) const
lldb::offset_t SetData(const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order)
Set data with a buffer that is caller owned.
uint32_t m_synthetic_symbol_idx
Definition: ObjectFile.h:680
uint32_t GetTargetByteSize() const
Definition: Section.h:241
uint64_t offset_t
Definition: lldb-types.h:87
An object file that contains only debug information.
Definition: ObjectFile.h:70
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:57
An intermediate object file.
Definition: ObjectFile.h:72
lldb::offset_t CopyData(lldb::offset_t offset, lldb::offset_t length, void *dst) const
Copy length bytes from *offset, without swapping bytes.
SectionLoadList & GetSectionLoadList()
Definition: Target.h:1012
~ObjectFile() override
Destructor.
Definition: ObjectFile.cpp:301
lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP &section_sp) const
virtual SectionList * GetSectionList(bool update_module_section_list=true)
Gets the section list for the currently selected architecture (and object for archives).
Definition: ObjectFile.cpp:605
lldb::ProcessWP m_process_wp
Definition: ObjectFile.h:676
JIT code that has symbols, sections and possibly debug info.
Definition: ObjectFile.h:76
llvm::StringRef GetString() const
static lldb::DataBufferSP ReadMemory(const lldb::ProcessSP &process_sp, lldb::addr_t addr, size_t byte_size)
Definition: ObjectFile.cpp:460
bool ValueIsAddress() const
Definition: Symbol.cpp:114
lldb::addr_t GetByteSize() const
Definition: Section.h:164
lldb::SectionSP GetSectionAtIndex(size_t idx) const
Definition: Section.cpp:497
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:106
ModuleChild(const lldb::ModuleSP &module_sp)
Construct with owning module.
Definition: ModuleChild.cpp:13
Symbol * FindSymbolContainingFileAddress(lldb::addr_t file_addr)
Definition: Symtab.cpp:994
uint64_t GetByteSize() const
Get the number of bytes contained in this object.
static lldb::DataBufferSP MapFileData(const FileSpec &file, uint64_t Size, uint64_t Offset)
Definition: ObjectFile.cpp:680
DataExtractor m_data
The data for this object file so things can be parsed lazily.
Definition: ObjectFile.h:675
llvm::ArrayRef< uint8_t > Contents
Definition: ObjectFile.h:90
bool IsInMemory() const
Definition: ObjectFile.h:640
lldb::SectionType GetType() const
Definition: Section.h:182
const lldb::addr_t m_memory_addr
Definition: ObjectFile.h:677
uint64_t addr_t
Definition: lldb-types.h:83
size_t GetNumSections(uint32_t depth) const
Definition: Section.cpp:486
const uint8_t * GetDataStart() const
Get the data start pointer.
lldb::addr_t m_file_offset
The offset in bytes into the file, or the address in memory.
Definition: ObjectFile.h:669
A uniqued constant string class.
Definition: ConstString.h:38
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:247
bool Execute(llvm::StringRef string, Match *match=nullptr) const
Executes a regular expression.
Definition: SBAddress.h:15
bool Exists(const FileSpec &file_spec) const
Returns whether the given file exists.
#define PATH_MAX
A core file that has a checkpoint of a program&#39;s execution state.
Definition: ObjectFile.h:68
A mix in class that contains a pointer back to the module that owns the object which inherits from it...
Definition: ModuleChild.h:19
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
Definition: FileSpec.cpp:198
lldb::SectionSP GetSection() const
Get const accessor for the section.
Definition: Address.h:410
virtual Symtab * GetSymtab()=0
Gets the symbol table for the currently selected architecture (and object for archives).
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:376
virtual void CreateSections(SectionList &unified_section_list)=0
void Printf(const char *format,...) __attribute__((format(printf
Definition: Log.cpp:113
ConstString GetNextSyntheticSymbolName()
Definition: ObjectFile.cpp:641
static lldb::SymbolType GetSymbolTypeFromName(llvm::StringRef name, lldb::SymbolType symbol_type_hint=lldb::eSymbolTypeUndefined)
Definition: ObjectFile.cpp:622
lldb::addr_t m_length
The length of this object file if it is known (can be zero if length is unknown or can&#39;t be determine...
Definition: ObjectFile.h:671
ObjectFile(const lldb::ModuleSP &module_sp, const FileSpec *file_spec_ptr, lldb::offset_t file_offset, lldb::offset_t length, const lldb::DataBufferSP &data_sp, lldb::offset_t data_offset)
Construct with a parent module, offset, and header data.
Definition: ObjectFile.cpp:258
An error handling class.
Definition: Status.h:44
void SetByteOrder(lldb::ByteOrder byte_order)
Set the byte_order value.
void SetCString(const char *cstr)
Set the C string value.