Index: include/llvm/BinaryFormat/Dwarf.h =================================================================== --- include/llvm/BinaryFormat/Dwarf.h +++ include/llvm/BinaryFormat/Dwarf.h @@ -72,7 +72,7 @@ /// @} /// Identifier of an invalid DIE offset in the .debug_info section. -const uint32_t DW_INVALID_OFFSET = UINT32_MAX; +const uint64_t DW_INVALID_OFFSET = UINT64_MAX; enum Tag : uint16_t { #define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR) DW_TAG_##NAME = ID, Index: include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h +++ include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h @@ -130,11 +130,11 @@ /// \param Attr DWARF attribute to search for. /// \param U the DWARFUnit the contains the DIE. /// \returns Optional DWARF form value if the attribute was extracted. - Optional getAttributeValue(const uint32_t DIEOffset, + Optional getAttributeValue(const uint64_t DIEOffset, const dwarf::Attribute Attr, const DWARFUnit &U) const; - bool extract(DataExtractor Data, uint32_t* OffsetPtr); + bool extract(DataExtractor Data, uint64_t* OffsetPtr); void dump(raw_ostream &OS) const; // Return an optional byte size of all attribute data in this abbreviation Index: include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h +++ include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h @@ -96,7 +96,7 @@ using AtomType = uint16_t; using Form = dwarf::Form; - uint32_t DIEOffsetBase; + uint64_t DIEOffsetBase; SmallVector, 3> Atoms; Optional extractOffset(Optional Value) const; @@ -109,7 +109,7 @@ /// Returns true if we should continue scanning for entries or false if we've /// reached the last (sentinel) entry of encountered a parsing error. bool dumpName(ScopedPrinter &W, SmallVectorImpl &AtomForms, - uint32_t *DataOffset) const; + uint64_t *DataOffset) const; public: /// Apple-specific implementation of an Accelerator Entry. @@ -119,7 +119,7 @@ Entry(const HeaderData &Data); Entry() = default; - void extract(const AppleAcceleratorTable &AccelTable, uint32_t *Offset); + void extract(const AppleAcceleratorTable &AccelTable, uint64_t *Offset); public: Optional getCUOffset() const override; @@ -143,7 +143,7 @@ class ValueIterator : public std::iterator { const AppleAcceleratorTable *AccelTable = nullptr; Entry Current; ///< The current entry. - unsigned DataOffset = 0; ///< Offset into the section. + uint64_t DataOffset = 0; ///< Offset into the section. unsigned Data = 0; ///< Current data entry. unsigned NumData = 0; ///< Number of data entries. @@ -151,7 +151,7 @@ void Next(); public: /// Construct a new iterator for the entries at \p DataOffset. - ValueIterator(const AppleAcceleratorTable &AccelTable, unsigned DataOffset); + ValueIterator(const AppleAcceleratorTable &AccelTable, uint64_t DataOffset); /// End marker. ValueIterator() = default; @@ -193,7 +193,7 @@ /// DieOffset is the offset into the .debug_info section for the DIE /// related to the input hash data offset. /// DieTag is the tag of the DIE - std::pair readAtoms(uint32_t &HashDataOffset); + std::pair readAtoms(uint64_t &HashDataOffset); void dump(raw_ostream &OS) const override; /// Look up all entries in the accelerator table matching \c Key. @@ -245,7 +245,7 @@ struct Header : public HeaderPOD { SmallString<8> AugmentationString; - Error extract(const DWARFDataExtractor &AS, uint32_t *Offset); + Error extract(const DWARFDataExtractor &AS, uint64_t *Offset); void dump(ScopedPrinter &W) const; }; @@ -354,12 +354,12 @@ DataExtractor StrData; uint32_t Index; - uint32_t StringOffset; - uint32_t EntryOffset; + uint64_t StringOffset; + uint64_t EntryOffset; public: NameTableEntry(const DataExtractor &StrData, uint32_t Index, - uint32_t StringOffset, uint32_t EntryOffset) + uint64_t StringOffset, uint64_t EntryOffset) : StrData(StrData), Index(Index), StringOffset(StringOffset), EntryOffset(EntryOffset) {} @@ -367,17 +367,17 @@ uint32_t getIndex() const { return Index; } /// Returns the offset of the name of the described entities. - uint32_t getStringOffset() const { return StringOffset; } + uint64_t getStringOffset() const { return StringOffset; } /// Return the string referenced by this name table entry or nullptr if the /// string offset is not valid. const char *getString() const { - uint32_t Off = StringOffset; + uint64_t Off = StringOffset; return StrData.getCStr(&Off); } /// Returns the offset of the first Entry in the list. - uint32_t getEntryOffset() const { return EntryOffset; } + uint64_t getEntryOffset() const { return EntryOffset; } }; /// Represents a single accelerator table within the DWARF v5 .debug_names @@ -389,40 +389,40 @@ // Base of the whole unit and of various important tables, as offsets from // the start of the section. - uint32_t Base; - uint32_t CUsBase; - uint32_t BucketsBase; - uint32_t HashesBase; - uint32_t StringOffsetsBase; - uint32_t EntryOffsetsBase; - uint32_t EntriesBase; + uint64_t Base; + uint64_t CUsBase; + uint64_t BucketsBase; + uint64_t HashesBase; + uint64_t StringOffsetsBase; + uint64_t EntryOffsetsBase; + uint64_t EntriesBase; void dumpCUs(ScopedPrinter &W) const; void dumpLocalTUs(ScopedPrinter &W) const; void dumpForeignTUs(ScopedPrinter &W) const; void dumpAbbreviations(ScopedPrinter &W) const; - bool dumpEntry(ScopedPrinter &W, uint32_t *Offset) const; + bool dumpEntry(ScopedPrinter &W, uint64_t *Offset) const; void dumpName(ScopedPrinter &W, const NameTableEntry &NTE, Optional Hash) const; void dumpBucket(ScopedPrinter &W, uint32_t Bucket) const; - Expected extractAttributeEncoding(uint32_t *Offset); + Expected extractAttributeEncoding(uint64_t *Offset); Expected> - extractAttributeEncodings(uint32_t *Offset); + extractAttributeEncodings(uint64_t *Offset); - Expected extractAbbrev(uint32_t *Offset); + Expected extractAbbrev(uint64_t *Offset); public: - NameIndex(const DWARFDebugNames &Section, uint32_t Base) + NameIndex(const DWARFDebugNames &Section, uint64_t Base) : Section(Section), Base(Base) {} /// Reads offset of compilation unit CU. CU is 0-based. - uint32_t getCUOffset(uint32_t CU) const; + uint64_t getCUOffset(uint32_t CU) const; uint32_t getCUCount() const { return Hdr.CompUnitCount; } /// Reads offset of local type unit TU, TU is 0-based. - uint32_t getLocalTUOffset(uint32_t TU) const; + uint64_t getLocalTUOffset(uint32_t TU) const; uint32_t getLocalTUCount() const { return Hdr.LocalTypeUnitCount; } /// Reads signature of foreign type unit TU. TU is 0-based. @@ -451,7 +451,7 @@ return Abbrevs; } - Expected getEntry(uint32_t *Offset) const; + Expected getEntry(uint64_t *Offset) const; /// Look up all entries in this Name Index matching \c Key. iterator_range equal_range(StringRef Key) const; @@ -460,8 +460,8 @@ NameIterator end() const { return NameIterator(this, getNameCount() + 1); } Error extract(); - uint32_t getUnitOffset() const { return Base; } - uint32_t getNextUnitOffset() const { return Base + 4 + Hdr.UnitLength; } + uint64_t getUnitOffset() const { return Base; } + uint64_t getNextUnitOffset() const { return Base + 4 + Hdr.UnitLength; } void dump(ScopedPrinter &W) const; friend class DWARFDebugNames; @@ -479,12 +479,12 @@ bool IsLocal; Optional CurrentEntry; - unsigned DataOffset = 0; ///< Offset into the section. + uint64_t DataOffset = 0; ///< Offset into the section. std::string Key; ///< The Key we are searching for. Optional Hash; ///< Hash of Key, if it has been computed. bool getEntryAtCurrentOffset(); - Optional findEntryOffsetInCurrentIndex(); + Optional findEntryOffsetInCurrentIndex(); bool findInCurrentIndex(); void searchFromStartOfCurrentIndex(); void next(); @@ -572,7 +572,7 @@ private: SmallVector NameIndices; - DenseMap CUToNameIndex; + DenseMap CUToNameIndex; public: DWARFDebugNames(const DWARFDataExtractor &AccelSection, @@ -591,7 +591,7 @@ /// Return the Name Index covering the compile unit at CUOffset, or nullptr if /// there is no Name Index covering that unit. - const NameIndex *getCUNameIndex(uint32_t CUOffset); + const NameIndex *getCUNameIndex(uint64_t CUOffset); }; } // end namespace llvm Index: include/llvm/DebugInfo/DWARF/DWARFAttribute.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFAttribute.h +++ include/llvm/DebugInfo/DWARF/DWARFAttribute.h @@ -23,7 +23,7 @@ /// attributes in a DWARFDie. struct DWARFAttribute { /// The debug info/types offset for this attribute. - uint32_t Offset = 0; + uint64_t Offset = 0; /// The debug info/types section byte size of the data for this attribute. uint32_t ByteSize = 0; /// The attribute enumeration of this attribute. @@ -31,7 +31,7 @@ /// The form and value for this attribute. DWARFFormValue Value; - DWARFAttribute(uint32_t O, dwarf::Attribute A = dwarf::Attribute(0), + DWARFAttribute(uint64_t O, dwarf::Attribute A = dwarf::Attribute(0), dwarf::Form F = dwarf::Form(0)) : Attr(A), Value(F) {} bool isValid() const { Index: include/llvm/DebugInfo/DWARF/DWARFContext.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFContext.h +++ include/llvm/DebugInfo/DWARF/DWARFContext.h @@ -225,10 +225,10 @@ DWARFCompileUnit *getDWOCompileUnitForHash(uint64_t Hash); /// Return the compile unit that includes an offset (relative to .debug_info). - DWARFCompileUnit *getCompileUnitForOffset(uint32_t Offset); + DWARFCompileUnit *getCompileUnitForOffset(uint64_t Offset); /// Get a DIE given an exact offset. - DWARFDie getDIEForOffset(uint32_t Offset); + DWARFDie getDIEForOffset(uint64_t Offset); unsigned getMaxVersion() { // Ensure info units have been parsed to discover MaxVersion Index: include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h +++ include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h @@ -35,12 +35,12 @@ /// Extracts a value and applies a relocation to the result if /// one exists for the given offset. - uint64_t getRelocatedValue(uint32_t Size, uint32_t *Off, + uint64_t getRelocatedValue(uint32_t Size, uint64_t *Off, uint64_t *SectionIndex = nullptr) const; /// Extracts an address-sized value and applies a relocation to the result if /// one exists for the given offset. - uint64_t getRelocatedAddress(uint32_t *Off, uint64_t *SecIx = nullptr) const { + uint64_t getRelocatedAddress(uint64_t *Off, uint64_t *SecIx = nullptr) const { return getRelocatedValue(getAddressSize(), Off, SecIx); } @@ -48,7 +48,7 @@ /// There is a DWARF encoding that uses a PC-relative adjustment. /// For these values, \p AbsPosOffset is used to fix them, which should /// reflect the absolute address of this pointer. - Optional getEncodedPointer(uint32_t *Offset, uint8_t Encoding, + Optional getEncodedPointer(uint64_t *Offset, uint8_t Encoding, uint64_t AbsPosOffset = 0) const; size_t size() const { return Section == nullptr ? 0 : Section->Data.size(); } Index: include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h +++ include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h @@ -20,7 +20,7 @@ class raw_ostream; class DWARFAbbreviationDeclarationSet { - uint32_t Offset; + uint64_t Offset; /// Code of the first abbreviation, if all abbreviations in the set have /// consecutive codes. UINT32_MAX otherwise. uint32_t FirstAbbrCode; @@ -32,9 +32,9 @@ public: DWARFAbbreviationDeclarationSet(); - uint32_t getOffset() const { return Offset; } + uint64_t getOffset() const { return Offset; } void dump(raw_ostream &OS) const; - bool extract(DataExtractor Data, uint32_t *OffsetPtr); + bool extract(DataExtractor Data, uint64_t *OffsetPtr); const DWARFAbbreviationDeclaration * getAbbreviationDeclaration(uint32_t AbbrCode) const; Index: include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h +++ include/llvm/DebugInfo/DWARF/DWARFDebugAddr.h @@ -45,7 +45,7 @@ private: dwarf::DwarfFormat Format; - uint32_t HeaderOffset; + uint64_t HeaderOffset; Header HeaderData; uint32_t DataSize = 0; std::vector Addrs; @@ -54,11 +54,11 @@ void clear(); /// Extract an entire table, including all addresses. - Error extract(DWARFDataExtractor Data, uint32_t *OffsetPtr, + Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr, uint16_t Version, uint8_t AddrSize, std::function WarnCallback); - uint32_t getHeaderOffset() const { return HeaderOffset; } + uint64_t getHeaderOffset() const { return HeaderOffset; } uint8_t getAddrSize() const { return HeaderData.AddrSize; } void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) const; Index: include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h +++ include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h @@ -26,7 +26,7 @@ uint32_t Length; /// The offset from the beginning of the .debug_info section of the /// compilation unit entry referenced by the table. - uint32_t CuOffset; + uint64_t CuOffset; /// The DWARF version number. uint16_t Version; /// The size in bytes of an address on the target architecture. For segmented @@ -49,7 +49,7 @@ using DescriptorColl = std::vector; using desc_iterator_range = iterator_range; - uint32_t Offset; + uint64_t Offset; Header HeaderData; DescriptorColl ArangeDescriptors; @@ -57,10 +57,10 @@ DWARFDebugArangeSet() { clear(); } void clear(); - bool extract(DataExtractor data, uint32_t *offset_ptr); + bool extract(DataExtractor data, uint64_t *offset_ptr); void dump(raw_ostream &OS) const; - uint32_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; } + uint64_t getCompileUnitDIEOffset() const { return HeaderData.CuOffset; } const Header &getHeader() const { return HeaderData; } Index: include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h +++ include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h @@ -21,19 +21,19 @@ class DWARFDebugAranges { public: void generate(DWARFContext *CTX); - uint32_t findAddress(uint64_t Address) const; + uint64_t findAddress(uint64_t Address) const; private: void clear(); void extract(DataExtractor DebugArangesData); /// Call appendRange multiple times and then call construct. - void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC); + void appendRange(uint64_t CUOffset, uint64_t LowPC, uint64_t HighPC); void construct(); struct Range { explicit Range(uint64_t LowPC = -1ULL, uint64_t HighPC = -1ULL, - uint32_t CUOffset = -1U) + uint64_t CUOffset = -1ULL) : LowPC(LowPC), Length(HighPC - LowPC), CUOffset(CUOffset) {} void setHighPC(uint64_t HighPC) { @@ -55,15 +55,15 @@ uint64_t LowPC; /// Start of address range. uint32_t Length; /// End of address range (not including this address). - uint32_t CUOffset; /// Offset of the compile unit or die. + uint64_t CUOffset; /// Offset of the compile unit or die. }; struct RangeEndpoint { uint64_t Address; - uint32_t CUOffset; + uint64_t CUOffset; bool IsRangeStart; - RangeEndpoint(uint64_t Address, uint32_t CUOffset, bool IsRangeStart) + RangeEndpoint(uint64_t Address, uint64_t CUOffset, bool IsRangeStart) : Address(Address), CUOffset(CUOffset), IsRangeStart(IsRangeStart) {} bool operator<(const RangeEndpoint &Other) const { @@ -76,7 +76,7 @@ std::vector Endpoints; RangeColl Aranges; - DenseSet ParsedCUOffsets; + DenseSet ParsedCUOffsets; }; } // end namespace llvm Index: include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h +++ include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h @@ -69,7 +69,7 @@ /// starting at *Offset and ending at EndOffset. *Offset is updated /// to EndOffset upon successful parsing, or indicates the offset /// where a problem occurred in case an error is returned. - Error parse(DataExtractor Data, uint32_t *Offset, uint32_t EndOffset); + Error parse(DataExtractor Data, uint64_t *Offset, uint64_t EndOffset); void dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH, unsigned IndentLevel = 1) const; Index: include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h +++ include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h @@ -22,7 +22,7 @@ /// DWARFDebugInfoEntry - A DIE with only the minimum required data. class DWARFDebugInfoEntry { /// Offset within the .debug_info of the start of this entry. - uint32_t Offset = 0; + uint64_t Offset = 0; /// The integer depth of this DIE within the compile unit DIEs where the /// compile/type unit DIE has a depth of zero. @@ -36,14 +36,14 @@ /// Extracts a debug info entry, which is a child of a given unit, /// starting at a given offset. If DIE can't be extracted, returns false and /// doesn't change OffsetPtr. - bool extractFast(const DWARFUnit &U, uint32_t *OffsetPtr); + bool extractFast(const DWARFUnit &U, uint64_t *OffsetPtr); /// High performance extraction should use this call. - bool extractFast(const DWARFUnit &U, uint32_t *OffsetPtr, - const DWARFDataExtractor &DebugInfoData, uint32_t UEndOffset, + bool extractFast(const DWARFUnit &U, uint64_t *OffsetPtr, + const DWARFDataExtractor &DebugInfoData, uint64_t UEndOffset, uint32_t Depth); - uint32_t getOffset() const { return Offset; } + uint64_t getOffset() const { return Offset; } uint32_t getDepth() const { return Depth; } dwarf::Tag getTag() const { Index: include/llvm/DebugInfo/DWARF/DWARFDebugLine.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDebugLine.h +++ include/llvm/DebugInfo/DWARF/DWARFDebugLine.h @@ -123,7 +123,7 @@ void clear(); void dump(raw_ostream &OS, DIDumpOptions DumpOptions) const; - Error parse(const DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr, + Error parse(const DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, const DWARFContext &Ctx, const DWARFUnit *U = nullptr); }; @@ -263,7 +263,7 @@ /// Parse prologue and all rows. Error parse( - DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr, + DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, const DWARFContext &Ctx, const DWARFUnit *U, std::function RecoverableErrorCallback, raw_ostream *OS = nullptr); @@ -295,9 +295,9 @@ std::vector &Result) const; }; - const LineTable *getLineTable(uint32_t Offset) const; + const LineTable *getLineTable(uint64_t Offset) const; Expected getOrParseLineTable( - DWARFDataExtractor &DebugLineData, uint32_t Offset, + DWARFDataExtractor &DebugLineData, uint64_t Offset, const DWARFContext &Ctx, const DWARFUnit *U, std::function RecoverableErrorCallback); @@ -340,17 +340,17 @@ bool done() const { return Done; } /// Get the offset the parser has reached. - uint32_t getOffset() const { return Offset; } + uint64_t getOffset() const { return Offset; } private: - DWARFUnit *prepareToParse(uint32_t Offset); - void moveToNextTable(uint32_t OldOffset, const Prologue &P); + DWARFUnit *prepareToParse(uint64_t Offset); + void moveToNextTable(uint64_t OldOffset, const Prologue &P); LineToUnitMap LineToUnit; DWARFDataExtractor &DebugLineData; const DWARFContext &Context; - uint32_t Offset = 0; + uint64_t Offset = 0; bool Done = false; }; @@ -367,7 +367,7 @@ struct Sequence Sequence; }; - using LineTableMapTy = std::map; + using LineTableMapTy = std::map; using LineTableIter = LineTableMapTy::iterator; using LineTableConstIter = LineTableMapTy::const_iterator; Index: include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h +++ include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h @@ -36,7 +36,7 @@ struct LocationList { /// The beginning offset where this location list is stored in the debug_loc /// section. - unsigned Offset; + uint64_t Offset; /// All the locations in which the variable is stored. SmallVector Entries; /// Dump this list on OS. @@ -69,7 +69,7 @@ LocationList const *getLocationListAtOffset(uint64_t Offset) const; Optional parseOneLocationList(DWARFDataExtractor Data, - uint32_t *Offset); + uint64_t *Offset); }; class DWARFDebugLoclists { @@ -82,7 +82,7 @@ }; struct LocationList { - unsigned Offset; + uint64_t Offset; SmallVector Entries; void dump(raw_ostream &OS, uint64_t BaseAddr, bool IsLittleEndian, unsigned AddressSize, const MCRegisterInfo *RegInfo, @@ -107,7 +107,7 @@ LocationList const *getLocationListAtOffset(uint64_t Offset) const; static Optional - parseOneLocationList(DataExtractor Data, unsigned *Offset, unsigned Version); + parseOneLocationList(DataExtractor Data, uint64_t *Offset, unsigned Version); }; } // end namespace llvm Index: include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h +++ include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h @@ -25,7 +25,7 @@ public: struct Entry { /// Section offset from the beginning of the compilation unit. - uint32_t SecOffset; + uint64_t SecOffset; /// An entry of the various gnu_pub* debug sections. dwarf::PubIndexEntryDescriptor Descriptor; @@ -50,7 +50,7 @@ /// The offset from the beginning of the .debug_info section of the /// compilation unit header referenced by the set. - uint32_t Offset; + uint64_t Offset; /// The size in bytes of the contents of the .debug_info section generated /// to represent that compilation unit. Index: include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h +++ include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h @@ -60,7 +60,7 @@ private: /// Offset in .debug_ranges section. - uint32_t Offset; + uint64_t Offset; uint8_t AddressSize; std::vector Entries; @@ -69,7 +69,7 @@ void clear(); void dump(raw_ostream &OS) const; - Error extract(const DWARFDataExtractor &data, uint32_t *offset_ptr); + Error extract(const DWARFDataExtractor &data, uint64_t *offset_ptr); const std::vector &getEntries() { return Entries; } /// getAbsoluteRanges - Returns absolute address ranges defined by this range Index: include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h +++ include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h @@ -34,7 +34,7 @@ uint64_t Value0; uint64_t Value1; - Error extract(DWARFDataExtractor Data, uint32_t End, uint32_t *OffsetPtr); + Error extract(DWARFDataExtractor Data, uint64_t End, uint64_t *OffsetPtr); void dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength, uint64_t &CurrentBase, DIDumpOptions DumpOpts, llvm::function_ref(uint32_t)> Index: include/llvm/DebugInfo/DWARF/DWARFDie.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFDie.h +++ include/llvm/DebugInfo/DWARF/DWARFDie.h @@ -63,7 +63,7 @@ /// Get the absolute offset into the debug info or types section. /// /// \returns the DIE offset or -1U if invalid. - uint32_t getOffset() const { + uint64_t getOffset() const { assert(isValid() && "must check validity prior to calling"); return Die->getOffset(); } Index: include/llvm/DebugInfo/DWARF/DWARFExpression.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFExpression.h +++ include/llvm/DebugInfo/DWARF/DWARFExpression.h @@ -77,18 +77,18 @@ uint8_t Opcode; ///< The Op Opcode, DW_OP_. Description Desc; bool Error; - uint32_t EndOffset; + uint64_t EndOffset; uint64_t Operands[2]; - uint32_t OperandEndOffsets[2]; + uint64_t OperandEndOffsets[2]; public: Description &getDescription() { return Desc; } uint8_t getCode() { return Opcode; } uint64_t getRawOperand(unsigned Idx) { return Operands[Idx]; } - uint32_t getOperandEndOffset(unsigned Idx) { return OperandEndOffsets[Idx]; } - uint32_t getEndOffset() { return EndOffset; } + uint64_t getOperandEndOffset(unsigned Idx) { return OperandEndOffsets[Idx]; } + uint64_t getEndOffset() { return EndOffset; } bool extract(DataExtractor Data, uint16_t Version, uint8_t AddressSize, - uint32_t Offset); + uint64_t Offset); bool isError() { return Error; } bool print(raw_ostream &OS, const DWARFExpression *Expr, const MCRegisterInfo *RegInfo, DWARFUnit *U, bool isEH); @@ -101,9 +101,9 @@ Operation> { friend class DWARFExpression; const DWARFExpression *Expr; - uint32_t Offset; + uint64_t Offset; Operation Op; - iterator(const DWARFExpression *Expr, uint32_t Offset) + iterator(const DWARFExpression *Expr, uint64_t Offset) : Expr(Expr), Offset(Offset) { Op.Error = Offset >= Expr->Data.getData().size() || Index: include/llvm/DebugInfo/DWARF/DWARFFormValue.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFFormValue.h +++ include/llvm/DebugInfo/DWARF/DWARFFormValue.h @@ -70,7 +70,7 @@ static DWARFFormValue createFromBlockValue(dwarf::Form F, ArrayRef D); static DWARFFormValue createFromUnit(dwarf::Form F, const DWARFUnit *Unit, - uint32_t *OffsetPtr); + uint64_t *OffsetPtr); dwarf::Form getForm() const { return Form; } uint64_t getRawUValue() const { return Value.uval; } @@ -87,12 +87,12 @@ /// in \p FormParams is needed to interpret some forms. The optional /// \p Context and \p Unit allows extracting information if the form refers /// to other sections (e.g., .debug_str). - bool extractValue(const DWARFDataExtractor &Data, uint32_t *OffsetPtr, + bool extractValue(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, dwarf::FormParams FormParams, const DWARFContext *Context = nullptr, const DWARFUnit *Unit = nullptr); - bool extractValue(const DWARFDataExtractor &Data, uint32_t *OffsetPtr, + bool extractValue(const DWARFDataExtractor &Data, uint64_t *OffsetPtr, dwarf::FormParams FormParams, const DWARFUnit *U) { return extractValue(Data, OffsetPtr, FormParams, nullptr, U); } @@ -128,7 +128,7 @@ /// \param OffsetPtr A reference to the offset that will be updated. /// \param Params DWARF parameters to help interpret forms. /// \returns true on success, false if the form was not skipped. - bool skipValue(DataExtractor DebugInfoData, uint32_t *OffsetPtr, + bool skipValue(DataExtractor DebugInfoData, uint64_t *OffsetPtr, const dwarf::FormParams Params) const { return DWARFFormValue::skipValue(Form, DebugInfoData, OffsetPtr, Params); } @@ -144,7 +144,7 @@ /// \param FormParams DWARF parameters to help interpret forms. /// \returns true on success, false if the form was not skipped. static bool skipValue(dwarf::Form Form, DataExtractor DebugInfoData, - uint32_t *OffsetPtr, + uint64_t *OffsetPtr, const dwarf::FormParams FormParams); private: Index: include/llvm/DebugInfo/DWARF/DWARFListTable.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFListTable.h +++ include/llvm/DebugInfo/DWARF/DWARFListTable.h @@ -26,7 +26,7 @@ /// entries. struct DWARFListEntryBase { /// The offset at which the entry is located in the section. - uint32_t Offset; + uint64_t Offset; /// The DWARF encoding (DW_RLE_* or DW_LLE_*). uint8_t EntryKind; /// The index of the section this entry belongs to. @@ -46,8 +46,8 @@ const ListEntries &getEntries() const { return Entries; } bool empty() const { return Entries.empty(); } void clear() { Entries.clear(); } - Error extract(DWARFDataExtractor Data, uint32_t HeaderOffset, uint32_t End, - uint32_t *OffsetPtr, StringRef SectionName, + Error extract(DWARFDataExtractor Data, uint64_t HeaderOffset, uint64_t End, + uint64_t *OffsetPtr, StringRef SectionName, StringRef ListStringName); }; @@ -75,12 +75,12 @@ /// The offset table, which contains offsets to the individual list entries. /// It is used by forms such as DW_FORM_rnglistx. /// FIXME: Generate the table and use the appropriate forms. - std::vector Offsets; + std::vector Offsets; /// The table's format, either DWARF32 or DWARF64. dwarf::DwarfFormat Format; /// The offset at which the header (and hence the table) is located within /// its section. - uint32_t HeaderOffset; + uint64_t HeaderOffset; /// The name of the section the list is located in. StringRef SectionName; /// A characterization of the list for dumping purposes, e.g. "range" or @@ -95,7 +95,7 @@ HeaderData = {}; Offsets.clear(); } - uint32_t getHeaderOffset() const { return HeaderOffset; } + uint64_t getHeaderOffset() const { return HeaderOffset; } uint8_t getAddrSize() const { return HeaderData.AddrSize; } uint32_t getLength() const { return HeaderData.Length; } uint16_t getVersion() const { return HeaderData.Version; } @@ -104,14 +104,14 @@ dwarf::DwarfFormat getFormat() const { return Format; } void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) const; - Optional getOffsetEntry(uint32_t Index) const { + Optional getOffsetEntry(uint32_t Index) const { if (Index < Offsets.size()) return Offsets[Index]; return None; } /// Extract the table header and the array of offsets. - Error extract(DWARFDataExtractor Data, uint32_t *OffsetPtr); + Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr); /// Returns the length of the table, including the length field, or 0 if the /// length has not been determined (e.g. because the table has not yet been @@ -128,7 +128,7 @@ DWARFListTableHeader Header; /// A mapping between file offsets and lists. It is used to find a particular /// list based on an offset (obtained from DW_AT_ranges, for example). - std::map ListMap; + std::map ListMap; /// This string is displayed as a heading before the list is dumped /// (e.g. "ranges:"). StringRef HeaderString; @@ -144,16 +144,16 @@ ListMap.clear(); } /// Extract the table header and the array of offsets. - Error extractHeaderAndOffsets(DWARFDataExtractor Data, uint32_t *OffsetPtr) { + Error extractHeaderAndOffsets(DWARFDataExtractor Data, uint64_t *OffsetPtr) { return Header.extract(Data, OffsetPtr); } /// Extract an entire table, including all list entries. - Error extract(DWARFDataExtractor Data, uint32_t *OffsetPtr); + Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr); /// Look up a list based on a given offset. Extract it and enter it into the /// list map if necessary. - Expected findList(DWARFDataExtractor Data, uint32_t Offset); + Expected findList(DWARFDataExtractor Data, uint64_t Offset); - uint32_t getHeaderOffset() const { return Header.getHeaderOffset(); } + uint64_t getHeaderOffset() const { return Header.getHeaderOffset(); } uint8_t getAddrSize() const { return Header.getAddrSize(); } void dump(raw_ostream &OS, @@ -162,7 +162,7 @@ DIDumpOptions DumpOpts = {}) const; /// Return the contents of the offset entry designated by a given index. - Optional getOffsetEntry(uint32_t Index) const { + Optional getOffsetEntry(uint32_t Index) const { return Header.getOffsetEntry(Index); } /// Return the size of the table header including the length but not including @@ -183,16 +183,16 @@ template Error DWARFListTableBase::extract(DWARFDataExtractor Data, - uint32_t *OffsetPtr) { + uint64_t *OffsetPtr) { clear(); if (Error E = extractHeaderAndOffsets(Data, OffsetPtr)) return E; Data.setAddressSize(Header.getAddrSize()); - uint32_t End = getHeaderOffset() + Header.length(); + uint64_t End = getHeaderOffset() + Header.length(); while (*OffsetPtr < End) { DWARFListType CurrentList; - uint32_t Off = *OffsetPtr; + uint64_t Off = *OffsetPtr; if (Error E = CurrentList.extract(Data, getHeaderOffset(), End, OffsetPtr, Header.getSectionName(), Header.getListTypeString())) @@ -208,13 +208,13 @@ template Error DWARFListType::extract(DWARFDataExtractor Data, - uint32_t HeaderOffset, uint32_t End, - uint32_t *OffsetPtr, + uint64_t HeaderOffset, uint64_t End, + uint64_t *OffsetPtr, StringRef SectionName, StringRef ListTypeString) { if (*OffsetPtr < HeaderOffset || *OffsetPtr >= End) return createStringError(errc::invalid_argument, - "invalid %s list offset 0x%" PRIx32, + "invalid %s list offset 0x%" PRIx64, ListTypeString.data(), *OffsetPtr); Entries.clear(); while (*OffsetPtr < End) { @@ -227,7 +227,7 @@ } return createStringError(errc::illegal_byte_sequence, "no end of list marker detected at end of %s table " - "starting at offset 0x%" PRIx32, + "starting at offset 0x%" PRIx64, SectionName.data(), HeaderOffset); } @@ -261,15 +261,15 @@ template Expected DWARFListTableBase::findList(DWARFDataExtractor Data, - uint32_t Offset) { + uint64_t Offset) { auto Entry = ListMap.find(Offset); if (Entry != ListMap.end()) return Entry->second; // Extract the list from the section and enter it into the list map. DWARFListType List; - uint32_t End = getHeaderOffset() + Header.length(); - uint32_t StartingOffset = Offset; + uint64_t End = getHeaderOffset() + Header.length(); + uint64_t StartingOffset = Offset; if (Error E = List.extract(Data, getHeaderOffset(), End, &Offset, Header.getSectionName(), Header.getListTypeString())) Index: include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h +++ include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h @@ -34,7 +34,7 @@ LS, LE, IsDWO, UnitVector) {} uint64_t getTypeHash() const { return getHeader().getTypeHash(); } - uint32_t getTypeOffset() const { return getHeader().getTypeOffset(); } + uint64_t getTypeOffset() const { return getHeader().getTypeOffset(); } void dump(raw_ostream &OS, DIDumpOptions DumpOpts = {}) override; // Enable LLVM-style RTTI. Index: include/llvm/DebugInfo/DWARF/DWARFUnit.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFUnit.h +++ include/llvm/DebugInfo/DWARF/DWARFUnit.h @@ -45,7 +45,7 @@ /// parse the header before deciding what specific kind of unit to construct. class DWARFUnitHeader { // Offset within section. - uint32_t Offset = 0; + uint64_t Offset = 0; // Version, address size, and DWARF format. dwarf::FormParams FormParams; uint64_t Length = 0; @@ -56,7 +56,7 @@ // For type units only. uint64_t TypeHash = 0; - uint32_t TypeOffset = 0; + uint64_t TypeOffset = 0; // For v5 split or skeleton compile units only. Optional DWOId; @@ -70,10 +70,10 @@ public: /// Parse a unit header from \p debug_info starting at \p offset_ptr. bool extract(DWARFContext &Context, const DWARFDataExtractor &debug_info, - uint32_t *offset_ptr, DWARFSectionKind Kind = DW_SECT_INFO, + uint64_t *offset_ptr, DWARFSectionKind Kind = DW_SECT_INFO, const DWARFUnitIndex *Index = nullptr, const DWARFUnitIndex::Entry *Entry = nullptr); - uint32_t getOffset() const { return Offset; } + uint64_t getOffset() const { return Offset; } const dwarf::FormParams &getFormParams() const { return FormParams; } uint16_t getVersion() const { return FormParams.Version; } dwarf::DwarfFormat getFormat() const { return FormParams.Format; } @@ -91,13 +91,13 @@ } const DWARFUnitIndex::Entry *getIndexEntry() const { return IndexEntry; } uint64_t getTypeHash() const { return TypeHash; } - uint32_t getTypeOffset() const { return TypeOffset; } + uint64_t getTypeOffset() const { return TypeOffset; } uint8_t getUnitType() const { return UnitType; } bool isTypeUnit() const { return UnitType == dwarf::DW_UT_type || UnitType == dwarf::DW_UT_split_type; } uint8_t getSize() const { return Size; } - uint32_t getNextUnitOffset() const { + uint64_t getNextUnitOffset() const { return Offset + Length + (FormParams.Format == llvm::dwarf::DwarfFormat::DWARF64 ? 4 : 0) + FormParams.getDwarfOffsetByteSize(); @@ -110,7 +110,7 @@ /// Describe a collection of units. Intended to hold all units either from /// .debug_info and .debug_types, or from .debug_info.dwo and .debug_types.dwo. class DWARFUnitVector final : public SmallVector, 1> { - std::function(uint32_t, DWARFSectionKind, + std::function(uint64_t, DWARFSectionKind, const DWARFSection *, const DWARFUnitIndex::Entry *)> Parser; @@ -121,7 +121,7 @@ using iterator = typename UnitVector::iterator; using iterator_range = llvm::iterator_range; - DWARFUnit *getUnitForOffset(uint32_t Offset) const; + DWARFUnit *getUnitForOffset(uint64_t Offset) const; DWARFUnit *getUnitForIndexEntry(const DWARFUnitIndex::Entry &E); /// Read units from a .debug_info or .debug_types section. Calls made @@ -197,7 +197,7 @@ DWARFUnitHeader Header; const DWARFDebugAbbrev *Abbrev; const DWARFSection *RangeSection; - uint32_t RangeSectionBase; + uint64_t RangeSectionBase; /// We either keep track of the location list section or its data, depending /// on whether we are handling a split DWARF section or not. union { @@ -208,7 +208,7 @@ StringRef StringSection; const DWARFSection &StringOffsetSection; const DWARFSection *AddrOffsetSection; - uint32_t AddrOffsetSectionBase = 0; + uint64_t AddrOffsetSectionBase = 0; bool isLittleEndian; bool IsDWO; const DWARFUnitVector &UnitVector; @@ -275,7 +275,7 @@ const DWARFSection &getInfoSection() const { return InfoSection; } const DWARFSection *getLocSection() const { return LocSection; } StringRef getLocSectionData() const { return LocSectionData; } - uint32_t getOffset() const { return Header.getOffset(); } + uint64_t getOffset() const { return Header.getOffset(); } const dwarf::FormParams &getFormParams() const { return Header.getFormParams(); } @@ -288,14 +288,14 @@ uint32_t getLength() const { return Header.getLength(); } uint8_t getUnitType() const { return Header.getUnitType(); } bool isTypeUnit() const { return Header.isTypeUnit(); } - uint32_t getNextUnitOffset() const { return Header.getNextUnitOffset(); } + uint64_t getNextUnitOffset() const { return Header.getNextUnitOffset(); } const DWARFSection &getLineSection() const { return LineSection; } StringRef getStringSection() const { return StringSection; } const DWARFSection &getStringOffsetSection() const { return StringOffsetSection; } - void setAddrOffsetSection(const DWARFSection *AOS, uint32_t Base) { + void setAddrOffsetSection(const DWARFSection *AOS, uint64_t Base) { AddrOffsetSection = AOS; AddrOffsetSectionBase = Base; } @@ -303,7 +303,7 @@ /// Recursively update address to Die map. void updateAddressDieMap(DWARFDie Die); - void setRangesSection(const DWARFSection *RS, uint32_t Base) { + void setRangesSection(const DWARFSection *RS, uint64_t Base) { RangeSection = RS; RangeSectionBase = Base; } @@ -322,7 +322,7 @@ /// .debug_ranges section. If the extraction is unsuccessful, an error /// is returned. Successful extraction requires that the compile unit /// has already been extracted. - Error extractRangeList(uint32_t RangeListOffset, + Error extractRangeList(uint64_t RangeListOffset, DWARFDebugRangeList &RangeList) const; void clear(); @@ -405,7 +405,7 @@ /// Return a vector of address ranges resulting from a (possibly encoded) /// range list starting at a given offset in the appropriate ranges section. - Expected findRnglistFromOffset(uint32_t Offset); + Expected findRnglistFromOffset(uint64_t Offset); /// Return a vector of address ranges retrieved from an encoded range /// list whose offset is found via a table lookup given an index (DWARF v5 @@ -415,7 +415,7 @@ /// Return a rangelist's offset based on an index. The index designates /// an entry in the rangelist table's offset array and is supplied by /// DW_FORM_rnglistx. - Optional getRnglistOffset(uint32_t Index) { + Optional getRnglistOffset(uint32_t Index) { if (RngListTable) return RngListTable->getOffsetEntry(Index); return None; @@ -470,7 +470,7 @@ /// unit's DIE vector. /// /// The unit needs to have its DIEs extracted for this method to work. - DWARFDie getDIEForOffset(uint32_t Offset) { + DWARFDie getDIEForOffset(uint64_t Offset) { extractDIEsIfNeeded(false); assert(!DieArray.empty()); auto It = @@ -482,7 +482,7 @@ return DWARFDie(); } - uint32_t getLineTableOffset() const { + uint64_t getLineTableOffset() const { if (auto IndexEntry = Header.getIndexEntry()) if (const auto *Contrib = IndexEntry->getOffset(DW_SECT_LINE)) return Contrib->Offset; Index: include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h +++ include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h @@ -37,7 +37,7 @@ uint32_t NumUnits; uint32_t NumBuckets = 0; - bool parse(DataExtractor IndexData, uint32_t *OffsetPtr); + bool parse(DataExtractor IndexData, uint64_t *OffsetPtr); void dump(raw_ostream &OS) const; }; @@ -88,8 +88,8 @@ bool parse(DataExtractor IndexData); void dump(raw_ostream &OS) const; - const Entry *getFromOffset(uint32_t Offset) const; - const Entry *getFromHash(uint64_t Offset) const; + const Entry *getFromOffset(uint64_t Offset) const; + const Entry *getFromHash(uint64_t Hash) const; ArrayRef getColumnKinds() const { return makeArrayRef(ColumnKinds.get(), Header.NumColumns); Index: include/llvm/DebugInfo/DWARF/DWARFVerifier.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFVerifier.h +++ include/llvm/DebugInfo/DWARF/DWARFVerifier.h @@ -94,7 +94,7 @@ /// A map that tracks all references (converted absolute references) so we /// can verify each reference points to a valid DIE and not an offset that /// lies between to valid DIEs. - std::map> ReferenceToDIEOffsets; + std::map> ReferenceToDIEOffsets; uint32_t NumDebugLineErrors = 0; // Used to relax some checks that do not currently work portably bool IsObjectFile; @@ -138,7 +138,7 @@ /// /// \returns true if the header is verified successfully, false otherwise. bool verifyUnitHeader(const DWARFDataExtractor DebugInfoData, - uint32_t *Offset, unsigned UnitIndex, uint8_t &UnitType, + uint64_t *Offset, unsigned UnitIndex, uint8_t &UnitType, bool &isUnitDWARF64); /// Verifies the header of a unit in a .debug_info or .debug_types section. Index: include/llvm/Support/DataExtractor.h =================================================================== --- include/llvm/Support/DataExtractor.h +++ include/llvm/Support/DataExtractor.h @@ -79,7 +79,7 @@ /// pointed to by \a offset_ptr is out of bounds, or if the /// offset plus the length of the C string is out of bounds, /// NULL will be returned. - const char *getCStr(uint32_t *offset_ptr) const; + const char *getCStr(uint64_t *offset_ptr) const; /// Extract a C string from \a *OffsetPtr. /// @@ -101,7 +101,7 @@ /// pointed to by \a OffsetPtr is out of bounds, or if the /// offset plus the length of the C string is out of bounds, /// a default-initialized StringRef will be returned. - StringRef getCStrRef(uint32_t *OffsetPtr) const; + StringRef getCStrRef(uint64_t *OffsetPtr) const; /// Extract an unsigned integer of size \a byte_size from \a /// *offset_ptr. @@ -127,7 +127,7 @@ /// @return /// The unsigned integer value that was extracted, or zero on /// failure. - uint64_t getUnsigned(uint32_t *offset_ptr, uint32_t byte_size) const; + uint64_t getUnsigned(uint64_t *offset_ptr, uint32_t byte_size) const; /// Extract an signed integer of size \a byte_size from \a *offset_ptr. /// @@ -152,7 +152,7 @@ /// @return /// The sign extended signed integer value that was extracted, /// or zero on failure. - int64_t getSigned(uint32_t *offset_ptr, uint32_t size) const; + int64_t getSigned(uint64_t *offset_ptr, uint32_t size) const; //------------------------------------------------------------------ /// Extract an pointer from \a *offset_ptr. @@ -171,7 +171,7 @@ /// /// @return /// The extracted pointer value as a 64 integer. - uint64_t getAddress(uint32_t *offset_ptr) const { + uint64_t getAddress(uint64_t *offset_ptr) const { return getUnsigned(offset_ptr, AddressSize); } @@ -189,7 +189,7 @@ /// /// @return /// The extracted uint8_t value. - uint8_t getU8(uint32_t *offset_ptr) const; + uint8_t getU8(uint64_t *offset_ptr) const; /// Extract \a count uint8_t values from \a *offset_ptr. /// @@ -214,7 +214,7 @@ /// @return /// \a dst if all values were properly extracted and copied, /// NULL otherise. - uint8_t *getU8(uint32_t *offset_ptr, uint8_t *dst, uint32_t count) const; + uint8_t *getU8(uint64_t *offset_ptr, uint8_t *dst, uint32_t count) const; //------------------------------------------------------------------ /// Extract a uint16_t value from \a *offset_ptr. @@ -232,7 +232,7 @@ /// @return /// The extracted uint16_t value. //------------------------------------------------------------------ - uint16_t getU16(uint32_t *offset_ptr) const; + uint16_t getU16(uint64_t *offset_ptr) const; /// Extract \a count uint16_t values from \a *offset_ptr. /// @@ -257,7 +257,7 @@ /// @return /// \a dst if all values were properly extracted and copied, /// NULL otherise. - uint16_t *getU16(uint32_t *offset_ptr, uint16_t *dst, uint32_t count) const; + uint16_t *getU16(uint64_t *offset_ptr, uint16_t *dst, uint32_t count) const; /// Extract a 24-bit unsigned value from \a *offset_ptr and return it /// in a uint32_t. @@ -274,7 +274,7 @@ /// /// @return /// The extracted 24-bit value represented in a uint32_t. - uint32_t getU24(uint32_t *offset_ptr) const; + uint32_t getU24(uint64_t *offset_ptr) const; /// Extract a uint32_t value from \a *offset_ptr. /// @@ -290,7 +290,7 @@ /// /// @return /// The extracted uint32_t value. - uint32_t getU32(uint32_t *offset_ptr) const; + uint32_t getU32(uint64_t *offset_ptr) const; /// Extract \a count uint32_t values from \a *offset_ptr. /// @@ -315,7 +315,7 @@ /// @return /// \a dst if all values were properly extracted and copied, /// NULL otherise. - uint32_t *getU32(uint32_t *offset_ptr, uint32_t *dst, uint32_t count) const; + uint32_t *getU32(uint64_t *offset_ptr, uint32_t *dst, uint32_t count) const; /// Extract a uint64_t value from \a *offset_ptr. /// @@ -331,7 +331,7 @@ /// /// @return /// The extracted uint64_t value. - uint64_t getU64(uint32_t *offset_ptr) const; + uint64_t getU64(uint64_t *offset_ptr) const; /// Extract \a count uint64_t values from \a *offset_ptr. /// @@ -356,7 +356,7 @@ /// @return /// \a dst if all values were properly extracted and copied, /// NULL otherise. - uint64_t *getU64(uint32_t *offset_ptr, uint64_t *dst, uint32_t count) const; + uint64_t *getU64(uint64_t *offset_ptr, uint64_t *dst, uint32_t count) const; /// Extract a signed LEB128 value from \a *offset_ptr. /// @@ -374,7 +374,7 @@ /// /// @return /// The extracted signed integer value. - int64_t getSLEB128(uint32_t *offset_ptr) const; + int64_t getSLEB128(uint64_t *offset_ptr) const; /// Extract a unsigned LEB128 value from \a *offset_ptr. /// @@ -392,21 +392,21 @@ /// /// @return /// The extracted unsigned integer value. - uint64_t getULEB128(uint32_t *offset_ptr) const; + uint64_t getULEB128(uint64_t *offset_ptr) const; /// Test the validity of \a offset. /// /// @return /// \b true if \a offset is a valid offset into the data in this /// object, \b false otherwise. - bool isValidOffset(uint32_t offset) const { return Data.size() > offset; } + bool isValidOffset(uint64_t offset) const { return Data.size() > offset; } /// Test the availability of \a length bytes of data from \a offset. /// /// @return /// \b true if \a offset is a valid offset and there are \a /// length bytes available at that offset, \b false otherwise. - bool isValidOffsetForDataOfSize(uint32_t offset, uint32_t length) const { + bool isValidOffsetForDataOfSize(uint64_t offset, uint64_t length) const { return offset + length >= offset && isValidOffset(offset + length - 1); } @@ -417,7 +417,7 @@ /// \b true if \a offset is a valid offset and there are enough /// bytes for a pointer available at that offset, \b false /// otherwise. - bool isValidOffsetForAddress(uint32_t offset) const { + bool isValidOffsetForAddress(uint64_t offset) const { return isValidOffsetForDataOfSize(offset, AddressSize); } }; Index: include/llvm/XRay/FDRRecordProducer.h =================================================================== --- include/llvm/XRay/FDRRecordProducer.h +++ include/llvm/XRay/FDRRecordProducer.h @@ -27,7 +27,7 @@ class FileBasedRecordProducer : public RecordProducer { const XRayFileHeader &Header; DataExtractor &E; - uint32_t &OffsetPtr; + uint64_t &OffsetPtr; uint32_t CurrentBufferBytes = 0; // Helper function which gets the next record by speculatively reading through @@ -36,7 +36,7 @@ public: FileBasedRecordProducer(const XRayFileHeader &FH, DataExtractor &DE, - uint32_t &OP) + uint64_t &OP) : Header(FH), E(DE), OffsetPtr(OP) {} /// This producer encapsulates the logic for loading a File-backed Index: include/llvm/XRay/FileHeaderReader.h =================================================================== --- include/llvm/XRay/FileHeaderReader.h +++ include/llvm/XRay/FileHeaderReader.h @@ -24,7 +24,7 @@ /// Convenience function for loading the file header given a data extractor at a /// specified offset. Expected readBinaryFormatHeader(DataExtractor &HeaderExtractor, - uint32_t &OffsetPtr); + uint64_t &OffsetPtr); } // namespace xray } // namespace llvm Index: lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp +++ lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp @@ -38,9 +38,9 @@ bool DWARFAbbreviationDeclaration::extract(DataExtractor Data, - uint32_t* OffsetPtr) { + uint64_t* OffsetPtr) { clear(); - const uint32_t Offset = *OffsetPtr; + const uint64_t Offset = *OffsetPtr; Code = Data.getULEB128(OffsetPtr); if (Code == 0) { return false; @@ -148,7 +148,7 @@ } Optional DWARFAbbreviationDeclaration::getAttributeValue( - const uint32_t DIEOffset, const dwarf::Attribute Attr, + const uint64_t DIEOffset, const dwarf::Attribute Attr, const DWARFUnit &U) const { Optional MatchAttrIndex = findAttributeIndex(Attr); if (!MatchAttrIndex) @@ -158,7 +158,7 @@ // Add the byte size of ULEB that for the abbrev Code so we can start // skipping the attribute data. - uint32_t Offset = DIEOffset + CodeByteSize; + uint64_t Offset = DIEOffset + CodeByteSize; uint32_t AttrIndex = 0; for (const auto &Spec : AttributeSpecs) { if (*MatchAttrIndex == AttrIndex) { Index: lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp +++ lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp @@ -42,7 +42,7 @@ DWARFAcceleratorTable::~DWARFAcceleratorTable() = default; Error AppleAcceleratorTable::extract() { - uint32_t Offset = 0; + uint64_t Offset = 0; // Check that we can at least read the header. if (!AccelSection.isValidOffset(offsetof(Header, HeaderDataLength) + 4)) @@ -111,9 +111,9 @@ return true; } -std::pair -AppleAcceleratorTable::readAtoms(uint32_t &HashDataOffset) { - uint32_t DieOffset = dwarf::DW_INVALID_OFFSET; +std::pair +AppleAcceleratorTable::readAtoms(uint64_t &HashDataOffset) { + uint64_t DieOffset = dwarf::DW_INVALID_OFFSET; dwarf::Tag DieTag = dwarf::DW_TAG_null; dwarf::FormParams FormParams = {Hdr.Version, 0, dwarf::DwarfFormat::DWARF32}; @@ -163,19 +163,19 @@ bool AppleAcceleratorTable::dumpName(ScopedPrinter &W, SmallVectorImpl &AtomForms, - uint32_t *DataOffset) const { + uint64_t *DataOffset) const { dwarf::FormParams FormParams = {Hdr.Version, 0, dwarf::DwarfFormat::DWARF32}; - uint32_t NameOffset = *DataOffset; + uint64_t NameOffset = *DataOffset; if (!AccelSection.isValidOffsetForDataOfSize(*DataOffset, 4)) { W.printString("Incorrectly terminated list."); return false; } - unsigned StringOffset = AccelSection.getRelocatedValue(4, DataOffset); + uint64_t StringOffset = AccelSection.getRelocatedValue(4, DataOffset); if (!StringOffset) return false; // End of list DictScope NameScope(W, ("Name@0x" + Twine::utohexstr(NameOffset)).str()); - W.startLine() << format("String: 0x%08x", StringOffset); + W.startLine() << format("String: 0x%08" PRIx64, StringOffset); W.getOStream() << " \"" << StringSection.getCStr(&StringOffset) << "\"\n"; unsigned NumData = AccelSection.getU32(DataOffset); @@ -223,9 +223,9 @@ } // Now go through the actual tables and dump them. - uint32_t Offset = sizeof(Hdr) + Hdr.HeaderDataLength; - unsigned HashesBase = Offset + Hdr.BucketCount * 4; - unsigned OffsetsBase = HashesBase + Hdr.HashCount * 4; + uint64_t Offset = sizeof(Hdr) + Hdr.HeaderDataLength; + uint64_t HashesBase = Offset + Hdr.BucketCount * 4; + uint64_t OffsetsBase = HashesBase + Hdr.HashCount * 4; for (unsigned Bucket = 0; Bucket < Hdr.BucketCount; ++Bucket) { unsigned Index = AccelSection.getU32(&Offset); @@ -237,14 +237,14 @@ } for (unsigned HashIdx = Index; HashIdx < Hdr.HashCount; ++HashIdx) { - unsigned HashOffset = HashesBase + HashIdx*4; - unsigned OffsetsOffset = OffsetsBase + HashIdx*4; + uint64_t HashOffset = HashesBase + HashIdx*4; + uint64_t OffsetsOffset = OffsetsBase + HashIdx*4; uint32_t Hash = AccelSection.getU32(&HashOffset); if (Hash % Hdr.BucketCount != Bucket) break; - unsigned DataOffset = AccelSection.getU32(&OffsetsOffset); + uint64_t DataOffset = AccelSection.getU32(&OffsetsOffset); ListScope HashScope(W, ("Hash 0x" + Twine::utohexstr(Hash)).str()); if (!AccelSection.isValidOffset(DataOffset)) { W.printString("Invalid section offset"); @@ -265,7 +265,7 @@ } void AppleAcceleratorTable::Entry::extract( - const AppleAcceleratorTable &AccelTable, uint32_t *Offset) { + const AppleAcceleratorTable &AccelTable, uint64_t *Offset) { dwarf::FormParams FormParams = {AccelTable.Hdr.Version, 0, dwarf::DwarfFormat::DWARF32}; @@ -302,7 +302,7 @@ } AppleAcceleratorTable::ValueIterator::ValueIterator( - const AppleAcceleratorTable &AccelTable, unsigned Offset) + const AppleAcceleratorTable &AccelTable, uint64_t Offset) : AccelTable(&AccelTable), Current(AccelTable.HdrData), DataOffset(Offset) { if (!AccelTable.AccelSection.isValidOffsetForDataOfSize(DataOffset, 4)) return; @@ -333,25 +333,25 @@ // Find the bucket. unsigned HashValue = djbHash(Key); unsigned Bucket = HashValue % Hdr.BucketCount; - unsigned BucketBase = sizeof(Hdr) + Hdr.HeaderDataLength; - unsigned HashesBase = BucketBase + Hdr.BucketCount * 4; - unsigned OffsetsBase = HashesBase + Hdr.HashCount * 4; + uint64_t BucketBase = sizeof(Hdr) + Hdr.HeaderDataLength; + uint64_t HashesBase = BucketBase + Hdr.BucketCount * 4; + uint64_t OffsetsBase = HashesBase + Hdr.HashCount * 4; - unsigned BucketOffset = BucketBase + Bucket * 4; + uint64_t BucketOffset = BucketBase + Bucket * 4; unsigned Index = AccelSection.getU32(&BucketOffset); // Search through all hashes in the bucket. for (unsigned HashIdx = Index; HashIdx < Hdr.HashCount; ++HashIdx) { - unsigned HashOffset = HashesBase + HashIdx * 4; - unsigned OffsetsOffset = OffsetsBase + HashIdx * 4; + uint64_t HashOffset = HashesBase + HashIdx * 4; + uint64_t OffsetsOffset = OffsetsBase + HashIdx * 4; uint32_t Hash = AccelSection.getU32(&HashOffset); if (Hash % Hdr.BucketCount != Bucket) // We are already in the next bucket. break; - unsigned DataOffset = AccelSection.getU32(&OffsetsOffset); - unsigned StringOffset = AccelSection.getRelocatedValue(4, &DataOffset); + uint64_t DataOffset = AccelSection.getU32(&OffsetsOffset); + uint64_t StringOffset = AccelSection.getRelocatedValue(4, &DataOffset); if (!StringOffset) break; @@ -377,7 +377,7 @@ } Error DWARFDebugNames::Header::extract(const DWARFDataExtractor &AS, - uint32_t *Offset) { + uint64_t *Offset) { // Check that we can read the fixed-size part. if (!AS.isValidOffset(*Offset + sizeof(HeaderPOD) - 1)) return createStringError(errc::illegal_byte_sequence, @@ -437,7 +437,7 @@ } Expected -DWARFDebugNames::NameIndex::extractAttributeEncoding(uint32_t *Offset) { +DWARFDebugNames::NameIndex::extractAttributeEncoding(uint64_t *Offset) { if (*Offset >= EntriesBase) { return createStringError(errc::illegal_byte_sequence, "Incorrectly terminated abbreviation table."); @@ -449,7 +449,7 @@ } Expected> -DWARFDebugNames::NameIndex::extractAttributeEncodings(uint32_t *Offset) { +DWARFDebugNames::NameIndex::extractAttributeEncodings(uint64_t *Offset) { std::vector Result; for (;;) { auto AttrEncOr = extractAttributeEncoding(Offset); @@ -463,7 +463,7 @@ } Expected -DWARFDebugNames::NameIndex::extractAbbrev(uint32_t *Offset) { +DWARFDebugNames::NameIndex::extractAbbrev(uint64_t *Offset) { if (*Offset >= EntriesBase) { return createStringError(errc::illegal_byte_sequence, "Incorrectly terminated abbreviation table."); @@ -482,7 +482,7 @@ Error DWARFDebugNames::NameIndex::extract() { const DWARFDataExtractor &AS = Section.AccelSection; - uint32_t Offset = Base; + uint64_t Offset = Base; if (Error E = Hdr.extract(AS, &Offset)) return E; @@ -577,27 +577,27 @@ return inconvertibleErrorCode(); } -uint32_t DWARFDebugNames::NameIndex::getCUOffset(uint32_t CU) const { +uint64_t DWARFDebugNames::NameIndex::getCUOffset(uint32_t CU) const { assert(CU < Hdr.CompUnitCount); - uint32_t Offset = CUsBase + 4 * CU; + uint64_t Offset = CUsBase + 4 * CU; return Section.AccelSection.getRelocatedValue(4, &Offset); } -uint32_t DWARFDebugNames::NameIndex::getLocalTUOffset(uint32_t TU) const { +uint64_t DWARFDebugNames::NameIndex::getLocalTUOffset(uint32_t TU) const { assert(TU < Hdr.LocalTypeUnitCount); - uint32_t Offset = CUsBase + 4 * (Hdr.CompUnitCount + TU); + uint64_t Offset = CUsBase + 4 * (Hdr.CompUnitCount + TU); return Section.AccelSection.getRelocatedValue(4, &Offset); } uint64_t DWARFDebugNames::NameIndex::getForeignTUSignature(uint32_t TU) const { assert(TU < Hdr.ForeignTypeUnitCount); - uint32_t Offset = + uint64_t Offset = CUsBase + 4 * (Hdr.CompUnitCount + Hdr.LocalTypeUnitCount) + 8 * TU; return Section.AccelSection.getU64(&Offset); } Expected -DWARFDebugNames::NameIndex::getEntry(uint32_t *Offset) const { +DWARFDebugNames::NameIndex::getEntry(uint64_t *Offset) const { const DWARFDataExtractor &AS = Section.AccelSection; if (!AS.isValidOffset(*Offset)) return createStringError(errc::illegal_byte_sequence, @@ -625,12 +625,12 @@ DWARFDebugNames::NameTableEntry DWARFDebugNames::NameIndex::getNameTableEntry(uint32_t Index) const { assert(0 < Index && Index <= Hdr.NameCount); - uint32_t StringOffsetOffset = StringOffsetsBase + 4 * (Index - 1); - uint32_t EntryOffsetOffset = EntryOffsetsBase + 4 * (Index - 1); + uint64_t StringOffsetOffset = StringOffsetsBase + 4 * (Index - 1); + uint64_t EntryOffsetOffset = EntryOffsetsBase + 4 * (Index - 1); const DWARFDataExtractor &AS = Section.AccelSection; - uint32_t StringOffset = AS.getRelocatedValue(4, &StringOffsetOffset); - uint32_t EntryOffset = AS.getU32(&EntryOffsetOffset); + uint64_t StringOffset = AS.getRelocatedValue(4, &StringOffsetOffset); + uint64_t EntryOffset = AS.getU32(&EntryOffsetOffset); EntryOffset += EntriesBase; return {Section.StringSection, Index, StringOffset, EntryOffset}; } @@ -638,13 +638,13 @@ uint32_t DWARFDebugNames::NameIndex::getBucketArrayEntry(uint32_t Bucket) const { assert(Bucket < Hdr.BucketCount); - uint32_t BucketOffset = BucketsBase + 4 * Bucket; + uint64_t BucketOffset = BucketsBase + 4 * Bucket; return Section.AccelSection.getU32(&BucketOffset); } uint32_t DWARFDebugNames::NameIndex::getHashArrayEntry(uint32_t Index) const { assert(0 < Index && Index <= Hdr.NameCount); - uint32_t HashOffset = HashesBase + 4 * (Index - 1); + uint64_t HashOffset = HashesBase + 4 * (Index - 1); return Section.AccelSection.getU32(&HashOffset); } @@ -653,8 +653,8 @@ // it's not possible to recover this entry list (but the other lists may still // parse OK). bool DWARFDebugNames::NameIndex::dumpEntry(ScopedPrinter &W, - uint32_t *Offset) const { - uint32_t EntryId = *Offset; + uint64_t *Offset) const { + uint64_t EntryId = *Offset; auto EntryOr = getEntry(Offset); if (!EntryOr) { handleAllErrors(EntryOr.takeError(), [](const SentinelError &) {}, @@ -674,10 +674,10 @@ if (Hash) W.printHex("Hash", *Hash); - W.startLine() << format("String: 0x%08x", NTE.getStringOffset()); + W.startLine() << format("String: 0x%08" PRIx64, NTE.getStringOffset()); W.getOStream() << " \"" << NTE.getString() << "\"\n"; - uint32_t EntryOffset = NTE.getEntryOffset(); + uint64_t EntryOffset = NTE.getEntryOffset(); while (dumpEntry(W, &EntryOffset)) /*empty*/; } @@ -685,7 +685,7 @@ void DWARFDebugNames::NameIndex::dumpCUs(ScopedPrinter &W) const { ListScope CUScope(W, "Compilation Unit offsets"); for (uint32_t CU = 0; CU < Hdr.CompUnitCount; ++CU) - W.startLine() << format("CU[%u]: 0x%08x\n", CU, getCUOffset(CU)); + W.startLine() << format("CU[%u]: 0x%08" PRIx64 "\n", CU, getCUOffset(CU)); } void DWARFDebugNames::NameIndex::dumpLocalTUs(ScopedPrinter &W) const { @@ -694,7 +694,7 @@ ListScope TUScope(W, "Local Type Unit offsets"); for (uint32_t TU = 0; TU < Hdr.LocalTypeUnitCount; ++TU) - W.startLine() << format("LocalTU[%u]: 0x%08x\n", TU, getLocalTUOffset(TU)); + W.startLine() << format("LocalTU[%u]: 0x%08" PRIx64 "\n", TU, getLocalTUOffset(TU)); } void DWARFDebugNames::NameIndex::dumpForeignTUs(ScopedPrinter &W) const { @@ -756,7 +756,7 @@ } Error DWARFDebugNames::extract() { - uint32_t Offset = 0; + uint64_t Offset = 0; while (AccelSection.isValidOffset(Offset)) { NameIndex Next(*this, Offset); if (Error E = Next.extract()) @@ -778,7 +778,7 @@ NI.dump(W); } -Optional +Optional DWARFDebugNames::ValueIterator::findEntryOffsetInCurrentIndex() { const Header &Hdr = CurrentIndex->Hdr; if (Hdr.BucketCount == 0) { @@ -822,7 +822,7 @@ } bool DWARFDebugNames::ValueIterator::findInCurrentIndex() { - Optional Offset = findEntryOffsetInCurrentIndex(); + Optional Offset = findEntryOffsetInCurrentIndex(); if (!Offset) return false; DataOffset = *Offset; @@ -877,7 +877,7 @@ } const DWARFDebugNames::NameIndex * -DWARFDebugNames::getCUNameIndex(uint32_t CUOffset) { +DWARFDebugNames::getCUNameIndex(uint64_t CUOffset) { if (CUToNameIndex.size() == 0 && NameIndices.size() > 0) { for (const auto &NI : *this) { for (uint32_t CU = 0; CU < NI.getCUCount(); ++CU) Index: lib/DebugInfo/DWARF/DWARFCompileUnit.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFCompileUnit.cpp +++ lib/DebugInfo/DWARF/DWARFCompileUnit.cpp @@ -15,16 +15,16 @@ using namespace llvm; void DWARFCompileUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) { - OS << format("0x%08x", getOffset()) << ": Compile Unit:" + OS << format("0x%08" PRIx64, getOffset()) << ": Compile Unit:" << " length = " << format("0x%08x", getLength()) << " version = " << format("0x%04x", getVersion()); if (getVersion() >= 5) OS << " unit_type = " << dwarf::UnitTypeString(getUnitType()); - OS << " abbr_offset = " << format("0x%04x", getAbbreviations()->getOffset()) + OS << " abbr_offset = " << format("0x%04" PRIx64, getAbbreviations()->getOffset()) << " addr_size = " << format("0x%02x", getAddressByteSize()); if (getVersion() >= 5 && getUnitType() != dwarf::DW_UT_compile) OS << " DWO_id = " << format("0x%016" PRIx64, *getDWOId()); - OS << " (next unit at " << format("0x%08x", getNextUnitOffset()) << ")\n"; + OS << " (next unit at " << format("0x%08" PRIx64, getNextUnitOffset()) << ")\n"; if (DWARFDie CUDie = getUnitDIE(false)) CUDie.dump(OS, 0, DumpOpts); Index: lib/DebugInfo/DWARF/DWARFContext.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFContext.cpp +++ lib/DebugInfo/DWARF/DWARFContext.cpp @@ -138,7 +138,7 @@ DWARFDataExtractor StrOffsetExt(Obj, StringOffsetsSection, LittleEndian, 0); DataExtractor StrData(StringSection, LittleEndian, 0); uint64_t SectionSize = StringOffsetsSection.Data.size(); - uint32_t Offset = 0; + uint64_t Offset = 0; for (auto &Contribution : Contributions) { // Report an ill-formed contribution. if (!Contribution) { @@ -166,7 +166,7 @@ } // Report a gap in the table. if (Offset < ContributionHeader) { - OS << format("0x%8.8x: Gap, length = ", Offset); + OS << format("0x%8.8" PRIx64 ": Gap, length = ", Offset); OS << (ContributionHeader - Offset) << "\n"; } OS << format("0x%8.8x: ", (uint32_t)ContributionHeader); @@ -181,26 +181,28 @@ Offset = Contribution->Base; unsigned EntrySize = Contribution->getDwarfOffsetByteSize(); while (Offset - Contribution->Base < Contribution->Size) { - OS << format("0x%8.8x: ", Offset); - // FIXME: We can only extract strings if the offset fits in 32 bits. + OS << format("0x%8.8" PRIx64 ": ", Offset); uint64_t StringOffset = StrOffsetExt.getRelocatedValue(EntrySize, &Offset); - // Extract the string if we can and display it. Otherwise just report - // the offset. - if (StringOffset <= std::numeric_limits::max()) { - uint32_t StringOffset32 = (uint32_t)StringOffset; - OS << format("%8.8x ", StringOffset32); - const char *S = StrData.getCStr(&StringOffset32); - if (S) - OS << format("\"%s\"", S); - } else + if (StringOffset <= std::numeric_limits::max()) + OS << format("%8.8x ", (uint32_t)StringOffset); + else OS << format("%16.16" PRIx64 " ", StringOffset); + if (!StrData.isValidOffset(StringOffset)) { + OS << "error: the offset is invalid.\n"; + return; + } + // !!! A valid offset does not exceed size_t even on a 32-bit platform. + size_t StringOffsetSz = (size_t)StringOffset; + const char *S = StrData.getCStr(&StringOffsetSz); + if (S) + OS << format("\"%s\"", S); OS << "\n"; } } // Report a gap at the end of the table. if (Offset < SectionSize) { - OS << format("0x%8.8x: Gap, length = ", Offset); + OS << format("0x%8.8" PRIx64 ": Gap, length = ", Offset); OS << (SectionSize - Offset) << "\n"; } } @@ -225,7 +227,7 @@ StringSection, Units, LittleEndian); else { DataExtractor strOffsetExt(StringOffsetsSection.Data, LittleEndian, 0); - uint32_t offset = 0; + uint64_t offset = 0; uint64_t size = StringOffsetsSection.Data.size(); // Ensure that size is a multiple of the size of an entry. if (size & ((uint64_t)(sizeof(uint32_t) - 1))) { @@ -235,9 +237,9 @@ } DataExtractor StrData(StringSection, LittleEndian, 0); while (offset < size) { - OS << format("0x%8.8x: ", offset); - uint32_t StringOffset = strOffsetExt.getU32(&offset); - OS << format("%8.8x ", StringOffset); + OS << format("0x%8.8" PRIx64 ": ", offset); + uint64_t StringOffset = strOffsetExt.getU32(&offset); + OS << format("%8.8" PRIx64 " ", StringOffset); const char *S = StrData.getCStr(&StringOffset); if (S) OS << format("\"%s\"", S); @@ -250,10 +252,10 @@ static void dumpAddrSection(raw_ostream &OS, DWARFDataExtractor &AddrData, DIDumpOptions DumpOpts, uint16_t Version, uint8_t AddrSize) { - uint32_t Offset = 0; + uint64_t Offset = 0; while (AddrData.isValidOffset(Offset)) { DWARFDebugAddrTable AddrTable; - uint32_t TableOffset = Offset; + uint64_t TableOffset = Offset; if (Error Err = AddrTable.extract(AddrData, &Offset, Version, AddrSize, DWARFContext::dumpWarning)) { WithColor::error() << toString(std::move(Err)) << '\n'; @@ -275,10 +277,10 @@ llvm::function_ref(uint32_t)> LookupPooledAddress, DIDumpOptions DumpOpts) { - uint32_t Offset = 0; + uint64_t Offset = 0; while (rnglistData.isValidOffset(Offset)) { llvm::DWARFDebugRnglistTable Rnglists; - uint32_t TableOffset = Offset; + uint64_t TableOffset = Offset; if (Error Err = Rnglists.extract(rnglistData, &Offset)) { WithColor::error() << toString(std::move(Err)) << '\n'; uint64_t Length = Rnglists.length(); @@ -297,7 +299,7 @@ DWARFDataExtractor Data, const MCRegisterInfo *MRI, Optional DumpOffset) { - uint32_t Offset = 0; + uint64_t Offset = 0; DWARFDebugLoclists Loclists; DWARFListTableHeader Header(".debug_loclists", "locations"); @@ -418,7 +420,7 @@ if (shouldDump(Explicit, ".debug_aranges", DIDT_ID_DebugAranges, DObj->getARangeSection())) { - uint32_t offset = 0; + uint64_t offset = 0; DataExtractor arangesData(DObj->getARangeSection(), isLittleEndian(), 0); DWARFDebugArangeSet set; while (set.extract(arangesData, &offset)) @@ -476,30 +478,30 @@ if (shouldDump(Explicit, ".debug_str", DIDT_ID_DebugStr, DObj->getStringSection())) { DataExtractor strData(DObj->getStringSection(), isLittleEndian(), 0); - uint32_t offset = 0; - uint32_t strOffset = 0; + uint64_t offset = 0; + uint64_t strOffset = 0; while (const char *s = strData.getCStr(&offset)) { - OS << format("0x%8.8x: \"%s\"\n", strOffset, s); + OS << format("0x%8.8" PRIx64 ": \"%s\"\n", strOffset, s); strOffset = offset; } } if (shouldDump(ExplicitDWO, ".debug_str.dwo", DIDT_ID_DebugStr, DObj->getStringDWOSection())) { DataExtractor strDWOData(DObj->getStringDWOSection(), isLittleEndian(), 0); - uint32_t offset = 0; - uint32_t strDWOOffset = 0; + uint64_t offset = 0; + uint64_t strDWOOffset = 0; while (const char *s = strDWOData.getCStr(&offset)) { - OS << format("0x%8.8x: \"%s\"\n", strDWOOffset, s); + OS << format("0x%8.8" PRIx64 ": \"%s\"\n", strDWOOffset, s); strDWOOffset = offset; } } if (shouldDump(Explicit, ".debug_line_str", DIDT_ID_DebugLineStr, DObj->getLineStringSection())) { DataExtractor strData(DObj->getLineStringSection(), isLittleEndian(), 0); - uint32_t offset = 0; - uint32_t strOffset = 0; + uint64_t offset = 0; + uint64_t strOffset = 0; while (const char *s = strData.getCStr(&offset)) { - OS << format("0x%8.8x: \"", strOffset); + OS << format("0x%8.8" PRIx64 ": \"", strOffset); OS.write_escaped(s); OS << "\"\n"; strOffset = offset; @@ -518,7 +520,7 @@ uint8_t savedAddressByteSize = getCUAddrSize(); DWARFDataExtractor rangesData(*DObj, DObj->getRangeSection(), isLittleEndian(), savedAddressByteSize); - uint32_t offset = 0; + uint64_t offset = 0; DWARFDebugRangeList rangeList; while (rangesData.isValidOffset(offset)) { if (Error E = rangeList.extract(rangesData, &offset)) { @@ -641,7 +643,7 @@ return nullptr; } -DWARFDie DWARFContext::getDIEForOffset(uint32_t Offset) { +DWARFDie DWARFContext::getDIEForOffset(uint64_t Offset) { parseNormalUnits(); if (auto *CU = NormalUnits.getUnitForOffset(Offset)) return CU->getDIEForOffset(Offset); @@ -858,7 +860,7 @@ if (!Offset) return nullptr; // No line table for this compile unit. - uint32_t stmtOffset = *Offset + U->getLineTableOffset(); + uint64_t stmtOffset = *Offset + U->getLineTableOffset(); // See if the line table is cached. if (const DWARFLineTable *lt = Line->getLineTable(stmtOffset)) return lt; @@ -898,7 +900,7 @@ }); } -DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) { +DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint64_t Offset) { parseNormalUnits(); return dyn_cast_or_null( NormalUnits.getUnitForOffset(Offset)); @@ -906,7 +908,7 @@ DWARFCompileUnit *DWARFContext::getCompileUnitForAddress(uint64_t Address) { // First, get the offset of the compile unit. - uint32_t CUOffset = getDebugAranges()->findAddress(Address); + uint64_t CUOffset = getDebugAranges()->findAddress(Address); // Retrieve the compile unit. return getCompileUnitForOffset(CUOffset); } Index: lib/DebugInfo/DWARF/DWARFDataExtractor.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDataExtractor.cpp +++ lib/DebugInfo/DWARF/DWARFDataExtractor.cpp @@ -12,7 +12,7 @@ using namespace llvm; -uint64_t DWARFDataExtractor::getRelocatedValue(uint32_t Size, uint32_t *Off, +uint64_t DWARFDataExtractor::getRelocatedValue(uint32_t Size, uint64_t *Off, uint64_t *SecNdx) const { if (SecNdx) *SecNdx = object::SectionedAddress::UndefSection; @@ -28,13 +28,13 @@ } Optional -DWARFDataExtractor::getEncodedPointer(uint32_t *Offset, uint8_t Encoding, +DWARFDataExtractor::getEncodedPointer(uint64_t *Offset, uint8_t Encoding, uint64_t PCRelOffset) const { if (Encoding == dwarf::DW_EH_PE_omit) return None; uint64_t Result = 0; - uint32_t OldOffset = *Offset; + uint64_t OldOffset = *Offset; // First get value switch (Encoding & 0x0F) { case dwarf::DW_EH_PE_absptr: Index: lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp +++ lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp @@ -26,9 +26,9 @@ } bool DWARFAbbreviationDeclarationSet::extract(DataExtractor Data, - uint32_t *OffsetPtr) { + uint64_t *OffsetPtr) { clear(); - const uint32_t BeginOffset = *OffsetPtr; + const uint64_t BeginOffset = *OffsetPtr; Offset = BeginOffset; DWARFAbbreviationDeclaration AbbrDecl; uint32_t PrevAbbrCode = 0; @@ -82,12 +82,12 @@ void DWARFDebugAbbrev::parse() const { if (!Data) return; - uint32_t Offset = 0; + uint64_t Offset = 0; auto I = AbbrDeclSets.begin(); while (Data->isValidOffset(Offset)) { while (I != AbbrDeclSets.end() && I->first < Offset) ++I; - uint32_t CUAbbrOffset = Offset; + uint64_t CUAbbrOffset = Offset; DWARFAbbreviationDeclarationSet AbbrDecls; if (!AbbrDecls.extract(*Data, &Offset)) break; @@ -124,7 +124,7 @@ } if (Data && CUAbbrOffset < Data->getData().size()) { - uint32_t Offset = CUAbbrOffset; + uint64_t Offset = CUAbbrOffset; DWARFAbbreviationDeclarationSet AbbrDecls; if (!AbbrDecls.extract(*Data, &Offset)) return nullptr; Index: lib/DebugInfo/DWARF/DWARFDebugAddr.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugAddr.cpp +++ lib/DebugInfo/DWARF/DWARFDebugAddr.cpp @@ -19,7 +19,7 @@ } Error DWARFDebugAddrTable::extract(DWARFDataExtractor Data, - uint32_t *OffsetPtr, + uint64_t *OffsetPtr, uint16_t Version, uint8_t AddrSize, std::function WarnCallback) { @@ -47,7 +47,7 @@ if (HeaderData.Length == 0xffffffffu) { invalidateLength(); return createStringError(errc::not_supported, - "DWARF64 is not supported in .debug_addr at offset 0x%" PRIx32, + "DWARF64 is not supported in .debug_addr at offset 0x%" PRIx64, HeaderOffset); } if (HeaderData.Length + sizeof(uint32_t) < sizeof(Header)) { @@ -59,13 +59,13 @@ ") to contain a complete header", HeaderOffset, TmpLength); } - uint32_t End = HeaderOffset + getLength(); + uint64_t End = HeaderOffset + getLength(); if (!Data.isValidOffsetForDataOfSize(HeaderOffset, End - HeaderOffset)) { uint32_t TmpLength = getLength(); invalidateLength(); return createStringError(errc::invalid_argument, "section is not large enough to contain a .debug_addr table " - "of length 0x%" PRIx32 " at offset 0x%" PRIx32, + "of length 0x%" PRIx32 " at offset 0x%" PRIx64, TmpLength, HeaderOffset); } @@ -88,7 +88,7 @@ // and consists only of a series of addresses. if (HeaderData.Version > 5) { return createStringError(errc::not_supported, "version %" PRIu16 - " of .debug_addr section at offset 0x%" PRIx32 " is not supported", + " of .debug_addr section at offset 0x%" PRIx64 " is not supported", HeaderData.Version, HeaderOffset); } // FIXME: For now we just treat version mismatch as an error, @@ -97,19 +97,19 @@ // attribute in the info table. if (HeaderData.Version != UnitVersion) return createStringError(errc::invalid_argument, - ".debug_addr table at offset 0x%" PRIx32 + ".debug_addr table at offset 0x%" PRIx64 " has version %" PRIu16 " which is different from the version suggested" " by the DWARF unit header: %" PRIu16, HeaderOffset, HeaderData.Version, UnitVersion); if (HeaderData.AddrSize != 4 && HeaderData.AddrSize != 8) return createStringError(errc::not_supported, - ".debug_addr table at offset 0x%" PRIx32 + ".debug_addr table at offset 0x%" PRIx64 " has unsupported address size %" PRIu8, HeaderOffset, HeaderData.AddrSize); if (HeaderData.AddrSize != AddrSize && AddrSize != 0) return createStringError(errc::invalid_argument, - ".debug_addr table at offset 0x%" PRIx32 + ".debug_addr table at offset 0x%" PRIx64 " has address size %" PRIu8 " which is different from CU address size %" PRIu8, HeaderOffset, HeaderData.AddrSize, AddrSize); @@ -117,13 +117,13 @@ // TODO: add support for non-zero segment selector size. if (HeaderData.SegSize != 0) return createStringError(errc::not_supported, - ".debug_addr table at offset 0x%" PRIx32 + ".debug_addr table at offset 0x%" PRIx64 " has unsupported segment selector size %" PRIu8, HeaderOffset, HeaderData.SegSize); if (DataSize % HeaderData.AddrSize != 0) { invalidateLength(); return createStringError(errc::invalid_argument, - ".debug_addr table at offset 0x%" PRIx32 + ".debug_addr table at offset 0x%" PRIx64 " contains data of size %" PRIu32 " which is not a multiple of addr size %" PRIu8, HeaderOffset, DataSize, HeaderData.AddrSize); @@ -140,7 +140,7 @@ void DWARFDebugAddrTable::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const { if (DumpOpts.Verbose) - OS << format("0x%8.8" PRIx32 ": ", HeaderOffset); + OS << format("0x%8.8" PRIx64 ": ", HeaderOffset); OS << format("Addr Section: length = 0x%8.8" PRIx32 ", version = 0x%4.4" PRIx16 ", " "addr_size = 0x%2.2" PRIx8 ", seg_size = 0x%2.2" PRIx8 "\n", @@ -177,7 +177,7 @@ return Addrs[Index]; return createStringError(errc::invalid_argument, "Index %" PRIu32 " is out of range of the " - ".debug_addr table at offset 0x%" PRIx32, + ".debug_addr table at offset 0x%" PRIx64, Index, HeaderOffset); } Index: lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp +++ lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp @@ -24,13 +24,13 @@ } void DWARFDebugArangeSet::clear() { - Offset = -1U; + Offset = -1ULL; std::memset(&HeaderData, 0, sizeof(Header)); ArangeDescriptors.clear(); } bool -DWARFDebugArangeSet::extract(DataExtractor data, uint32_t *offset_ptr) { +DWARFDebugArangeSet::extract(DataExtractor data, uint64_t *offset_ptr) { if (data.isValidOffset(*offset_ptr)) { ArangeDescriptors.clear(); Offset = *offset_ptr; @@ -68,7 +68,7 @@ // appropriate boundary. const uint32_t header_size = *offset_ptr - Offset; const uint32_t tuple_size = HeaderData.AddrSize * 2; - uint32_t first_tuple_offset = 0; + uint64_t first_tuple_offset = 0; while (first_tuple_offset < header_size) first_tuple_offset += tuple_size; @@ -101,7 +101,7 @@ void DWARFDebugArangeSet::dump(raw_ostream &OS) const { OS << format("Address Range Header: length = 0x%8.8x, version = 0x%4.4x, ", HeaderData.Length, HeaderData.Version) - << format("cu_offset = 0x%8.8x, addr_size = 0x%2.2x, seg_size = 0x%2.2x\n", + << format("cu_offset = 0x%8.8" PRIx64 ", addr_size = 0x%2.2x, seg_size = 0x%2.2x\n", HeaderData.CuOffset, HeaderData.AddrSize, HeaderData.SegSize); for (const auto &Desc : ArangeDescriptors) { Index: lib/DebugInfo/DWARF/DWARFDebugAranges.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugAranges.cpp +++ lib/DebugInfo/DWARF/DWARFDebugAranges.cpp @@ -23,11 +23,11 @@ void DWARFDebugAranges::extract(DataExtractor DebugArangesData) { if (!DebugArangesData.isValidOffset(0)) return; - uint32_t Offset = 0; + uint64_t Offset = 0; DWARFDebugArangeSet Set; while (Set.extract(DebugArangesData, &Offset)) { - uint32_t CUOffset = Set.getCompileUnitDIEOffset(); + uint64_t CUOffset = Set.getCompileUnitDIEOffset(); for (const auto &Desc : Set.descriptors()) { uint64_t LowPC = Desc.Address; uint64_t HighPC = Desc.getEndAddress(); @@ -71,7 +71,7 @@ ParsedCUOffsets.clear(); } -void DWARFDebugAranges::appendRange(uint32_t CUOffset, uint64_t LowPC, +void DWARFDebugAranges::appendRange(uint64_t CUOffset, uint64_t LowPC, uint64_t HighPC) { if (LowPC >= HighPC) return; @@ -80,8 +80,8 @@ } void DWARFDebugAranges::construct() { - std::multiset ValidCUs; // Maintain the set of CUs describing - // a current address range. + std::multiset ValidCUs; // Maintain the set of CUs describing + // a current address range. llvm::sort(Endpoints); uint64_t PrevAddress = -1ULL; for (const auto &E : Endpoints) { @@ -113,10 +113,10 @@ Endpoints.shrink_to_fit(); } -uint32_t DWARFDebugAranges::findAddress(uint64_t Address) const { +uint64_t DWARFDebugAranges::findAddress(uint64_t Address) const { RangeCollIterator It = partition_point(Aranges, [=](Range R) { return R.HighPC() <= Address; }); if (It != Aranges.end() && It->LowPC <= Address) return It->CUOffset; - return -1U; + return -1ULL; } Index: lib/DebugInfo/DWARF/DWARFDebugFrame.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugFrame.cpp +++ lib/DebugInfo/DWARF/DWARFDebugFrame.cpp @@ -34,8 +34,8 @@ const uint8_t DWARF_CFI_PRIMARY_OPCODE_MASK = 0xc0; const uint8_t DWARF_CFI_PRIMARY_OPERAND_MASK = 0x3f; -Error CFIProgram::parse(DataExtractor Data, uint32_t *Offset, - uint32_t EndOffset) { +Error CFIProgram::parse(DataExtractor Data, uint64_t *Offset, + uint64_t EndOffset) { while (*Offset < EndOffset) { uint8_t Opcode = Data.getU8(Offset); // Some instructions have a primary opcode encoded in the top bits. @@ -331,7 +331,7 @@ DWARFDebugFrame::~DWARFDebugFrame() = default; static void LLVM_ATTRIBUTE_UNUSED dumpDataAux(DataExtractor Data, - uint32_t Offset, int Length) { + uint64_t Offset, int Length) { errs() << "DUMP: "; for (int i = 0; i < Length; ++i) { uint8_t c = Data.getU8(&Offset); @@ -344,7 +344,7 @@ // noreturn attribute usage in lambdas. Once the support for those // compilers are phased out, we can remove this and return back to // a ReportError lambda: [StartOffset](const char *ErrorMsg). -static void LLVM_ATTRIBUTE_NORETURN ReportError(uint32_t StartOffset, +static void LLVM_ATTRIBUTE_NORETURN ReportError(uint64_t StartOffset, const char *ErrorMsg) { std::string Str; raw_string_ostream OS(Str); @@ -354,11 +354,11 @@ } void DWARFDebugFrame::parse(DWARFDataExtractor Data) { - uint32_t Offset = 0; - DenseMap CIEs; + uint64_t Offset = 0; + DenseMap CIEs; while (Data.isValidOffset(Offset)) { - uint32_t StartOffset = Offset; + uint64_t StartOffset = Offset; bool IsDWARF64 = false; uint64_t Length = Data.getU32(&Offset); @@ -376,10 +376,8 @@ // Length is the structure size excluding itself. Compute an offset one // past the end of the structure (needed to know how many instructions to // read). - // TODO: For honest DWARF64 support, DataExtractor will have to treat - // offset_ptr as uint64_t* - uint32_t StartStructureOffset = Offset; - uint32_t EndStructureOffset = Offset + static_cast(Length); + uint64_t StartStructureOffset = Offset; + uint64_t EndStructureOffset = Offset + Length; // The Id field's size depends on the DWARF format Id = Data.getUnsigned(&Offset, (IsDWARF64 && !IsEH) ? 8 : 4); @@ -407,22 +405,22 @@ Optional PersonalityEncoding; if (IsEH) { Optional AugmentationLength; - uint32_t StartAugmentationOffset; - uint32_t EndAugmentationOffset; + uint64_t StartAugmentationOffset; + uint64_t EndAugmentationOffset; // Walk the augmentation string to get all the augmentation data. for (unsigned i = 0, e = AugmentationString.size(); i != e; ++i) { switch (AugmentationString[i]) { default: ReportError(StartOffset, - "Unknown augmentation character in entry at %lx"); + "Unknown augmentation character in entry at %" PRIx64); case 'L': LSDAPointerEncoding = Data.getU8(&Offset); break; case 'P': { if (Personality) ReportError(StartOffset, - "Duplicate personality in entry at %lx"); + "Duplicate personality in entry at %" PRIx64); PersonalityEncoding = Data.getU8(&Offset); Personality = Data.getEncodedPointer( &Offset, *PersonalityEncoding, @@ -438,13 +436,12 @@ case 'z': if (i) ReportError(StartOffset, - "'z' must be the first character at %lx"); + "'z' must be the first character at %" PRIx64); // Parse the augmentation length first. We only parse it if // the string contains a 'z'. AugmentationLength = Data.getULEB128(&Offset); StartAugmentationOffset = Offset; - EndAugmentationOffset = Offset + - static_cast(*AugmentationLength); + EndAugmentationOffset = Offset + *AugmentationLength; break; case 'B': // B-Key is used for signing functions associated with this @@ -455,7 +452,7 @@ if (AugmentationLength.hasValue()) { if (Offset != EndAugmentationOffset) - ReportError(StartOffset, "Parsing augmentation data at %lx failed"); + ReportError(StartOffset, "Parsing augmentation data at %" PRIx64 " failed"); AugmentationData = Data.getData().slice(StartAugmentationOffset, EndAugmentationOffset); @@ -498,8 +495,7 @@ // Parse the augmentation length and data for this FDE. uint64_t AugmentationLength = Data.getULEB128(&Offset); - uint32_t EndAugmentationOffset = - Offset + static_cast(AugmentationLength); + uint64_t EndAugmentationOffset = Offset + AugmentationLength; // Decode the LSDA if the CIE augmentation string said we should. if (Cie->getLSDAPointerEncoding() != DW_EH_PE_omit) { @@ -509,7 +505,7 @@ } if (Offset != EndAugmentationOffset) - ReportError(StartOffset, "Parsing augmentation data at %lx failed"); + ReportError(StartOffset, "Parsing augmentation data at %" PRIx64 " failed"); } } else { InitialLocation = Data.getAddress(&Offset); @@ -527,7 +523,7 @@ } if (Offset != EndStructureOffset) - ReportError(StartOffset, "Parsing entry instructions at %lx failed"); + ReportError(StartOffset, "Parsing entry instructions at %" PRIx64 " failed"); } } Index: lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp +++ lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp @@ -19,15 +19,15 @@ using namespace dwarf; bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U, - uint32_t *OffsetPtr) { + uint64_t *OffsetPtr) { DWARFDataExtractor DebugInfoData = U.getDebugInfoExtractor(); - const uint32_t UEndOffset = U.getNextUnitOffset(); + const uint64_t UEndOffset = U.getNextUnitOffset(); return extractFast(U, OffsetPtr, DebugInfoData, UEndOffset, 0); } -bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U, uint32_t *OffsetPtr, +bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U, uint64_t *OffsetPtr, const DWARFDataExtractor &DebugInfoData, - uint32_t UEndOffset, uint32_t D) { + uint64_t UEndOffset, uint32_t D) { Offset = *OffsetPtr; Depth = D; if (Offset >= UEndOffset || !DebugInfoData.isValidOffset(Offset)) Index: lib/DebugInfo/DWARF/DWARFDebugLine.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -136,7 +136,7 @@ // Parse v2-v4 directory and file tables. static void parseV2DirFileTables(const DWARFDataExtractor &DebugLineData, - uint32_t *OffsetPtr, uint64_t EndPrologueOffset, + uint64_t *OffsetPtr, uint64_t EndPrologueOffset, DWARFDebugLine::ContentTypeTracker &ContentTypes, std::vector &IncludeDirectories, std::vector &FileNames) { @@ -170,7 +170,7 @@ // Returns the descriptors, or an empty vector if we did not find a path or // ran off the end of the prologue. static ContentDescriptors -parseV5EntryFormat(const DWARFDataExtractor &DebugLineData, uint32_t +parseV5EntryFormat(const DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, uint64_t EndPrologueOffset, DWARFDebugLine::ContentTypeTracker *ContentTypes) { ContentDescriptors Descriptors; @@ -194,7 +194,7 @@ static bool parseV5DirFileTables(const DWARFDataExtractor &DebugLineData, - uint32_t *OffsetPtr, uint64_t EndPrologueOffset, + uint64_t *OffsetPtr, uint64_t EndPrologueOffset, const dwarf::FormParams &FormParams, const DWARFContext &Ctx, const DWARFUnit *U, DWARFDebugLine::ContentTypeTracker &ContentTypes, @@ -274,7 +274,7 @@ } Error DWARFDebugLine::Prologue::parse(const DWARFDataExtractor &DebugLineData, - uint32_t *OffsetPtr, + uint64_t *OffsetPtr, const DWARFContext &Ctx, const DWARFUnit *U) { const uint64_t PrologueOffset = *OffsetPtr; @@ -447,7 +447,7 @@ } const DWARFDebugLine::LineTable * -DWARFDebugLine::getLineTable(uint32_t Offset) const { +DWARFDebugLine::getLineTable(uint64_t Offset) const { LineTableConstIter Pos = LineTableMap.find(Offset); if (Pos != LineTableMap.end()) return &Pos->second; @@ -455,10 +455,10 @@ } Expected DWARFDebugLine::getOrParseLineTable( - DWARFDataExtractor &DebugLineData, uint32_t Offset, const DWARFContext &Ctx, + DWARFDataExtractor &DebugLineData, uint64_t Offset, const DWARFContext &Ctx, const DWARFUnit *U, std::function RecoverableErrorCallback) { if (!DebugLineData.isValidOffset(Offset)) - return createStringError(errc::invalid_argument, "offset 0x%8.8" PRIx32 + return createStringError(errc::invalid_argument, "offset 0x%8.8" PRIx64 " is not a valid debug line section offset", Offset); @@ -475,10 +475,10 @@ } Error DWARFDebugLine::LineTable::parse( - DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr, + DWARFDataExtractor &DebugLineData, uint64_t *OffsetPtr, const DWARFContext &Ctx, const DWARFUnit *U, std::function RecoverableErrorCallback, raw_ostream *OS) { - const uint32_t DebugLineOffset = *OffsetPtr; + const uint64_t DebugLineOffset = *OffsetPtr; clear(); @@ -494,7 +494,7 @@ if (PrologueErr) return PrologueErr; - const uint32_t EndOffset = + const uint64_t EndOffset = DebugLineOffset + Prologue.TotalLength + Prologue.sizeofTotalLength(); // See if we should tell the data extractor the address size. @@ -508,7 +508,7 @@ while (*OffsetPtr < EndOffset) { if (OS) - *OS << format("0x%08.08" PRIx32 ": ", *OffsetPtr); + *OS << format("0x%08.08" PRIx64 ": ", *OffsetPtr); uint8_t Opcode = DebugLineData.getU8(OffsetPtr); @@ -519,7 +519,7 @@ // Extended Opcodes always start with a zero opcode followed by // a uleb128 length so you can skip ones you don't know about uint64_t Len = DebugLineData.getULEB128(OffsetPtr); - uint32_t ExtOffset = *OffsetPtr; + uint64_t ExtOffset = *OffsetPtr; // Tolerate zero-length; assume length is correct and soldier on. if (Len == 0) { @@ -564,7 +564,7 @@ DebugLineData.setAddressSize(Len - 1); else if (DebugLineData.getAddressSize() != Len - 1) { return createStringError(errc::invalid_argument, - "mismatching address size at offset 0x%8.8" PRIx32 + "mismatching address size at offset 0x%8.8" PRIx64 " expected 0x%2.2" PRIx8 " found 0x%2.2" PRIx64, ExtOffset, DebugLineData.getAddressSize(), Len - 1); @@ -631,8 +631,8 @@ // Otherwise we have an unparseable line-number program. if (*OffsetPtr - ExtOffset != Len) return createStringError(errc::illegal_byte_sequence, - "unexpected line op length at offset 0x%8.8" PRIx32 - " expected 0x%2.2" PRIx64 " found 0x%2.2" PRIx32, + "unexpected line op length at offset 0x%8.8" PRIx64 + " expected 0x%2.2" PRIx64 " found 0x%2.2" PRIx64, ExtOffset, Len, *OffsetPtr - ExtOffset); } else if (Opcode < Prologue.OpcodeBase) { if (OS) @@ -1101,7 +1101,7 @@ assert(DebugLineData.isValidOffset(Offset) && "parsing should have terminated"); DWARFUnit *U = prepareToParse(Offset); - uint32_t OldOffset = Offset; + uint64_t OldOffset = Offset; LineTable LT; if (Error Err = LT.parse(DebugLineData, &Offset, Context, U, RecoverableErrorCallback, OS)) @@ -1115,14 +1115,14 @@ assert(DebugLineData.isValidOffset(Offset) && "parsing should have terminated"); DWARFUnit *U = prepareToParse(Offset); - uint32_t OldOffset = Offset; + uint64_t OldOffset = Offset; LineTable LT; if (Error Err = LT.Prologue.parse(DebugLineData, &Offset, Context, U)) ErrorCallback(std::move(Err)); moveToNextTable(OldOffset, LT.Prologue); } -DWARFUnit *DWARFDebugLine::SectionParser::prepareToParse(uint32_t Offset) { +DWARFUnit *DWARFDebugLine::SectionParser::prepareToParse(uint64_t Offset) { DWARFUnit *U = nullptr; auto It = LineToUnit.find(Offset); if (It != LineToUnit.end()) @@ -1131,7 +1131,7 @@ return U; } -void DWARFDebugLine::SectionParser::moveToNextTable(uint32_t OldOffset, +void DWARFDebugLine::SectionParser::moveToNextTable(uint64_t OldOffset, const Prologue &P) { // If the length field is not valid, we don't know where the next table is, so // cannot continue to parse. Mark the parser as done, and leave the Offset Index: lib/DebugInfo/DWARF/DWARFDebugLoc.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugLoc.cpp +++ lib/DebugInfo/DWARF/DWARFDebugLoc.cpp @@ -67,7 +67,7 @@ void DWARFDebugLoc::dump(raw_ostream &OS, const MCRegisterInfo *MRI, Optional Offset) const { auto DumpLocationList = [&](const LocationList &L) { - OS << format("0x%8.8x: ", L.Offset); + OS << format("0x%8.8" PRIx64 ": ", L.Offset); L.dump(OS, IsLittleEndian, AddressSize, MRI, nullptr, 0, 12); OS << "\n\n"; }; @@ -84,7 +84,7 @@ } Optional -DWARFDebugLoc::parseOneLocationList(DWARFDataExtractor Data, unsigned *Offset) { +DWARFDebugLoc::parseOneLocationList(DWARFDataExtractor Data, uint64_t *Offset) { LocationList LL; LL.Offset = *Offset; @@ -132,7 +132,7 @@ IsLittleEndian = data.isLittleEndian(); AddressSize = data.getAddressSize(); - uint32_t Offset = 0; + uint64_t Offset = 0; while (data.isValidOffset(Offset + data.getAddressSize() - 1)) { if (auto LL = parseOneLocationList(data, &Offset)) Locations.push_back(std::move(*LL)); @@ -144,7 +144,7 @@ } Optional -DWARFDebugLoclists::parseOneLocationList(DataExtractor Data, unsigned *Offset, +DWARFDebugLoclists::parseOneLocationList(DataExtractor Data, uint64_t *Offset, unsigned Version) { LocationList LL; LL.Offset = *Offset; @@ -201,7 +201,7 @@ IsLittleEndian = data.isLittleEndian(); AddressSize = data.getAddressSize(); - uint32_t Offset = 0; + uint64_t Offset = 0; while (data.isValidOffset(Offset)) { if (auto LL = parseOneLocationList(data, &Offset, Version)) Locations.push_back(std::move(*LL)); Index: lib/DebugInfo/DWARF/DWARFDebugMacro.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugMacro.cpp +++ lib/DebugInfo/DWARF/DWARFDebugMacro.cpp @@ -53,7 +53,7 @@ } void DWARFDebugMacro::parse(DataExtractor data) { - uint32_t Offset = 0; + uint64_t Offset = 0; while (data.isValidOffset(Offset)) { // A macro list entry consists of: Entry E; Index: lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp +++ lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp @@ -23,7 +23,7 @@ bool LittleEndian, bool GnuStyle) : GnuStyle(GnuStyle) { DWARFDataExtractor PubNames(Obj, Sec, LittleEndian, 0); - uint32_t Offset = 0; + uint64_t Offset = 0; while (PubNames.isValidOffset(Offset)) { Sets.push_back({}); Set &SetData = Sets.back(); @@ -34,7 +34,7 @@ SetData.Size = PubNames.getU32(&Offset); while (Offset < Sec.Data.size()) { - uint32_t DieRef = PubNames.getU32(&Offset); + uint64_t DieRef = PubNames.getU32(&Offset); if (DieRef == 0) break; uint8_t IndexEntryValue = GnuStyle ? PubNames.getU8(&Offset) : 0; @@ -49,13 +49,13 @@ for (const Set &S : Sets) { OS << "length = " << format("0x%08x", S.Length); OS << " version = " << format("0x%04x", S.Version); - OS << " unit_offset = " << format("0x%08x", S.Offset); + OS << " unit_offset = " << format("0x%08" PRIx64, S.Offset); OS << " unit_size = " << format("0x%08x", S.Size) << '\n'; OS << (GnuStyle ? "Offset Linkage Kind Name\n" : "Offset Name\n"); for (const Entry &E : S.Entries) { - OS << format("0x%8.8x ", E.SecOffset); + OS << format("0x%8.8" PRIx64 " ", E.SecOffset); if (GnuStyle) { StringRef EntryLinkage = GDBIndexEntryLinkageString(E.Descriptor.Linkage); Index: lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp +++ lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp @@ -17,17 +17,17 @@ using namespace llvm; void DWARFDebugRangeList::clear() { - Offset = -1U; + Offset = -1ULL; AddressSize = 0; Entries.clear(); } Error DWARFDebugRangeList::extract(const DWARFDataExtractor &data, - uint32_t *offset_ptr) { + uint64_t *offset_ptr) { clear(); if (!data.isValidOffset(*offset_ptr)) return createStringError(errc::invalid_argument, - "invalid range list offset 0x%" PRIx32, *offset_ptr); + "invalid range list offset 0x%" PRIx64, *offset_ptr); AddressSize = data.getAddressSize(); if (AddressSize != 4 && AddressSize != 8) @@ -38,7 +38,7 @@ RangeListEntry Entry; Entry.SectionIndex = -1ULL; - uint32_t prev_offset = *offset_ptr; + uint64_t prev_offset = *offset_ptr; Entry.StartAddress = data.getRelocatedAddress(offset_ptr); Entry.EndAddress = data.getRelocatedAddress(offset_ptr, &Entry.SectionIndex); @@ -47,7 +47,7 @@ if (*offset_ptr != prev_offset + 2 * AddressSize) { clear(); return createStringError(errc::invalid_argument, - "invalid range list entry at offset 0x%" PRIx32, + "invalid range list entry at offset 0x%" PRIx64, prev_offset); } if (Entry.isEndOfListEntry()) @@ -60,11 +60,11 @@ void DWARFDebugRangeList::dump(raw_ostream &OS) const { for (const RangeListEntry &RLE : Entries) { const char *format_str = (AddressSize == 4 - ? "%08x %08" PRIx64 " %08" PRIx64 "\n" - : "%08x %016" PRIx64 " %016" PRIx64 "\n"); + ? "%08" PRIx64 " %08" PRIx64 " %08" PRIx64 "\n" + : "%08" PRIx64 " %016" PRIx64 " %016" PRIx64 "\n"); OS << format(format_str, Offset, RLE.StartAddress, RLE.EndAddress); } - OS << format("%08x \n", Offset); + OS << format("%08" PRIx64 " \n", Offset); } DWARFAddressRangesVector DWARFDebugRangeList::getAbsoluteRanges( Index: lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp +++ lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp @@ -16,8 +16,8 @@ using namespace llvm; -Error RangeListEntry::extract(DWARFDataExtractor Data, uint32_t End, - uint32_t *OffsetPtr) { +Error RangeListEntry::extract(DWARFDataExtractor Data, uint64_t End, + uint64_t *OffsetPtr) { Offset = *OffsetPtr; SectionIndex = -1ULL; // The caller should guarantee that we have at least 1 byte available, so @@ -32,41 +32,41 @@ break; // TODO: Support other encodings. case dwarf::DW_RLE_base_addressx: { - uint32_t PreviousOffset = *OffsetPtr - 1; + uint64_t PreviousOffset = *OffsetPtr - 1; Value0 = Data.getULEB128(OffsetPtr); if (End < *OffsetPtr) return createStringError( errc::invalid_argument, "read past end of table when reading " - "DW_RLE_base_addressx encoding at offset 0x%" PRIx32, + "DW_RLE_base_addressx encoding at offset 0x%" PRIx64, PreviousOffset); break; } case dwarf::DW_RLE_startx_endx: return createStringError(errc::not_supported, "unsupported rnglists encoding DW_RLE_startx_endx at " - "offset 0x%" PRIx32, + "offset 0x%" PRIx64, *OffsetPtr - 1); case dwarf::DW_RLE_startx_length: { - uint32_t PreviousOffset = *OffsetPtr - 1; + uint64_t PreviousOffset = *OffsetPtr - 1; Value0 = Data.getULEB128(OffsetPtr); Value1 = Data.getULEB128(OffsetPtr); if (End < *OffsetPtr) return createStringError( errc::invalid_argument, "read past end of table when reading " - "DW_RLE_startx_length encoding at offset 0x%" PRIx32, + "DW_RLE_startx_length encoding at offset 0x%" PRIx64, PreviousOffset); break; } case dwarf::DW_RLE_offset_pair: { - uint32_t PreviousOffset = *OffsetPtr - 1; + uint64_t PreviousOffset = *OffsetPtr - 1; Value0 = Data.getULEB128(OffsetPtr); Value1 = Data.getULEB128(OffsetPtr); if (End < *OffsetPtr) return createStringError(errc::invalid_argument, "read past end of table when reading " - "DW_RLE_offset_pair encoding at offset 0x%" PRIx32, + "DW_RLE_offset_pair encoding at offset 0x%" PRIx64, PreviousOffset); break; } @@ -74,7 +74,7 @@ if ((End - *OffsetPtr) < Data.getAddressSize()) return createStringError(errc::invalid_argument, "insufficient space remaining in table for " - "DW_RLE_base_address encoding at offset 0x%" PRIx32, + "DW_RLE_base_address encoding at offset 0x%" PRIx64, *OffsetPtr - 1); Value0 = Data.getRelocatedAddress(OffsetPtr, &SectionIndex); break; @@ -84,27 +84,27 @@ return createStringError(errc::invalid_argument, "insufficient space remaining in table for " "DW_RLE_start_end encoding " - "at offset 0x%" PRIx32, + "at offset 0x%" PRIx64, *OffsetPtr - 1); Value0 = Data.getRelocatedAddress(OffsetPtr, &SectionIndex); Value1 = Data.getRelocatedAddress(OffsetPtr); break; } case dwarf::DW_RLE_start_length: { - uint32_t PreviousOffset = *OffsetPtr - 1; + uint64_t PreviousOffset = *OffsetPtr - 1; Value0 = Data.getRelocatedAddress(OffsetPtr, &SectionIndex); Value1 = Data.getULEB128(OffsetPtr); if (End < *OffsetPtr) return createStringError(errc::invalid_argument, "read past end of table when reading " - "DW_RLE_start_length encoding at offset 0x%" PRIx32, + "DW_RLE_start_length encoding at offset 0x%" PRIx64, PreviousOffset); break; } default: return createStringError(errc::not_supported, "unknown rnglists encoding 0x%" PRIx32 - " at offset 0x%" PRIx32, + " at offset 0x%" PRIx64, uint32_t(Encoding), *OffsetPtr - 1); } @@ -187,7 +187,7 @@ if (DumpOpts.Verbose) { // Print the section offset in verbose mode. - OS << format("0x%8.8" PRIx32 ":", Offset); + OS << format("0x%8.8" PRIx64 ":", Offset); auto EncodingString = dwarf::RangeListEncodingString(EntryKind); // Unsupported encodings should have been reported during parsing. assert(!EncodingString.empty() && "Unknown range entry encoding"); Index: lib/DebugInfo/DWARF/DWARFDie.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDie.cpp +++ lib/DebugInfo/DWARF/DWARFDie.cpp @@ -92,7 +92,7 @@ FormValue.dump(OS, DumpOpts); if (FormValue.isFormClass(DWARFFormValue::FC_SectionOffset)) { - uint32_t Offset = *FormValue.getAsSectionOffset(); + uint64_t Offset = *FormValue.getAsSectionOffset(); if (!U->isDWOUnit() && !U->getLocSection()->Data.empty()) { DWARFDebugLoc DebugLoc; DWARFDataExtractor Data(Obj, *U->getLocSection(), Ctx.isLittleEndian(), @@ -264,7 +264,7 @@ } static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die, - uint32_t *OffsetPtr, dwarf::Attribute Attr, + uint64_t *OffsetPtr, dwarf::Attribute Attr, dwarf::Form Form, unsigned Indent, DIDumpOptions DumpOpts) { if (!Die.isValid()) @@ -568,8 +568,8 @@ if (!isValid()) return; DWARFDataExtractor debug_info_data = U->getDebugInfoExtractor(); - const uint32_t Offset = getOffset(); - uint32_t offset = Offset; + const uint64_t Offset = getOffset(); + uint64_t offset = Offset; if (DumpOpts.ShowParents) { DIDumpOptions ParentDumpOpts = DumpOpts; ParentDumpOpts.ShowParents = false; @@ -581,7 +581,7 @@ uint32_t abbrCode = debug_info_data.getULEB128(&offset); if (DumpOpts.ShowAddresses) WithColor(OS, HighlightColor::Address).get() - << format("\n0x%8.8x: ", Offset); + << format("\n0x%8.8" PRIx64 ": ", Offset); if (abbrCode) { auto AbbrevDecl = getAbbreviationDeclarationPtr(); @@ -685,7 +685,7 @@ AttrValue.Attr = AbbrDecl.getAttrByIndex(Index); // Add the previous byte size of any previous attribute value. AttrValue.Offset += AttrValue.ByteSize; - uint32_t ParseOffset = AttrValue.Offset; + uint64_t ParseOffset = AttrValue.Offset; auto U = Die.getDwarfUnit(); assert(U && "Die must have valid DWARF unit"); AttrValue.Value = DWARFFormValue::createFromUnit( Index: lib/DebugInfo/DWARF/DWARFExpression.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFExpression.cpp +++ lib/DebugInfo/DWARF/DWARFExpression.cpp @@ -119,7 +119,7 @@ } bool DWARFExpression::Operation::extract(DataExtractor Data, uint16_t Version, - uint8_t AddressSize, uint32_t Offset) { + uint8_t AddressSize, uint64_t Offset) { Opcode = Data.getU8(&Offset); Desc = getOpDesc(Opcode); @@ -263,7 +263,7 @@ if (Size == Operation::BaseTypeRef && U) { auto Die = U->getDIEForOffset(U->getOffset() + Operands[Operand]); if (Die && Die.getTag() == dwarf::DW_TAG_base_type) { - OS << format(" (0x%08x)", U->getOffset() + Operands[Operand]); + OS << format(" (0x%08" PRIx64 ")", U->getOffset() + Operands[Operand]); if (auto Name = Die.find(dwarf::DW_AT_name)) OS << " \"" << Name->getAsCString() << "\""; } else { @@ -271,7 +271,7 @@ Operands[Operand]); } } else if (Size == Operation::SizeBlock) { - uint32_t Offset = Operands[Operand]; + uint64_t Offset = Operands[Operand]; for (unsigned i = 0; i < Operands[Operand - 1]; ++i) OS << format(" 0x%02x", Expr->Data.getU8(&Offset)); } else { @@ -290,7 +290,7 @@ uint32_t EntryValExprSize = 0; for (auto &Op : *this) { if (!Op.print(OS, this, RegInfo, U, IsEH)) { - uint32_t FailOffset = Op.getEndOffset(); + uint64_t FailOffset = Op.getEndOffset(); while (FailOffset < Data.getData().size()) OS << format(" %02x", Data.getU8(&FailOffset)); return; Index: lib/DebugInfo/DWARF/DWARFFormValue.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFFormValue.cpp +++ lib/DebugInfo/DWARF/DWARFFormValue.cpp @@ -98,7 +98,7 @@ } DWARFFormValue DWARFFormValue::createFromUnit(dwarf::Form F, const DWARFUnit *U, - uint32_t *OffsetPtr) { + uint64_t *OffsetPtr) { DWARFFormValue FormValue(F); FormValue.extractValue(U->getDebugInfoExtractor(), OffsetPtr, U->getFormParams(), U); @@ -106,7 +106,7 @@ } bool DWARFFormValue::skipValue(dwarf::Form Form, DataExtractor DebugInfoData, - uint32_t *OffsetPtr, + uint64_t *OffsetPtr, const dwarf::FormParams Params) { bool Indirect = false; do { @@ -234,7 +234,7 @@ } bool DWARFFormValue::extractValue(const DWARFDataExtractor &Data, - uint32_t *OffsetPtr, dwarf::FormParams FP, + uint64_t *OffsetPtr, dwarf::FormParams FP, const DWARFContext *Ctx, const DWARFUnit *CU) { if (!Ctx && CU) @@ -590,7 +590,7 @@ // FIXME: Add support for DW_FORM_GNU_strp_alt if (Form == DW_FORM_GNU_strp_alt || C == nullptr) return None; - uint32_t Offset = Value.uval; + uint64_t Offset = Value.uval; if (Form == DW_FORM_line_strp) { // .debug_line_str is tracked in the Context. if (const char *Str = C->getLineStringExtractor().getCStr(&Offset)) Index: lib/DebugInfo/DWARF/DWARFGdbIndex.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFGdbIndex.cpp +++ lib/DebugInfo/DWARF/DWARFGdbIndex.cpp @@ -112,7 +112,7 @@ } bool DWARFGdbIndex::parseImpl(DataExtractor Data) { - uint32_t Offset = 0; + uint64_t Offset = 0; // Only version 7 is supported at this moment. Version = Data.getU32(&Offset); Index: lib/DebugInfo/DWARF/DWARFListTable.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFListTable.cpp +++ lib/DebugInfo/DWARF/DWARFListTable.cpp @@ -16,32 +16,32 @@ using namespace llvm; Error DWARFListTableHeader::extract(DWARFDataExtractor Data, - uint32_t *OffsetPtr) { + uint64_t *OffsetPtr) { HeaderOffset = *OffsetPtr; // Read and verify the length field. if (!Data.isValidOffsetForDataOfSize(*OffsetPtr, sizeof(uint32_t))) return createStringError(errc::invalid_argument, "section is not large enough to contain a " - "%s table length at offset 0x%" PRIx32, + "%s table length at offset 0x%" PRIx64, SectionName.data(), *OffsetPtr); // TODO: Add support for DWARF64. HeaderData.Length = Data.getU32(OffsetPtr); if (HeaderData.Length == 0xffffffffu) return createStringError(errc::not_supported, - "DWARF64 is not supported in %s at offset 0x%" PRIx32, + "DWARF64 is not supported in %s at offset 0x%" PRIx64, SectionName.data(), HeaderOffset); Format = dwarf::DwarfFormat::DWARF32; if (HeaderData.Length + sizeof(uint32_t) < sizeof(Header)) return createStringError(errc::invalid_argument, - "%s table at offset 0x%" PRIx32 + "%s table at offset 0x%" PRIx64 " has too small length (0x%" PRIx32 ") to contain a complete header", SectionName.data(), HeaderOffset, length()); - uint32_t End = HeaderOffset + length(); + uint64_t End = HeaderOffset + length(); if (!Data.isValidOffsetForDataOfSize(HeaderOffset, End - HeaderOffset)) return createStringError(errc::invalid_argument, "section is not large enough to contain a %s table " - "of length 0x%" PRIx32 " at offset 0x%" PRIx32, + "of length 0x%" PRIx32 " at offset 0x%" PRIx64, SectionName.data(), length(), HeaderOffset); HeaderData.Version = Data.getU16(OffsetPtr); @@ -53,22 +53,22 @@ if (HeaderData.Version != 5) return createStringError(errc::invalid_argument, "unrecognised %s table version %" PRIu16 - " in table at offset 0x%" PRIx32, + " in table at offset 0x%" PRIx64, SectionName.data(), HeaderData.Version, HeaderOffset); if (HeaderData.AddrSize != 4 && HeaderData.AddrSize != 8) return createStringError(errc::not_supported, - "%s table at offset 0x%" PRIx32 + "%s table at offset 0x%" PRIx64 " has unsupported address size %" PRIu8, SectionName.data(), HeaderOffset, HeaderData.AddrSize); if (HeaderData.SegSize != 0) return createStringError(errc::not_supported, - "%s table at offset 0x%" PRIx32 + "%s table at offset 0x%" PRIx64 " has unsupported segment selector size %" PRIu8, SectionName.data(), HeaderOffset, HeaderData.SegSize); if (End < HeaderOffset + sizeof(HeaderData) + HeaderData.OffsetEntryCount * sizeof(uint32_t)) return createStringError(errc::invalid_argument, - "%s table at offset 0x%" PRIx32 " has more offset entries (%" PRIu32 + "%s table at offset 0x%" PRIx64 " has more offset entries (%" PRIu32 ") than there is space for", SectionName.data(), HeaderOffset, HeaderData.OffsetEntryCount); Data.setAddressSize(HeaderData.AddrSize); @@ -79,7 +79,7 @@ void DWARFListTableHeader::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const { if (DumpOpts.Verbose) - OS << format("0x%8.8" PRIx32 ": ", HeaderOffset); + OS << format("0x%8.8" PRIx64 ": ", HeaderOffset); OS << format( "%s list header: length = 0x%8.8" PRIx32 ", version = 0x%4.4" PRIx16 ", " "addr_size = 0x%2.2" PRIx8 ", seg_size = 0x%2.2" PRIx8 @@ -91,9 +91,9 @@ if (HeaderData.OffsetEntryCount > 0) { OS << "offsets: ["; for (const auto &Off : Offsets) { - OS << format("\n0x%8.8" PRIx32, Off); + OS << format("\n0x%8.8" PRIx64, Off); if (DumpOpts.Verbose) - OS << format(" => 0x%8.8" PRIx32, + OS << format(" => 0x%8.8" PRIx64, Off + HeaderOffset + sizeof(HeaderData)); } OS << "\n]\n"; Index: lib/DebugInfo/DWARF/DWARFTypeUnit.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFTypeUnit.cpp +++ lib/DebugInfo/DWARF/DWARFTypeUnit.cpp @@ -28,17 +28,17 @@ return; } - OS << format("0x%08x", getOffset()) << ": Type Unit:" + OS << format("0x%08" PRIx64, getOffset()) << ": Type Unit:" << " length = " << format("0x%08x", getLength()) << " version = " << format("0x%04x", getVersion()); if (getVersion() >= 5) OS << " unit_type = " << dwarf::UnitTypeString(getUnitType()); - OS << " abbr_offset = " << format("0x%04x", getAbbreviations()->getOffset()) + OS << " abbr_offset = " << format("0x%04" PRIx64, getAbbreviations()->getOffset()) << " addr_size = " << format("0x%02x", getAddressByteSize()) << " name = '" << Name << "'" << " type_signature = " << format("0x%016" PRIx64, getTypeHash()) - << " type_offset = " << format("0x%04x", getTypeOffset()) - << " (next unit at " << format("0x%08x", getNextUnitOffset()) << ")\n"; + << " type_offset = " << format("0x%04" PRIx64, getTypeOffset()) + << " (next unit at " << format("0x%08" PRIx64, getNextUnitOffset()) << ")\n"; if (DWARFDie TU = getUnitDIE(false)) TU.dump(OS, 0, DumpOpts); Index: lib/DebugInfo/DWARF/DWARFUnit.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFUnit.cpp +++ lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -66,7 +66,7 @@ // Lazy initialization of Parser, now that we have all section info. if (!Parser) { Parser = [=, &Context, &Obj, &Section, &SOS, - &LS](uint32_t Offset, DWARFSectionKind SectionKind, + &LS](uint64_t Offset, DWARFSectionKind SectionKind, const DWARFSection *CurSection, const DWARFUnitIndex::Entry *IndexEntry) -> std::unique_ptr { @@ -101,7 +101,7 @@ // within a section, although not necessarily within the object file, // even if we do lazy parsing. auto I = this->begin(); - uint32_t Offset = 0; + uint64_t Offset = 0; while (Data.isValidOffset(Offset)) { if (I != this->end() && (&(*I)->getInfoSection() != &Section || (*I)->getOffset() == Offset)) { @@ -126,11 +126,11 @@ return this->insert(I, std::move(Unit))->get(); } -DWARFUnit *DWARFUnitVector::getUnitForOffset(uint32_t Offset) const { +DWARFUnit *DWARFUnitVector::getUnitForOffset(uint64_t Offset) const { auto end = begin() + getNumInfoUnits(); auto *CU = std::upper_bound(begin(), end, Offset, - [](uint32_t LHS, const std::unique_ptr &RHS) { + [](uint64_t LHS, const std::unique_ptr &RHS) { return LHS < RHS->getNextUnitOffset(); }); if (CU != end && (*CU)->getOffset() <= Offset) @@ -149,7 +149,7 @@ auto *CU = std::upper_bound(begin(), end, CUOff->Offset, - [](uint32_t LHS, const std::unique_ptr &RHS) { + [](uint64_t LHS, const std::unique_ptr &RHS) { return LHS < RHS->getNextUnitOffset(); }); if (CU != end && (*CU)->getOffset() <= Offset) @@ -209,7 +209,7 @@ if (I != R.end() && std::next(I) == R.end()) return (*I)->getAddrOffsetSectionItem(Index); } - uint32_t Offset = AddrOffsetSectionBase + Index * getAddressByteSize(); + uint64_t Offset = AddrOffsetSectionBase + Index * getAddressByteSize(); if (AddrOffsetSection->Data.size() < Offset + getAddressByteSize()) return None; DWARFDataExtractor DA(Context.getDWARFObj(), *AddrOffsetSection, @@ -223,7 +223,7 @@ if (!StringOffsetsTableContribution) return None; unsigned ItemSize = getDwarfStringOffsetsByteSize(); - uint32_t Offset = getStringOffsetsBase() + Index * ItemSize; + uint64_t Offset = getStringOffsetsBase() + Index * ItemSize; if (StringOffsetSection.Data.size() < Offset + ItemSize) return None; DWARFDataExtractor DA(Context.getDWARFObj(), StringOffsetSection, @@ -233,7 +233,7 @@ bool DWARFUnitHeader::extract(DWARFContext &Context, const DWARFDataExtractor &debug_info, - uint32_t *offset_ptr, + uint64_t *offset_ptr, DWARFSectionKind SectionKind, const DWARFUnitIndex *Index, const DWARFUnitIndex::Entry *Entry) { @@ -306,14 +306,14 @@ // Parse the rangelist table header, including the optional array of offsets // following it (DWARF v5 and later). static Expected -parseRngListTableHeader(DWARFDataExtractor &DA, uint32_t Offset) { +parseRngListTableHeader(DWARFDataExtractor &DA, uint64_t Offset) { // TODO: Support DWARF64 // We are expected to be called with Offset 0 or pointing just past the table // header, which is 12 bytes long for DWARF32. if (Offset > 0) { if (Offset < 12U) return createStringError(errc::invalid_argument, "Did not detect a valid" - " range list table with base = 0x%" PRIu32, + " range list table with base = 0x%" PRIu64, Offset); Offset -= 12U; } @@ -323,13 +323,13 @@ return Table; } -Error DWARFUnit::extractRangeList(uint32_t RangeListOffset, +Error DWARFUnit::extractRangeList(uint64_t RangeListOffset, DWARFDebugRangeList &RangeList) const { // Require that compile unit is extracted. assert(!DieArray.empty()); DWARFDataExtractor RangesData(Context.getDWARFObj(), *RangeSection, isLittleEndian, getAddressByteSize()); - uint32_t ActualRangeListOffset = RangeSectionBase + RangeListOffset; + uint64_t ActualRangeListOffset = RangeSectionBase + RangeListOffset; return RangeList.extract(RangesData, &ActualRangeListOffset); } @@ -354,8 +354,8 @@ // Set the offset to that of the first DIE and calculate the start of the // next compilation unit header. - uint32_t DIEOffset = getOffset() + getHeaderSize(); - uint32_t NextCUOffset = getNextUnitOffset(); + uint64_t DIEOffset = getOffset() + getHeaderSize(); + uint64_t NextCUOffset = getNextUnitOffset(); DWARFDebugInfoEntry DIE; DWARFDataExtractor DebugInfoData = getDebugInfoExtractor(); uint32_t Depth = 0; @@ -396,8 +396,8 @@ // unit header). if (DIEOffset > NextCUOffset) WithColor::warning() << format("DWARF compile unit extends beyond its " - "bounds cu 0x%8.8x at 0x%8.8x\n", - getOffset(), DIEOffset); + "bounds cu 0x%8.8" PRIx64 " at 0x%8.8" PRIx64 + "\n", getOffset(), DIEOffset); } size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) { @@ -541,7 +541,7 @@ } Expected -DWARFUnit::findRnglistFromOffset(uint32_t Offset) { +DWARFUnit::findRnglistFromOffset(uint64_t Offset) { if (getVersion() <= 4) { DWARFDebugRangeList RangeList; if (Error E = extractRangeList(Offset, RangeList)) @@ -772,7 +772,7 @@ uint64_t ValidationSize = alignTo(Size, EntrySize); // Guard against overflow. if (ValidationSize >= Size) - if (DA.isValidOffsetForDataOfSize((uint32_t)Base, ValidationSize)) + if (DA.isValidOffsetForDataOfSize(Base, ValidationSize)) return *this; return createStringError(errc::invalid_argument, "length exceeds section size"); } @@ -780,7 +780,7 @@ // Look for a DWARF64-formatted contribution to the string offsets table // starting at a given offset and record it in a descriptor. static Expected -parseDWARF64StringOffsetsTableHeader(DWARFDataExtractor &DA, uint32_t Offset) { +parseDWARF64StringOffsetsTableHeader(DWARFDataExtractor &DA, uint64_t Offset) { if (!DA.isValidOffsetForDataOfSize(Offset, 16)) return createStringError(errc::invalid_argument, "section offset exceeds section size"); @@ -798,7 +798,7 @@ // Look for a DWARF32-formatted contribution to the string offsets table // starting at a given offset and record it in a descriptor. static Expected -parseDWARF32StringOffsetsTableHeader(DWARFDataExtractor &DA, uint32_t Offset) { +parseDWARF32StringOffsetsTableHeader(DWARFDataExtractor &DA, uint64_t Offset) { if (!DA.isValidOffsetForDataOfSize(Offset, 8)) return createStringError(errc::invalid_argument, "section offset exceeds section size"); @@ -823,7 +823,7 @@ case dwarf::DwarfFormat::DWARF64: { if (Offset < 16) return createStringError(errc::invalid_argument, "insufficient space for 64 bit header prefix"); - auto DescOrError = parseDWARF64StringOffsetsTableHeader(DA, (uint32_t)Offset - 16); + auto DescOrError = parseDWARF64StringOffsetsTableHeader(DA, Offset - 16); if (!DescOrError) return DescOrError.takeError(); Desc = *DescOrError; @@ -832,7 +832,7 @@ case dwarf::DwarfFormat::DWARF32: { if (Offset < 8) return createStringError(errc::invalid_argument, "insufficient space for 32 bit header prefix"); - auto DescOrError = parseDWARF32StringOffsetsTableHeader(DA, (uint32_t)Offset - 8); + auto DescOrError = parseDWARF32StringOffsetsTableHeader(DA, Offset - 8); if (!DescOrError) return DescOrError.takeError(); Desc = *DescOrError; Index: lib/DebugInfo/DWARF/DWARFUnitIndex.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFUnitIndex.cpp +++ lib/DebugInfo/DWARF/DWARFUnitIndex.cpp @@ -18,7 +18,7 @@ using namespace llvm; bool DWARFUnitIndex::Header::parse(DataExtractor IndexData, - uint32_t *OffsetPtr) { + uint64_t *OffsetPtr) { if (!IndexData.isValidOffsetForDataOfSize(*OffsetPtr, 16)) return false; Version = IndexData.getU32(OffsetPtr); @@ -45,7 +45,7 @@ } bool DWARFUnitIndex::parseImpl(DataExtractor IndexData) { - uint32_t Offset = 0; + uint64_t Offset = 0; if (!Header.parse(IndexData, &Offset)) return false; @@ -162,7 +162,7 @@ } const DWARFUnitIndex::Entry * -DWARFUnitIndex::getFromOffset(uint32_t Offset) const { +DWARFUnitIndex::getFromOffset(uint64_t Offset) const { if (OffsetLookup.empty()) { for (uint32_t i = 0; i != Header.NumBuckets; ++i) if (Rows[i].Contributions) Index: lib/DebugInfo/DWARF/DWARFVerifier.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFVerifier.cpp +++ lib/DebugInfo/DWARF/DWARFVerifier.cpp @@ -98,7 +98,7 @@ } bool DWARFVerifier::verifyUnitHeader(const DWARFDataExtractor DebugInfoData, - uint32_t *Offset, unsigned UnitIndex, + uint64_t *Offset, unsigned UnitIndex, uint8_t &UnitType, bool &isUnitDWARF64) { uint64_t AbbrOffset, Length; uint8_t AddrSize = 0; @@ -111,7 +111,7 @@ bool ValidType = true; bool ValidAbbrevOffset = true; - uint32_t OffsetStart = *Offset; + uint64_t OffsetStart = *Offset; Length = DebugInfoData.getU32(Offset); if (Length == UINT32_MAX) { Length = DebugInfoData.getU64(Offset); @@ -139,7 +139,7 @@ if (!ValidLength || !ValidVersion || !ValidAddrSize || !ValidAbbrevOffset || !ValidType) { Success = false; - error() << format("Units[%d] - start offset: 0x%08x \n", UnitIndex, + error() << format("Units[%d] - start offset: 0x%08" PRIx64 "\n", UnitIndex, OffsetStart); if (!ValidLength) note() << "The length for this unit is too " @@ -273,7 +273,8 @@ const DWARFObject &DObj = DCtx.getDWARFObj(); DWARFDataExtractor DebugInfoData(DObj, S, DCtx.isLittleEndian(), 0); unsigned NumDebugInfoErrors = 0; - uint32_t OffsetStart = 0, Offset = 0, UnitIdx = 0; + uint64_t OffsetStart = 0, Offset = 0; + uint32_t UnitIdx = 0; uint8_t UnitType = 0; bool isUnitDWARF64 = false; bool isHeaderChainValid = true; @@ -635,7 +636,7 @@ // getting the DIE by offset and emitting an error OS << "Verifying .debug_info references...\n"; unsigned NumErrors = 0; - for (const std::pair> &Pair : + for (const std::pair> &Pair : ReferenceToDIEOffsets) { if (DCtx.getDIEForOffset(Pair.first)) continue; @@ -659,12 +660,12 @@ auto StmtSectionOffset = toSectionOffset(Die.find(DW_AT_stmt_list)); if (!StmtSectionOffset) continue; - const uint32_t LineTableOffset = *StmtSectionOffset; + const uint64_t LineTableOffset = *StmtSectionOffset; auto LineTable = DCtx.getLineTableForUnit(CU.get()); if (LineTableOffset < DCtx.getDWARFObj().getLineSection().Data.size()) { if (!LineTable) { ++NumDebugLineErrors; - error() << ".debug_line[" << format("0x%08" PRIx32, LineTableOffset) + error() << ".debug_line[" << format("0x%08" PRIx64, LineTableOffset) << "] was not able to be parsed for CU:\n"; dump(Die) << '\n'; continue; @@ -680,8 +681,8 @@ if (Iter != StmtListToDie.end()) { ++NumDebugLineErrors; error() << "two compile unit DIEs, " - << format("0x%08" PRIx32, Iter->second.getOffset()) << " and " - << format("0x%08" PRIx32, Die.getOffset()) + << format("0x%08" PRIx64, Iter->second.getOffset()) << " and " + << format("0x%08" PRIx64, Die.getOffset()) << ", have the same DW_AT_stmt_list section offset:\n"; dump(Iter->second); dump(Die) << '\n'; @@ -826,10 +827,10 @@ uint32_t NumBuckets = AccelTable.getNumBuckets(); uint32_t NumHashes = AccelTable.getNumHashes(); - uint32_t BucketsOffset = + uint64_t BucketsOffset = AccelTable.getSizeHdr() + AccelTable.getHeaderDataLength(); - uint32_t HashesBase = BucketsOffset + NumBuckets * 4; - uint32_t OffsetsBase = HashesBase + NumHashes * 4; + uint64_t HashesBase = BucketsOffset + NumBuckets * 4; + uint64_t OffsetsBase = HashesBase + NumHashes * 4; for (uint32_t BucketIdx = 0; BucketIdx < NumBuckets; ++BucketIdx) { uint32_t HashIdx = AccelSectionData.getU32(&BucketsOffset); if (HashIdx >= NumHashes && HashIdx != UINT32_MAX) { @@ -849,21 +850,21 @@ } for (uint32_t HashIdx = 0; HashIdx < NumHashes; ++HashIdx) { - uint32_t HashOffset = HashesBase + 4 * HashIdx; - uint32_t DataOffset = OffsetsBase + 4 * HashIdx; + uint64_t HashOffset = HashesBase + 4 * HashIdx; + uint64_t DataOffset = OffsetsBase + 4 * HashIdx; uint32_t Hash = AccelSectionData.getU32(&HashOffset); - uint32_t HashDataOffset = AccelSectionData.getU32(&DataOffset); + uint64_t HashDataOffset = AccelSectionData.getU32(&DataOffset); if (!AccelSectionData.isValidOffsetForDataOfSize(HashDataOffset, sizeof(uint64_t))) { - error() << format("Hash[%d] has invalid HashData offset: 0x%08x.\n", - HashIdx, HashDataOffset); + error() << format("Hash[%d] has invalid HashData offset: " + "0x%08" PRIx64 ".\n", HashIdx, HashDataOffset); ++NumErrors; } - uint32_t StrpOffset; - uint32_t StringOffset; + uint64_t StrpOffset; + uint64_t StringOffset; uint32_t StringCount = 0; - unsigned Offset; + uint64_t Offset; unsigned Tag; while ((StrpOffset = AccelSectionData.getU32(&HashDataOffset)) != 0) { const uint32_t NumHashDataObjects = @@ -882,8 +883,9 @@ error() << format( "%s Bucket[%d] Hash[%d] = 0x%08x " - "Str[%u] = 0x%08x " - "DIE[%d] = 0x%08x is not a valid DIE offset for \"%s\".\n", + "Str[%u] = 0x%08" PRIx64 " " + "DIE[%d] = 0x%08" PRIx64 " " + "is not a valid DIE offset for \"%s\".\n", SectionName, BucketIdx, HashIdx, Hash, StringCount, StrpOffset, HashDataIdx, Offset, Name); @@ -908,8 +910,8 @@ DWARFVerifier::verifyDebugNamesCULists(const DWARFDebugNames &AccelTable) { // A map from CU offset to the (first) Name Index offset which claims to index // this CU. - DenseMap CUMap; - const uint32_t NotIndexed = std::numeric_limits::max(); + DenseMap CUMap; + const uint64_t NotIndexed = std::numeric_limits::max(); CUMap.reserve(DCtx.getNumCompileUnits()); for (const auto &CU : DCtx.compile_units()) @@ -924,7 +926,7 @@ continue; } for (uint32_t CU = 0, End = NI.getCUCount(); CU < End; ++CU) { - uint32_t Offset = NI.getCUOffset(CU); + uint64_t Offset = NI.getCUOffset(CU); auto Iter = CUMap.find(Offset); if (Iter == CUMap.end()) { @@ -1205,8 +1207,8 @@ unsigned NumErrors = 0; unsigned NumEntries = 0; - uint32_t EntryID = NTE.getEntryOffset(); - uint32_t NextEntryID = EntryID; + uint64_t EntryID = NTE.getEntryOffset(); + uint64_t NextEntryID = EntryID; Expected EntryOr = NI.getEntry(&NextEntryID); for (; EntryOr; ++NumEntries, EntryID = NextEntryID, EntryOr = NI.getEntry(&NextEntryID)) { @@ -1218,7 +1220,7 @@ ++NumErrors; continue; } - uint32_t CUOffset = NI.getCUOffset(CUIndex); + uint64_t CUOffset = NI.getCUOffset(CUIndex); uint64_t DIEOffset = CUOffset + *EntryOr->getDIEUnitOffset(); DWARFDie DIE = DCtx.getDIEForOffset(DIEOffset); if (!DIE) { Index: lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp =================================================================== --- lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp +++ lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp @@ -179,10 +179,8 @@ // For the purposes of symbolization, pretend the symbol's address is that // of the function's code, not the descriptor. uint64_t OpdOffset = SymbolAddress - OpdAddress; - uint32_t OpdOffset32 = OpdOffset; - if (OpdOffset == OpdOffset32 && - OpdExtractor->isValidOffsetForAddress(OpdOffset32)) - SymbolAddress = OpdExtractor->getAddress(&OpdOffset32); + if (OpdExtractor->isValidOffsetForAddress(OpdOffset)) + SymbolAddress = OpdExtractor->getAddress(&OpdOffset); } Expected SymbolNameOrErr = Symbol.getName(); if (!SymbolNameOrErr) Index: lib/DebugInfo/Symbolize/Symbolize.cpp =================================================================== --- lib/DebugInfo/Symbolize/Symbolize.cpp +++ lib/DebugInfo/Symbolize/Symbolize.cpp @@ -248,7 +248,7 @@ return false; } DataExtractor DE(*ContentsOrErr, Obj->isLittleEndian(), 0); - uint32_t Offset = 0; + uint64_t Offset = 0; if (const char *DebugNameStr = DE.getCStr(&Offset)) { // 4-byte align the offset. Offset = (Offset + 3) & ~0x3; Index: lib/Object/Decompressor.cpp =================================================================== --- lib/Object/Decompressor.cpp +++ lib/Object/Decompressor.cpp @@ -56,7 +56,7 @@ return createError("corrupted compressed section header"); DataExtractor Extractor(SectionData, IsLittleEndian, 0); - uint32_t Offset = 0; + uint64_t Offset = 0; if (Extractor.getUnsigned(&Offset, Is64Bit ? sizeof(Elf64_Word) : sizeof(Elf32_Word)) != ELFCOMPRESS_ZLIB) Index: lib/Object/MachOObjectFile.cpp =================================================================== --- lib/Object/MachOObjectFile.cpp +++ lib/Object/MachOObjectFile.cpp @@ -4619,7 +4619,7 @@ SmallVectorImpl &Out) const { DataExtractor extractor(ObjectFile::getData(), true, 0); - uint32_t offset = Index; + uint64_t offset = Index; uint64_t data = 0; while (uint64_t delta = extractor.getULEB128(&offset)) { data += delta; Index: lib/Support/DataExtractor.cpp =================================================================== --- lib/Support/DataExtractor.cpp +++ lib/Support/DataExtractor.cpp @@ -14,10 +14,10 @@ using namespace llvm; template -static T getU(uint32_t *offset_ptr, const DataExtractor *de, +static T getU(uint64_t *offset_ptr, const DataExtractor *de, bool isLittleEndian, const char *Data) { T val = 0; - uint32_t offset = *offset_ptr; + uint64_t offset = *offset_ptr; if (de->isValidOffsetForDataOfSize(offset, sizeof(val))) { std::memcpy(&val, &Data[offset], sizeof(val)); if (sys::IsLittleEndianHost != isLittleEndian) @@ -30,9 +30,9 @@ } template -static T *getUs(uint32_t *offset_ptr, T *dst, uint32_t count, +static T *getUs(uint64_t *offset_ptr, T *dst, uint32_t count, const DataExtractor *de, bool isLittleEndian, const char *Data){ - uint32_t offset = *offset_ptr; + uint64_t offset = *offset_ptr; if (count > 0 && de->isValidOffsetForDataOfSize(offset, sizeof(*dst)*count)) { for (T *value_ptr = dst, *end = dst + count; value_ptr != end; @@ -47,56 +47,55 @@ return nullptr; } -uint8_t DataExtractor::getU8(uint32_t *offset_ptr) const { +uint8_t DataExtractor::getU8(uint64_t *offset_ptr) const { return getU(offset_ptr, this, IsLittleEndian, Data.data()); } uint8_t * -DataExtractor::getU8(uint32_t *offset_ptr, uint8_t *dst, uint32_t count) const { +DataExtractor::getU8(uint64_t *offset_ptr, uint8_t *dst, uint32_t count) const { return getUs(offset_ptr, dst, count, this, IsLittleEndian, Data.data()); } - -uint16_t DataExtractor::getU16(uint32_t *offset_ptr) const { +uint16_t DataExtractor::getU16(uint64_t *offset_ptr) const { return getU(offset_ptr, this, IsLittleEndian, Data.data()); } -uint16_t *DataExtractor::getU16(uint32_t *offset_ptr, uint16_t *dst, +uint16_t *DataExtractor::getU16(uint64_t *offset_ptr, uint16_t *dst, uint32_t count) const { return getUs(offset_ptr, dst, count, this, IsLittleEndian, Data.data()); } -uint32_t DataExtractor::getU24(uint32_t *offset_ptr) const { +uint32_t DataExtractor::getU24(uint64_t *offset_ptr) const { uint24_t ExtractedVal = getU(offset_ptr, this, IsLittleEndian, Data.data()); // The 3 bytes are in the correct byte order for the host. return ExtractedVal.getAsUint32(sys::IsLittleEndianHost); } -uint32_t DataExtractor::getU32(uint32_t *offset_ptr) const { +uint32_t DataExtractor::getU32(uint64_t *offset_ptr) const { return getU(offset_ptr, this, IsLittleEndian, Data.data()); } -uint32_t *DataExtractor::getU32(uint32_t *offset_ptr, uint32_t *dst, +uint32_t *DataExtractor::getU32(uint64_t *offset_ptr, uint32_t *dst, uint32_t count) const { return getUs(offset_ptr, dst, count, this, IsLittleEndian, Data.data()); } -uint64_t DataExtractor::getU64(uint32_t *offset_ptr) const { +uint64_t DataExtractor::getU64(uint64_t *offset_ptr) const { return getU(offset_ptr, this, IsLittleEndian, Data.data()); } -uint64_t *DataExtractor::getU64(uint32_t *offset_ptr, uint64_t *dst, +uint64_t *DataExtractor::getU64(uint64_t *offset_ptr, uint64_t *dst, uint32_t count) const { return getUs(offset_ptr, dst, count, this, IsLittleEndian, Data.data()); } uint64_t -DataExtractor::getUnsigned(uint32_t *offset_ptr, uint32_t byte_size) const { +DataExtractor::getUnsigned(uint64_t *offset_ptr, uint32_t byte_size) const { switch (byte_size) { case 1: return getU8(offset_ptr); @@ -111,7 +110,7 @@ } int64_t -DataExtractor::getSigned(uint32_t *offset_ptr, uint32_t byte_size) const { +DataExtractor::getSigned(uint64_t *offset_ptr, uint32_t byte_size) const { switch (byte_size) { case 1: return (int8_t)getU8(offset_ptr); @@ -125,8 +124,8 @@ llvm_unreachable("getSigned unhandled case!"); } -const char *DataExtractor::getCStr(uint32_t *offset_ptr) const { - uint32_t offset = *offset_ptr; +const char *DataExtractor::getCStr(uint64_t *offset_ptr) const { + uint64_t offset = *offset_ptr; StringRef::size_type pos = Data.find('\0', offset); if (pos != StringRef::npos) { *offset_ptr = pos + 1; @@ -135,8 +134,8 @@ return nullptr; } -StringRef DataExtractor::getCStrRef(uint32_t *OffsetPtr) const { - uint32_t Start = *OffsetPtr; +StringRef DataExtractor::getCStrRef(uint64_t *OffsetPtr) const { + uint64_t Start = *OffsetPtr; StringRef::size_type Pos = Data.find('\0', Start); if (Pos != StringRef::npos) { *OffsetPtr = Pos + 1; @@ -145,7 +144,7 @@ return StringRef(); } -uint64_t DataExtractor::getULEB128(uint32_t *offset_ptr) const { +uint64_t DataExtractor::getULEB128(uint64_t *offset_ptr) const { assert(*offset_ptr <= Data.size()); const char *error; @@ -159,7 +158,7 @@ return result; } -int64_t DataExtractor::getSLEB128(uint32_t *offset_ptr) const { +int64_t DataExtractor::getSLEB128(uint64_t *offset_ptr) const { assert(*offset_ptr <= Data.size()); const char *error; Index: lib/XRay/FDRRecordProducer.cpp =================================================================== --- lib/XRay/FDRRecordProducer.cpp +++ lib/XRay/FDRRecordProducer.cpp @@ -89,7 +89,7 @@ if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading one byte from offset %d.", OffsetPtr); + "Failed reading one byte from offset %" PRId64 ".", OffsetPtr); if (isMetadataIntroducer(FirstByte)) { auto LoadedType = FirstByte >> 1; @@ -151,7 +151,7 @@ if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading one byte from offset %d.", OffsetPtr); + "Failed reading one byte from offset %" PRId64 ".", OffsetPtr); // For metadata records, handle especially here. if (isMetadataIntroducer(FirstByte)) { @@ -162,7 +162,8 @@ MetadataRecordOrErr.takeError(), createStringError( std::make_error_code(std::errc::executable_format_error), - "Encountered an unsupported metadata record (%d) at offset %d.", + "Encountered an unsupported metadata record (%d) " + "at offset %" PRId64 ".", LoadedType, PreReadOffset)); R = std::move(MetadataRecordOrErr.get()); } else { @@ -182,8 +183,8 @@ if (OffsetPtr - PreReadOffset > CurrentBufferBytes) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Buffer over-read at offset %d (over-read by %d bytes); Record Type " - "= %s.", + "Buffer over-read at offset %" PRId64 " " + "(over-read by %" PRId64 " bytes); Record Type = %s.", OffsetPtr, (OffsetPtr - PreReadOffset) - CurrentBufferBytes, Record::kindToString(R->getRecordType()).data()); Index: lib/XRay/FileHeaderReader.cpp =================================================================== --- lib/XRay/FileHeaderReader.cpp +++ lib/XRay/FileHeaderReader.cpp @@ -12,7 +12,7 @@ // Populates the FileHeader reference by reading the first 32 bytes of the file. Expected readBinaryFormatHeader(DataExtractor &HeaderExtractor, - uint32_t &OffsetPtr) { + uint64_t &OffsetPtr) { // FIXME: Maybe deduce whether the data is little or big-endian using some // magic bytes in the beginning of the file? @@ -30,21 +30,24 @@ if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Failed reading version from file header at offset %d.", OffsetPtr); + "Failed reading version from file header at offset %" PRId64 ".", + OffsetPtr); PreReadOffset = OffsetPtr; FileHeader.Type = HeaderExtractor.getU16(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Failed reading file type from file header at offset %d.", OffsetPtr); + "Failed reading file type from file header at offset %" PRId64 ".", + OffsetPtr); PreReadOffset = OffsetPtr; uint32_t Bitfield = HeaderExtractor.getU32(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Failed reading flag bits from file header at offset %d.", OffsetPtr); + "Failed reading flag bits from file header at offset %" PRId64 ".", + OffsetPtr); FileHeader.ConstantTSC = Bitfield & 1uL; FileHeader.NonstopTSC = Bitfield & 1uL << 1; @@ -53,7 +56,7 @@ if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::invalid_argument), - "Failed reading cycle frequency from file header at offset %d.", + "Failed reading cycle frequency from file header at offset %" PRId64 ".", OffsetPtr); std::memcpy(&FileHeader.FreeFormData, Index: lib/XRay/Trace.cpp =================================================================== --- lib/XRay/Trace.cpp +++ lib/XRay/Trace.cpp @@ -47,7 +47,7 @@ std::make_error_code(std::errc::invalid_argument)); DataExtractor Reader(Data, IsLittleEndian, 8); - uint32_t OffsetPtr = 0; + uint64_t OffsetPtr = 0; auto FileHeaderOrError = readBinaryFormatHeader(Reader, OffsetPtr); if (!FileHeaderOrError) return FileHeaderOrError.takeError(); @@ -67,13 +67,14 @@ if (!Reader.isValidOffsetForDataOfSize(OffsetPtr, 32)) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Not enough bytes to read a full record at offset %d.", OffsetPtr); + "Not enough bytes to read a full record at offset %" PRId64 ".", + OffsetPtr); auto PreReadOffset = OffsetPtr; auto RecordType = Reader.getU16(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading record type at offset %d.", OffsetPtr); + "Failed reading record type at offset %" PRId64 ".", OffsetPtr); switch (RecordType) { case 0: { // Normal records. @@ -86,14 +87,15 @@ if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading CPU field at offset %d.", OffsetPtr); + "Failed reading CPU field at offset %" PRId64 ".", OffsetPtr); PreReadOffset = OffsetPtr; auto Type = Reader.getU8(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading record type field at offset %d.", OffsetPtr); + "Failed reading record type field at offset %" PRId64 ".", + OffsetPtr); switch (Type) { case 0: @@ -111,7 +113,7 @@ default: return createStringError( std::make_error_code(std::errc::executable_format_error), - "Unknown record type '%d' at offset %d.", Type, OffsetPtr); + "Unknown record type '%d' at offset %" PRId64 ".", Type, OffsetPtr); } PreReadOffset = OffsetPtr; @@ -119,28 +121,29 @@ if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading function id field at offset %d.", OffsetPtr); + "Failed reading function id field at offset %" PRId64 ".", + OffsetPtr); PreReadOffset = OffsetPtr; Record.TSC = Reader.getU64(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading TSC field at offset %d.", OffsetPtr); + "Failed reading TSC field at offset %" PRId64 ".", OffsetPtr); PreReadOffset = OffsetPtr; Record.TId = Reader.getU32(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading thread id field at offset %d.", OffsetPtr); + "Failed reading thread id field at offset %" PRId64 ".", OffsetPtr); PreReadOffset = OffsetPtr; Record.PId = Reader.getU32(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading process id at offset %d.", OffsetPtr); + "Failed reading process id at offset %" PRId64 ".", OffsetPtr); break; } @@ -155,21 +158,23 @@ if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading function id field at offset %d.", OffsetPtr); + "Failed reading function id field at offset %" PRId64 ".", + OffsetPtr); PreReadOffset = OffsetPtr; auto TId = Reader.getU32(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading thread id field at offset %d.", OffsetPtr); + "Failed reading thread id field at offset %" PRId64 ".", OffsetPtr); PreReadOffset = OffsetPtr; auto PId = Reader.getU32(&OffsetPtr); if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading process id field at offset %d.", OffsetPtr); + "Failed reading process id field at offset %" PRId64 ".", + OffsetPtr); // Make a check for versions above 3 for the Pid field if (Record.FuncId != FuncId || Record.TId != TId || @@ -178,7 +183,7 @@ std::make_error_code(std::errc::executable_format_error), "Corrupted log, found arg payload following non-matching " "function+thread record. Record for function %d != %d at offset " - "%d", + "%" PRId64, Record.FuncId, FuncId, OffsetPtr); PreReadOffset = OffsetPtr; @@ -186,7 +191,8 @@ if (OffsetPtr == PreReadOffset) return createStringError( std::make_error_code(std::errc::executable_format_error), - "Failed reading argument payload at offset %d.", OffsetPtr); + "Failed reading argument payload at offset %" PRId64 ".", + OffsetPtr); Record.CallArgs.push_back(Arg); break; @@ -194,7 +200,8 @@ default: return createStringError( std::make_error_code(std::errc::executable_format_error), - "Unknown record type '%d' at offset %d.", RecordType, OffsetPtr); + "Unknown record type '%d' at offset %" PRId64 ".", RecordType, + OffsetPtr); } // Advance the offset pointer enough bytes to align to 32-byte records for // basic mode logs. @@ -265,7 +272,7 @@ "Not enough bytes for an XRay FDR log."); DataExtractor DE(Data, IsLittleEndian, 8); - uint32_t OffsetPtr = 0; + uint64_t OffsetPtr = 0; auto FileHeaderOrError = readBinaryFormatHeader(DE, OffsetPtr); if (!FileHeaderOrError) return FileHeaderOrError.takeError(); Index: unittests/Support/DataExtractorTest.cpp =================================================================== --- unittests/Support/DataExtractorTest.cpp +++ unittests/Support/DataExtractorTest.cpp @@ -24,7 +24,7 @@ TEST(DataExtractorTest, UnsignedNumbers) { DataExtractor DE(StringRef(numberData, sizeof(numberData)-1), false, 8); - uint32_t offset = 0; + uint64_t offset = 0; EXPECT_EQ(0x80U, DE.getU8(&offset)); EXPECT_EQ(1U, offset); @@ -72,7 +72,7 @@ TEST(DataExtractorTest, SignedNumbers) { DataExtractor DE(StringRef(numberData, sizeof(numberData)-1), false, 8); - uint32_t offset = 0; + uint64_t offset = 0; EXPECT_EQ(-128, DE.getSigned(&offset, 1)); EXPECT_EQ(1U, offset); @@ -89,7 +89,7 @@ TEST(DataExtractorTest, Strings) { DataExtractor DE(StringRef(stringData, sizeof(stringData)-1), false, 8); - uint32_t offset = 0; + uint64_t offset = 0; EXPECT_EQ(stringData, DE.getCStr(&offset)); EXPECT_EQ(11U, offset); @@ -99,7 +99,7 @@ TEST(DataExtractorTest, LEB128) { DataExtractor DE(StringRef(leb128data, sizeof(leb128data)-1), false, 8); - uint32_t offset = 0; + uint64_t offset = 0; EXPECT_EQ(9382ULL, DE.getULEB128(&offset)); EXPECT_EQ(2U, offset);