[llvm-branch-commits] [lld] r367986 - Merging r367836:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Aug 6 00:47:52 PDT 2019


Author: hans
Date: Tue Aug  6 00:47:52 2019
New Revision: 367986

URL: http://llvm.org/viewvc/llvm-project?rev=367986&view=rev
Log:
Merging r367836:
------------------------------------------------------------------------
r367836 | mstorsjo | 2019-08-05 13:57:00 +0200 (Mon, 05 Aug 2019) | 17 lines

[COFF] Omit automatically imported symbols from the symbol table

These symbols actually point to the symbol's IAT entry, which
obviously is different from the symbol itself (which is imported
from a different module and doesn't exist in the current one).

Omitting this symbol helps gdb inspect automatically imported
symbols, see https://sourceware.org/bugzilla/show_bug.cgi?id=24574
for discussion on the matter.

Surprisingly, those extra symbols don't seem to be an issue for
gdb when the sources have been built with clang, only with gcc.
The actual logic in gdb that this depends on still is unknown, but
omitting these symbols from the symbol table is the right thing to
do in any case.

Differential Revision: https://reviews.llvm.org/D65727
------------------------------------------------------------------------

Modified:
    lld/branches/release_90/   (props changed)
    lld/branches/release_90/COFF/Writer.cpp
    lld/branches/release_90/test/COFF/autoimport-gnu-implib.s
    lld/branches/release_90/test/COFF/autoimport-x86.s

Propchange: lld/branches/release_90/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug  6 00:47:52 2019
@@ -1 +1 @@
-/lld/trunk:366445,366500,366504,366780,366784
+/lld/trunk:366445,366500,366504,366780,366784,367836

Modified: lld/branches/release_90/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_90/COFF/Writer.cpp?rev=367986&r1=367985&r2=367986&view=diff
==============================================================================
--- lld/branches/release_90/COFF/Writer.cpp (original)
+++ lld/branches/release_90/COFF/Writer.cpp Tue Aug  6 00:47:52 2019
@@ -1095,6 +1095,13 @@ Optional<coff_symbol16> Writer::createSy
   }
   }
 
+  // Symbols that are runtime pseudo relocations don't point to the actual
+  // symbol data itself (as they are imported), but points to the IAT entry
+  // instead. Avoid emitting them to the symbol table, as they can confuse
+  // debuggers.
+  if (def->isRuntimePseudoReloc)
+    return None;
+
   StringRef name = def->getName();
   if (name.size() > COFF::NameSize) {
     sym.Name.Offset.Zeroes = 0;

Modified: lld/branches/release_90/test/COFF/autoimport-gnu-implib.s
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_90/test/COFF/autoimport-gnu-implib.s?rev=367986&r1=367985&r2=367986&view=diff
==============================================================================
--- lld/branches/release_90/test/COFF/autoimport-gnu-implib.s (original)
+++ lld/branches/release_90/test/COFF/autoimport-gnu-implib.s Tue Aug  6 00:47:52 2019
@@ -7,9 +7,10 @@
 # RUN: llvm-ar rcs %t-implib.a %t-dabcdh.o %t-dabcds00000.o %t-dabcdt.o
 
 # RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.obj
-# RUN: lld-link -lldmingw -out:%t.exe -entry:main %t.obj %t-implib.a -verbose
+# RUN: lld-link -lldmingw -debug:symtab -out:%t.exe -entry:main %t.obj %t-implib.a -verbose
 
 # RUN: llvm-readobj --coff-imports %t.exe | FileCheck -check-prefix=IMPORTS %s
+# RUN: llvm-nm %t.exe | FileCheck -check-prefix=SYMBOLS %s
 
 # IMPORTS: Import {
 # IMPORTS-NEXT: Name: foo.dll
@@ -18,6 +19,10 @@
 # IMPORTS-NEXT: Symbol: data (0)
 # IMPORTS-NEXT: }
 
+# Check that the automatically imported symbol "data" is not listed in
+# the symbol table.
+# SYMBOLS-NOT: {{ }}data
+
     .global main
     .text
 main:

Modified: lld/branches/release_90/test/COFF/autoimport-x86.s
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_90/test/COFF/autoimport-x86.s?rev=367986&r1=367985&r2=367986&view=diff
==============================================================================
--- lld/branches/release_90/test/COFF/autoimport-x86.s (original)
+++ lld/branches/release_90/test/COFF/autoimport-x86.s Tue Aug  6 00:47:52 2019
@@ -5,11 +5,12 @@
 # RUN: lld-link -out:%t-lib.dll -dll -entry:DllMainCRTStartup %t-lib.obj -lldmingw -implib:%t-lib.lib
 
 # RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.obj
-# RUN: lld-link -lldmingw -out:%t.exe -entry:main %t.obj %t-lib.lib -verbose
+# RUN: lld-link -lldmingw -debug:symtab -out:%t.exe -entry:main %t.obj %t-lib.lib -verbose
 
 # RUN: llvm-readobj --coff-imports %t.exe | FileCheck -check-prefix=IMPORTS %s
 # RUN: llvm-objdump -d %t.exe | FileCheck -check-prefix=DISASM %s
 # RUN: llvm-objdump -s %t.exe | FileCheck -check-prefix=CONTENTS %s
+# RUN: llvm-nm %t.exe | FileCheck -check-prefix=SYMBOLS %s
 
 # IMPORTS: Import {
 # IMPORTS-NEXT: Name: autoimport-x86.s.tmp-lib.dll
@@ -20,7 +21,7 @@
 
 # DISASM: Disassembly of section .text:
 # DISASM-EMPTY:
-# DISASM: .text:
+# DISASM: main:
 # Relative offset at 0x1002 pointing at the IAT at 0x2080.
 # DISASM: 140001000:      8b 05 7a 10 00 00       movl    4218(%rip), %eax
 # DISASM: 140001006:      c3      retq
@@ -41,6 +42,10 @@
 # CONTENTS:  140003000 80200040 01000000 00200040 01000000
 # CONTENTS:  140003010 24200040 01000000
 
+# Check that the automatically imported symbol "variable" is not listed in
+# the symbol table.
+# SYMBOLS-NOT: variable
+
     .global main
     .text
 main:




More information about the llvm-branch-commits mailing list