abg-writer.cc: fix write_elf_symbol_reference loop
The function write_elf_symbol_reference iterates through aliases,
looking for an unsuppressed alias to use. The existing code went wrong
in the case when aliases are present. In the case of all symbols
suppressed, it would also have selected the last alias, rather than
the first, if the data structure invariants had matched the code's
The main symbol is always distinguished. When aliases are absent, the
sole symbol's next pointer is null, but when aliases are present, they
form a circular list. This makes traversal of aliases a bit tricky.
The code now picks the first symbol from the following:
- the given symbol, if unsuppressed
- the main symbol, if unsuppressed
- the unsuppressed aliases in the remainder of the alias chain
- the main symbol (suppressed)
The given symbol, which need not be the same as the main symbol, will
be tested twice, if suppressed, but addressing this would make the
code even more elaborate and fragile.
The last case may be unreachable if symbol suppression triggers when
all aliases are suppressed.
* src/abg-writer.cc (write_elf_symbol_reference): Check main
symbol and aliases with more care.
Fixes: f0fdfcbadc76 ("dwarf-reader/writer: consider aliases when dealing with suppressions")
Signed-off-by: Giuliano Procida <firstname.lastname@example.org>
Signed-off-by: Matthias Maennich <email@example.com>
1 file changed