Index: ELF/Relocations.cpp =================================================================== --- ELF/Relocations.cpp +++ ELF/Relocations.cpp @@ -1455,9 +1455,9 @@ // many Thunks. Create a new ThunkSection as close to the InputSection as // possible. Error if InputSection is so large we cannot place ThunkSection // anywhere in Range. - uint64_t ThunkSecOff = IS->OutSecOff; + uint64_t ThunkSecOff = IS->OutSecOff + IS->getSize(); if (!Target->inBranchRange(Type, Src, OS->Addr + ThunkSecOff)) { - ThunkSecOff = IS->OutSecOff + IS->getSize(); + ThunkSecOff = IS->OutSecOff; if (!Target->inBranchRange(Type, Src, OS->Addr + ThunkSecOff)) fatal("InputSection too large for range extension thunk " + IS->getObjMsg(Src - (OS->Addr + IS->OutSecOff)));