Backport upstream commits 1f0fab7ff86, aa19bc1d259, acc117b57f7,
aff250145af, and 3644f41dc80. These commits reduce the size of the
generated gdb-index file, and also ensure that the gdb-index and
dwarf-5 index are generated consistently even as the number of worker
threads that GDB uses changes (RHBZ 2232086).
The first and third of these patches are refactoring, but are required
by the other patches in this series.
The second patch fixes a bug that causes the gdb-index files to
be (sometimes) bigger than needed.
The fourth and fifth patches ensure that the gdb-index and dwarf-5
index (respectively) are generated the same (for the same input
binary), regardless of how many worker threads that GDB uses.