+ if (i == e) {
+ ec = object_error::success;
+ return;
+ }
+
+ StringRef Name = i->getRawName();
+
+ // Below is the pattern that is used to figure out the archive format
+ // GNU archive format
+ // First member : / (may exist, if it exists, points to the symbol table )
+ // Second member : // (may exist, if it exists, points to the string table)
+ // Note : The string table is used if the filename exceeds 15 characters
+ // BSD archive format
+ // First member : __.SYMDEF or "__.SYMDEF SORTED" (the symbol table)
+ // There is no string table, if the filename exceeds 15 characters or has a
+ // embedded space, the filename has #1/<size>, The size represents the size
+ // of the filename that needs to be read after the archive header
+ // COFF archive format
+ // First member : /
+ // Second member : / (provides a directory of symbols)
+ // Third member : // (may exist, if it exists, contains the string table)
+ // Note: Microsoft PE/COFF Spec 8.3 says that the third member is present
+ // even if the string table is empty. However, lib.exe does not in fact
+ // seem to create the third member if there's no member whose filename
+ // exceeds 15 characters. So the third member is optional.
+
+ if (Name == "__.SYMDEF") {
+ Format = K_BSD;
+ SymbolTable = i;
+ ++i;
+ FirstRegular = i;
+ ec = object_error::success;
+ return;
+ }
+
+ if (Name.startswith("#1/")) {
+ Format = K_BSD;
+ // We know this is BSD, so getName will work since there is no string table.
+ ec = i->getName(Name);
+ if (ec)
+ return;
+ if (Name == "__.SYMDEF SORTED") {
+ SymbolTable = i;
+ ++i;
+ }
+ FirstRegular = i;
+ return;
+ }
+
+ if (Name == "/") {