LLDB mainline
Section.cpp
Go to the documentation of this file.
1//===-- Section.cpp -------------------------------------------------------===//
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
9#include "lldb/Core/Section.h"
10#include "lldb/Core/Address.h"
11#include "lldb/Core/Module.h"
14#include "lldb/Target/Target.h"
16#include <cinttypes>
17#include <limits>
18#include <utility>
19
20namespace lldb_private {
21class DataExtractor;
22}
23using namespace lldb;
24using namespace lldb_private;
25
26const char *Section::GetTypeAsCString() const {
27 switch (m_type) {
29 return "invalid";
31 return "code";
33 return "container";
35 return "data";
37 return "data-cstr";
39 return "data-cstr-ptr";
41 return "data-symbol-addr";
43 return "data-4-byte";
45 return "data-8-byte";
47 return "data-16-byte";
49 return "data-ptrs";
51 return "debug";
53 return "zero-fill";
55 return "objc-message-refs";
57 return "objc-cfstrings";
59 return "dwarf-abbrev";
61 return "dwarf-abbrev-dwo";
63 return "dwarf-addr";
65 return "dwarf-aranges";
67 return "dwarf-cu-index";
69 return "dwarf-tu-index";
71 return "dwarf-frame";
73 return "dwarf-info";
75 return "dwarf-info-dwo";
77 return "dwarf-line";
79 return "dwarf-line-str";
81 return "dwarf-loc";
83 return "dwarf-loc-dwo";
85 return "dwarf-loclists";
87 return "dwarf-loclists-dwo";
89 return "dwarf-macinfo";
91 return "dwarf-macro";
93 return "dwarf-pubnames";
95 return "dwarf-pubtypes";
97 return "dwarf-ranges";
99 return "dwarf-rnglists";
101 return "dwarf-rnglists-dwo";
103 return "dwarf-str";
105 return "dwarf-str-dwo";
107 return "dwarf-str-offsets";
109 return "dwarf-str-offsets-dwo";
111 return "dwarf-types";
113 return "dwarf-types-dwo";
115 return "dwarf-names";
117 return "elf-symbol-table";
119 return "elf-dynamic-symbols";
121 return "elf-relocation-entries";
123 return "elf-dynamic-link-info";
125 return "apple-names";
127 return "apple-types";
129 return "apple-namespaces";
131 return "apple-objc";
133 return "eh-frame";
135 return "ARM.exidx";
137 return "ARM.extab";
139 return "compact-unwind";
141 return "go-symtab";
143 return "absolute";
145 return "dwarf-gnu-debugaltlink";
146 case eSectionTypeCTF:
147 return "ctf";
149 return "lldb-type-summaries";
151 return "lldb-formatters";
153 return "swift-modules";
155 return "wasm-name";
157 return "wasm-global";
159 return "regular";
160 }
161 return "unknown";
162}
163
164Section::Section(const ModuleSP &module_sp, ObjectFile *obj_file,
165 user_id_t sect_id, ConstString name, SectionType sect_type,
166 addr_t file_addr, addr_t byte_size, lldb::offset_t file_offset,
167 lldb::offset_t file_size, uint32_t log2align, uint32_t flags)
168 : ModuleChild(module_sp), UserID(sect_id), Flags(flags),
169 m_obj_file(obj_file), m_type(sect_type), m_parent_wp(), m_name(name),
170 m_file_addr(file_addr), m_byte_size(byte_size),
171 m_file_offset(file_offset), m_file_size(file_size),
172 m_log2align(log2align), m_children(), m_fake(false), m_encrypted(false),
173 m_thread_specific(false), m_readable(false), m_writable(false),
174 m_executable(false), m_relocated(false) {}
175
176Section::Section(const lldb::SectionSP &parent_section_sp,
177 const ModuleSP &module_sp, ObjectFile *obj_file,
178 user_id_t sect_id, ConstString name, SectionType sect_type,
179 addr_t file_addr, addr_t byte_size, lldb::offset_t file_offset,
180 lldb::offset_t file_size, uint32_t log2align, uint32_t flags)
181 : ModuleChild(module_sp), UserID(sect_id), Flags(flags),
182 m_obj_file(obj_file), m_type(sect_type), m_parent_wp(), m_name(name),
183 m_file_addr(file_addr), m_byte_size(byte_size),
184 m_file_offset(file_offset), m_file_size(file_size),
185 m_log2align(log2align), m_children(), m_fake(false), m_encrypted(false),
186 m_thread_specific(false), m_readable(false), m_writable(false),
187 m_executable(false), m_relocated(false) {
188 if (parent_section_sp)
189 m_parent_wp = parent_section_sp;
190}
191
192Section::~Section() = default;
193
195 SectionSP parent_sp(GetParent());
196 if (parent_sp) {
197 // This section has a parent which means m_file_addr is an offset into the
198 // parent section, so the file address for this section is the file address
199 // of the parent plus the offset
200 return parent_sp->GetFileAddress() + m_file_addr;
201 }
202 // This section has no parent, so m_file_addr is the file base address
203 return m_file_addr;
204}
205
207 SectionSP parent_sp(GetParent());
208 if (parent_sp) {
209 if (m_file_addr >= file_addr)
210 return parent_sp->SetFileAddress(m_file_addr - file_addr);
211 return false;
212 } else {
213 // This section has no parent, so m_file_addr is the file base address
214 m_file_addr = file_addr;
215 return true;
216 }
217}
218
220 // This section has a parent which means m_file_addr is an offset.
221 SectionSP parent_sp(GetParent());
222 if (parent_sp)
223 return m_file_addr;
224
225 // This section has no parent, so there is no offset to be had
226 return 0;
227}
228
230 addr_t load_base_addr = LLDB_INVALID_ADDRESS;
231 SectionSP parent_sp(GetParent());
232 if (parent_sp) {
233 load_base_addr = parent_sp->GetLoadBaseAddress(target);
234 if (load_base_addr != LLDB_INVALID_ADDRESS)
235 load_base_addr += GetOffset();
236 }
237 if (load_base_addr == LLDB_INVALID_ADDRESS) {
238 load_base_addr = target->GetSectionLoadAddress(
239 const_cast<Section *>(this)->shared_from_this());
240 }
241 return load_base_addr;
242}
243
245 bool allow_section_end) const {
246 const size_t num_children = m_children.GetSize();
247 for (size_t i = 0; i < num_children; i++) {
248 Section *child_section = m_children.GetSectionAtIndex(i).get();
249
250 addr_t child_offset = child_section->GetOffset();
251 if (child_offset <= offset &&
252 offset - child_offset <
253 child_section->GetByteSize() + (allow_section_end ? 1 : 0))
254 return child_section->ResolveContainedAddress(offset - child_offset,
255 so_addr, allow_section_end);
256 }
257 so_addr = Address(const_cast<Section *>(this)->shared_from_this(), offset);
258
259 // Ensure that there are no orphaned (i.e., moduleless) sections.
260 assert(GetModule().get());
261 return true;
262}
263
265 const addr_t file_addr = GetFileAddress();
266 if (file_addr != LLDB_INVALID_ADDRESS && !IsThreadSpecific()) {
267 if (file_addr <= vm_addr) {
268 const addr_t offset = vm_addr - file_addr;
269 return offset < GetByteSize();
270 }
271 }
272 return false;
273}
274
275void Section::Dump(llvm::raw_ostream &s, unsigned indent, Target *target,
276 uint32_t depth) const {
277 s.indent(indent);
278 s << llvm::format("0x%16.16" PRIx64 " %-22s ", GetID(), GetTypeAsCString());
279 bool resolved = true;
281
282 if (GetByteSize() == 0)
283 s.indent(39);
284 else {
285 if (target)
286 addr = GetLoadBaseAddress(target);
287
288 if (addr == LLDB_INVALID_ADDRESS) {
289 if (target)
290 resolved = false;
291 addr = GetFileAddress();
292 }
293
294 DumpAddressRange(s, addr, addr + m_byte_size, 8);
295 }
296
297 s << llvm::format("%c %c%c%c 0x%8.8" PRIx64 " 0x%8.8" PRIx64 " 0x%8.8x ",
298 resolved ? ' ' : '*', m_readable ? 'r' : '-',
299 m_writable ? 'w' : '-', m_executable ? 'x' : '-',
301
302 DumpName(s);
303
304 s << "\n";
305
306 if (depth > 0)
307 m_children.Dump(s, indent, target, false, depth - 1);
308}
309
310void Section::DumpName(llvm::raw_ostream &s) const {
311 SectionSP parent_sp(GetParent());
312 if (parent_sp) {
313 parent_sp->DumpName(s);
314 s << '.';
315 } else {
316 // The top most section prints the module basename
317 llvm::StringRef name;
318 ModuleSP module_sp(GetModule());
319
320 if (m_obj_file) {
321 const FileSpec &file_spec = m_obj_file->GetFileSpec();
322 name = file_spec.GetFilename();
323 }
324 if (name.empty() && module_sp)
325 name = module_sp->GetFileSpec().GetFilename();
326 if (!name.empty())
327 s << name << '.';
328 }
329 s << m_name;
330}
331
332bool Section::IsDescendant(const Section *section) {
333 if (this == section)
334 return true;
335 SectionSP parent_sp(GetParent());
336 if (parent_sp)
337 return parent_sp->IsDescendant(section);
338 return false;
339}
340
341bool Section::Slide(addr_t slide_amount, bool slide_children) {
343 if (slide_amount == 0)
344 return true;
345
346 m_file_addr += slide_amount;
347
348 if (slide_children)
349 m_children.Slide(slide_amount, slide_children);
350
351 return true;
352 }
353 return false;
354}
355
356/// Get the permissions as OR'ed bits from lldb::Permissions
357uint32_t Section::GetPermissions() const {
358 uint32_t permissions = 0;
359 if (m_readable)
360 permissions |= ePermissionsReadable;
361 if (m_writable)
362 permissions |= ePermissionsWritable;
363 if (m_executable)
364 permissions |= ePermissionsExecutable;
365 return permissions;
366}
367
368/// Set the permissions using bits OR'ed from lldb::Permissions
369void Section::SetPermissions(uint32_t permissions) {
370 m_readable = (permissions & ePermissionsReadable) != 0;
371 m_writable = (permissions & ePermissionsWritable) != 0;
372 m_executable = (permissions & ePermissionsExecutable) != 0;
373}
374
376 lldb::offset_t offset) {
377 if (m_obj_file)
378 return m_obj_file->ReadSectionData(this, offset, dst, dst_len);
379 return 0;
380}
381
383 if (m_obj_file)
384 return m_obj_file->ReadSectionData(this, section_data);
385 return 0;
386}
387
389 switch (m_type) {
391 case eSectionTypeCode:
393 case eSectionTypeData:
417 // Used for "__dof_cache" in mach-o or ".debug" for COFF which isn't debug
418 // information that we parse at all. This was causing system files with no
419 // debug info to show debug info byte sizes in the "statistics dump" output
420 // for each module. New "eSectionType" enums should be created for dedicated
421 // debug info that has a predefined format if we wish for these sections to
422 // show up as debug info.
424 return false;
425
460 case eSectionTypeCTF:
464 return true;
465 }
466 return false;
467}
468
470 return GetObjectFile()->IsGOTSection(*this);
471}
472
473#pragma mark SectionList
474
476
478 if (this != &rhs)
480 return *this;
481}
482
483size_t SectionList::AddSection(const lldb::SectionSP &section_sp) {
484 if (section_sp) {
485 size_t section_index = m_sections.size();
486 m_sections.push_back(section_sp);
487 return section_index;
488 }
489
490 return std::numeric_limits<size_t>::max();
491}
492
493// Warning, this can be slow as it's removing items from a std::vector.
495 if (idx < m_sections.size()) {
496 m_sections.erase(m_sections.begin() + idx);
497 return true;
498 }
499 return false;
500}
501
503 iterator sect_iter;
504 iterator begin = m_sections.begin();
505 iterator end = m_sections.end();
506 for (sect_iter = begin; sect_iter != end; ++sect_iter) {
507 if (sect_iter->get() == sect) {
508 // The secton was already in this section list
509 return std::distance(begin, sect_iter);
510 }
511 }
512 return UINT32_MAX;
513}
514
516 size_t sect_idx = FindSectionIndex(sect_sp.get());
517 if (sect_idx == UINT32_MAX) {
518 sect_idx = AddSection(sect_sp);
519 }
520 return sect_idx;
521}
522
524 const lldb::SectionSP &replace_sect_sp,
525 uint32_t depth) {
526 // Make sure this isn't the same section pointer.
527 if (remove_sect_sp == replace_sect_sp)
528 return false;
529 iterator sect_iter, end = m_sections.end();
530 for (sect_iter = m_sections.begin(); sect_iter != end; ++sect_iter) {
531 if (*sect_iter == remove_sect_sp) {
532 *sect_iter = replace_sect_sp;
533 return true;
534 } else if (depth > 0) {
535 if ((*sect_iter)
536 ->GetChildren()
537 .ReplaceSection(remove_sect_sp, replace_sect_sp, depth - 1))
538 return true;
539 }
540 }
541 return false;
542}
543
544size_t SectionList::GetNumSections(uint32_t depth) const {
545 size_t count = m_sections.size();
546 if (depth > 0) {
547 const_iterator sect_iter, end = m_sections.end();
548 for (sect_iter = m_sections.begin(); sect_iter != end; ++sect_iter) {
549 count += (*sect_iter)->GetChildren().GetNumSections(depth - 1);
550 }
551 }
552 return count;
553}
554
556 SectionSP sect_sp;
557 if (idx < m_sections.size())
558 sect_sp = m_sections[idx];
559 return sect_sp;
560}
561
562SectionSP SectionList::FindSectionByName(llvm::StringRef section_name) const {
563 SectionSP sect_sp;
564 // Check if we have a valid section string
565 if (!section_name.empty() && !m_sections.empty()) {
566 const_iterator sect_iter;
568 for (sect_iter = m_sections.begin();
569 sect_iter != end && sect_sp.get() == nullptr; ++sect_iter) {
570 Section *child_section = sect_iter->get();
571 if (child_section) {
572 if (child_section->GetName() == section_name) {
573 sect_sp = *sect_iter;
574 } else {
575 sect_sp =
576 child_section->GetChildren().FindSectionByName(section_name);
577 }
578 }
579 }
580 }
581 return sect_sp;
582}
583
585 SectionSP sect_sp;
586 if (sect_id) {
587 const_iterator sect_iter;
589 for (sect_iter = m_sections.begin();
590 sect_iter != end && sect_sp.get() == nullptr; ++sect_iter) {
591 if ((*sect_iter)->GetID() == sect_id) {
592 sect_sp = *sect_iter;
593 break;
594 } else {
595 sect_sp = (*sect_iter)->GetChildren().FindSectionByID(sect_id);
596 }
597 }
598 }
599 return sect_sp;
600}
601
603 bool check_children,
604 size_t start_idx) const {
605 SectionSP sect_sp;
606 size_t num_sections = m_sections.size();
607 for (size_t idx = start_idx; idx < num_sections; ++idx) {
608 if (m_sections[idx]->GetType() == sect_type) {
609 sect_sp = m_sections[idx];
610 break;
611 } else if (check_children) {
612 sect_sp = m_sections[idx]->GetChildren().FindSectionByType(
613 sect_type, check_children, 0);
614 if (sect_sp)
615 break;
616 }
617 }
618 return sect_sp;
619}
620
622 uint32_t depth) const {
623 SectionSP sect_sp;
624 const_iterator sect_iter;
626 for (sect_iter = m_sections.begin();
627 sect_iter != end && sect_sp.get() == nullptr; ++sect_iter) {
628 Section *sect = sect_iter->get();
629 if (sect->ContainsFileAddress(vm_addr)) {
630 // The file address is in this section. We need to make sure one of our
631 // child sections doesn't contain this address as well as obeying the
632 // depth limit that was passed in.
633 if (depth > 0)
635 vm_addr, depth - 1);
636
637 if (sect_sp.get() == nullptr && !sect->IsFake())
638 sect_sp = *sect_iter;
639 }
640 }
641 return sect_sp;
642}
643
645 return FindSectionByID(sect_id).get() != nullptr;
646}
647
648void SectionList::Dump(llvm::raw_ostream &s, unsigned indent, Target *target,
649 bool show_header, uint32_t depth) const {
650 bool target_has_loaded_sections = target && target->HasLoadedSections();
651 if (show_header && !m_sections.empty()) {
652 s.indent(indent);
653 s << llvm::formatv(
654 "SectID Type {0} Address "
655 " Perm File Off. File Size Flags Section Name\n",
656 target_has_loaded_sections ? "Load" : "File");
657 s.indent(indent);
658 s << "------------------ ---------------------- "
659 "--------------------------------------- ---- ---------- ---------- "
660 "---------- ----------------------------\n";
661 }
662
663 for (const auto &section_sp : m_sections)
664 section_sp->Dump(s, indent, target_has_loaded_sections ? target : nullptr,
665 depth);
666}
667
668size_t SectionList::Slide(addr_t slide_amount, bool slide_children) {
669 size_t count = 0;
670 const_iterator pos, end = m_sections.end();
671 for (pos = m_sections.begin(); pos != end; ++pos) {
672 if ((*pos)->Slide(slide_amount, slide_children))
673 ++count;
674 }
675 return count;
676}
677
679 uint64_t debug_info_size = 0;
680 for (const auto &section : m_sections) {
681 const SectionList &sub_sections = section->GetChildren();
682 if (sub_sections.GetSize() > 0)
683 debug_info_size += sub_sections.GetDebugInfoSize();
684 else if (section->ContainsOnlyDebugInfo())
685 debug_info_size += section->GetFileSize();
686 }
687 return debug_info_size;
688}
689
691 MergeCallback filter) {
692 SectionList output_list;
693
694 // Iterate through all the sections in lhs and see if we have matches in
695 // the rhs list.
696 for (const auto &lhs_section : lhs) {
697 auto rhs_section = rhs.FindSectionByName(lhs_section->GetName());
698 if (rhs_section)
699 output_list.AddSection(filter(lhs_section, rhs_section));
700 else
701 output_list.AddSection(lhs_section);
702 }
703
704 // Now that we've visited all possible duplicates, we can iterate over
705 // the rhs and take any values not in lhs.
706 for (const auto &rhs_section : rhs) {
707 auto lhs_section = lhs.FindSectionByName(rhs_section->GetName());
708 // Because we already visited everything overlapping between rhs
709 // and lhs, any section not in lhs is unique and can be output.
710 if (!lhs_section)
711 output_list.AddSection(rhs_section);
712 }
713
714 return output_list;
715}
716
717namespace llvm {
718namespace json {
719
720bool fromJSON(const llvm::json::Value &value,
721 lldb_private::JSONSection &section, llvm::json::Path path) {
722 llvm::json::ObjectMapper o(value, path);
723 return o && o.map("name", section.name) && o.map("type", section.type) &&
724 o.map("address", section.address) && o.map("size", section.size) &&
725 o.map("read", section.read) && o.map("write", section.write) &&
726 o.map("execute", section.execute) &&
727 o.mapOptional("subsections", section.subsections) &&
728 o.map("user_id", section.user_id) &&
729 o.map("file_offset", section.file_offset) &&
730 o.map("file_size", section.file_size) &&
731 o.map("alignment", section.log2align) &&
732 o.map("flags", section.flags) && o.map("fake", section.fake) &&
733 o.map("encrypted", section.encrypted) &&
734 o.map("thread_specific", section.thread_specific);
735}
736
737bool fromJSON(const llvm::json::Value &value, lldb::SectionType &type,
738 llvm::json::Path path) {
739 if (auto str = value.getAsString()) {
740 type = llvm::StringSwitch<lldb::SectionType>(*str)
741 .Case("code", eSectionTypeCode)
742 .Case("container", eSectionTypeContainer)
743 .Case("data", eSectionTypeData)
744 .Case("debug", eSectionTypeDebug)
745 .Default(eSectionTypeInvalid);
746
747 if (type == eSectionTypeInvalid) {
748 path.report("invalid section type");
749 return false;
750 }
751
752 return true;
753 }
754 path.report("expected string");
755 return false;
756}
757} // namespace json
758} // namespace llvm
A section + offset based address class.
Definition Address.h:62
A uniqued constant string class.
Definition ConstString.h:40
An data extractor class.
A file utility class.
Definition FileSpec.h:57
llvm::StringRef GetFilename() const
Filename string const get accessor.
Definition FileSpec.h:249
Flags(ValueType flags=0)
Construct with initial flag bit values.
Definition Flags.h:34
ValueType Get() const
Get accessor for all flags.
Definition Flags.h:40
ModuleChild(const lldb::ModuleSP &module_sp)
Construct with owning module.
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
A plug-in interface definition class for object file parsers.
Definition ObjectFile.h:46
virtual bool IsGOTSection(const lldb_private::Section &section) const
Returns true if the section is a global offset table section.
Definition ObjectFile.h:738
const_iterator begin() const
Definition Section.h:41
bool ContainsSection(lldb::user_id_t sect_id) const
Definition Section.cpp:644
bool ReplaceSection(const lldb::SectionSP &remove_section_sp, const lldb::SectionSP &replace_section_sp, uint32_t depth=UINT32_MAX)
Definition Section.cpp:523
const_iterator end() const
Definition Section.h:42
collection::iterator iterator
Definition Section.h:38
static SectionList Merge(SectionList &lhs, SectionList &rhs, MergeCallback filter)
Definition Section.cpp:690
size_t GetNumSections(uint32_t depth) const
Definition Section.cpp:544
lldb::SectionSP FindSectionByID(lldb::user_id_t sect_id) const
Definition Section.cpp:584
SectionList()=default
Create an empty list.
size_t Slide(lldb::addr_t slide_amount, bool slide_children)
Definition Section.cpp:668
lldb::SectionSP FindSectionContainingFileAddress(lldb::addr_t addr, uint32_t depth=UINT32_MAX) const
Definition Section.cpp:621
uint64_t GetDebugInfoSize() const
Get the debug information size from all sections that contain debug information.
Definition Section.cpp:678
size_t GetSize() const
Definition Section.h:77
lldb::SectionSP FindSectionByName(llvm::StringRef section_name) const
Definition Section.cpp:562
std::function< lldb::SectionSP(lldb::SectionSP, lldb::SectionSP)> MergeCallback
Definition Section.h:103
bool DeleteSection(size_t idx)
Definition Section.cpp:494
size_t AddSection(const lldb::SectionSP &section_sp)
Definition Section.cpp:483
SectionList & operator=(const SectionList &rhs)
Definition Section.cpp:477
size_t FindSectionIndex(const Section *sect)
Definition Section.cpp:502
lldb::SectionSP FindSectionByType(lldb::SectionType sect_type, bool check_children, size_t start_idx=0) const
Definition Section.cpp:602
size_t AddUniqueSection(const lldb::SectionSP &section_sp)
Definition Section.cpp:515
void Dump(llvm::raw_ostream &s, unsigned indent, Target *target, bool show_header, uint32_t depth) const
Definition Section.cpp:648
lldb::SectionSP GetSectionAtIndex(size_t idx) const
Definition Section.cpp:555
collection::const_iterator const_iterator
Definition Section.h:39
bool IsThreadSpecific() const
Definition Section.h:221
bool ContainsFileAddress(lldb::addr_t vm_addr) const
Definition Section.cpp:264
lldb::addr_t m_byte_size
Definition Section.h:296
lldb::addr_t GetOffset() const
Definition Section.cpp:219
lldb::addr_t m_file_addr
Definition Section.h:293
void SetPermissions(uint32_t permissions)
Set the permissions using bits OR'ed from lldb::Permissions.
Definition Section.cpp:369
bool IsFake() const
Definition Section.h:201
void DumpName(llvm::raw_ostream &s) const
Definition Section.cpp:310
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.
Definition Section.cpp:375
bool IsDescendant(const Section *section)
Definition Section.cpp:332
bool IsGOTSection() const
Returns true if this is a global offset table section.
Definition Section.cpp:469
ObjectFile * m_obj_file
Definition Section.h:288
lldb::SectionSP GetParent() const
Definition Section.h:219
uint32_t GetPermissions() const
Get the permissions as OR'ed bits from lldb::Permissions.
Definition Section.cpp:357
bool SetFileAddress(lldb::addr_t file_addr)
Definition Section.cpp:206
llvm::StringRef GetName() const
Definition Section.h:211
lldb::SectionWP m_parent_wp
Definition Section.h:291
ConstString m_name
Definition Section.h:292
lldb::addr_t GetFileAddress() const
Definition Section.cpp:194
SectionList & GetChildren()
Definition Section.h:167
lldb::SectionType m_type
Definition Section.h:290
ObjectFile * GetObjectFile()
Definition Section.h:231
bool ContainsOnlyDebugInfo() const
Returns true if this section contains debug information.
Definition Section.cpp:388
void Dump(llvm::raw_ostream &s, unsigned indent, Target *target, uint32_t depth) const
Definition Section.cpp:275
const char * GetTypeAsCString() const
Definition Section.cpp:26
lldb::addr_t GetLoadBaseAddress(Target *target) const
Definition Section.cpp:229
bool Slide(lldb::addr_t slide_amount, bool slide_children)
Definition Section.cpp:341
bool ResolveContainedAddress(lldb::addr_t offset, Address &so_addr, bool allow_section_end=false) const
Definition Section.cpp:244
lldb::offset_t m_file_offset
Definition Section.h:298
lldb::offset_t m_file_size
Definition Section.h:299
lldb::addr_t GetByteSize() const
Definition Section.h:197
SectionList m_children
Definition Section.h:303
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)
Definition Section.cpp:164
lldb::addr_t GetSectionLoadAddress(const lldb::SectionSP &section_sp)
Definition Target.cpp:6034
#define LLDB_INVALID_ADDRESS
#define UINT32_MAX
A class that represents a running process on the host machine.
void DumpAddressRange(llvm::raw_ostream &s, uint64_t lo_addr, uint64_t hi_addr, uint32_t addr_size, const char *prefix=nullptr, const char *suffix=nullptr)
Output an address range to this stream.
Definition Stream.cpp:120
bool fromJSON(const llvm::json::Value &value, SymbolValue &data, llvm::json::Path path)
uint64_t offset_t
Definition lldb-types.h:85
uint64_t user_id_t
Definition lldb-types.h:82
std::shared_ptr< lldb_private::Section > SectionSP
uint64_t addr_t
Definition lldb-types.h:80
@ eSectionTypeDWARFDebugStrOffsets
@ eSectionTypeELFDynamicSymbols
Elf SHT_DYNSYM section.
@ eSectionTypeInvalid
@ eSectionTypeDWARFDebugPubNames
@ eSectionTypeDataObjCCFStrings
Objective-C const CFString/NSString objects.
@ eSectionTypeZeroFill
@ eSectionTypeDWARFDebugLocDwo
@ eSectionTypeDWARFDebugFrame
@ eSectionTypeARMextab
@ eSectionTypeContainer
The section contains child sections.
@ eSectionTypeDWARFDebugLocLists
DWARF v5 .debug_loclists.
@ eSectionTypeDWARFDebugTypes
DWARF .debug_types section.
@ eSectionTypeDataSymbolAddress
Address of a symbol in the symbol table.
@ eSectionTypeELFDynamicLinkInfo
Elf SHT_DYNAMIC section.
@ eSectionTypeDWARFDebugMacInfo
@ eSectionTypeAbsoluteAddress
Dummy section for symbols with absolute address.
@ eSectionTypeCompactUnwind
compact unwind section in Mach-O, __TEXT,__unwind_info
@ eSectionTypeELFRelocationEntries
Elf SHT_REL or SHT_REL section.
@ eSectionTypeDWARFAppleNamespaces
@ eSectionTypeLLDBFormatters
@ eSectionTypeDWARFDebugNames
DWARF v5 .debug_names.
@ eSectionTypeDWARFDebugRngLists
DWARF v5 .debug_rnglists.
@ eSectionTypeEHFrame
@ eSectionTypeDWARFDebugStrOffsetsDwo
@ eSectionTypeDWARFDebugMacro
@ eSectionTypeDWARFAppleTypes
@ eSectionTypeWasmGlobal
@ eSectionTypeDWARFDebugInfo
@ eSectionTypeDWARFDebugTypesDwo
@ eSectionTypeDWARFDebugRanges
@ eSectionTypeDWARFDebugRngListsDwo
@ eSectionTypeLLDBTypeSummaries
@ eSectionTypeGoSymtab
@ eSectionTypeARMexidx
@ eSectionTypeDWARFDebugLine
@ eSectionTypeDWARFDebugPubTypes
@ eSectionTypeDataObjCMessageRefs
Pointer to function pointer + selector.
@ eSectionTypeDWARFDebugTuIndex
@ eSectionTypeDWARFDebugStr
@ eSectionTypeDWARFDebugLineStr
DWARF v5 .debug_line_str.
@ eSectionTypeDWARFDebugLoc
@ eSectionTypeDWARFAppleNames
@ eSectionTypeDataCStringPointers
Pointers to C string data.
@ eSectionTypeDWARFAppleObjC
@ eSectionTypeSwiftModules
@ eSectionTypeDWARFDebugCuIndex
@ eSectionTypeDWARFDebugAranges
@ eSectionTypeDWARFDebugAbbrevDwo
@ eSectionTypeDWARFGNUDebugAltLink
@ eSectionTypeDWARFDebugStrDwo
@ eSectionTypeDWARFDebugAbbrev
@ eSectionTypeDataPointers
@ eSectionTypeDWARFDebugLocListsDwo
@ eSectionTypeDWARFDebugInfoDwo
@ eSectionTypeDWARFDebugAddr
@ eSectionTypeWasmName
@ eSectionTypeDataCString
Inlined C string data.
@ eSectionTypeELFSymbolTable
Elf SHT_SYMTAB section.
std::shared_ptr< lldb_private::Module > ModuleSP
std::optional< lldb::user_id_t > user_id
Definition Section.h:117
std::optional< uint64_t > log2align
Definition Section.h:124
std::optional< uint64_t > size
Definition Section.h:121
std::optional< uint64_t > flags
Definition Section.h:125
std::optional< bool > encrypted
Definition Section.h:133
std::optional< bool > fake
Definition Section.h:132
std::optional< lldb::SectionType > type
Definition Section.h:119
std::optional< bool > write
Definition Section.h:129
std::optional< bool > execute
Definition Section.h:130
std::optional< uint64_t > file_offset
Definition Section.h:122
std::optional< uint64_t > address
Definition Section.h:120
std::optional< bool > thread_specific
Definition Section.h:134
std::optional< uint64_t > file_size
Definition Section.h:123
std::vector< JSONSection > subsections
Definition Section.h:136
std::optional< bool > read
Definition Section.h:128
UserID(lldb::user_id_t uid=LLDB_INVALID_UID)
Construct with optional user ID.
Definition UserID.h:33
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition UserID.h:47