Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 623e845

Browse files
committed
Recognize BSS-only DATA segments as sections that need to be slid
ObjectFileMachO::SetLoadAddress() should allow for a DATA segment that has no file content to be slid in the vmaddr, it is valid to have such a section. Differential Revision: https://reviews.llvm.org/D154037 rdar://99744343
1 parent 35bb2bb commit 623e845

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -6048,7 +6048,8 @@ bool ObjectFileMachO::SectionIsLoadable(const Section *section) {
60486048
if (!section)
60496049
return false;
60506050
const bool is_dsym = (m_header.filetype == MH_DSYM);
6051-
if (section->GetFileSize() == 0 && !is_dsym)
6051+
if (section->GetFileSize() == 0 && !is_dsym &&
6052+
section->GetName() != GetSegmentNameDATA())
60526053
return false;
60536054
if (section->IsThreadSpecific())
60546055
return false;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
C_SOURCES := main.c
2+
3+
include Makefile.rules
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""Test that we a BSS-data only DATA segment is slid with other segments."""
2+
3+
import lldb
4+
from lldbsuite.test.decorators import *
5+
from lldbsuite.test.lldbtest import *
6+
from lldbsuite.test import lldbutil
7+
8+
9+
class TestBSSOnlyDataSectionSliding(TestBase):
10+
@skipUnlessDarwin
11+
def test_with_python_api(self):
12+
"""Test that we get thread names when interrupting a process."""
13+
self.build()
14+
exe = self.getBuildArtifact("a.out")
15+
16+
target = self.dbg.CreateTarget(exe, "", "", False, lldb.SBError())
17+
self.assertTrue(target, VALID_TARGET)
18+
19+
module = target.modules[0]
20+
self.assertTrue(module.IsValid())
21+
data_sect = module.section["__DATA"]
22+
self.assertTrue(data_sect.IsValid())
23+
24+
target.SetModuleLoadAddress(module, 0x170000000)
25+
self.assertEqual(
26+
data_sect.GetFileAddress() + 0x170000000, data_sect.GetLoadAddress(target)
27+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
int glob = 0;
2+
int main() { return glob; }

0 commit comments

Comments
 (0)