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, 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.
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.