[PATCH] D96144: [ELF] Add --dwarf32-before-dwarf64 to sort DWARF32 input sections before DWARF64

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 5 07:31:36 PST 2021


ikudrin created this revision.
ikudrin added reviewers: MaskRay, jhenderson, grimar, ayermolo.
ikudrin added projects: lld, LLVM, debug-info.
Herald added subscribers: dang, arichardson, emaste.
ikudrin requested review of this revision.

DWARF64 debug info is suitable for cases when a particular debug section can be larger than 4GiB so that DWARF32 data cannot reference the higher parts of it. An application is usually linked against third-party libraries, and, while a user can control the debug info format of their own files, it can be difficult to enforce the 64-bit format for all inputs. Furthermore, as items of libraries are typically included in the linking after the inputs which reference them, their debug information also tends to be placed in higher positions, heightening the probability to cause the said issue.

The patch adds a switch that can be used to reorder debug info in output sections so that DWARF64 data is placed after DWARF32.

To simplify the implementation, the heuristic is used that all debug info in a single input file is stored in the same format. As the first relocation in a .debug_info section points a record in .debug_abbrev and its type depends on the format, that helps to assume the format of the file where that section belongs.

The patch is based on D91404 <https://reviews.llvm.org/D91404>, where the format was tried to be detected per section. Unfortunately, there are debug sections the used approach does not work on.

There were discussions in various mailing lists concerning the best ways to tackle the issue. There was no final decision achieved.

- https://lists.llvm.org/pipermail/llvm-dev/2020-November/146522.html
- https://sourceware.org/pipermail/binutils/2020-November/114099.html
- https://groups.google.com/g/generic-abi/c/i2Xio-47QdQ/m/RLi53QfaBwAJ

The main advantage of the proposed solution is that it is short, simple, and compatible with existing standards and tools. It does not degrade the performance of the linker for everyone who does not need it, yet resolves the issue in practice for those who come across it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96144

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96144.321757.patch
Type: text/x-patch
Size: 9457 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210205/6c795467/attachment.bin>


More information about the llvm-commits mailing list