Skip to content

Commit 027279a

Browse files
committed
[lld] Warn when missing needed sections for --gdb-index
1 parent 0469ff0 commit 027279a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lld/ELF/SyntheticSections.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,6 +3566,16 @@ std::unique_ptr<GdbIndexSection> GdbIndexSection::create(Ctx &ctx) {
35663566
DWARFContext dwarf(std::make_unique<LLDDwarfObj<ELFT>>(file));
35673567
auto &dobj = static_cast<const LLDDwarfObj<ELFT> &>(dwarf.getDWARFObj());
35683568

3569+
if (dobj.getGnuPubnamesSection().sec == nullptr &&
3570+
dobj.getGnuPubtypesSection().sec == nullptr) {
3571+
Warn(ctx)
3572+
<< files[i]
3573+
<< ": file contains debug info but is missing .debug_gnu_pubnames or "
3574+
".debug_gnu_pubtypes sections required by --gdb-index. Compile "
3575+
"the file using -gsplit-dwarf or -ggnu-pubnames to generate these "
3576+
"sections.";
3577+
}
3578+
35693579
// If the are multiple compile units .debug_info (very rare ld -r --unique),
35703580
// this only picks the last one. Other address ranges are lost.
35713581
chunks[i].sec = dobj.getInfoSection();

0 commit comments

Comments
 (0)