From b6ce889c8ddfe5cadb3efc5dcf96438f6f195ec3 Mon Sep 17 00:00:00 2001 From: Augusto Noronha Date: Fri, 11 Jul 2025 16:33:19 -0700 Subject: [PATCH] [RemoteMirrors] Fix losing the remote address on StaticMirror The Offset field of a DynamicRelocation is either an offset or a remote address, but was being treated only as a remote address on getDynamicSymbol. --- include/swift/StaticMirror/ObjectFileContext.h | 6 +++++- lib/StaticMirror/ObjectFileContext.cpp | 7 ++++++- test/Reflection/conformance_descriptors.swift | 1 - test/Reflection/typeref_decoding.swift | 1 - 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/swift/StaticMirror/ObjectFileContext.h b/include/swift/StaticMirror/ObjectFileContext.h index dec6641e3703b..927418cf5b7c7 100644 --- a/include/swift/StaticMirror/ObjectFileContext.h +++ b/include/swift/StaticMirror/ObjectFileContext.h @@ -39,8 +39,12 @@ class Image { uint64_t HeaderAddress; std::vector Segments; struct DynamicRelocation { + /// The symbol name that the pointer refers to. Empty if only an absolute + /// address is available. StringRef Symbol; - uint64_t Offset; + // The offset (if the symbol is available), or the resolved remote address + // if the symbol is empty. + uint64_t OffsetOrAddress; }; llvm::DenseMap DynamicRelocations; diff --git a/lib/StaticMirror/ObjectFileContext.cpp b/lib/StaticMirror/ObjectFileContext.cpp index 43d38baea6751..4ad8d5c3ce3e5 100644 --- a/lib/StaticMirror/ObjectFileContext.cpp +++ b/lib/StaticMirror/ObjectFileContext.cpp @@ -333,8 +333,13 @@ remote::RemoteAbsolutePointer Image::getDynamicSymbol(uint64_t Addr) const { auto found = DynamicRelocations.find(Addr); if (found == DynamicRelocations.end()) return nullptr; + if (!found->second.Symbol.empty()) + return remote::RemoteAbsolutePointer(found->second.Symbol, + found->second.OffsetOrAddress, + remote::RemoteAddress()); return remote::RemoteAbsolutePointer( - found->second.Symbol, found->second.Offset, remote::RemoteAddress()); + remote::RemoteAddress(found->second.OffsetOrAddress, + remote::RemoteAddress::DefaultAddressSpace)); } std::pair diff --git a/test/Reflection/conformance_descriptors.swift b/test/Reflection/conformance_descriptors.swift index e1bd98c08f4af..b114f76455280 100644 --- a/test/Reflection/conformance_descriptors.swift +++ b/test/Reflection/conformance_descriptors.swift @@ -5,7 +5,6 @@ // // Temporarily disable on AArch64 Linux (rdar://88451721) // UNSUPPORTED: OS=linux-gnu && CPU=aarch64 -// XFAIL: OS=linux-android // rdar://100558042 // UNSUPPORTED: CPU=arm64e diff --git a/test/Reflection/typeref_decoding.swift b/test/Reflection/typeref_decoding.swift index c01af893eda48..e0a3b4465a39e 100644 --- a/test/Reflection/typeref_decoding.swift +++ b/test/Reflection/typeref_decoding.swift @@ -10,7 +10,6 @@ // FIXME: rdar://127796117 // UNSUPPORTED: OS=linux-gnu && CPU=aarch64 -// XFAIL: OS=linux-android // RUN: %target-build-swift -target %target-swift-5.2-abi-triple -Xfrontend -enable-anonymous-context-mangled-names %S/Inputs/ConcreteTypes.swift %S/Inputs/GenericTypes.swift %S/Inputs/Protocols.swift %S/Inputs/Extensions.swift %S/Inputs/Closures.swift -parse-as-library -emit-module -emit-library %no-fixup-chains -module-name TypesToReflect -o %t/%target-library-name(TypesToReflect) // RUN: %target-build-swift -target %target-swift-5.2-abi-triple -Xfrontend -enable-anonymous-context-mangled-names %S/Inputs/ConcreteTypes.swift %S/Inputs/GenericTypes.swift %S/Inputs/Protocols.swift %S/Inputs/Extensions.swift %S/Inputs/Closures.swift %S/Inputs/main.swift -emit-module -emit-executable %no-fixup-chains -module-name TypesToReflect -o %t/TypesToReflect