https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101448
--- Comment #4 from Xinliang <xinliang.liu at linaro dot org> --- Looking into the relocation code[1] of ld. I'm very curious why ld can't handle long call here. [1]: ``` 2976 static enum elf_aarch64_stub_type 2977 aarch64_type_of_stub (asection *input_sec, 2978 const Elf_Internal_Rela *rel, 2979 asection *sym_sec, 2980 unsigned char st_type, 2981 bfd_vma destination) 2982 { 2983 bfd_vma location; 2984 bfd_signed_vma branch_offset; 2985 unsigned int r_type; 2986 enum elf_aarch64_stub_type stub_type = aarch64_stub_none; 2987 2988 if (st_type != STT_FUNC 2989 && (sym_sec == input_sec)) 2990 return stub_type; 2991 2992 /* Determine where the call point is. */ 2993 location = (input_sec->output_offset 2994 + input_sec->output_section->vma + rel->r_offset); 2995 2996 branch_offset = (bfd_signed_vma) (destination - location); 2997 2998 r_type = ELFNN_R_TYPE (rel->r_info); 2999 3000 /* We don't want to redirect any old unconditional jump in this way, 3001 only one which is being used for a sibcall, where it is 3002 acceptable for the IP0 and IP1 registers to be clobbered. */ 3003 if ((r_type == AARCH64_R (CALL26) || r_type == AARCH64_R (JUMP26)) 3004 && (branch_offset > AARCH64_MAX_FWD_BRANCH_OFFSET 3005 || branch_offset < AARCH64_MAX_BWD_BRANCH_OFFSET)) 3006 { 3007 stub_type = aarch64_stub_long_branch; 3008 } 3009 3010 return stub_type; 3011 } ``` https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/elfnn-aarch64.c;h=097a275990f1d350be8f68943093926a5c66157a;hb=07f9ddfeba5b572451471f905473f7ddbba1d472#l2316 FYI, there is a similar bug with the same error msg: https://sourceware.org/bugzilla/show_bug.cgi?id=18668