Skip to content

Commit 36a91b1

Browse files
committed
Check for stack truncations in the link map code, surprisingly.
1 parent f448ad2 commit 36a91b1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lldb/source/Target/Process.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6566,7 +6566,8 @@ static void AddSegmentRegisterSections(Process &process, ThreadSP &thread_sp,
65666566
AddRegion(thread_local_region, true, ranges);
65676567
}
65686568

6569-
static void AddLinkMapSections(Process &process, CoreFileMemoryRanges &ranges) {
6569+
static void AddLinkMapSections(Process &process, CoreFileMemoryRanges &ranges,
6570+
std::set<addr_t> &stack_ends) {
65706571
ModuleList &module_list = process.GetTarget().GetImages();
65716572
Target *target = &process.GetTarget();
65726573
for (size_t idx = 0; idx < module_list.GetSize(); idx++) {
@@ -6587,6 +6588,11 @@ static void AddLinkMapSections(Process &process, CoreFileMemoryRanges &ranges) {
65876588
if (err.Fail())
65886589
continue;
65896590

6591+
// Sometimes, the link map section is included in one of the stack memory
6592+
// ranges. In that case, we already saved a truncated version of that range
6593+
if (stack_ends.count(link_map_section.GetRange().GetRangeEnd()) == 0)
6594+
continue;
6595+
65906596
AddRegion(link_map_section, true, ranges);
65916597
}
65926598
}
@@ -6743,7 +6749,7 @@ Status Process::CalculateCoreFileSaveRanges(const SaveCoreOptions &options,
67436749
SaveOffRegionsWithStackPointers(*this, options, regions, ranges,
67446750
stack_ends);
67456751
// We need the link map for TLS data.
6746-
AddLinkMapSections(*this, ranges);
6752+
AddLinkMapSections(*this, ranges, stack_ends);
67476753
}
67486754

67496755
switch (core_style) {

0 commit comments

Comments
 (0)