summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Riss <friss@apple.com>2016-02-01 04:43:14 +0000
committerFrederic Riss <friss@apple.com>2016-02-01 04:43:14 +0000
commit1d53658eaeb7f1d9215e84b05f04a82c887d83ba (patch)
tree0738229d67ef1f6d0dda8e039257e265ba491164
parentefb41741f2b846666aec0a808f89710af8d37e89 (diff)
downloadbcm5719-llvm-1d53658eaeb7f1d9215e84b05f04a82c887d83ba.tar.gz
bcm5719-llvm-1d53658eaeb7f1d9215e84b05f04a82c887d83ba.zip
[dsymutil] Skip mach-o paired relocations
Noticed while working on scattered relocations. I do not think these relocs can actually happen in the debug_info section, but if they happen the code would mishandle them. Explicitely skip them and warn if we encounter one. llvm-svn: 259341
-rw-r--r--llvm/tools/dsymutil/DwarfLinker.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp
index 1cabc9a66c3..5a7a80576c3 100644
--- a/llvm/tools/dsymutil/DwarfLinker.cpp
+++ b/llvm/tools/dsymutil/DwarfLinker.cpp
@@ -1875,6 +1875,26 @@ void DwarfLinker::endDebugObject() {
DIEAlloc.Reset();
}
+static bool 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;
+ }
+}
+
/// \brief Iterate over the relocations of the given \p Section and
/// store the ones that correspond to debug map entries into the
/// ValidRelocs array.
@@ -1885,10 +1905,24 @@ findValidRelocsMachO(const object::SectionRef &Section,
StringRef Contents;
Section.getContents(Contents);
DataExtractor Data(Contents, Obj.isLittleEndian(), 0);
+ bool SkipNext = false;
for (const object::RelocationRef &Reloc : Section.relocations()) {
+ if (SkipNext) {
+ SkipNext = false;
+ continue;
+ }
+
object::DataRefImpl RelocDataRef = Reloc.getRawDataRefImpl();
MachO::any_relocation_info MachOReloc = Obj.getRelocation(RelocDataRef);
+
+ if (isMachOPairedReloc(Obj.getAnyRelocationType(MachOReloc),
+ Obj.getArch())) {
+ SkipNext = true;
+ Linker.reportWarning(" unsupported relocation in debug_info section.");
+ continue;
+ }
+
unsigned RelocSize = 1 << Obj.getAnyRelocationLength(MachOReloc);
uint64_t Offset64 = Reloc.getOffset();
if ((RelocSize != 4 && RelocSize != 8)) {
OpenPOWER on IntegriCloud