Fix assert failure in dump_syms caused by binary linked with gold.
In dwarf_cu_to_module.cc, in AssignLinesToFunctions(), here are the
assertions at the top of the loop:
// Assert the first invariant (see above).
At the bottom of the loop, it's advancing the iterators to preserve
the loop invariants:
// Advance iterators as needed. If lines overlap or functions overlap,
// then we could go around more than once. We don't worry too much
// about what result we produce in that case, just as long as we don't
// hang or crash.
while (func_it != functions->end()
&& current >= (*func_it)->address
func_it++;
func = (func_it != functions->end()) ? *func_it : NULL;
while (line_it != lines_.end()
&& current >= line_it->address
line_it++;
line = (line_it != lines_.end()) ? &*line_it : NULL;
// We must make progress.
assert(next_transition > current);
current = next_transition;
In the loops that advance the func_it and line_it iterators, current
should be replaced by next_transition. As written, when there are
overlapping entries, it's not always advancing the iterators far
enough for the next iteration of the loop.
The difference between gnu ld and gold that's causing this is how the
two linkers apply relocations that reference discarded symbols. In gnu
ld, the addend is ignored, while gold applies the relocation with the
addend. As a result, the entries for discarded functions all appear as
zero-length functions, and they don't actually overlap.
TESTED: Ran make check inside dump_syms directory and ran on binary that was
previously failing. Both succeeded.