[PATCH] D126257: Round up zero-sized symbols to 1 byte in `.debug_aranges`.

Patrick Walton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 23 16:32:34 PDT 2022


pcwalton created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
pcwalton requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This commit modifies the AsmPrinter to avoid emitting any zero-sized symbols to
the .debug_aranges table, by rounding their size up to 1. Entries with zero
length violate the DWARF 5 spec, which states:

> Each descriptor is a triple consisting of a segment selector, the beginning
> address within that segment of a range of text or data covered by some entry
> owned by the corresponding compilation unit, followed by the non-zero length
> of that range.

In practice, these zero-sized entries produce annoying warnings in lld and
cause GNU binutils to truncate the table when parsing it.

Other parts of LLVM, such as DWARFDebugARanges in the DebugInfo module
(specifically the appendRange method), already avoid emitting zero-sized
symbols to .debug_aranges, but not comprehensively in the AsmPrinter. In fact,
the AsmPrinter does try to avoid emitting such zero-sized symbols when labels
aren't involved, but doesn't when the symbol to emitted is a difference of two
labels; this patch extends that logic to handle the case in which the symbol is
defined via labels.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126257

Files:
  llvm/include/llvm/MC/MCStreamer.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/test/CodeGen/Generic/dwarf-aranges-zero-size.ll
  llvm/test/DebugInfo/MSP430/dwarf-basics-v5.ll
  llvm/test/DebugInfo/X86/dwarf-aranges.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126257.431521.patch
Type: text/x-patch
Size: 6212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220523/4b8f5cb2/attachment.bin>


More information about the llvm-commits mailing list