Skip to content

Commit 9e85b88

Browse files
committed
[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.
1 parent bfb026c commit 9e85b88

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

include/swift/StaticMirror/ObjectFileContext.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ class Image {
3939
uint64_t HeaderAddress;
4040
std::vector<Segment> Segments;
4141
struct DynamicRelocation {
42+
/// The symbol name that the pointer refers to. Empty if only an absolute
43+
/// address is available.
4244
StringRef Symbol;
43-
uint64_t Offset;
45+
// The offset (if the symbol is available), or the resolved remote address
46+
// if the symbol is empty.
47+
uint64_t OffsetOrAddress;
4448
};
4549
llvm::DenseMap<uint64_t, DynamicRelocation> DynamicRelocations;
4650

lib/StaticMirror/ObjectFileContext.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,13 @@ remote::RemoteAbsolutePointer Image::getDynamicSymbol(uint64_t Addr) const {
332332
auto found = DynamicRelocations.find(Addr);
333333
if (found == DynamicRelocations.end())
334334
return nullptr;
335-
return remote::RemoteAbsolutePointer(found->second.Symbol,
336-
found->second.Offset,
337-
remote::RemoteAddress((uint64_t)0));
335+
if (!found->second.Symbol.empty())
336+
return remote::RemoteAbsolutePointer(found->second.Symbol,
337+
found->second.OffsetOrAddress,
338+
remote::RemoteAddress());
339+
return remote::RemoteAbsolutePointer(
340+
remote::RemoteAddress(found->second.OffsetOrAddress,
341+
remote::RemoteAddress::DefaultAddressSpace));
338342
}
339343

340344
std::pair<const Image *, uint64_t>

0 commit comments

Comments
 (0)