llvm-dwp needs to remap string offsets from input .dwo or .dwp files and therefore needs to be made aware of DWARF v5 string offsets tables now that llvm generates them. Unlike the pre-v5 GNU-style string offsets tables, DWARF v5 string offsets tables have a header describing length, format and version of the table. This patch preserves the header and performs some simple validation when it rewrites the string offsets table contributions.
It also makes llvm-dwp handle v5 compile unit headers.
One thing to note is that the current implementation recreates the string offsets table in one single loop over the entire string offsets section. Since we want to support a mixture of v5 and pre-v5 CUs, we can't parse the section without knowing where the pre-v5 units' contributions are. This is a similar problem as in llvm-dwarfdump, so we go unit by unit in re-writing the table.
Worth having repro steps here? (original source, commands used to produce it, including describing the manual steps used to reorder sections)
Should this comment explain why the string offset contributions are reordered? Might help - though probably want to explain it in the test file too.
Also perhaps it'd be easier if the string_offsets.test file were split (there aren't that many "BOTH" lines - might be easier to read as two separate tests rather than trying to have pieces in common?) & then this mixed_dwp.s could be its own test with the RUN/CHECK lines written in the file directly, rather than split over two files?