This change adds JSON output to llvm-readelf. It is enabled through the --elf-output-style
option which now supports JSON in addition to the existing LLVM and GNU. This patch
just lays out the needed infrastructure and skeleton code but doesn't include any
implementation.
The major change was the need for a json printer that can be instantiated at the top level
of llvm-readobj. Since llvm-readobj uses ScopedPrinter this change adds a JSONScopedPrinter
as well as a ScopedPrinterBase which both ScopedPrinter and JSONScopedPrinter both
inherit from.
Corresponding RFC: https://lists.llvm.org/pipermail/llvm-dev/2021-September/152994.html
In a similar manner to the COFF dumper earlier, it would be ideal if you could avoid the cast, and just pass a ScopedPrinterBase instance into the ELFDumper constructors. This would allow you to avoid many of the changes you've made where you pass in a ScopedPrinter now, and decouple the printer style from the actual scoped printer (in some cases, this may be all you need to get some functions to work for JSON style).