filter out zero length functions in LC_FUNCTION_STARTS --- src/ld/LinkEdit.hpp +++ src/ld/LinkEdit.hpp @@ -1332,6 +1332,9 @@ void FunctionStartsAtom::encode() const std::vector& atoms = sect->atoms; for (std::vector::iterator ait = atoms.begin(); ait != atoms.end(); ++ait) { const ld::Atom* atom = *ait; + // filter out zero-length atoms, so LC_FUNCTION_STARTS address can't spill into next section + if ( atom->size() == 0 ) + continue; uint64_t nextAddr = atom->finalAddress(); if ( atom->isThumb() ) nextAddr |= 1;