BinaryAnalysisPlatform / bap

Binary Analysis Platform
MIT License
2.07k stars 273 forks source link

fixes the address size computation in the llvm backend #1330

Closed ivg closed 3 years ago

ivg commented 3 years ago

The getBytesInAddress virutal member-function for ELF files is implemented incorrectly in LLVM,

template <class ELFT>
uint8_t ELFObjectFile<ELFT>::getBytesInAddress() const {
  return ELFT::Is64Bits ? 8 : 4;
}

It is actually a static file that returns 32 for ELF32 and 64 for ELF64, which has nothing to do with the actual bitness of the target architecture address.

The if is using the information obtained from the target (triple) and falls back to getBytesInAddress only if the target is not 16, 32, or 64 bit (the target interface is also strange as it doesn't allow any other values).