[COFF] Add an LLD specific option -debug:symbtab

With this set, we retain the symbol table, but skip the actual debug
information.

This is meant to be used by the MinGW frontend.

Differential Revision: https://reviews.llvm.org/D48745

llvm-svn: 335946
This commit is contained in:
Martin Storsjo 2018-06-29 06:08:25 +00:00
parent 8bf793fb35
commit 3a7905b2aa
6 changed files with 19 additions and 1 deletions

View File

@ -98,6 +98,7 @@ struct Configuration {
bool Debug = false;
bool DebugDwarf = false;
bool DebugGHashes = false;
bool DebugSymtab = false;
bool ShowTiming = false;
unsigned DebugTypes = static_cast<unsigned>(DebugType::None);
std::vector<std::string> NatvisFiles;

View File

@ -1217,6 +1217,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
!Config->DLL && Args.hasFlag(OPT_tsaware, OPT_tsaware_no, true);
Config->DebugDwarf = Args.hasArg(OPT_debug_dwarf);
Config->DebugGHashes = Args.hasArg(OPT_debug_ghash);
Config->DebugSymtab = Args.hasArg(OPT_debug_symtab);
Config->MapFile = getMapFile(Args);

View File

@ -139,6 +139,7 @@ def help_q : Flag<["/?", "-?"], "">, Alias<help>;
// LLD extensions
def debug_ghash : F<"debug:ghash">;
def debug_dwarf : F<"debug:dwarf">;
def debug_symtab : F<"debug:symtab">;
def export_all_symbols : F<"export-all-symbols">;
def kill_at : F<"kill-at">;
def lldmingw : F<"lldmingw">;

View File

@ -665,7 +665,7 @@ void Writer::createSymbolAndStringTable() {
Sec->setStringTableOff(addEntryToStringTable(Sec->Name));
}
if (Config->DebugDwarf) {
if (Config->DebugDwarf || Config->DebugSymtab) {
for (ObjFile *File : ObjFile::Instances) {
for (Symbol *B : File->getSymbols()) {
auto *D = dyn_cast_or_null<Defined>(B);

View File

@ -1,6 +1,12 @@
# RUN: yaml2obj < %s > %t.obj
# RUN: lld-link /debug /out:%t.exe /entry:main %t.obj
# RUN: llvm-readobj -sections %t.exe | FileCheck %s
# RUN: lld-link /debug:dwarf /out:%t.exe /entry:main %t.obj
# RUN: llvm-readobj -sections %t.exe | FileCheck %s
# RUN: lld-link /out:%t.exe /entry:main %t.obj
# RUN: llvm-readobj -sections %t.exe | FileCheck -check-prefix=NODEBUG %s
# RUN: lld-link /debug:symtab /out:%t.exe /entry:main %t.obj
# RUN: llvm-readobj -sections %t.exe | FileCheck -check-prefix=NODEBUG %s
# CHECK: Name: .text
# CHECK: Name: .debug_abbrev
@ -10,6 +16,13 @@
# CHECK: Name: .debug_pubtypes
# CHECK: Name: .reloc
# NODEBUG: Name: .text
# NODEBUG-NOT: Name: .debug_abbrev
# NODEBUG-NOT: Name: .debug_info
# NODEBUG-NOT: Name: .debug_line
# NODEBUG-NOT: Name: .debug_pubnames
# NODEBUG-NOT: Name: .debug_pubtypes
# NODEBUG: Name: .reloc
--- !COFF
header:

View File

@ -3,6 +3,8 @@
# RUN: llvm-readobj -symbols %t.exe | FileCheck %s
# RUN: lld-link /debug:dwarf /opt:noref /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib
# RUN: llvm-readobj -symbols %t.exe | FileCheck %s
# RUN: lld-link /debug:symtab /opt:noref /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib
# RUN: llvm-readobj -symbols %t.exe | FileCheck %s
# RUN: lld-link /debug /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib
# RUN: llvm-readobj -symbols %t.exe | FileCheck -check-prefix=NO %s