This patch prepares llvm-objcopy to move its implementation
into a separate library. To make it possible it is necessary
to minimize internal dependencies. Current CopyConfig has the following
drawbacks:
- Current CopyConfig has parsed and unparsed options at the same time. Thus, parsing functionality is located in different places. Instead, It would be good to parse options once and then have parsed options inside CopyConfig. This patch does all parsing job in the parse*() routines.
- Current implementation has an attempt to hide format-specific options. This patch makes it in a more general way: separate format-specific options using subclasses and allow to create the format-specific views at all options.
So, this patch creates some interfaces representing common and format-specific options:
CopyConfigBase CopyConfigELF CopyConfigCOFF CopyConfigMachO CopyConfigWasm
And a class that allows to switch the view on the full options set:
MultiFormatCopyConfig.
I'd be inclined to call these something like Config and ElfCfg (or even ElfConfig if you don't mind the hiding of the class type within this function). This reduces the changes needed here at least. Thinking about it, even if you want to name CommonConfig something reflecting the Common aspect, I'd call the variable CommonCfg not simply Common, and Elf similarly becomes ElfCfg. The reason is that Elf normally implies some sort of Elf object, not a config class. Renaming Common also helps describe its purpose more clearly.