Currently LLD calls the isMicroMips routine to determine type of PLT entries needs to be generated: regular or microMIPS. This routine checks ELF header flags in the FirstObj to retrieve type of linked object files. So if the first file does not contain microMIPS code, LLD will generate PLT entries with regular (non-microMIPS) code only.
Ideally, if a PLT entry is referenced by microMIPS code only this entry should contain microMIPS code, if a PLT entry is referenced by regular code this entry should contain regular code. In a "mixed" case the PLT entry can be either microMIPS or regular, but each "cross-mode-call" has additional cost.
It's rather difficult to implement this ideal solution. But we can assume that if there is an input object file with microMIPS code, the most part of the code is microMIPS too. So we need to deduce type of PLT entries based on finally calculated ELF header flags and do not check only the first input object file.
This change implements this.
- The getMipsEFlags function caches result of ELF flags calculation. Now it's cheap to call it multiple times.
- The isMicroMips and isMipsR6 routines call getMipsEFlags to get and check calculated ELF flags.
- A side effect - these functions become non-template.