The code to insert patch section merges them with a comparison function that uses logic of the form:
return (isa<PatchSection>(a) && !isa<PatchSection>(b));
The PatchSections don't implement classof so this check fails if a is a PatchSection and b (is not a PatchSection, but is a SyntheticSection). This can result in relocations in the patches being out of range if the SyntheticSection is big, for example a ThunkSection with lots of thunks.
fixes part of pr44071 https://bugs.llvm.org/show_bug.cgi?id=44071 . Namely the relocation out of range errors. The convergence failures in pr44071 are a separate problem that will be addressed in a follow up patch.
The test case is a simulation of the Chromium build reported in pr44071 . It will fail with relocation out of range errors without classof implemented. It isn't easy to replicate the out of range errors, it needs large thunk sections and a large number of patches. These won't be seen in the vast majority of AArch64 programs. The Chromium build in pr44071 is fully instrumented.
I've not got a real world example of the Arm Cortex-A8 patch failing, but it has the same code sequence so I've implemented the classof function. It is possible to write a test case, but it is difficult to find the right conditions to actually make it fail, I've erred on submitting the fix without one to unblock the Chromium team running into the problem.
Probably return SyntheticSection::classof(d) && d->name == ".text.patch";
See EhFrameSection::classof.