Index: include/llvm/Support/MathExtras.h =================================================================== --- include/llvm/Support/MathExtras.h +++ include/llvm/Support/MathExtras.h @@ -252,6 +252,12 @@ return static_cast(Value); } +/// Lo_Bits - This function returns the low \p Bits bits of Value. +inline uint64_t Lo_Bits(uint64_t Value, unsigned Bits) { + assert(Bits <= 64); + return Value & (~0ULL >> (64 - Bits)); +} + /// Make_64 - This functions makes a 64-bit integer from a high / low pair of /// 32-bit integers. inline uint64_t Make_64(uint32_t High, uint32_t Low) { Index: tools/dsymutil/DwarfLinker.cpp =================================================================== --- tools/dsymutil/DwarfLinker.cpp +++ tools/dsymutil/DwarfLinker.cpp @@ -34,6 +34,7 @@ #include "llvm/Object/MachO.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/LEB128.h" +#include "llvm/Support/MathExtras.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" @@ -838,8 +839,10 @@ Asm->OutStreamer->EmitIntValue(0, AddressSize); break; } - Asm->OutStreamer->EmitIntValue(Low + LocPcOffset, AddressSize); - Asm->OutStreamer->EmitIntValue(High + LocPcOffset, AddressSize); + Asm->OutStreamer->EmitIntValue( + llvm::Lo_Bits(Low + LocPcOffset, 8 * AddressSize), AddressSize); + Asm->OutStreamer->EmitIntValue( + llvm::Lo_Bits(High + LocPcOffset, 8 * AddressSize), AddressSize); uint64_t Length = Data.getU16(&Offset); Asm->OutStreamer->EmitIntValue(Length, 2); // Just copy the bytes over.