Skip to content

Commit 3602748

Browse files
authored
Merge pull request #8943 from jasonmolenda/cp/r129870649-pure-bss-segments-are-loadable-6.0
[lldb] [ObjectFileMachO] BSS segments are loadable segments (llvm#96983)
2 parents 97d4829 + 80d20ca commit 3602748

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6189,10 +6189,6 @@ Section *ObjectFileMachO::GetMachHeaderSection() {
61896189
bool ObjectFileMachO::SectionIsLoadable(const Section *section) {
61906190
if (!section)
61916191
return false;
6192-
const bool is_dsym = (m_header.filetype == MH_DSYM);
6193-
if (section->GetFileSize() == 0 && !is_dsym &&
6194-
section->GetName() != GetSegmentNameDATA())
6195-
return false;
61966192
if (section->IsThreadSpecific())
61976193
return false;
61986194
if (GetModule().get() != section->GetModule().get())
@@ -6232,6 +6228,7 @@ lldb::addr_t ObjectFileMachO::CalculateSectionLoadAddressForMemoryImage(
62326228

62336229
bool ObjectFileMachO::SetLoadAddress(Target &target, lldb::addr_t value,
62346230
bool value_is_offset) {
6231+
Log *log(GetLog(LLDBLog::DynamicLoader));
62356232
ModuleSP module_sp = GetModule();
62366233
if (!module_sp)
62376234
return false;
@@ -6247,17 +6244,33 @@ bool ObjectFileMachO::SetLoadAddress(Target &target, lldb::addr_t value,
62476244
// malformed.
62486245
const bool warn_multiple = true;
62496246

6247+
if (log) {
6248+
StreamString logmsg;
6249+
logmsg << "ObjectFileMachO::SetLoadAddress ";
6250+
if (GetFileSpec())
6251+
logmsg << "path='" << GetFileSpec().GetPath() << "' ";
6252+
if (GetUUID()) {
6253+
logmsg << "uuid=" << GetUUID().GetAsString();
6254+
}
6255+
LLDB_LOGF(log, "%s", logmsg.GetData());
6256+
}
62506257
if (value_is_offset) {
62516258
// "value" is an offset to apply to each top level segment
62526259
for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
62536260
// Iterate through the object file sections to find all of the
62546261
// sections that size on disk (to avoid __PAGEZERO) and load them
62556262
SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
6256-
if (SectionIsLoadable(section_sp.get()))
6263+
if (SectionIsLoadable(section_sp.get())) {
6264+
LLDB_LOGF(log,
6265+
"ObjectFileMachO::SetLoadAddress segment '%s' load addr is "
6266+
"0x%" PRIx64,
6267+
section_sp->GetName().AsCString(),
6268+
section_sp->GetFileAddress() + value);
62576269
if (target.GetSectionLoadList().SetSectionLoadAddress(
62586270
section_sp, section_sp->GetFileAddress() + value,
62596271
warn_multiple))
62606272
++num_loaded_sections;
6273+
}
62616274
}
62626275
} else {
62636276
// "value" is the new base address of the mach_header, adjust each
@@ -6272,6 +6285,10 @@ bool ObjectFileMachO::SetLoadAddress(Target &target, lldb::addr_t value,
62726285
CalculateSectionLoadAddressForMemoryImage(
62736286
value, mach_header_section, section_sp.get());
62746287
if (section_load_addr != LLDB_INVALID_ADDRESS) {
6288+
LLDB_LOGF(log,
6289+
"ObjectFileMachO::SetLoadAddress segment '%s' load addr is "
6290+
"0x%" PRIx64,
6291+
section_sp->GetName().AsCString(), section_load_addr);
62756292
if (target.GetSectionLoadList().SetSectionLoadAddress(
62766293
section_sp, section_load_addr, warn_multiple))
62776294
++num_loaded_sections;

0 commit comments

Comments
 (0)