mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
MetadataReader: Add an API for reading absolute pointers.
Pointer data in some remote reflection targets may required relocation, or may not be fully resolvable, such as when we're dumping info from a single image on disk that references other dynamic libraries. Add a `RemoteAbsolutePointer` type that can hold a symbol, offset, or combination of both, and add APIs to `MemoryReader` and `MetadataReader` for reading pointers that can get unresolved relocation info from an image, or apply relocations to pointer information. MetadataReader can use the symbol name information to fill in demanglings of symbolic-reference-bearing mangled names by using the information from the symbol name to fill in the name even though the context descriptors are not available. For now, this is NFC (MemoryReader::resolvePointer just forwards the pointer data), but lays the groundwork for implementation of relocation in ObjectMemoryReader.
This commit is contained in:
@@ -491,7 +491,7 @@ public:
|
||||
|
||||
Result<OpenedExistential>
|
||||
getDynamicTypeAndAddressClassExistential(RemoteAddress object) {
|
||||
auto pointerval = Reader.readPointerValue(object.getAddressData());
|
||||
auto pointerval = Reader.readResolvedPointerValue(object.getAddressData());
|
||||
if (!pointerval)
|
||||
return getFailure<OpenedExistential>();
|
||||
auto result = Reader.readMetadataFromInstance(*pointerval);
|
||||
@@ -508,7 +508,7 @@ public:
|
||||
getDynamicTypeAndAddressErrorExistential(RemoteAddress object,
|
||||
bool dereference=true) {
|
||||
if (dereference) {
|
||||
auto pointerval = Reader.readPointerValue(object.getAddressData());
|
||||
auto pointerval = Reader.readResolvedPointerValue(object.getAddressData());
|
||||
if (!pointerval)
|
||||
return getFailure<OpenedExistential>();
|
||||
object = RemoteAddress(*pointerval);
|
||||
@@ -531,7 +531,7 @@ public:
|
||||
auto payloadAddress = result->PayloadAddress;
|
||||
if (!result->IsBridgedError &&
|
||||
typeResult->getClassOrBoundGenericClass()) {
|
||||
auto pointerval = Reader.readPointerValue(
|
||||
auto pointerval = Reader.readResolvedPointerValue(
|
||||
payloadAddress.getAddressData());
|
||||
if (!pointerval)
|
||||
return getFailure<OpenedExistential>();
|
||||
@@ -559,7 +559,7 @@ public:
|
||||
// of the reference.
|
||||
auto payloadAddress = result->PayloadAddress;
|
||||
if (typeResult->getClassOrBoundGenericClass()) {
|
||||
auto pointerval = Reader.readPointerValue(
|
||||
auto pointerval = Reader.readResolvedPointerValue(
|
||||
payloadAddress.getAddressData());
|
||||
if (!pointerval)
|
||||
return getFailure<OpenedExistential>();
|
||||
@@ -578,7 +578,7 @@ public:
|
||||
// 1) Loading a pointer from the input address
|
||||
// 2) Reading it as metadata and resolving the type
|
||||
// 3) Wrapping the resolved type in an existential metatype.
|
||||
auto pointerval = Reader.readPointerValue(object.getAddressData());
|
||||
auto pointerval = Reader.readResolvedPointerValue(object.getAddressData());
|
||||
if (!pointerval)
|
||||
return getFailure<OpenedExistential>();
|
||||
auto typeResult = Reader.readTypeFromMetadata(*pointerval);
|
||||
|
||||
Reference in New Issue
Block a user