ObjectFile.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- ObjectFile.h - File format independent object file -------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file declares a file format independent ObjectFile class.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_OBJECT_OBJECTFILE_H
  18. #define LLVM_OBJECT_OBJECTFILE_H
  19. #include "llvm/ADT/DenseMapInfo.h"
  20. #include "llvm/ADT/StringRef.h"
  21. #include "llvm/ADT/Triple.h"
  22. #include "llvm/ADT/iterator_range.h"
  23. #include "llvm/BinaryFormat/Magic.h"
  24. #include "llvm/BinaryFormat/Swift.h"
  25. #include "llvm/Object/Binary.h"
  26. #include "llvm/Object/Error.h"
  27. #include "llvm/Object/SymbolicFile.h"
  28. #include "llvm/Support/Casting.h"
  29. #include "llvm/Support/Error.h"
  30. #include "llvm/Support/MemoryBuffer.h"
  31. #include <cassert>
  32. #include <cstdint>
  33. #include <memory>
  34. #include <system_error>
  35. namespace llvm {
  36. class SubtargetFeatures;
  37. namespace object {
  38. class COFFObjectFile;
  39. class MachOObjectFile;
  40. class ObjectFile;
  41. class SectionRef;
  42. class SymbolRef;
  43. class symbol_iterator;
  44. class WasmObjectFile;
  45. using section_iterator = content_iterator<SectionRef>;
  46. /// This is a value type class that represents a single relocation in the list
  47. /// of relocations in the object file.
  48. class RelocationRef {
  49. DataRefImpl RelocationPimpl;
  50. const ObjectFile *OwningObject = nullptr;
  51. public:
  52. RelocationRef() = default;
  53. RelocationRef(DataRefImpl RelocationP, const ObjectFile *Owner);
  54. bool operator==(const RelocationRef &Other) const;
  55. void moveNext();
  56. uint64_t getOffset() const;
  57. symbol_iterator getSymbol() const;
  58. uint64_t getType() const;
  59. /// Get a string that represents the type of this relocation.
  60. ///
  61. /// This is for display purposes only.
  62. void getTypeName(SmallVectorImpl<char> &Result) const;
  63. DataRefImpl getRawDataRefImpl() const;
  64. const ObjectFile *getObject() const;
  65. };
  66. using relocation_iterator = content_iterator<RelocationRef>;
  67. /// This is a value type class that represents a single section in the list of
  68. /// sections in the object file.
  69. class SectionRef {
  70. friend class SymbolRef;
  71. DataRefImpl SectionPimpl;
  72. const ObjectFile *OwningObject = nullptr;
  73. public:
  74. SectionRef() = default;
  75. SectionRef(DataRefImpl SectionP, const ObjectFile *Owner);
  76. bool operator==(const SectionRef &Other) const;
  77. bool operator!=(const SectionRef &Other) const;
  78. bool operator<(const SectionRef &Other) const;
  79. void moveNext();
  80. Expected<StringRef> getName() const;
  81. uint64_t getAddress() const;
  82. uint64_t getIndex() const;
  83. uint64_t getSize() const;
  84. Expected<StringRef> getContents() const;
  85. /// Get the alignment of this section as the actual value (not log 2).
  86. uint64_t getAlignment() const;
  87. bool isCompressed() const;
  88. /// Whether this section contains instructions.
  89. bool isText() const;
  90. /// Whether this section contains data, not instructions.
  91. bool isData() const;
  92. /// Whether this section contains BSS uninitialized data.
  93. bool isBSS() const;
  94. bool isVirtual() const;
  95. bool isBitcode() const;
  96. bool isStripped() const;
  97. /// Whether this section will be placed in the text segment, according to the
  98. /// Berkeley size format. This is true if the section is allocatable, and
  99. /// contains either code or readonly data.
  100. bool isBerkeleyText() const;
  101. /// Whether this section will be placed in the data segment, according to the
  102. /// Berkeley size format. This is true if the section is allocatable and
  103. /// contains data (e.g. PROGBITS), but is not text.
  104. bool isBerkeleyData() const;
  105. /// Whether this section is a debug section.
  106. bool isDebugSection() const;
  107. bool containsSymbol(SymbolRef S) const;
  108. relocation_iterator relocation_begin() const;
  109. relocation_iterator relocation_end() const;
  110. iterator_range<relocation_iterator> relocations() const {
  111. return make_range(relocation_begin(), relocation_end());
  112. }
  113. /// Returns the related section if this section contains relocations. The
  114. /// returned section may or may not have applied its relocations.
  115. Expected<section_iterator> getRelocatedSection() const;
  116. DataRefImpl getRawDataRefImpl() const;
  117. const ObjectFile *getObject() const;
  118. };
  119. struct SectionedAddress {
  120. const static uint64_t UndefSection = UINT64_MAX;
  121. uint64_t Address = 0;
  122. uint64_t SectionIndex = UndefSection;
  123. };
  124. inline bool operator<(const SectionedAddress &LHS,
  125. const SectionedAddress &RHS) {
  126. return std::tie(LHS.SectionIndex, LHS.Address) <
  127. std::tie(RHS.SectionIndex, RHS.Address);
  128. }
  129. inline bool operator==(const SectionedAddress &LHS,
  130. const SectionedAddress &RHS) {
  131. return std::tie(LHS.SectionIndex, LHS.Address) ==
  132. std::tie(RHS.SectionIndex, RHS.Address);
  133. }
  134. raw_ostream &operator<<(raw_ostream &OS, const SectionedAddress &Addr);
  135. /// This is a value type class that represents a single symbol in the list of
  136. /// symbols in the object file.
  137. class SymbolRef : public BasicSymbolRef {
  138. friend class SectionRef;
  139. public:
  140. enum Type {
  141. ST_Unknown, // Type not specified
  142. ST_Data,
  143. ST_Debug,
  144. ST_File,
  145. ST_Function,
  146. ST_Other
  147. };
  148. SymbolRef() = default;
  149. SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner);
  150. SymbolRef(const BasicSymbolRef &B) : BasicSymbolRef(B) {
  151. assert(isa<ObjectFile>(BasicSymbolRef::getObject()));
  152. }
  153. Expected<StringRef> getName() const;
  154. /// Returns the symbol virtual address (i.e. address at which it will be
  155. /// mapped).
  156. Expected<uint64_t> getAddress() const;
  157. /// Return the value of the symbol depending on the object this can be an
  158. /// offset or a virtual address.
  159. Expected<uint64_t> getValue() const;
  160. /// Get the alignment of this symbol as the actual value (not log 2).
  161. uint32_t getAlignment() const;
  162. uint64_t getCommonSize() const;
  163. Expected<SymbolRef::Type> getType() const;
  164. /// Get section this symbol is defined in reference to. Result is
  165. /// end_sections() if it is undefined or is an absolute symbol.
  166. Expected<section_iterator> getSection() const;
  167. const ObjectFile *getObject() const;
  168. };
  169. class symbol_iterator : public basic_symbol_iterator {
  170. public:
  171. symbol_iterator(SymbolRef Sym) : basic_symbol_iterator(Sym) {}
  172. symbol_iterator(const basic_symbol_iterator &B)
  173. : basic_symbol_iterator(SymbolRef(B->getRawDataRefImpl(),
  174. cast<ObjectFile>(B->getObject()))) {}
  175. const SymbolRef *operator->() const {
  176. const BasicSymbolRef &P = basic_symbol_iterator::operator *();
  177. return static_cast<const SymbolRef*>(&P);
  178. }
  179. const SymbolRef &operator*() const {
  180. const BasicSymbolRef &P = basic_symbol_iterator::operator *();
  181. return static_cast<const SymbolRef&>(P);
  182. }
  183. };
  184. /// This class is the base class for all object file types. Concrete instances
  185. /// of this object are created by createObjectFile, which figures out which type
  186. /// to create.
  187. class ObjectFile : public SymbolicFile {
  188. virtual void anchor();
  189. protected:
  190. ObjectFile(unsigned int Type, MemoryBufferRef Source);
  191. const uint8_t *base() const {
  192. return reinterpret_cast<const uint8_t *>(Data.getBufferStart());
  193. }
  194. // These functions are for SymbolRef to call internally. The main goal of
  195. // this is to allow SymbolRef::SymbolPimpl to point directly to the symbol
  196. // entry in the memory mapped object file. SymbolPimpl cannot contain any
  197. // virtual functions because then it could not point into the memory mapped
  198. // file.
  199. //
  200. // Implementations assume that the DataRefImpl is valid and has not been
  201. // modified externally. It's UB otherwise.
  202. friend class SymbolRef;
  203. virtual Expected<StringRef> getSymbolName(DataRefImpl Symb) const = 0;
  204. Error printSymbolName(raw_ostream &OS,
  205. DataRefImpl Symb) const override;
  206. virtual Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const = 0;
  207. virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const = 0;
  208. virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const;
  209. virtual uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const = 0;
  210. virtual Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const = 0;
  211. virtual Expected<section_iterator>
  212. getSymbolSection(DataRefImpl Symb) const = 0;
  213. // Same as above for SectionRef.
  214. friend class SectionRef;
  215. virtual void moveSectionNext(DataRefImpl &Sec) const = 0;
  216. virtual Expected<StringRef> getSectionName(DataRefImpl Sec) const = 0;
  217. virtual uint64_t getSectionAddress(DataRefImpl Sec) const = 0;
  218. virtual uint64_t getSectionIndex(DataRefImpl Sec) const = 0;
  219. virtual uint64_t getSectionSize(DataRefImpl Sec) const = 0;
  220. virtual Expected<ArrayRef<uint8_t>>
  221. getSectionContents(DataRefImpl Sec) const = 0;
  222. virtual uint64_t getSectionAlignment(DataRefImpl Sec) const = 0;
  223. virtual bool isSectionCompressed(DataRefImpl Sec) const = 0;
  224. virtual bool isSectionText(DataRefImpl Sec) const = 0;
  225. virtual bool isSectionData(DataRefImpl Sec) const = 0;
  226. virtual bool isSectionBSS(DataRefImpl Sec) const = 0;
  227. // A section is 'virtual' if its contents aren't present in the object image.
  228. virtual bool isSectionVirtual(DataRefImpl Sec) const = 0;
  229. virtual bool isSectionBitcode(DataRefImpl Sec) const;
  230. virtual bool isSectionStripped(DataRefImpl Sec) const;
  231. virtual bool isBerkeleyText(DataRefImpl Sec) const;
  232. virtual bool isBerkeleyData(DataRefImpl Sec) const;
  233. virtual bool isDebugSection(DataRefImpl Sec) const;
  234. virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const = 0;
  235. virtual relocation_iterator section_rel_end(DataRefImpl Sec) const = 0;
  236. virtual Expected<section_iterator> getRelocatedSection(DataRefImpl Sec) const;
  237. // Same as above for RelocationRef.
  238. friend class RelocationRef;
  239. virtual void moveRelocationNext(DataRefImpl &Rel) const = 0;
  240. virtual uint64_t getRelocationOffset(DataRefImpl Rel) const = 0;
  241. virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const = 0;
  242. virtual uint64_t getRelocationType(DataRefImpl Rel) const = 0;
  243. virtual void getRelocationTypeName(DataRefImpl Rel,
  244. SmallVectorImpl<char> &Result) const = 0;
  245. virtual llvm::binaryformat::Swift5ReflectionSectionKind
  246. mapReflectionSectionNameToEnumValue(StringRef SectionName) const {
  247. return llvm::binaryformat::Swift5ReflectionSectionKind::unknown;
  248. };
  249. Expected<uint64_t> getSymbolValue(DataRefImpl Symb) const;
  250. public:
  251. ObjectFile() = delete;
  252. ObjectFile(const ObjectFile &other) = delete;
  253. uint64_t getCommonSymbolSize(DataRefImpl Symb) const {
  254. Expected<uint32_t> SymbolFlagsOrErr = getSymbolFlags(Symb);
  255. if (!SymbolFlagsOrErr)
  256. // TODO: Actually report errors helpfully.
  257. report_fatal_error(SymbolFlagsOrErr.takeError());
  258. assert(*SymbolFlagsOrErr & SymbolRef::SF_Common);
  259. return getCommonSymbolSizeImpl(Symb);
  260. }
  261. virtual std::vector<SectionRef> dynamic_relocation_sections() const {
  262. return std::vector<SectionRef>();
  263. }
  264. using symbol_iterator_range = iterator_range<symbol_iterator>;
  265. symbol_iterator_range symbols() const {
  266. return symbol_iterator_range(symbol_begin(), symbol_end());
  267. }
  268. virtual section_iterator section_begin() const = 0;
  269. virtual section_iterator section_end() const = 0;
  270. using section_iterator_range = iterator_range<section_iterator>;
  271. section_iterator_range sections() const {
  272. return section_iterator_range(section_begin(), section_end());
  273. }
  274. /// The number of bytes used to represent an address in this object
  275. /// file format.
  276. virtual uint8_t getBytesInAddress() const = 0;
  277. virtual StringRef getFileFormatName() const = 0;
  278. virtual Triple::ArchType getArch() const = 0;
  279. virtual SubtargetFeatures getFeatures() const = 0;
  280. virtual Optional<StringRef> tryGetCPUName() const { return None; };
  281. virtual void setARMSubArch(Triple &TheTriple) const { }
  282. virtual Expected<uint64_t> getStartAddress() const {
  283. return errorCodeToError(object_error::parse_failed);
  284. };
  285. /// Create a triple from the data in this object file.
  286. Triple makeTriple() const;
  287. /// Maps a debug section name to a standard DWARF section name.
  288. virtual StringRef mapDebugSectionName(StringRef Name) const { return Name; }
  289. /// True if this is a relocatable object (.o/.obj).
  290. virtual bool isRelocatableObject() const = 0;
  291. /// @returns Pointer to ObjectFile subclass to handle this type of object.
  292. /// @param ObjectPath The path to the object file. ObjectPath.isObject must
  293. /// return true.
  294. /// Create ObjectFile from path.
  295. static Expected<OwningBinary<ObjectFile>>
  296. createObjectFile(StringRef ObjectPath);
  297. static Expected<std::unique_ptr<ObjectFile>>
  298. createObjectFile(MemoryBufferRef Object, llvm::file_magic Type,
  299. bool InitContent = true);
  300. static Expected<std::unique_ptr<ObjectFile>>
  301. createObjectFile(MemoryBufferRef Object) {
  302. return createObjectFile(Object, llvm::file_magic::unknown);
  303. }
  304. static bool classof(const Binary *v) {
  305. return v->isObject();
  306. }
  307. static Expected<std::unique_ptr<COFFObjectFile>>
  308. createCOFFObjectFile(MemoryBufferRef Object);
  309. static Expected<std::unique_ptr<ObjectFile>>
  310. createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType);
  311. static Expected<std::unique_ptr<ObjectFile>>
  312. createELFObjectFile(MemoryBufferRef Object, bool InitContent = true);
  313. static Expected<std::unique_ptr<MachOObjectFile>>
  314. createMachOObjectFile(MemoryBufferRef Object,
  315. uint32_t UniversalCputype = 0,
  316. uint32_t UniversalIndex = 0);
  317. static Expected<std::unique_ptr<WasmObjectFile>>
  318. createWasmObjectFile(MemoryBufferRef Object);
  319. };
  320. // Inline function definitions.
  321. inline SymbolRef::SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner)
  322. : BasicSymbolRef(SymbolP, Owner) {}
  323. inline Expected<StringRef> SymbolRef::getName() const {
  324. return getObject()->getSymbolName(getRawDataRefImpl());
  325. }
  326. inline Expected<uint64_t> SymbolRef::getAddress() const {
  327. return getObject()->getSymbolAddress(getRawDataRefImpl());
  328. }
  329. inline Expected<uint64_t> SymbolRef::getValue() const {
  330. return getObject()->getSymbolValue(getRawDataRefImpl());
  331. }
  332. inline uint32_t SymbolRef::getAlignment() const {
  333. return getObject()->getSymbolAlignment(getRawDataRefImpl());
  334. }
  335. inline uint64_t SymbolRef::getCommonSize() const {
  336. return getObject()->getCommonSymbolSize(getRawDataRefImpl());
  337. }
  338. inline Expected<section_iterator> SymbolRef::getSection() const {
  339. return getObject()->getSymbolSection(getRawDataRefImpl());
  340. }
  341. inline Expected<SymbolRef::Type> SymbolRef::getType() const {
  342. return getObject()->getSymbolType(getRawDataRefImpl());
  343. }
  344. inline const ObjectFile *SymbolRef::getObject() const {
  345. const SymbolicFile *O = BasicSymbolRef::getObject();
  346. return cast<ObjectFile>(O);
  347. }
  348. /// SectionRef
  349. inline SectionRef::SectionRef(DataRefImpl SectionP,
  350. const ObjectFile *Owner)
  351. : SectionPimpl(SectionP)
  352. , OwningObject(Owner) {}
  353. inline bool SectionRef::operator==(const SectionRef &Other) const {
  354. return OwningObject == Other.OwningObject &&
  355. SectionPimpl == Other.SectionPimpl;
  356. }
  357. inline bool SectionRef::operator!=(const SectionRef &Other) const {
  358. return !(*this == Other);
  359. }
  360. inline bool SectionRef::operator<(const SectionRef &Other) const {
  361. assert(OwningObject == Other.OwningObject);
  362. return SectionPimpl < Other.SectionPimpl;
  363. }
  364. inline void SectionRef::moveNext() {
  365. return OwningObject->moveSectionNext(SectionPimpl);
  366. }
  367. inline Expected<StringRef> SectionRef::getName() const {
  368. return OwningObject->getSectionName(SectionPimpl);
  369. }
  370. inline uint64_t SectionRef::getAddress() const {
  371. return OwningObject->getSectionAddress(SectionPimpl);
  372. }
  373. inline uint64_t SectionRef::getIndex() const {
  374. return OwningObject->getSectionIndex(SectionPimpl);
  375. }
  376. inline uint64_t SectionRef::getSize() const {
  377. return OwningObject->getSectionSize(SectionPimpl);
  378. }
  379. inline Expected<StringRef> SectionRef::getContents() const {
  380. Expected<ArrayRef<uint8_t>> Res =
  381. OwningObject->getSectionContents(SectionPimpl);
  382. if (!Res)
  383. return Res.takeError();
  384. return StringRef(reinterpret_cast<const char *>(Res->data()), Res->size());
  385. }
  386. inline uint64_t SectionRef::getAlignment() const {
  387. return OwningObject->getSectionAlignment(SectionPimpl);
  388. }
  389. inline bool SectionRef::isCompressed() const {
  390. return OwningObject->isSectionCompressed(SectionPimpl);
  391. }
  392. inline bool SectionRef::isText() const {
  393. return OwningObject->isSectionText(SectionPimpl);
  394. }
  395. inline bool SectionRef::isData() const {
  396. return OwningObject->isSectionData(SectionPimpl);
  397. }
  398. inline bool SectionRef::isBSS() const {
  399. return OwningObject->isSectionBSS(SectionPimpl);
  400. }
  401. inline bool SectionRef::isVirtual() const {
  402. return OwningObject->isSectionVirtual(SectionPimpl);
  403. }
  404. inline bool SectionRef::isBitcode() const {
  405. return OwningObject->isSectionBitcode(SectionPimpl);
  406. }
  407. inline bool SectionRef::isStripped() const {
  408. return OwningObject->isSectionStripped(SectionPimpl);
  409. }
  410. inline bool SectionRef::isBerkeleyText() const {
  411. return OwningObject->isBerkeleyText(SectionPimpl);
  412. }
  413. inline bool SectionRef::isBerkeleyData() const {
  414. return OwningObject->isBerkeleyData(SectionPimpl);
  415. }
  416. inline bool SectionRef::isDebugSection() const {
  417. return OwningObject->isDebugSection(SectionPimpl);
  418. }
  419. inline relocation_iterator SectionRef::relocation_begin() const {
  420. return OwningObject->section_rel_begin(SectionPimpl);
  421. }
  422. inline relocation_iterator SectionRef::relocation_end() const {
  423. return OwningObject->section_rel_end(SectionPimpl);
  424. }
  425. inline Expected<section_iterator> SectionRef::getRelocatedSection() const {
  426. return OwningObject->getRelocatedSection(SectionPimpl);
  427. }
  428. inline DataRefImpl SectionRef::getRawDataRefImpl() const {
  429. return SectionPimpl;
  430. }
  431. inline const ObjectFile *SectionRef::getObject() const {
  432. return OwningObject;
  433. }
  434. /// RelocationRef
  435. inline RelocationRef::RelocationRef(DataRefImpl RelocationP,
  436. const ObjectFile *Owner)
  437. : RelocationPimpl(RelocationP)
  438. , OwningObject(Owner) {}
  439. inline bool RelocationRef::operator==(const RelocationRef &Other) const {
  440. return RelocationPimpl == Other.RelocationPimpl;
  441. }
  442. inline void RelocationRef::moveNext() {
  443. return OwningObject->moveRelocationNext(RelocationPimpl);
  444. }
  445. inline uint64_t RelocationRef::getOffset() const {
  446. return OwningObject->getRelocationOffset(RelocationPimpl);
  447. }
  448. inline symbol_iterator RelocationRef::getSymbol() const {
  449. return OwningObject->getRelocationSymbol(RelocationPimpl);
  450. }
  451. inline uint64_t RelocationRef::getType() const {
  452. return OwningObject->getRelocationType(RelocationPimpl);
  453. }
  454. inline void RelocationRef::getTypeName(SmallVectorImpl<char> &Result) const {
  455. return OwningObject->getRelocationTypeName(RelocationPimpl, Result);
  456. }
  457. inline DataRefImpl RelocationRef::getRawDataRefImpl() const {
  458. return RelocationPimpl;
  459. }
  460. inline const ObjectFile *RelocationRef::getObject() const {
  461. return OwningObject;
  462. }
  463. } // end namespace object
  464. template <> struct DenseMapInfo<object::SectionRef> {
  465. static bool isEqual(const object::SectionRef &A,
  466. const object::SectionRef &B) {
  467. return A == B;
  468. }
  469. static object::SectionRef getEmptyKey() {
  470. return object::SectionRef({}, nullptr);
  471. }
  472. static object::SectionRef getTombstoneKey() {
  473. object::DataRefImpl TS;
  474. TS.p = (uintptr_t)-1;
  475. return object::SectionRef(TS, nullptr);
  476. }
  477. static unsigned getHashValue(const object::SectionRef &Sec) {
  478. object::DataRefImpl Raw = Sec.getRawDataRefImpl();
  479. return hash_combine(Raw.p, Raw.d.a, Raw.d.b);
  480. }
  481. };
  482. } // end namespace llvm
  483. #endif // LLVM_OBJECT_OBJECTFILE_H
  484. #ifdef __GNUC__
  485. #pragma GCC diagnostic pop
  486. #endif