Skip to content

Commit 23e6e88

Browse files
authored
[LLD] [COFF] Rewrite the config flags for dwarf debug info or symtab. NFC. (#75172)
This shouldn't have any user visible effect, but makes the logic within the linker implementation more explicit. Note how DWARF debug info sections were retained even if enabling a link with PDB info only; that behaviour is preserved.
1 parent f11bda7 commit 23e6e88

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

lld/COFF/Config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ struct Configuration {
130130
bool forceMultipleRes = false;
131131
bool forceUnresolved = false;
132132
bool debug = false;
133-
bool debugDwarf = false;
133+
bool includeDwarfChunks = false;
134134
bool debugGHashes = false;
135-
bool debugSymtab = false;
135+
bool writeSymtab = false;
136136
bool driver = false;
137137
bool driverUponly = false;
138138
bool driverWdm = false;

lld/COFF/Driver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,6 +1653,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
16531653
debug == DebugKind::GHash || debug == DebugKind::NoGHash) {
16541654
config->debug = true;
16551655
config->incremental = true;
1656+
config->includeDwarfChunks = true;
16561657
}
16571658

16581659
// Handle /demangle
@@ -2029,9 +2030,8 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
20292030
parseSwaprun(arg->getValue());
20302031
config->terminalServerAware =
20312032
!config->dll && args.hasFlag(OPT_tsaware, OPT_tsaware_no, true);
2032-
config->debugDwarf = debug == DebugKind::Dwarf;
20332033
config->debugGHashes = debug == DebugKind::GHash || debug == DebugKind::Full;
2034-
config->debugSymtab = debug == DebugKind::Symtab;
2034+
config->writeSymtab = debug == DebugKind::Dwarf || debug == DebugKind::Symtab;
20352035
config->autoImport =
20362036
args.hasFlag(OPT_auto_import, OPT_auto_import_no, config->mingw);
20372037
config->pseudoRelocs = args.hasFlag(
@@ -2050,7 +2050,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
20502050

20512051
// Don't warn about long section names, such as .debug_info, for mingw or
20522052
// when -debug:dwarf is requested.
2053-
if (config->mingw || config->debugDwarf)
2053+
if (config->mingw || debug == DebugKind::Dwarf)
20542054
config->warnLongSectionNames = false;
20552055

20562056
if (config->incremental && args.hasArg(OPT_profile)) {

lld/COFF/InputFiles.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ SectionChunk *ObjFile::readSection(uint32_t sectionNumber,
236236
// CodeView needs linker support. We need to interpret debug info,
237237
// and then write it to a separate .pdb file.
238238

239-
// Ignore DWARF debug info unless /debug is given.
240-
if (!ctx.config.debug && name.starts_with(".debug_"))
239+
// Ignore DWARF debug info unless requested to be included.
240+
if (!ctx.config.includeDwarfChunks && name.starts_with(".debug_"))
241241
return nullptr;
242242

243243
if (sec->Characteristics & llvm::COFF::IMAGE_SCN_LNK_REMOVE)

lld/COFF/Writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ void Writer::createSymbolAndStringTable() {
13791379
sec->setStringTableOff(addEntryToStringTable(sec->name));
13801380
}
13811381

1382-
if (ctx.config.debugDwarf || ctx.config.debugSymtab) {
1382+
if (ctx.config.writeSymtab) {
13831383
for (ObjFile *file : ctx.objFileInstances) {
13841384
for (Symbol *b : file->getSymbols()) {
13851385
auto *d = dyn_cast_or_null<Defined>(b);

0 commit comments

Comments
 (0)