Archive.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. //===- Archive.cpp - ar File Format implementation --------------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file defines the ArchiveObjectFile class.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "llvm/Object/Archive.h"
  14. #include "llvm/ADT/APInt.h"
  15. #include "llvm/ADT/SmallString.h"
  16. #include "llvm/ADT/Twine.h"
  17. #include "llvm/Support/Endian.h"
  18. #include "llvm/Support/MemoryBuffer.h"
  19. #include "llvm/Support/Path.h"
  20. using namespace llvm;
  21. using namespace object;
  22. using namespace llvm::support::endian;
  23. static const char *const Magic = "!<arch>\n";
  24. static const char *const ThinMagic = "!<thin>\n";
  25. void Archive::anchor() { }
  26. StringRef ArchiveMemberHeader::getName() const {
  27. char EndCond;
  28. if (Name[0] == '/' || Name[0] == '#')
  29. EndCond = ' ';
  30. else
  31. EndCond = '/';
  32. llvm::StringRef::size_type end =
  33. llvm::StringRef(Name, sizeof(Name)).find(EndCond);
  34. if (end == llvm::StringRef::npos)
  35. end = sizeof(Name);
  36. assert(end <= sizeof(Name) && end > 0);
  37. // Don't include the EndCond if there is one.
  38. return llvm::StringRef(Name, end);
  39. }
  40. ErrorOr<uint32_t> ArchiveMemberHeader::getSize() const {
  41. uint32_t Ret;
  42. if (llvm::StringRef(Size, sizeof(Size)).rtrim(" ").getAsInteger(10, Ret))
  43. return object_error::parse_failed; // Size is not a decimal number.
  44. return Ret;
  45. }
  46. sys::fs::perms ArchiveMemberHeader::getAccessMode() const {
  47. unsigned Ret;
  48. if (StringRef(AccessMode, sizeof(AccessMode)).rtrim(" ").getAsInteger(8, Ret))
  49. llvm_unreachable("Access mode is not an octal number.");
  50. return static_cast<sys::fs::perms>(Ret);
  51. }
  52. sys::TimeValue ArchiveMemberHeader::getLastModified() const {
  53. unsigned Seconds;
  54. if (StringRef(LastModified, sizeof(LastModified)).rtrim(" ")
  55. .getAsInteger(10, Seconds))
  56. llvm_unreachable("Last modified time not a decimal number.");
  57. sys::TimeValue Ret;
  58. Ret.fromEpochTime(Seconds);
  59. return Ret;
  60. }
  61. unsigned ArchiveMemberHeader::getUID() const {
  62. unsigned Ret;
  63. if (StringRef(UID, sizeof(UID)).rtrim(" ").getAsInteger(10, Ret))
  64. llvm_unreachable("UID time not a decimal number.");
  65. return Ret;
  66. }
  67. unsigned ArchiveMemberHeader::getGID() const {
  68. unsigned Ret;
  69. if (StringRef(GID, sizeof(GID)).rtrim(" ").getAsInteger(10, Ret))
  70. llvm_unreachable("GID time not a decimal number.");
  71. return Ret;
  72. }
  73. Archive::Child::Child(const Archive *Parent, StringRef Data,
  74. uint16_t StartOfFile)
  75. : Parent(Parent), Data(Data), StartOfFile(StartOfFile) {}
  76. Archive::Child::Child(const Archive *Parent, const char *Start,
  77. std::error_code *EC)
  78. : Parent(Parent) {
  79. if (!Start)
  80. return;
  81. uint64_t Size = sizeof(ArchiveMemberHeader);
  82. Data = StringRef(Start, Size);
  83. if (!isThinMember()) {
  84. ErrorOr<uint64_t> MemberSize = getRawSize();
  85. if ((*EC = MemberSize.getError()))
  86. return;
  87. Size += MemberSize.get();
  88. Data = StringRef(Start, Size);
  89. }
  90. // Setup StartOfFile and PaddingBytes.
  91. StartOfFile = sizeof(ArchiveMemberHeader);
  92. // Don't include attached name.
  93. StringRef Name = getRawName();
  94. if (Name.startswith("#1/")) {
  95. uint64_t NameSize;
  96. if (Name.substr(3).rtrim(" ").getAsInteger(10, NameSize))
  97. llvm_unreachable("Long name length is not an integer");
  98. StartOfFile += NameSize;
  99. }
  100. }
  101. ErrorOr<uint64_t> Archive::Child::getSize() const {
  102. if (Parent->IsThin) {
  103. ErrorOr<uint32_t> Size = getHeader()->getSize();
  104. if (std::error_code EC = Size.getError())
  105. return EC;
  106. return Size.get();
  107. }
  108. return Data.size() - StartOfFile;
  109. }
  110. ErrorOr<uint64_t> Archive::Child::getRawSize() const {
  111. ErrorOr<uint32_t> Size = getHeader()->getSize();
  112. if (std::error_code EC = Size.getError())
  113. return EC;
  114. return Size.get();
  115. }
  116. bool Archive::Child::isThinMember() const {
  117. StringRef Name = getHeader()->getName();
  118. return Parent->IsThin && Name != "/" && Name != "//";
  119. }
  120. ErrorOr<StringRef> Archive::Child::getBuffer() const {
  121. if (!isThinMember()) {
  122. ErrorOr<uint32_t> Size = getSize();
  123. if (std::error_code EC = Size.getError())
  124. return EC;
  125. return StringRef(Data.data() + StartOfFile, Size.get());
  126. }
  127. ErrorOr<StringRef> Name = getName();
  128. if (std::error_code EC = Name.getError())
  129. return EC;
  130. SmallString<128> FullName = sys::path::parent_path(
  131. Parent->getMemoryBufferRef().getBufferIdentifier());
  132. sys::path::append(FullName, *Name);
  133. ErrorOr<std::unique_ptr<MemoryBuffer>> Buf = MemoryBuffer::getFile(FullName);
  134. if (std::error_code EC = Buf.getError())
  135. return EC;
  136. Parent->ThinBuffers.push_back(std::move(*Buf));
  137. return Parent->ThinBuffers.back()->getBuffer();
  138. }
  139. ErrorOr<Archive::Child> Archive::Child::getNext() const {
  140. size_t SpaceToSkip = Data.size();
  141. // If it's odd, add 1 to make it even.
  142. if (SpaceToSkip & 1)
  143. ++SpaceToSkip;
  144. const char *NextLoc = Data.data() + SpaceToSkip;
  145. // Check to see if this is at the end of the archive.
  146. if (NextLoc == Parent->Data.getBufferEnd())
  147. return Child(Parent, nullptr, nullptr);
  148. // Check to see if this is past the end of the archive.
  149. if (NextLoc > Parent->Data.getBufferEnd())
  150. return object_error::parse_failed;
  151. std::error_code EC;
  152. Child Ret(Parent, NextLoc, &EC);
  153. if (EC)
  154. return EC;
  155. return Ret;
  156. }
  157. uint64_t Archive::Child::getChildOffset() const {
  158. const char *a = Parent->Data.getBuffer().data();
  159. const char *c = Data.data();
  160. uint64_t offset = c - a;
  161. return offset;
  162. }
  163. ErrorOr<StringRef> Archive::Child::getName() const {
  164. StringRef name = getRawName();
  165. // Check if it's a special name.
  166. if (name[0] == '/') {
  167. if (name.size() == 1) // Linker member.
  168. return name;
  169. if (name.size() == 2 && name[1] == '/') // String table.
  170. return name;
  171. // It's a long name.
  172. // Get the offset.
  173. std::size_t offset;
  174. if (name.substr(1).rtrim(" ").getAsInteger(10, offset))
  175. llvm_unreachable("Long name offset is not an integer");
  176. // Verify it.
  177. if (offset >= Parent->StringTable.size())
  178. return object_error::parse_failed;
  179. const char *addr = Parent->StringTable.begin() + offset;
  180. // GNU long file names end with a "/\n".
  181. if (Parent->kind() == K_GNU || Parent->kind() == K_MIPS64) {
  182. StringRef::size_type End = StringRef(addr).find('\n');
  183. return StringRef(addr, End - 1);
  184. }
  185. return StringRef(addr);
  186. } else if (name.startswith("#1/")) {
  187. uint64_t name_size;
  188. if (name.substr(3).rtrim(" ").getAsInteger(10, name_size))
  189. llvm_unreachable("Long name length is not an ingeter");
  190. return Data.substr(sizeof(ArchiveMemberHeader), name_size)
  191. .rtrim(StringRef("\0", 1));
  192. }
  193. // It's a simple name.
  194. if (name[name.size() - 1] == '/')
  195. return name.substr(0, name.size() - 1);
  196. return name;
  197. }
  198. ErrorOr<MemoryBufferRef> Archive::Child::getMemoryBufferRef() const {
  199. ErrorOr<StringRef> NameOrErr = getName();
  200. if (std::error_code EC = NameOrErr.getError())
  201. return EC;
  202. StringRef Name = NameOrErr.get();
  203. ErrorOr<StringRef> Buf = getBuffer();
  204. if (std::error_code EC = Buf.getError())
  205. return EC;
  206. return MemoryBufferRef(*Buf, Name);
  207. }
  208. ErrorOr<std::unique_ptr<Binary>>
  209. Archive::Child::getAsBinary(LLVMContext *Context) const {
  210. ErrorOr<MemoryBufferRef> BuffOrErr = getMemoryBufferRef();
  211. if (std::error_code EC = BuffOrErr.getError())
  212. return EC;
  213. return createBinary(BuffOrErr.get(), Context);
  214. }
  215. ErrorOr<std::unique_ptr<Archive>> Archive::create(MemoryBufferRef Source) {
  216. std::error_code EC;
  217. std::unique_ptr<Archive> Ret(new Archive(Source, EC));
  218. if (EC)
  219. return EC;
  220. return std::move(Ret);
  221. }
  222. void Archive::setFirstRegular(const Child &C) {
  223. FirstRegularData = C.Data;
  224. FirstRegularStartOfFile = C.StartOfFile;
  225. }
  226. Archive::Archive(MemoryBufferRef Source, std::error_code &ec)
  227. : Binary(Binary::ID_Archive, Source) {
  228. StringRef Buffer = Data.getBuffer();
  229. // Check for sufficient magic.
  230. if (Buffer.startswith(ThinMagic)) {
  231. IsThin = true;
  232. } else if (Buffer.startswith(Magic)) {
  233. IsThin = false;
  234. } else {
  235. ec = object_error::invalid_file_type;
  236. return;
  237. }
  238. // Get the special members.
  239. child_iterator I = child_begin(false);
  240. if ((ec = I->getError()))
  241. return;
  242. child_iterator E = child_end();
  243. if (I == E) {
  244. ec = std::error_code();
  245. return;
  246. }
  247. const Child *C = &**I;
  248. auto Increment = [&]() {
  249. ++I;
  250. if ((ec = I->getError()))
  251. return true;
  252. C = &**I;
  253. return false;
  254. };
  255. StringRef Name = C->getRawName();
  256. // Below is the pattern that is used to figure out the archive format
  257. // GNU archive format
  258. // First member : / (may exist, if it exists, points to the symbol table )
  259. // Second member : // (may exist, if it exists, points to the string table)
  260. // Note : The string table is used if the filename exceeds 15 characters
  261. // BSD archive format
  262. // First member : __.SYMDEF or "__.SYMDEF SORTED" (the symbol table)
  263. // There is no string table, if the filename exceeds 15 characters or has a
  264. // embedded space, the filename has #1/<size>, The size represents the size
  265. // of the filename that needs to be read after the archive header
  266. // COFF archive format
  267. // First member : /
  268. // Second member : / (provides a directory of symbols)
  269. // Third member : // (may exist, if it exists, contains the string table)
  270. // Note: Microsoft PE/COFF Spec 8.3 says that the third member is present
  271. // even if the string table is empty. However, lib.exe does not in fact
  272. // seem to create the third member if there's no member whose filename
  273. // exceeds 15 characters. So the third member is optional.
  274. if (Name == "__.SYMDEF") {
  275. Format = K_BSD;
  276. // We know that the symbol table is not an external file, so we just assert
  277. // there is no error.
  278. SymbolTable = *C->getBuffer();
  279. if (Increment())
  280. return;
  281. setFirstRegular(*C);
  282. ec = std::error_code();
  283. return;
  284. }
  285. if (Name.startswith("#1/")) {
  286. Format = K_BSD;
  287. // We know this is BSD, so getName will work since there is no string table.
  288. ErrorOr<StringRef> NameOrErr = C->getName();
  289. ec = NameOrErr.getError();
  290. if (ec)
  291. return;
  292. Name = NameOrErr.get();
  293. if (Name == "__.SYMDEF SORTED" || Name == "__.SYMDEF") {
  294. // We know that the symbol table is not an external file, so we just
  295. // assert there is no error.
  296. SymbolTable = *C->getBuffer();
  297. if (Increment())
  298. return;
  299. }
  300. setFirstRegular(*C);
  301. return;
  302. }
  303. // MIPS 64-bit ELF archives use a special format of a symbol table.
  304. // This format is marked by `ar_name` field equals to "/SYM64/".
  305. // For detailed description see page 96 in the following document:
  306. // http://techpubs.sgi.com/library/manuals/4000/007-4658-001/pdf/007-4658-001.pdf
  307. bool has64SymTable = false;
  308. if (Name == "/" || Name == "/SYM64/") {
  309. // We know that the symbol table is not an external file, so we just assert
  310. // there is no error.
  311. SymbolTable = *C->getBuffer();
  312. if (Name == "/SYM64/")
  313. has64SymTable = true;
  314. if (Increment())
  315. return;
  316. if (I == E) {
  317. ec = std::error_code();
  318. return;
  319. }
  320. Name = C->getRawName();
  321. }
  322. if (Name == "//") {
  323. Format = has64SymTable ? K_MIPS64 : K_GNU;
  324. // The string table is never an external member, so we just assert on the
  325. // ErrorOr.
  326. StringTable = *C->getBuffer();
  327. if (Increment())
  328. return;
  329. setFirstRegular(*C);
  330. ec = std::error_code();
  331. return;
  332. }
  333. if (Name[0] != '/') {
  334. Format = has64SymTable ? K_MIPS64 : K_GNU;
  335. setFirstRegular(*C);
  336. ec = std::error_code();
  337. return;
  338. }
  339. if (Name != "/") {
  340. ec = object_error::parse_failed;
  341. return;
  342. }
  343. Format = K_COFF;
  344. // We know that the symbol table is not an external file, so we just assert
  345. // there is no error.
  346. SymbolTable = *C->getBuffer();
  347. if (Increment())
  348. return;
  349. if (I == E) {
  350. setFirstRegular(*C);
  351. ec = std::error_code();
  352. return;
  353. }
  354. Name = C->getRawName();
  355. if (Name == "//") {
  356. // The string table is never an external member, so we just assert on the
  357. // ErrorOr.
  358. StringTable = *C->getBuffer();
  359. if (Increment())
  360. return;
  361. }
  362. setFirstRegular(*C);
  363. ec = std::error_code();
  364. }
  365. Archive::child_iterator Archive::child_begin(bool SkipInternal) const {
  366. if (Data.getBufferSize() == 8) // empty archive.
  367. return child_end();
  368. if (SkipInternal)
  369. return Child(this, FirstRegularData, FirstRegularStartOfFile);
  370. const char *Loc = Data.getBufferStart() + strlen(Magic);
  371. std::error_code EC;
  372. Child c(this, Loc, &EC);
  373. if (EC)
  374. return child_iterator(EC);
  375. return child_iterator(c);
  376. }
  377. Archive::child_iterator Archive::child_end() const {
  378. return Child(this, nullptr, nullptr);
  379. }
  380. StringRef Archive::Symbol::getName() const {
  381. return Parent->getSymbolTable().begin() + StringIndex;
  382. }
  383. ErrorOr<Archive::Child> Archive::Symbol::getMember() const {
  384. const char *Buf = Parent->getSymbolTable().begin();
  385. const char *Offsets = Buf;
  386. if (Parent->kind() == K_MIPS64)
  387. Offsets += sizeof(uint64_t);
  388. else
  389. Offsets += sizeof(uint32_t);
  390. uint32_t Offset = 0;
  391. if (Parent->kind() == K_GNU) {
  392. Offset = read32be(Offsets + SymbolIndex * 4);
  393. } else if (Parent->kind() == K_MIPS64) {
  394. Offset = read64be(Offsets + SymbolIndex * 8);
  395. } else if (Parent->kind() == K_BSD) {
  396. // The SymbolIndex is an index into the ranlib structs that start at
  397. // Offsets (the first uint32_t is the number of bytes of the ranlib
  398. // structs). The ranlib structs are a pair of uint32_t's the first
  399. // being a string table offset and the second being the offset into
  400. // the archive of the member that defines the symbol. Which is what
  401. // is needed here.
  402. Offset = read32le(Offsets + SymbolIndex * 8 + 4);
  403. } else {
  404. // Skip offsets.
  405. uint32_t MemberCount = read32le(Buf);
  406. Buf += MemberCount * 4 + 4;
  407. uint32_t SymbolCount = read32le(Buf);
  408. if (SymbolIndex >= SymbolCount)
  409. return object_error::parse_failed;
  410. // Skip SymbolCount to get to the indices table.
  411. const char *Indices = Buf + 4;
  412. // Get the index of the offset in the file member offset table for this
  413. // symbol.
  414. uint16_t OffsetIndex = read16le(Indices + SymbolIndex * 2);
  415. // Subtract 1 since OffsetIndex is 1 based.
  416. --OffsetIndex;
  417. if (OffsetIndex >= MemberCount)
  418. return object_error::parse_failed;
  419. Offset = read32le(Offsets + OffsetIndex * 4);
  420. }
  421. const char *Loc = Parent->getData().begin() + Offset;
  422. std::error_code EC;
  423. Child C(Parent, Loc, &EC);
  424. if (EC)
  425. return EC;
  426. return C;
  427. }
  428. Archive::Symbol Archive::Symbol::getNext() const {
  429. Symbol t(*this);
  430. if (Parent->kind() == K_BSD) {
  431. // t.StringIndex is an offset from the start of the __.SYMDEF or
  432. // "__.SYMDEF SORTED" member into the string table for the ranlib
  433. // struct indexed by t.SymbolIndex . To change t.StringIndex to the
  434. // offset in the string table for t.SymbolIndex+1 we subtract the
  435. // its offset from the start of the string table for t.SymbolIndex
  436. // and add the offset of the string table for t.SymbolIndex+1.
  437. // The __.SYMDEF or "__.SYMDEF SORTED" member starts with a uint32_t
  438. // which is the number of bytes of ranlib structs that follow. The ranlib
  439. // structs are a pair of uint32_t's the first being a string table offset
  440. // and the second being the offset into the archive of the member that
  441. // define the symbol. After that the next uint32_t is the byte count of
  442. // the string table followed by the string table.
  443. const char *Buf = Parent->getSymbolTable().begin();
  444. uint32_t RanlibCount = 0;
  445. RanlibCount = read32le(Buf) / 8;
  446. // If t.SymbolIndex + 1 will be past the count of symbols (the RanlibCount)
  447. // don't change the t.StringIndex as we don't want to reference a ranlib
  448. // past RanlibCount.
  449. if (t.SymbolIndex + 1 < RanlibCount) {
  450. const char *Ranlibs = Buf + 4;
  451. uint32_t CurRanStrx = 0;
  452. uint32_t NextRanStrx = 0;
  453. CurRanStrx = read32le(Ranlibs + t.SymbolIndex * 8);
  454. NextRanStrx = read32le(Ranlibs + (t.SymbolIndex + 1) * 8);
  455. t.StringIndex -= CurRanStrx;
  456. t.StringIndex += NextRanStrx;
  457. }
  458. } else {
  459. // Go to one past next null.
  460. t.StringIndex = Parent->getSymbolTable().find('\0', t.StringIndex) + 1;
  461. }
  462. ++t.SymbolIndex;
  463. return t;
  464. }
  465. Archive::symbol_iterator Archive::symbol_begin() const {
  466. if (!hasSymbolTable())
  467. return symbol_iterator(Symbol(this, 0, 0));
  468. const char *buf = getSymbolTable().begin();
  469. if (kind() == K_GNU) {
  470. uint32_t symbol_count = 0;
  471. symbol_count = read32be(buf);
  472. buf += sizeof(uint32_t) + (symbol_count * (sizeof(uint32_t)));
  473. } else if (kind() == K_MIPS64) {
  474. uint64_t symbol_count = read64be(buf);
  475. buf += sizeof(uint64_t) + (symbol_count * (sizeof(uint64_t)));
  476. } else if (kind() == K_BSD) {
  477. // The __.SYMDEF or "__.SYMDEF SORTED" member starts with a uint32_t
  478. // which is the number of bytes of ranlib structs that follow. The ranlib
  479. // structs are a pair of uint32_t's the first being a string table offset
  480. // and the second being the offset into the archive of the member that
  481. // define the symbol. After that the next uint32_t is the byte count of
  482. // the string table followed by the string table.
  483. uint32_t ranlib_count = 0;
  484. ranlib_count = read32le(buf) / 8;
  485. const char *ranlibs = buf + 4;
  486. uint32_t ran_strx = 0;
  487. ran_strx = read32le(ranlibs);
  488. buf += sizeof(uint32_t) + (ranlib_count * (2 * (sizeof(uint32_t))));
  489. // Skip the byte count of the string table.
  490. buf += sizeof(uint32_t);
  491. buf += ran_strx;
  492. } else {
  493. uint32_t member_count = 0;
  494. uint32_t symbol_count = 0;
  495. member_count = read32le(buf);
  496. buf += 4 + (member_count * 4); // Skip offsets.
  497. symbol_count = read32le(buf);
  498. buf += 4 + (symbol_count * 2); // Skip indices.
  499. }
  500. uint32_t string_start_offset = buf - getSymbolTable().begin();
  501. return symbol_iterator(Symbol(this, 0, string_start_offset));
  502. }
  503. Archive::symbol_iterator Archive::symbol_end() const {
  504. return symbol_iterator(Symbol(this, getNumberOfSymbols(), 0));
  505. }
  506. uint32_t Archive::getNumberOfSymbols() const {
  507. if (!hasSymbolTable())
  508. return 0;
  509. const char *buf = getSymbolTable().begin();
  510. if (kind() == K_GNU)
  511. return read32be(buf);
  512. if (kind() == K_MIPS64)
  513. return read64be(buf);
  514. if (kind() == K_BSD)
  515. return read32le(buf) / 8;
  516. uint32_t member_count = 0;
  517. member_count = read32le(buf);
  518. buf += 4 + (member_count * 4); // Skip offsets.
  519. return read32le(buf);
  520. }
  521. Archive::child_iterator Archive::findSym(StringRef name) const {
  522. Archive::symbol_iterator bs = symbol_begin();
  523. Archive::symbol_iterator es = symbol_end();
  524. for (; bs != es; ++bs) {
  525. StringRef SymName = bs->getName();
  526. if (SymName == name) {
  527. ErrorOr<Archive::child_iterator> ResultOrErr = bs->getMember();
  528. // FIXME: Should we really eat the error?
  529. if (ResultOrErr.getError())
  530. return child_end();
  531. return ResultOrErr.get();
  532. }
  533. }
  534. return child_end();
  535. }
  536. bool Archive::hasSymbolTable() const { return !SymbolTable.empty(); }