Now target specific code inherits writer classes from ExecutableWriter and DynamicLibraryWriter. It is OK unitil we need to add some target specific functionality which is common to both executable and dynamic library writers. We have to either duplicate such code or move it to utility routine.
The patch tries to solve this problem using some sort of template trick. Both ExecutableWriter and DynamicLibraryWriter classes get one more template argument BaseWriter and use it as a base class. By default this argument has OutputELFWriter<ELFT> so we get the same code as now. If we need to share some code amont executable and dynamic library writers we create new class (for example MipsOutputWriter) inherited from OutputWriter and put common code to this class. Then we create writer as in example below:
template <class ELFT> class MipsExecutableWriter : public ExecutableWriter<ELFT, MipsOutputWriter<ELFT>> { ... }; template <class ELFT> using MipsDynamicLibraryWriter = DynamicLibraryWriter<ELFT, MipsOutputWriter<ELFT>>;
The patch makes some part of code more complicated but reduces code size and prevent code duplication.
Any objections and / or comments?