[PATCH] D21550: [lld] support --trace-symbol (alias -y) option

Shridhar Joshi via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 21 12:10:34 PDT 2016


joshishr marked 9 inline comments as done.
joshishr added a comment.

In http://reviews.llvm.org/D21550#463069, @ruiu wrote:

> Noticed that there's a better way to print out "definition of" messages.
>
> First, just add `traceUndefined` member function to ObjectFile and print out "reference to" messages if a given string is a member of Config->TraceSymbol.


This will not address references from shared file.

> And then define `traceSymbol` member function to SymbolTable. That function should iterate over all strings in Config->TraceSymbol. For each string, it looks up a defined symbol, and if it is defined, it prints out a "definition of" message. SymbolTable has scan* functions, and they are good examples how to do it.

> 

> In this way, I think code for --trace-symbol would be separated nicely from the main code.


This will not address symbol defined in different object files with strong and weak bindings and with different link order of those object files. It also will not address same symbol defined in archive and shared library with archive library being first in link order.


================
Comment at: ELF/SymbolTable.cpp:348-349
@@ -347,2 +347,4 @@
   int Cmp = compareDefinedNonCommon(S, WasInserted, Sym.getBinding());
+  if (Cmp >= 0)
+    cast<InputFile>(Section->getFile())->notify(Name, true);
   if (Cmp > 0)
----------------
ruiu wrote:
> Remove.
This is required to print object files names containing weak and strong definitions as below.
main.o references foo function
foo-weak.o contains weak definition of foo
foo-strong.o contains strong definition of foo 

$ld.lld --trace-symbol=foo main.o foo-weak.o foo-strong.o 
main.o: reference to foo
foo-weak.o: definition of foo
foo-strong.o: definition of foo

now if the link order of foo-weak.o and foo-strong.o is changed then:
$ld.lld --trace-symbol=foo main.o  foo-strong.o  foo-weak.o
main.o: reference to foo
foo-strong.o: definition of foo

Please note it has not print "foo-weak.o definition of foo"


http://reviews.llvm.org/D21550





More information about the llvm-commits mailing list