From: Martin Storsjo Date: Thu, 13 Jul 2017 05:54:08 +0000 (+0000) Subject: [llvm-objdump] Correctly distinguish between the MachO upper/lower16 relocations X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8ca723ae601b3626fb9864ecd1e7d69be020f597;p=llvm [llvm-objdump] Correctly distinguish between the MachO upper/lower16 relocations All other code in MachODump.cpp uses the same comparison, ((r_length & 0x1) == 1), for distinguishing between the two, while the code in llvm-objdump.cpp seemed to be incorrect. Differential Revision: https://reviews.llvm.org/D35240 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307882 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/tools/llvm-objdump/ARM/Inputs/reloc-half.obj.macho-arm b/test/tools/llvm-objdump/ARM/Inputs/reloc-half.obj.macho-arm new file mode 100644 index 00000000000..79d19962e00 Binary files /dev/null and b/test/tools/llvm-objdump/ARM/Inputs/reloc-half.obj.macho-arm differ diff --git a/test/tools/llvm-objdump/ARM/macho-reloc-half.test b/test/tools/llvm-objdump/ARM/macho-reloc-half.test new file mode 100644 index 00000000000..888c7f58911 --- /dev/null +++ b/test/tools/llvm-objdump/ARM/macho-reloc-half.test @@ -0,0 +1,4 @@ +RUN: llvm-objdump -r %p/Inputs/reloc-half.obj.macho-arm | FileCheck %s + +CHECK-DAG: 00000004 ARM_RELOC_HALF :upper16:(_stringbuf) +CHECK-DAG: 00000000 ARM_RELOC_HALF :lower16:(_stringbuf) diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp index be5635a3d4c..812f1af3ac6 100644 --- a/tools/llvm-objdump/llvm-objdump.cpp +++ b/tools/llvm-objdump/llvm-objdump.cpp @@ -1032,7 +1032,7 @@ static std::error_code getRelocationValueString(const MachOObjectFile *Obj, case MachO::ARM_RELOC_HALF_SECTDIFF: { // Half relocations steal a bit from the length field to encode // whether this is an upper16 or a lower16 relocation. - bool isUpper = Obj->getAnyRelocationLength(RE) >> 1; + bool isUpper = (Obj->getAnyRelocationLength(RE) & 0x1) == 1; if (isUpper) fmt << ":upper16:(";