malformed .o file crashes/hangs linker --- src/ld/parsers/macho_relocatable_file.cpp +++ src/ld/parsers/macho_relocatable_file.cpp @@ -822,6 +822,8 @@ template const uint8_t* Atom::contentPointer() const { const macho_section

* sct = this->sect().machoSection(); + if ( this->_objAddress > sct->addr() + sct->size() ) + throwf("malformed .o file, symbol has address 0x%0llX which is outside range of its section", (uint64_t)this->_objAddress); uint32_t fileOffset = sct->offset() - sct->addr() + this->_objAddress; return this->sect().file().fileContent()+fileOffset; }