View | Details | Raw Unified | Return to bug 251251
Collapse All | Expand All

(-)src/contrib/llvm-project/lld/ELF/MapFile.cpp (-6 / +14 lines)
Lines 212-219 Link Here
212
  }
212
  }
213
}
213
}
214
214
215
static void print(StringRef a, StringRef b) {
215
static void print(raw_ostream &os, StringRef a, StringRef b) {
216
  lld::outs() << left_justify(a, 49) << " " << b << "\n";
216
  os << left_justify(a, 49) << " " << b << "\n";
217
}
217
}
218
218
219
// Output a cross reference table to stdout. This is for --cref.
219
// Output a cross reference table to stdout. This is for --cref.
Lines 231-236 Link Here
231
  if (!config->cref)
231
  if (!config->cref)
232
    return;
232
    return;
233
233
234
  std::string outfile = config->mapFile.empty() ? "-" : config->mapFile;
235
  std::error_code ec;
236
  raw_fd_ostream os(outfile, ec, sys::fs::OF_Append);
237
  if (ec) {
238
    error("cannot open " + outfile + ": " + ec.message());
239
    return;
240
  }
241
234
  // Collect symbols and files.
242
  // Collect symbols and files.
235
  MapVector<Symbol *, SetVector<InputFile *>> map;
243
  MapVector<Symbol *, SetVector<InputFile *>> map;
236
  for (InputFile *file : objectFiles) {
244
  for (InputFile *file : objectFiles) {
Lines 244-261 Link Here
244
  }
252
  }
245
253
246
  // Print out a header.
254
  // Print out a header.
247
  lld::outs() << "Cross Reference Table\n\n";
255
  os << "Cross Reference Table\n\n";
248
  print("Symbol", "File");
256
  print(os, "Symbol", "File");
249
257
250
  // Print out a table.
258
  // Print out a table.
251
  for (auto kv : map) {
259
  for (auto kv : map) {
252
    Symbol *sym = kv.first;
260
    Symbol *sym = kv.first;
253
    SetVector<InputFile *> &files = kv.second;
261
    SetVector<InputFile *> &files = kv.second;
254
262
255
    print(toString(*sym), toString(sym->file));
263
    print(os, toString(*sym), toString(sym->file));
256
    for (InputFile *file : files)
264
    for (InputFile *file : files)
257
      if (file != sym->file)
265
      if (file != sym->file)
258
        print("", toString(file));
266
        print(os, "", toString(file));
259
  }
267
  }
260
}
268
}
261
269

Return to bug 251251