BaseTools: Library hashing fix and optimization for --hash feature