- Notifications
You must be signed in to change notification settings - Fork 15.1k
[lld] Warn for missing needed sections by --gdb-index #166626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
| @llvm/pr-subscribers-lld @llvm/pr-subscribers-lld-elf Author: None (aury6623) ChangesIssue a warning when lld is passed Full diff: https://github.com/llvm/llvm-project/pull/166626.diff 1 Files Affected:
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index a4150ebfa1653..77487de805960 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -3566,6 +3566,16 @@ std::unique_ptr<GdbIndexSection> GdbIndexSection::create(Ctx &ctx) { DWARFContext dwarf(std::make_unique<LLDDwarfObj<ELFT>>(file)); auto &dobj = static_cast<const LLDDwarfObj<ELFT> &>(dwarf.getDWARFObj()); + if (dobj.getGnuPubnamesSection().sec == nullptr && + dobj.getGnuPubtypesSection().sec == nullptr) { + Warn(ctx) + << files[i] + << ": file contains debug info but is missing .debug_gnu_pubnames or " + ".debug_gnu_pubtypes sections required by --gdb-index. Compile " + "the file using -gsplit-dwarf or -ggnu-pubnames to generate these " + "sections."; + } + // If the are multiple compile units .debug_info (very rare ld -r --unique), // this only picks the last one. Other address ranges are lost. chunks[i].sec = dobj.getInfoSection(); |
| This edit is a solution for Issue #156732 I posted a few months ago. Having this warning would have saved me a day or two of debugging! In particular, when only some files are compiled with Now knowing what the issue is, I found this forum post where someone is running into a similar issue: which suggests that other people may find this warning to be helpful too. This is my first time contributing to llvm-project. I know adding new tests for a change is normally expected, but I'm not sure what test changes (if any) are expected for only an addition of a warning message, or where that test should be added. Please advise. Thanks! |
lenary left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please can you add a test?
Sure, happy to! This is my first contribution to llvm-project, so I'm not quite familiar with the testing infrastructure. I've read this page: If you could let me know where a test for an edit like this should go, that would be helpful! Thanks! |
| Yeah, that guide is good at the higher level, but I can see why you need more guidance :) I think what we'd want is an assembly + linker test. This would consist of 1 (maybe 2) assembly files, which are assembled with The core assertion behind the test would be to invoke LLD, and then run It's fine to take a simple C example, and compile it on your own using |
Issue a warning when lld is passed
--gdb-indexand some object files have general debug info but not the specific debug sections generated by-ggnu-pubnamesor-gsplit-dwarf. Missing those sections on all inputs leads to an empty index, which gdb ignores. Missing those sections on only some sources leads to a partially complete index, which confuses gdb.Addresses #156732 and #34168