Go to the documentation of this file.
28 const char *Section::GetTypeAsCString()
const {
41 return "data-cstr-ptr";
43 return "data-symbol-addr";
49 return "data-16-byte";
57 return "objc-message-refs";
59 return "objc-cfstrings";
61 return "dwarf-abbrev";
63 return "dwarf-abbrev-dwo";
67 return "dwarf-aranges";
69 return "dwarf-cu-index";
71 return "dwarf-tu-index";
77 return "dwarf-info-dwo";
81 return "dwarf-line-str";
85 return "dwarf-loc-dwo";
87 return "dwarf-loclists";
89 return "dwarf-loclists-dwo";
91 return "dwarf-macinfo";
95 return "dwarf-pubnames";
97 return "dwarf-pubtypes";
99 return "dwarf-ranges";
101 return "dwarf-rnglists";
103 return "dwarf-rnglists-dwo";
107 return "dwarf-str-dwo";
109 return "dwarf-str-offsets";
111 return "dwarf-str-offsets-dwo";
113 return "dwarf-types";
115 return "dwarf-types-dwo";
117 return "dwarf-names";
119 return "elf-symbol-table";
121 return "elf-dynamic-symbols";
123 return "elf-relocation-entries";
125 return "elf-dynamic-link-info";
127 return "apple-names";
129 return "apple-types";
131 return "apple-namespaces";
141 return "compact-unwind";
147 return "dwarf-gnu-debugaltlink";
154 Section::Section(
const ModuleSP &module_sp,
ObjectFile *obj_file,
161 m_obj_file(obj_file), m_type(sect_type), m_parent_wp(), m_name(name),
162 m_file_addr(file_addr), m_byte_size(byte_size),
163 m_file_offset(file_offset), m_file_size(file_size),
164 m_log2align(log2align), m_children(), m_fake(false), m_encrypted(false),
165 m_thread_specific(false), m_readable(false), m_writable(false),
166 m_executable(false), m_relocated(false), m_target_byte_size(target_byte_size) {
176 const ModuleSP &module_sp,
ObjectFile *obj_file,
183 m_obj_file(obj_file), m_type(sect_type), m_parent_wp(), m_name(name),
184 m_file_addr(file_addr), m_byte_size(byte_size),
185 m_file_offset(file_offset), m_file_size(file_size),
186 m_log2align(log2align), m_children(), m_fake(false), m_encrypted(false),
187 m_thread_specific(false), m_readable(false), m_writable(false),
188 m_executable(false), m_relocated(false), m_target_byte_size(target_byte_size) {
195 if (parent_section_sp)
219 return parent_sp->SetFileAddress(
m_file_addr - file_addr);
242 load_base_addr = parent_sp->GetLoadBaseAddress(target);
248 const_cast<Section *
>(
this)->shared_from_this());
250 return load_base_addr;
254 bool allow_section_end)
const {
256 for (
size_t i = 0; i < num_children; i++) {
260 if (child_offset <= offset &&
261 offset - child_offset <
262 child_section->
GetByteSize() + (allow_section_end ? 1 : 0))
264 so_addr, allow_section_end);
277 if (file_addr <= vm_addr) {
289 bool resolved =
true;
308 s << llvm::format(
"%c %c%c%c 0x%8.8" PRIx64
" 0x%8.8" PRIx64
" 0x%8.8x ",
324 parent_sp->DumpName(s);
328 const char *name =
nullptr;
335 if ((!name || !name[0]) && module_sp)
336 name = module_sp->GetFileSpec().GetFilename().AsCString();
348 return parent_sp->IsDescendant(section);
354 if (slide_amount == 0)
371 permissions |= ePermissionsReadable;
373 permissions |= ePermissionsWritable;
375 permissions |= ePermissionsExecutable;
381 m_readable = (permissions & ePermissionsReadable) != 0;
382 m_writable = (permissions & ePermissionsWritable) != 0;
383 m_executable = (permissions & ePermissionsExecutable) != 0;
399 #pragma mark SectionList
411 return section_index;
414 return std::numeric_limits<size_t>::max();
430 for (sect_iter =
begin; sect_iter !=
end; ++sect_iter) {
431 if (sect_iter->get() == sect) {
433 return std::distance(
begin, sect_iter);
448 const lldb::SectionSP §_sp,
451 for (sect_iter =
m_sections.begin(); sect_iter !=
end; ++sect_iter) {
452 if ((*sect_iter)->GetID() == sect_id) {
453 *sect_iter = sect_sp;
455 }
else if (depth > 0) {
469 for (sect_iter =
m_sections.begin(); sect_iter !=
end; ++sect_iter) {
470 count += (*sect_iter)->GetChildren().GetNumSections(depth - 1);
491 sect_iter !=
end && sect_sp.get() ==
nullptr; ++sect_iter) {
492 Section *child_section = sect_iter->get();
494 if (child_section->
GetName() == section_dstr) {
495 sect_sp = *sect_iter;
512 sect_iter !=
end && sect_sp.get() ==
nullptr; ++sect_iter) {
513 if ((*sect_iter)->GetID() == sect_id) {
514 sect_sp = *sect_iter;
517 sect_sp = (*sect_iter)->GetChildren().FindSectionByID(sect_id);
526 size_t start_idx)
const {
529 for (
size_t idx = start_idx; idx < num_sections; ++idx) {
530 if (
m_sections[idx]->GetType() == sect_type) {
533 }
else if (check_children) {
534 sect_sp =
m_sections[idx]->GetChildren().FindSectionByType(
535 sect_type, check_children, 0);
549 sect_iter !=
end && sect_sp.get() ==
nullptr; ++sect_iter) {
550 Section *sect = sect_iter->get();
559 if (sect_sp.get() ==
nullptr && !sect->
IsFake())
560 sect_sp = *sect_iter;
571 bool show_header,
uint32_t depth)
const {
572 bool target_has_loaded_sections =
577 "SectID Type {0} Address "
578 " Perm File Off. File Size Flags "
580 target_has_loaded_sections ?
"Load" :
"File");
582 s <<
"---------- ---------------- "
583 "--------------------------------------- ---- ---------- "
585 "---------- ----------------------------\n";
589 section_sp->Dump(s, indent, target_has_loaded_sections ? target :
nullptr,
597 if ((*pos)->Slide(slide_amount, slide_children))
bool ReplaceSection(lldb::user_id_t sect_id, const lldb::SectionSP §ion_sp, uint32_t depth=UINT32_MAX)
@ eSectionTypeDWARFDebugLoc
lldb::SectionSP FindSectionContainingFileAddress(lldb::addr_t addr, uint32_t depth=UINT32_MAX) const
@ eSectionTypeDWARFDebugRngListsDwo
lldb::SectionSP FindSectionByName(ConstString section_dstr) const
@ eSectionTypeDWARFAppleNamespaces
@ eSectionTypeDWARFAppleObjC
const_iterator begin() const
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
void Dump(llvm::raw_ostream &s, unsigned indent, Target *target, bool show_header, uint32_t depth) const
@ eSectionTypeDataCStringPointers
Pointers to C string data.
@ eSectionTypeDataPointers
@ eSectionTypeDWARFDebugAranges
@ eSectionTypeELFSymbolTable
Elf SHT_SYMTAB section.
@ eSectionTypeDWARFDebugStrOffsetsDwo
@ eSectionTypeDWARFDebugRanges
@ eSectionTypeDWARFDebugMacro
@ eSectionTypeDWARFDebugInfoDwo
@ eSectionTypeDWARFDebugFrame
bool ContainsSection(lldb::user_id_t sect_id) const
@ eSectionTypeDWARFDebugLine
@ eSectionTypeDWARFDebugAbbrevDwo
size_t Slide(lldb::addr_t slide_amount, bool slide_children)
virtual size_t ReadSectionData(Section *section, lldb::offset_t section_offset, void *dst, size_t dst_len)
@ eSectionTypeDWARFDebugAddr
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
void Dump(llvm::raw_ostream &s, unsigned indent, Target *target, uint32_t depth) const
lldb::offset_t m_file_offset
bool IsDescendant(const Section *section)
void DumpName(llvm::raw_ostream &s) const
@ eSectionTypeDWARFDebugStrOffsets
size_t GetNumSections(uint32_t depth) const
lldb::SectionSP GetParent() const
lldb::offset_t m_file_size
const char * GetTypeAsCString() const
size_t AddSection(const lldb::SectionSP §ion_sp)
const_iterator end() const
lldb::addr_t GetFileAddress() const
@ eSectionTypeELFRelocationEntries
Elf SHT_REL or SHT_REL section.
@ eSectionTypeDWARFDebugLocDwo
@ eSectionTypeDataObjCMessageRefs
Pointer to function pointer + selector.
lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP §ion_sp) const
@ eSectionTypeDWARFDebugLocListsDwo
SectionList & operator=(const SectionList &rhs)
bool SetFileAddress(lldb::addr_t file_addr)
@ eSectionTypeDWARFDebugAbbrev
@ eSectionTypeCompactUnwind
compact unwind section in Mach-O, __TEXT,__unwind_info
void Dump(llvm::raw_ostream &s, lldb::addr_t base_addr=0, uint32_t addr_width=8) const
Section(const lldb::ModuleSP &module_sp, ObjectFile *obj_file, lldb::user_id_t sect_id, ConstString name, lldb::SectionType sect_type, lldb::addr_t file_vm_addr, lldb::addr_t vm_size, lldb::offset_t file_offset, lldb::offset_t file_size, uint32_t log2align, uint32_t flags, uint32_t target_byte_size=1)
@ eSectionTypeDataSymbolAddress
Address of a symbol in the symbol table.
@ eSectionTypeDataObjCCFStrings
Objective-C const CFString/NSString objects.
@ eSectionTypeDWARFDebugStr
void SetSection(const lldb::SectionSP §ion_sp)
Set accessor for the section.
SectionList & GetChildren()
bool Slide(lldb::addr_t slide_amount, bool slide_children)
bool IsThreadSpecific() const
size_t FindSectionIndex(const Section *sect)
ConstString GetName() const
@ eSectionTypeDWARFDebugInfo
lldb::addr_t GetOffset() const
@ eSectionTypeDWARFDebugTypes
DWARF .debug_types section.
lldb::SectionSP GetSectionAtIndex(size_t idx) const
@ eSectionTypeDWARFAppleTypes
@ eSectionTypeDWARFAppleNames
@ eSectionTypeDWARFGNUDebugAltLink
@ eSectionTypeELFDynamicSymbols
Elf SHT_DYNSYM section.
lldb::addr_t GetLoadBaseAddress(Target *target) const
void SetPermissions(uint32_t permissions)
Set the permissions using bits OR'ed from lldb::Permissions.
@ eSectionTypeAbsoluteAddress
Dummy section for symbols with absolute address.
@ eSectionTypeDWARFDebugCuIndex
bool DeleteSection(size_t idx)
lldb::SectionWP m_parent_wp
lldb::user_id_t GetID() const
Get accessor for the user ID.
@ eSectionTypeDWARFDebugTuIndex
lldb::SectionSP FindSectionByType(lldb::SectionType sect_type, bool check_children, size_t start_idx=0) const
lldb::addr_t GetByteSize() const
@ eSectionTypeContainer
The section contains child sections.
@ eSectionTypeELFDynamicLinkInfo
Elf SHT_DYNAMIC section.
ValueType Get() const
Get accessor for all flags.
@ eSectionTypeDWARFDebugStrDwo
uint32_t m_target_byte_size
@ eSectionTypeDWARFDebugPubTypes
@ eSectionTypeDWARFDebugNames
DWARF v5 .debug_names.
collection::const_iterator const_iterator
@ eSectionTypeDWARFDebugPubNames
@ eSectionTypeDataCString
Inlined C string data.
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
@ eSectionTypeDWARFDebugLineStr
DWARF v5 .debug_line_str.
bool SetOffset(lldb::addr_t offset)
Set accessor for the offset.
SectionLoadList & GetSectionLoadList()
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
A class that represents a running process on the host machine.
bool ResolveContainedAddress(lldb::addr_t offset, Address &so_addr, bool allow_section_end=false) const
@ eSectionTypeDWARFDebugMacInfo
size_t AddUniqueSection(const lldb::SectionSP §ion_sp)
bool ContainsFileAddress(lldb::addr_t vm_addr) const
@ eSectionTypeDWARFDebugTypesDwo
collection::iterator iterator
ConstString & GetFilename()
Filename string get accessor.
@ eSectionTypeDWARFDebugLocLists
DWARF v5 .debug_loclists.
lldb::offset_t GetSectionData(void *dst, lldb::offset_t dst_len, lldb::offset_t offset=0)
Read the section data from the object file that the section resides in.
lldb::SectionSP FindSectionByID(lldb::user_id_t sect_id) const
uint32_t GetPermissions() const
Get the permissions as OR'ed bits from lldb::Permissions.
@ eSectionTypeDWARFDebugRngLists
DWARF v5 .debug_rnglists.