llvm.org GIT mirror llvm / e75ca3d
eliminate residual cruft related to recognizing bytecode files. bitcode files are the only LLVM format left. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37945 91177308-0d34-0410-b5e6-96231b3b80d8 Gabor Greif 12 years ago
9 changed file(s) with 13 addition(s) and 71 deletion(s). Raw diff Collapse all Expand all
5050 SVR4SymbolTableFlag = 2, ///< Member is a SVR4 symbol table
5151 BSD4SymbolTableFlag = 4, ///< Member is a BSD4 symbol table
5252 LLVMSymbolTableFlag = 8, ///< Member is an LLVM symbol table
53 BytecodeFlag = 16, ///< Member is uncompressed bytecode
54 CompressedBytecodeFlag = 32, ///< Member is compressed bytecode
53 BitcodeFlag = 16, ///< Member is uncompressed bytecode
5554 HasPathFlag = 64, ///< Member has a full or partial path
5655 HasLongFilenameFlag = 128, ///< Member uses the long filename syntax
5756 StringTableFlag = 256 ///< Member is an ar(1) format string table
111110
112111 /// This method determines if the member is a regular compressed file. Note
113112 /// that compressed bytecode files will yield "false" for this method.
114 /// @see isCompressedBytecode()
115113 /// @returns true iff the archive member is a compressed regular file.
116114 /// @brief Determine if the member is a compressed regular file.
117115 bool isCompressed() const { return flags&CompressedFlag; }
134132
135133 /// @returns true iff the archive member is an uncompressed bytecode file.
136134 /// @brief Determine if this member is a bytecode file.
137 bool isBytecode() const { return flags&BytecodeFlag; }
138
139 /// @returns true iff the archive member is a compressed bytecode file.
140 /// @brief Determine if the member is a compressed bytecode file.
141 bool isCompressedBytecode() const { return flags&CompressedBytecodeFlag;}
135 bool isBitcode() const { return flags&BitcodeFlag; }
142136
143137 /// @returns true iff the file name contains a path (directory) component.
144138 /// @brief Determine if the member has a path
306306 bool isArchive() const;
307307
308308 /// This function determines if the path name in the object references an
309 /// LLVM Bytecode file by looking at its magic number.
310 /// @returns true if the file starts with the magic number for LLVM
311 /// bytecode files.
312 /// @brief Determine if the path references a bytecode file.
313 bool isBytecodeFile() const;
314
315 /// This function determines if the path name in the object references an
316309 /// LLVM Bitcode file by looking at its magic number.
317310 /// @returns true if the file starts with the magic number for LLVM
318311 /// bitcode files.
620613 /// This enumeration delineates the kinds of files that LLVM knows about.
621614 enum LLVMFileType {
622615 Unknown_FileType = 0, ///< Unrecognized file
623 Bytecode_FileType, ///< Uncompressed bytecode file
624616 Bitcode_FileType, ///< Bitcode file
625 CompressedBytecode_FileType, ///< Compressed bytecode file
626617 Archive_FileType, ///< ar style archive file
627618 ELF_Relocatable_FileType, ///< ELF Relocatable object file
628619 ELF_Executable_FileType, ///< ELF Executable image
125125
126126 // Determine what kind of file it is
127127 switch (sys::IdentifyFileType(signature,4)) {
128 case sys::Bytecode_FileType:
129 flags |= BytecodeFlag;
130 break;
131 case sys::CompressedBytecode_FileType:
132 flags |= CompressedBytecodeFlag;
133 flags &= ~CompressedFlag;
134 break;
135128 default:
136 flags &= ~(BytecodeFlag|CompressedBytecodeFlag);
129 flags &= ~BitcodeFlag;
137130 break;
138131 }
139132 return false;
206206 // Determine if this is a bytecode file
207207 switch (sys::IdentifyFileType(At, 4)) {
208208 case sys::Bitcode_FileType:
209 case sys::Bytecode_FileType:
210 flags |= ArchiveMember::BytecodeFlag;
211 break;
212 case sys::CompressedBytecode_FileType:
213 flags |= ArchiveMember::CompressedBytecodeFlag;
214 flags &= ~ArchiveMember::CompressedFlag;
209 flags |= ArchiveMember::BitcodeFlag;
215210 break;
216211 default:
217 flags &= ~(ArchiveMember::BytecodeFlag|
218 ArchiveMember::CompressedBytecodeFlag);
212 flags &= ~ArchiveMember::BitcodeFlag;
219213 break;
220214 }
221215
348342 Archive::getAllModules(std::vector& Modules, std::string* ErrMessage) {
349343
350344 for (iterator I=begin(), E=end(); I != E; ++I) {
351 if (I->isBytecode() || I->isCompressedBytecode()) {
345 if (I->isBitcode()) {
352346 std::string FullMemberName = archPath.toString() +
353347 "(" + I->getPath().toString() + ")";
354348 MemoryBuffer *Buffer =
534528 return false;
535529
536530 // If it contains symbols
537 if (mbr->isBytecode() || mbr->isCompressedBytecode()) {
531 if (mbr->isBitcode()) {
538532 // Get the symbols
539533 std::vector symbols;
540534 std::string FullMemberName = archPath.toString() + "(" +
611605 // Scan the archive, trying to load a bitcode member. We only load one to
612606 // see if this works.
613607 for (iterator I = begin(), E = end(); I != E; ++I) {
614 if (!I->isBytecode() && !I->isCompressedBytecode())
608 if (!I->isBitcode())
615609 continue;
616610
617611 std::string FullMemberName =
178178 mbr->path.getMagicNumber(magic,4);
179179 switch (sys::IdentifyFileType(magic.c_str(),4)) {
180180 case sys::Bitcode_FileType:
181 case sys::Bytecode_FileType:
182 flags |= ArchiveMember::BytecodeFlag;
183 break;
184 case sys::CompressedBytecode_FileType:
185 flags |= ArchiveMember::CompressedBytecodeFlag;
181 flags |= ArchiveMember::BitcodeFlag;
186182 break;
187183 default:
188184 break;
222218
223219 // Now that we have the data in memory, update the
224220 // symbol table if its a bitcode file.
225 if (CreateSymbolTable &&
226 (member.isBytecode() || member.isCompressedBytecode())) {
221 if (CreateSymbolTable && member.isBitcode()) {
227222 std::vector symbols;
228223 std::string FullMemberName = archPath.toString() + "(" +
229224 member.getPath().toString()
8181 case sys::Unknown_FileType:
8282 return warning("Supposed library '" + Lib + "' isn't a library.");
8383
84 case sys::Bytecode_FileType:
8584 case sys::Bitcode_FileType:
86 case sys::CompressedBytecode_FileType:
8785 // LLVM ".so" file.
8886 if (LinkInFile(Pathname, is_native))
8987 return error("Cannot link file '" + Pathname.toString() + "'");
175173 return error("Cannot link archive '" + File.toString() + "'");
176174 break;
177175
178 case sys::Bitcode_FileType:
179 case sys::Bytecode_FileType:
180 case sys::CompressedBytecode_FileType: {
176 case sys::Bitcode_FileType: {
181177 verbose("Linking bitcode file '" + File.toString() + "'");
182178 std::auto_ptr M(LoadObject(File));
183179 if (M.get() == 0)
141141 FullPath.appendSuffix(&(LTDL_SHLIB_EXT[1]));
142142 if (FullPath.isDynamicLibrary()) // Native shared library?
143143 return FullPath;
144 if (FullPath.isBytecodeFile()) // .so file containing bytecode?
145 return FullPath;
146144 if (FullPath.isBitcodeFile()) // .so file containing bitcode?
147145 return FullPath;
148146
4545 case 'B':
4646 if (magic[1] == 'C' && magic[2] == (char)0xC0 && magic[3] == (char)0xDE)
4747 return Bitcode_FileType;
48 break;
49 case 'l':
50 if (magic[1] == 'l' && magic[2] == 'v') {
51 if (magic[3] == 'c')
52 return CompressedBytecode_FileType;
53 else if (magic[3] == 'm')
54 return Bytecode_FileType;
55 }
5648 break;
5749 case '!':
5850 if (length >= 8)
164156 }
165157
166158 bool
167 Path::isBytecodeFile() const {
168 std::string actualMagic;
169 if (!getMagicNumber(actualMagic, 4))
170 return false;
171 return actualMagic == "llvc" || actualMagic == "llvm";
172 }
173
174 bool
175159 Path::isBitcodeFile() const {
176160 std::string actualMagic;
177161 if (!getMagicNumber(actualMagic, 4))
355355
356356 // Skip things that don't make sense to print
357357 if (I->isLLVMSymbolTable() || I->isSVR4SymbolTable() ||
358 I->isBSD4SymbolTable() || (!DontSkipBitcode &&
359 (I->isBytecode() || I->isCompressedBytecode())))
358 I->isBSD4SymbolTable() || (!DontSkipBitcode && I->isBitcode()))
360359 continue;
361360
362361 if (Verbose)
405404 if (Verbose) {
406405 // FIXME: Output should be this format:
407406 // Zrw-r--r-- 500/ 500 525 Nov 8 17:42 2004 Makefile
408 if (I->isBytecode())
407 if (I->isBitcode())
409408 std::cout << "b";
410 else if (I->isCompressedBytecode())
411 std::cout << "B";
412409 else if (I->isCompressed())
413410 std::cout << "Z";
414411 else