Note: this patch is large and not intended for submission as-is. Instead, this patch presents a poor implementation that makes llvm-objdump GNU compatibile for this option (with all existing tests passing, but few added tests, hacky code, etc.), and will serve as context for smaller changes to be submitted separately with more careful review.
llvm-objdump -h was implemented to be similar to readelf -S (see rL141579). However, it is not completely compatible with that, and anyone that does want headers displayed that way can use llvm-readelf -S now that it exists. Make llvm-objdump compatible with GNU objdump instead.
A brief overview of changes:
- Add file offset (with implementations for all filetypes supported by llvm-readobj).
- Add 2**n section alignment column (with implementations for all filetypes supported by llvm-readobj).
- Section numbers are not the actual section numbers, but something different, corresponding to libbfd section numbers. llvm-readelf -s prints the actual section numbers if those are desired.
- Filter out certain sections like symtabs/strtabs/relocs. The actual logic is a lot more convoluted (and probably isn't fully compatibile, but is pretty close).