https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106270
--- Comment #1 from qinzhao at gcc dot gnu.org --- from Jose Marchesi: ==== We looked at this issue and these are our findings. - When this problem happens: When the linker (ld) fails to insert a veneer (that transforms the immediate bl jumps generated by GCC into an indirect call) in range with the original bl instruction. This issue happens because it contains .text sections bigger than ~128MiB or when the range between a bl instruction and the beginning/or/end of the containing section exceeds ~128MiB. Note that this also happens with linker-generated PLT sections when linking shared objects, much like the veneers. - Proposed solutions: We can think on two complementary solutions: a) At the moment the aarch64 linker seems to only know how to insert a veneer _after_ the section that contains the branch/call instruction. We could make the linker smarter so it knows how to insert the veneer _before_ the sect on containing the branch/call instruction. This would make things better, but obviously would not work in all cases. b) So, in any case, we propose to add a new option to GCC (aarch64 specific) that will make GCC to generate indirect branch instructions (blr) for non-PLT calls to symbols not having local binding/scope: -mlong-calls -> Make aarch64_is_long_call_p return true -> This makes GCC to generate blr instead of bl when compiling non-PIC and calls to symbol references with non-local binding. -> This will have an impact in performance, but this will _not_ impact inter-section calls nor to calls to local objects.