Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Docs/generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ list, regular member-table entry, root entry, or loaded class/category
relationship preserves its readable siblings and produces a typed degradation;
unloaded relative lists are skipped without warning. These guarantees cover
structural table, list, and layout ranges; they do not validate referenced C
strings or loaded class RW-extension arrays. Once that target is published,
PrivateHeaderKit reports the precise owner and degradation as an
strings. MachOObjCSection's public loaded class RW-extension list-array queries
now apply the same bounded structural reads, although PrivateHeaderKit's current
raw dump does not query that dependency surface. When a queried target is
degraded, PrivateHeaderKit reports the precise owner and degradation as an
`objc-metadata-warning` and persists the warning in `generation.sqlite`. A
bounded diagnostics report records when additional warnings were omitted, so
malformed metadata cannot grow process output without limit. Live warning
Expand Down
4 changes: 2 additions & 2 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ let package = Package(
),
.package(
url: "https://github.com/lynnswap/MachOObjCSection.git",
revision: "8f0ff76f02c0865422a72662177b5e687e43522d"
revision: "cc9a70f46d69683882dedce7d6d293a565e7863a"
),
.package(
url: "https://github.com/MxIris-Reverse-Engineering/swift-objc-dump.git",
from: "0.8.100"
),
.package(
url: "https://github.com/lynnswap/MachOSwiftSection.git",
revision: "06ed57ab39fc24956f9079beeb407fffa30d50f4"
revision: "905703af9d192c778054417a1a5052a26051cc96"
),
.package(
url: "https://github.com/MxIris-Reverse-Engineering/swift-demangling",
Expand Down
19 changes: 18 additions & 1 deletion Sources/PrivateHeaderKitRawDumpCore/RawDumpObjCDiagnostics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ private func privateHeaderKitDiagnostic(
)
}

private func rawDumpMetadataTableDiagnostic(
func rawDumpMetadataTableDiagnostic(
owner: ObjCMetadataTableDiagnostic.Owner,
site: ObjCMetadataTableDiagnostic.Site,
failure: ObjCMetadataTableDiagnostic.Failure
Expand All @@ -289,6 +289,11 @@ private func rawDumpMetadataTableDiagnostic(
metadataDescription =
"\(pointerWidthDescription(pointerWidth))"
+ " \(rootSectionDescription(section)) root table"
case let .loadedRWExtension(kind, pointerWidth):
ownerDescription = "Objective-C loaded RW-extension list arrays"
metadataDescription =
"\(pointerWidthDescription(pointerWidth))"
+ " \(rwExtensionListKindDescription(kind)) list array"
case let .loadedRelationship(subject, role):
ownerDescription = subjectDescription(subject)
metadataDescription = "\(loadedRelationshipDescription(role)) relationship"
Expand Down Expand Up @@ -363,6 +368,16 @@ private func pointerWidthDescription(
}
}

private func rwExtensionListKindDescription(
_ kind: ObjCMetadataTableDiagnostic.RWExtensionListKind
) -> String {
switch kind {
case .method: "method"
case .property: "property"
case .protocol: "protocol"
}
}

private func loadedRelationshipDescription(
_ role: ObjCMetadataTableDiagnostic.LoadedRelationshipRole
) -> String {
Expand Down Expand Up @@ -690,5 +705,7 @@ private func failureDescription(
case let .invalidEntryArithmetic(baseAddress, targetAddress):
"target address \(targetAddress) cannot be represented relative"
+ " to base address \(baseAddress)"
case .relativeImageUnavailable(let imageIndex):
"cache image index \(imageIndex) is unavailable"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ struct PrivateHeaderKitHelperProtocolTests {
let state = try #require(pin["state"] as? [String: Any])

#expect(pin["location"] as? String == "https://github.com/lynnswap/MachOObjCSection.git")
#expect(state["revision"] as? String == "8f0ff76f02c0865422a72662177b5e687e43522d")
#expect(state["revision"] as? String == "cc9a70f46d69683882dedce7d6d293a565e7863a")
#expect(state["version"] == nil)

let swiftSectionPin = try #require(
Expand All @@ -307,7 +307,7 @@ struct PrivateHeaderKitHelperProtocolTests {
)
#expect(
swiftSectionState["revision"] as? String
== "06ed57ab39fc24956f9079beeb407fffa30d50f4"
== "905703af9d192c778054417a1a5052a26051cc96"
)
#expect(swiftSectionState["version"] == nil)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,40 @@ struct ObjCMemberListDiagnosticsTests {
)
}

@Test func loadedRWExtensionDiagnosticsKeepKindWidthAndUnavailableImage() throws {
let fixture = try InvalidFileRootFixture()
let seedDiagnostic = try #require(
fixture.machO.objc.readRoots().tableDiagnostics.first
)
let cases: [(
ObjCMetadataTableDiagnostic.RWExtensionListKind,
ObjCMetadataTableDiagnostic.PointerWidth,
String
)] = [
(.method, .bits64, "64-bit method"),
(.property, .bits32, "32-bit property"),
(.protocol, .bits64, "64-bit protocol"),
]

for (kind, pointerWidth, prefix) in cases {
let record = rawDumpMetadataTableDiagnostic(
owner: .loadedRWExtension(
kind: kind,
pointerWidth: pointerWidth
),
site: seedDiagnostic.site,
failure: .relativeImageUnavailable(imageIndex: 1_194)
)

#expect(record.owner == "Objective-C loaded RW-extension list arrays")
#expect(
record.degradation
== "\(prefix) list array could not be fully read:"
+ " cache image index 1194 is unavailable"
)
}
}

@Test func wholeTableFailureKeepsMemberKindAndOuterOffset() {
let record = rawDumpMemberListDiagnostic(
className: "Owner",
Expand Down