Skip to content

Commit 1d28563

Browse files
committed
Check for stack truncations in the link map code, surprisingly.
1 parent 6134c0b commit 1d28563

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
@@ -6577,7 +6577,8 @@ static void AddSegmentRegisterSections(Process &process, ThreadSP &thread_sp,
65776577
AddRegion(thread_local_region, true, ranges);
65786578
}
65796579

6580-
static void AddLinkMapSections(Process &process, CoreFileMemoryRanges &ranges) {
6580+
static void AddLinkMapSections(Process &process, CoreFileMemoryRanges &ranges,
6581+
std::set<addr_t> &stack_ends) {
65816582
ModuleList &module_list = process.GetTarget().GetImages();
65826583
Target *target = &process.GetTarget();
65836584
for (size_t idx = 0; idx < module_list.GetSize(); idx++) {
@@ -6598,6 +6599,11 @@ static void AddLinkMapSections(Process &process, CoreFileMemoryRanges &ranges) {
65986599
if (err.Fail())
65996600
continue;
66006601

6602+
// Sometimes, the link map section is included in one of the stack memory
6603+
// ranges. In that case, we already saved a truncated version of that range
6604+
if (stack_ends.count(link_map_section.GetRange().GetRangeEnd()) == 0)
6605+
continue;
6606+
66016607
AddRegion(link_map_section, true, ranges);
66026608
}
66036609
}
@@ -6754,7 +6760,7 @@ Status Process::CalculateCoreFileSaveRanges(const SaveCoreOptions &options,
67546760
SaveOffRegionsWithStackPointers(*this, options, regions, ranges,
67556761
stack_ends);
67566762
// We need the link map for TLS data.
6757-
AddLinkMapSections(*this, ranges);
6763+
AddLinkMapSections(*this, ranges, stack_ends);
67586764
}
67596765

67606766
switch (core_style) {

0 commit comments

Comments
 (0)