[PATCH] D91404: RFC: [ELF] Add --dwarf32-before-dwarf64 to place DWARF32 input sections before DWARF64

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 12 23:02:07 PST 2020


MaskRay created this revision.
MaskRay added reviewers: grimar, jhenderson, psmith, ruiu.
Herald added subscribers: llvm-commits, dang, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
MaskRay requested review of this revision.

See https://lists.llvm.org/pipermail/llvm-dev/2020-November/146522.html
"[LLD] Support DWARF64, debug_info "sorting""

If a `.debug_*` output section S can be larger than 32-bit and its section
offset is referenced by a DWARF32 input section of itself or another `.debug_*` output section,
S may be subject to 32-bit relocation overflow. If we place such DWARF32
sections before DWARF64 sections, we can likely mitigate overflows.

Parsing DWARF is time consuming, breaks the "smart format, dumb linker" design goal of ELF,
and can get in the way if we eagerly free uncompressed buffers after `OutputSection::writeTo`.
So we use the relocation idea proposed by Igor Kudrin
https://lists.llvm.org/pipermail/llvm-dev/2020-November/146528.html

In practice, the first relocation of .debug_* is good indicator whether it is a
DWARF64 section, to list a few:

- .debug_info: the first relocation is a .debug_abbrev offset
- .debug_names references .debug_info: the first relocation is a .debug_info offset
- .debug_aranges references .debug_info: the first relocation is a .debug_info offset
- .debug_str_offsets references .debug_str: the first relocation is a .debug_str offset
- ...

This patch adds the partition code to `finalizeInputSections` so that it works
for both orphan sections and when an output section description for `.debug_info`
is used. In some sense --dwarf32-before-dwarf64 will behave like
--sort-section: it can affect input section order of a wildcard.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91404

Files:
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/Options.td
  lld/ELF/OutputSections.cpp
  lld/test/ELF/dwarf32-before-dwarf64.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91404.305036.patch
Type: text/x-patch
Size: 8509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201113/2deddd8d/attachment.bin>


More information about the llvm-commits mailing list