Fix #54456: objcopy --only-keep-debug produces a linked image with invalid
empty dynamic section. llvm-objdump -p currently reports an error which seems
excessive.
% llvm-readelf -l a.out llvm-readelf: warning: 'a.out': no valid dynamic table was found ...
Follow the spirit of llvm-readelf -l (D64472) and report a warning instead.
This allows later files to be dumped despite warnings for an input file.
This improves objdump compatibility in that the exit code is now 0 instead of 1.
% llvm-objdump -p a.out # new behavior ... Program Header: llvm-objdump: warning: 'a.out': invalid empty dynamic section % objdump -p a.out ... Dynamic Section:
Generally, I think dumper tools should avoid emitting errors for individual files, because it prevents later files from being dumped. @grimar and I both in the past made significant improvements to llvm-readobj and other tools (in my case llvm-dwarfdump at least) to achieve this. I don't think the same attention has been applied to llvm-objdump.
I've therefore suggested a rewording of the comment.