diff options
author | Augusto Noronha <augusto2112@me.com> | 2022-02-25 15:20:02 -0300 |
---|---|---|
committer | Augusto Noronha <augusto2112@me.com> | 2022-03-17 14:23:20 -0300 |
commit | 9b3af5e7b70239516cbe56f82fb195f8a55d3a2e (patch) | |
tree | a73ca06aa29e108cd048c23749ee83b7d44dbd5f /llvm/lib/Object/MachOObjectFile.cpp | |
parent | 6ce08d5c278609de8c53861e30e613030cc9c1de (diff) | |
download | llvm-9b3af5e7b70239516cbe56f82fb195f8a55d3a2e.zip llvm-9b3af5e7b70239516cbe56f82fb195f8a55d3a2e.tar.gz llvm-9b3af5e7b70239516cbe56f82fb195f8a55d3a2e.tar.bz2 |
[dsymutil] Apply relocations present in Swift reflection sections
The strippable Swift reflection sections contain subtractor relocations
that need to be applied. There are two situations we need to support.
1) Both symbols used in the relocation come from the .o file (for
example, one symbol lives in __swift5_fieldmd and the second in
__swift5_reflstr).
2) One symbol comes from th .o file and the second from the main
binary (for example, __swift5_fieldmd and __swift5_typeref).
Differential Revision: https://reviews.llvm.org/D120574
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/MachOObjectFile.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index a3e0516..e408062 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -4973,3 +4973,23 @@ MachOObjectFile::mapReflectionSectionNameToEnumValue( .Default(llvm::binaryformat::Swift5ReflectionSectionKind::unknown); #undef HANDLE_SWIFT_SECTION } + +bool MachOObjectFile::isMachOPairedReloc(uint64_t RelocType, uint64_t Arch) { + switch (Arch) { + case Triple::x86: + return RelocType == MachO::GENERIC_RELOC_SECTDIFF || + RelocType == MachO::GENERIC_RELOC_LOCAL_SECTDIFF; + case Triple::x86_64: + return RelocType == MachO::X86_64_RELOC_SUBTRACTOR; + case Triple::arm: + case Triple::thumb: + return RelocType == MachO::ARM_RELOC_SECTDIFF || + RelocType == MachO::ARM_RELOC_LOCAL_SECTDIFF || + RelocType == MachO::ARM_RELOC_HALF || + RelocType == MachO::ARM_RELOC_HALF_SECTDIFF; + case Triple::aarch64: + return RelocType == MachO::ARM64_RELOC_SUBTRACTOR; + default: + return false; + } +} |