public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "xinliang.liu at linaro dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [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
Date: Thu, 15 Jul 2021 09:42:37 +0000	[thread overview]
Message-ID: <bug-101448-4-z73E5Zyuf9@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101448-4@http.gcc.gnu.org/bugzilla/>

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

  parent reply	other threads:[~2021-07-15  9:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-14 10:42 [Bug c++/101448] New: Use GCC 9.3.0 to build Ceph crimson-osd, linker failed for "relocation truncated to fit" " kevin.zhao at linaro dot org
2021-07-14 12:52 ` [Bug target/101448] " rguenth at gcc dot gnu.org
2021-07-14 14:41 ` [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 " kevin.zhao at linaro dot org
2021-07-14 15:25 ` rearnsha at gcc dot gnu.org
2021-07-15  9:42 ` xinliang.liu at linaro dot org [this message]
2021-07-15 11:12 ` kevin.zhao at linaro dot org
2021-07-15 17:54 ` rearnsha at gcc dot gnu.org
2021-07-16  2:44 ` kevin.zhao at linaro dot org
2021-07-16 11:02 ` rearnsha at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-101448-4-z73E5Zyuf9@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).