[PATCH] D44336: Implement --cref.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 12 13:46:59 PDT 2018
Rui Ueyama via Phabricator via llvm-commits
<llvm-commits at lists.llvm.org> writes:
> +defm cref: B<"cref",
> + "Output cross reference table",
> + "Do not output cross reference table">;
> +
Why B? Is there a --no-cref?
> +// Output a cross reference table to stdout. This is for --cref.
> +//
> +// For each global symbol, we print out a file that defines the symbol
> +// followed by files that uses that symbol. Here is an example.
> +//
> +// strlen /lib/x86_64-linux-gnu/libc.so.6
> +// tools/lld/tools/lld/CMakeFiles/lld.dir/lld.cpp.o
> +// lib/libLLVMSupport.a(PrettyStackTrace.cpp.o)
> +//
> +// In this case, strlen is defined by libc.so.6 and used by other two
> +// files.
> +void elf::writeCrossReferenceTable() {
> + if (!Config->Cref)
> + return;
> +
> + // Collect symbols and files.
> + MapVector<Symbol *, SetVector<InputFile *>> Map;
> + for (InputFile *File : ObjectFiles) {
> + for (Symbol *B : File->getSymbols()) {
I would probably avoid B since it is a strange choice now that
SymbolBody is gone.
> + if (auto *Sym = dyn_cast<SharedSymbol>(B))
This can be an isa<>, no?
> + Map[Sym].insert(File);
> + if (auto *Sym = dyn_cast<Defined>(B))
> + if (!Sym->isLocal() || (!Sym->Section || Sym->Section->Live))
> + Map[Sym].insert(File);
> + }
> + }
> +
> + auto Print = [](StringRef A, StringRef B) {
> + outs() << left_justify(A, 49) << " " << B << "\n";
> + };
This doesn't need to be a lambda.
Cheers,
Rafael
More information about the llvm-commits
mailing list