This is an archive of the discontinued LLVM Phabricator instance.

[DWARF] Adjust warning condition for .dwo sections with relocations
ClosedPublic

Authored by MaskRay on Jun 22 2023, 6:07 PM.

Details

Summary

D106624 added a .dwo warning (when there are relocations) that may fire for
non-debug sections, e.g. .rodata.dwo when there is a data symbol foo in
-fdata-sections mode. Adjust it to only warn for .debug sections.

While here, change the diagnostic to be more conventional
https://llvm.org/docs/CodingStandards.html#error-and-warning-messages and use
the relocated section name instead of the relocation section name.

This change does not handle .zdebug (support was mostly removed from LLVM) or
__debug (Mach-O, no DWO support).

Diff Detail

Event Timeline

MaskRay created this revision.Jun 22 2023, 6:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2023, 6:07 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
MaskRay requested review of this revision.Jun 22 2023, 6:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2023, 6:07 PM
HaohaiWen added inline comments.Jun 23 2023, 7:49 AM
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
1916

Does dwo file only contains dwo sections? (all dwo sections starts with .debug_). If so, we may not need to check section name.

MaskRay marked an inline comment as done.Jun 23 2023, 10:13 AM
MaskRay added inline comments.
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
1916

ELF .dwo files also contain .strtab.

What this code move tries to address is this: the control flow here doesn't exclude sections such as .text.dwo .rodata.dwo. RelSecName.startswith(".debug") is to exclude them. All of COFF, ELF, and wasm use the .debug_ prefix.

Thanks for fixing this. I didn't realize there were {.text,.rodata}.dwo sections.
Any good spec/doc I can read up on it?

MaskRay marked an inline comment as done.EditedJun 23 2023, 4:53 PM

Thanks for fixing this. I didn't realize there were {.text,.rodata}.dwo sections.
Any good spec/doc I can read up on it?

-ffunction-sections appends the function name to .text., so a function named dwo in C or C++ extern "C" mode will get this section.
.rodata.dwo / .data.dwo is similar.

The original code uses contains, which means all dwo prefixed functions/variables may have the problem.

This revision is now accepted and ready to land.Jun 24 2023, 6:05 AM
ayermolo accepted this revision.Jun 24 2023, 6:24 AM

oh I see.... thx