Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: tools/llvm-nm/llvm-nm.cpp

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/llvm-nm/Makefile ('k') | tools/lto/Makefile » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===-- llvm-nm.cpp - Symbol table dumping utility for llvm ---------------===// 1 //===-- llvm-nm.cpp - Symbol table dumping utility for llvm ---------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This program is a utility that works like traditional Unix "nm", that is, it 10 // This program is a utility that works like traditional Unix "nm", that is, it
11 // prints out the names of symbols in a bitcode or object file, along with some 11 // prints out the names of symbols in a bitcode or object file, along with some
12 // information about each symbol. 12 // information about each symbol.
13 // 13 //
14 // This "nm" supports many of the features of GNU "nm", including its different 14 // This "nm" supports many of the features of GNU "nm", including its different
15 // output formats. 15 // output formats.
16 // 16 //
17 //===----------------------------------------------------------------------===// 17 //===----------------------------------------------------------------------===//
18 18
19 #include "llvm/IR/Function.h" 19 #include "llvm/IR/Function.h"
20 #include "llvm/IR/GlobalAlias.h" 20 #include "llvm/IR/GlobalAlias.h"
21 #include "llvm/IR/GlobalVariable.h" 21 #include "llvm/IR/GlobalVariable.h"
22 #include "llvm/IR/LLVMContext.h" 22 #include "llvm/IR/LLVMContext.h"
23 #include "llvm/Bitcode/NaCl/NaClReaderWriter.h" // @LOCALMOD
24 #include "llvm/IRReader/IRReader.h" // @LOCALMOD
23 #include "llvm/Object/Archive.h" 25 #include "llvm/Object/Archive.h"
24 #include "llvm/Object/COFF.h" 26 #include "llvm/Object/COFF.h"
25 #include "llvm/Object/ELFObjectFile.h" 27 #include "llvm/Object/ELFObjectFile.h"
26 #include "llvm/Object/IRObjectFile.h" 28 #include "llvm/Object/IRObjectFile.h"
27 #include "llvm/Object/MachO.h" 29 #include "llvm/Object/MachO.h"
28 #include "llvm/Object/MachOUniversal.h" 30 #include "llvm/Object/MachOUniversal.h"
29 #include "llvm/Object/ObjectFile.h" 31 #include "llvm/Object/ObjectFile.h"
30 #include "llvm/Support/COFF.h" 32 #include "llvm/Support/COFF.h"
31 #include "llvm/Support/CommandLine.h" 33 #include "llvm/Support/CommandLine.h"
32 #include "llvm/Support/FileSystem.h" 34 #include "llvm/Support/FileSystem.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 cl::opt<bool> NoLLVMBitcode("no-llvm-bc", 154 cl::opt<bool> NoLLVMBitcode("no-llvm-bc",
153 cl::desc("Disable LLVM bitcode reader")); 155 cl::desc("Disable LLVM bitcode reader"));
154 156
155 bool PrintAddress = true; 157 bool PrintAddress = true;
156 158
157 bool MultipleFiles = false; 159 bool MultipleFiles = false;
158 160
159 bool HadError = false; 161 bool HadError = false;
160 162
161 std::string ToolName; 163 std::string ToolName;
164
165 // @LOCALMOD-BEGIN
166 cl::opt<NaClFileFormat> InputFileFormat(
167 "bitcode-format", cl::desc("Define format of input file:"),
168 cl::values(clEnumValN(LLVMFormat, "llvm", "LLVM file (default)"),
169 clEnumValN(PNaClFormat, "pnacl", "PNaCl bitcode file"),
170 clEnumValEnd),
171 cl::init(LLVMFormat));
172
173 static cl::opt<bool>
174 VerboseErrors(
175 "verbose-parse-errors",
176 cl::desc("Print out more descriptive PNaCl bitcode parse errors"),
177 cl::init(false));
178 // @LOCALMOD-END
162 } 179 }
163 180
164 static void error(Twine Message, Twine Path = Twine()) { 181 static void error(Twine Message, Twine Path = Twine()) {
165 HadError = true; 182 HadError = true;
166 errs() << ToolName << ": " << Path << ": " << Message << ".\n"; 183 errs() << ToolName << ": " << Path << ": " << Message << ".\n";
167 } 184 }
168 185
169 static bool error(std::error_code EC, Twine Path = Twine()) { 186 static bool error(std::error_code EC, Twine Path = Twine()) {
170 if (EC) { 187 if (EC) {
171 error(EC.message(), Path); 188 error(EC.message(), Path);
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 return true; 1018 return true;
1002 } 1019 }
1003 1020
1004 static void dumpSymbolNamesFromFile(std::string &Filename) { 1021 static void dumpSymbolNamesFromFile(std::string &Filename) {
1005 ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr = 1022 ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
1006 MemoryBuffer::getFileOrSTDIN(Filename); 1023 MemoryBuffer::getFileOrSTDIN(Filename);
1007 if (error(BufferOrErr.getError(), Filename)) 1024 if (error(BufferOrErr.getError(), Filename))
1008 return; 1025 return;
1009 1026
1010 LLVMContext &Context = getGlobalContext(); 1027 LLVMContext &Context = getGlobalContext();
1028
1029 // @LOCALMOD-BEGIN
1030 // Support parsing PNaCl bitcode files
1031 switch (InputFileFormat) {
1032 case LLVMFormat:
1033 break;
1034 case PNaClFormat:
1035 case AutodetectFileFormat:
1036 report_fatal_error("command only supports LLVM file format!");
1037 }
1038 /* TODO(jfb) This is currently broken: the code base now requires an Object.
1039 if (InputFileFormat == PNaClFormat) {
1040 std::string VerboseBuffer;
1041 raw_string_ostream VerboseStrm(VerboseBuffer);
1042 raw_ostream *Verbose = VerboseErrors ? &VerboseStrm : nullptr;
1043 ErrorOr<Module *> Result =
1044 NaClParseBitcodeFile(BufferOrErr.get().release(), Verbose,
1045 Context);
1046 if (Result) {
1047 DumpSymbolNamesFromModule(Result.get());
1048 delete Result;
1049 } else {
1050 error(VerboseStrm.str() + Result.message()), Filename);
1051 return;
1052 }
1053 }
1054 */
1055 // @LOCALMOD-END
1056
1011 ErrorOr<std::unique_ptr<Binary>> BinaryOrErr = createBinary( 1057 ErrorOr<std::unique_ptr<Binary>> BinaryOrErr = createBinary(
1012 BufferOrErr.get()->getMemBufferRef(), NoLLVMBitcode ? nullptr : &Context); 1058 BufferOrErr.get()->getMemBufferRef(), NoLLVMBitcode ? nullptr : &Context);
1013 if (error(BinaryOrErr.getError(), Filename)) 1059 if (error(BinaryOrErr.getError(), Filename))
1014 return; 1060 return;
1015 Binary &Bin = *BinaryOrErr.get(); 1061 Binary &Bin = *BinaryOrErr.get();
1016 1062
1017 if (Archive *A = dyn_cast<Archive>(&Bin)) { 1063 if (Archive *A = dyn_cast<Archive>(&Bin)) {
1018 if (ArchiveMap) { 1064 if (ArchiveMap) {
1019 Archive::symbol_iterator I = A->symbol_begin(); 1065 Archive::symbol_iterator I = A->symbol_begin();
1020 Archive::symbol_iterator E = A->symbol_end(); 1066 Archive::symbol_iterator E = A->symbol_end();
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 "for the -s option"); 1331 "for the -s option");
1286 1332
1287 std::for_each(InputFilenames.begin(), InputFilenames.end(), 1333 std::for_each(InputFilenames.begin(), InputFilenames.end(),
1288 dumpSymbolNamesFromFile); 1334 dumpSymbolNamesFromFile);
1289 1335
1290 if (HadError) 1336 if (HadError)
1291 return 1; 1337 return 1;
1292 1338
1293 return 0; 1339 return 0;
1294 } 1340 }
OLDNEW
« no previous file with comments | « tools/llvm-nm/Makefile ('k') | tools/lto/Makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698