This is https://bugs.llvm.org/show_bug.cgi?id=37151,
GNU objdump spec says that "Normally the disassembly output will skip blocks of zeroes.",
but currently, llvm-objdump prints them.
The patch implements the -z/--disassemble-zeroes option and switches the default to always
skip blocks of zeroes.
GNU objdump has a bit more complex heuristic for this option. For example, it tries to
skip the last zero bytes in a section if the amount of them > 3:
https://github.com/CyberGrandChallenge/binutils/blob/master/binutils/objdump.c#L1489
so it tries to avoid disassembling zeroes inserted by section alignment.
I think it is too brittle and probably not very useful. Modern linkers like LLD insert/align sections with
trap instructions and not zeroes. Hence I tried to implement simple and clear rules in this patch
(see my comments in the code).
Output of llvm-objdump without -z option for at least this test case looks strange:
We skip the first nop at 20014 offset, but show nop at 20018 twice. I apply the patch at r350033.