[Bug target/101448] Use GCC 9.3.0 to build Ceph crimson-osd on Arm64, linker failed for relocation truncated to fit: R_AARCH64_CALL26 against symbol
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101448 Richard Earnshaw changed: What|Removed |Added Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #8 from Richard Earnshaw --- Closing as this is not a compiler bug. If there's a problem anywhere it is that the linker needs to implement mitigation strategies for very large code bases, but even that is an enhancement rather than a strict bug.
[Bug target/101448] Use GCC 9.3.0 to build Ceph crimson-osd on Arm64, linker failed for relocation truncated to fit: R_AARCH64_CALL26 against symbol
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101448 --- Comment #7 from Kevin Zhao --- Hi Richard, Thanks for your clarification. Really appreciated! I think that should be the root cause.
[Bug target/101448] Use GCC 9.3.0 to build Ceph crimson-osd on Arm64, linker failed for relocation truncated to fit: R_AARCH64_CALL26 against symbol
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101448 --- Comment #6 from Richard Earnshaw --- (In reply to Kevin Zhao from comment #5) > Hi Richard, > > Thanks for your info. > Previously it is built without any -O parameters, so it should be -O0 by > default. > > I've tried to use the "-Og" to link, it is quite interesting that use -Og we > can link success > > Also, use -O1, -O2 and -Os, Linking works quite well. -O0 generates *very* poor (and large) code. I wouldn't recommend using at all except for basic syntax checking of your application. -Og is pretty minimal optimization and should still be suitable for debugging an application if needed. So I think this is simply a case of you exceeded the limits of the system.
[Bug target/101448] Use GCC 9.3.0 to build Ceph crimson-osd on Arm64, linker failed for relocation truncated to fit: R_AARCH64_CALL26 against symbol
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101448 --- Comment #5 from Kevin Zhao --- Hi Richard, Thanks for your info. Previously it is built without any -O parameters, so it should be -O0 by default. I've tried to use the "-Og" to link, it is quite interesting that use -Og we can link success Also, use -O1, -O2 and -Os, Linking works quite well.
[Bug target/101448] Use GCC 9.3.0 to build Ceph crimson-osd on Arm64, linker failed for relocation truncated to fit: R_AARCH64_CALL26 against symbol
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101448 --- Comment #4 from Xinliang --- 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
[Bug target/101448] Use GCC 9.3.0 to build Ceph crimson-osd on Arm64, linker failed for relocation truncated to fit: R_AARCH64_CALL26 against symbol
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101448 --- Comment #3 from Richard Earnshaw --- What optimization level are you building with? The R_AARCH64_CALL26 relocation has a branch range of +/-2^27 bytes, or 128MBytes, so that puts a limit on the size of the code segment of a binary. If you're not building with optimization turned on code can bloat very quickly. You could try just -Og if you want minimal optimization or -Os if you really want to reduce code size as much as possible.
[Bug target/101448] Use GCC 9.3.0 to build Ceph crimson-osd on Arm64, linker failed for relocation truncated to fit: R_AARCH64_CALL26 against symbol
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101448 --- Comment #2 from Kevin Zhao --- Hi Richard, Thanks for your comments. Since we have built this with some of the .so file with -fPIC, and -mcmodel=large is incompatible with -fPIC, so rebuild with -mcmodel is hard to achieve.