-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read and write a LC_NOTE "addrable bits" for addressing mask
This patch adds code to process save-core for Mach-O files which embeds an "addrable bits" LC_NOTE when the process is using a code address mask (e.g. AArch64 v8.3 with ptrauth aka arm64e). Add code to ObjectFileMachO to read that LC_NOTE from corefiles, and ProcessMachCore to set the process masks based on it when reading a corefile back in. Also have "process status --verbose" print the current address masks that lldb is using internally to strip ptrauth bits off of addresses. Differential Revision: https://reviews.llvm.org/D106348 rdar://68630113
- Loading branch information
1 parent
924d62c
commit cdc6f8d
Showing
9 changed files
with
221 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
C_SOURCES := main.c | ||
|
||
include Makefile.rules |
59 changes: 59 additions & 0 deletions
59
lldb/test/API/macosx/lc-note/addrable-bits/TestAddrableBitsCorefile.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"""Test that corefiles with LC_NOTE "addrable bits" load command, creating and reading.""" | ||
|
||
|
||
|
||
import os | ||
import re | ||
import subprocess | ||
|
||
import lldb | ||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test import lldbutil | ||
|
||
|
||
class TestAddrableBitsCorefile(TestBase): | ||
|
||
mydir = TestBase.compute_mydir(__file__) | ||
NO_DEBUG_INFO_TESTCASE = True | ||
|
||
def initial_setup(self): | ||
self.build() | ||
self.exe = self.getBuildArtifact("a.out") | ||
self.corefile = self.getBuildArtifact("corefile") | ||
|
||
@skipIf(archs=no_match(['arm64e'])) | ||
@skipUnlessDarwin | ||
def test_lc_note_addrable_bits(self): | ||
self.initial_setup() | ||
|
||
self.target = self.dbg.CreateTarget(self.exe) | ||
err = lldb.SBError() | ||
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, "break here", | ||
lldb.SBFileSpec('main.c')) | ||
self.assertEqual(process.IsValid(), True) | ||
|
||
found_main = False | ||
for f in thread.frames: | ||
if f.GetFunctionName() == "main": | ||
found_main = True | ||
self.assertTrue(found_main) | ||
|
||
cmdinterp = self.dbg.GetCommandInterpreter() | ||
res = lldb.SBCommandReturnObject() | ||
cmdinterp.HandleCommand("process save-core %s" % self.corefile, res) | ||
self.assertTrue(res.Succeeded(), True) | ||
process.Kill() | ||
self.dbg.DeleteTarget(target) | ||
|
||
target = self.dbg.CreateTarget('') | ||
process = target.LoadCore(self.corefile) | ||
self.assertTrue(process.IsValid(), True) | ||
thread = process.GetSelectedThread() | ||
|
||
found_main = False | ||
for f in thread.frames: | ||
if f.GetFunctionName() == "main": | ||
found_main = True | ||
self.assertTrue(found_main) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
int pat (int in) { | ||
return in + 5; // break here | ||
} | ||
|
||
int tat (int in) { return pat(in + 10); } | ||
|
||
int mat (int in) { return tat(in + 15); } | ||
|
||
int main() { | ||
int (*matp)(int) = mat; | ||
return matp(10); | ||
} |