The reason of collecting all undefines in vector is that during reading files we already need to have Symtab created. Or like was done in that patch - to put undefines from scripts somewhere to delay Symtab.addUndefinedOpt() call.
Actually the main problem I see here is that currently ELF type is taken from first file. If we could know it earlier (I am not sure, from command line may be ?) then we would not need such solutions.