public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "shorne at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/99783] relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos
Date: Fri, 31 Dec 2021 00:14:07 +0000	[thread overview]
Message-ID: <bug-99783-4-ubxiP0GIqY@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99783-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99783

--- Comment #7 from shorne at gmail dot com ---
On Thu, Dec 30, 2021 at 09:59:57PM +0000, shorne at gmail dot com wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99783
> 
> --- Comment #6 from shorne at gmail dot com ---
> Ok, let me have a look.
> 

OK, I can reproduce, but I am not sure what is going on I will need to debug a
bit more.  This is what I have so far.

ERROR:

  I am seeing the same error you report.

   
buildroot/output/host/lib/gcc/or1k-buildroot-linux-uclibc/11.2.0/crtbeginS.o:
in function `deregister_tm_clones':
    crtstuff.c:(.text+0x44): relocation truncated to fit: R_OR1K_GOT16 against
undefined symbol `_ITM_deregisterTMCloneTable'
   
buildroot/output/host/lib/gcc/or1k-buildroot-linux-uclibc/11.2.0/crtbeginS.o:
in function `register_tm_clones':
    crtstuff.c:(.text+0xcc): relocation truncated to fit: R_OR1K_GOT16 against
undefined symbol `_ITM_registerTMCloneTable'
   
buildroot/output/host/lib/gcc/or1k-buildroot-linux-uclibc/11.2.0/crtbeginS.o:
in function `__do_global_dtors_aux':
    crtstuff.c:(.text+0x12c): relocation truncated to fit: R_OR1K_GOT16 against
symbol `__cxa_finalize' defined in .text section in
buildroot/output/host/or1k-buildroot-linux-uclibc/sysroot/lib/libc.so.1
    crtstuff.c:(.text+0x15c): relocation truncated to fit: R_OR1K_GOT16 against
symbol `__deregister_frame_info@@GLIBC_2.0' defined in .text section in
buildroot/output/host/lib/gcc/or1k-buildroot-linux-uclibc/11.2.0/../../../../or1k-buildroot-linux-uclibc/lib/libgcc_s.so
   
buildroot/output/host/lib/gcc/or1k-buildroot-linux-uclibc/11.2.0/crtbeginS.o:
in function `frame_dummy':


Actual Code patterns:

  Looking at the generated object file.
  We can see R_OR1K_GOT_AHI16 followed by R_OR1K_GOT16.  This confirms the
  cmodel=large is ON.

    or1k-elf-objdump -dr
buildroot/output/host/lib/gcc/or1k-buildroot-linux-uclibc/11.2.0/crtbeginS.o

    deregister_tm_clones:

      38:   1a 20 00 00     l.movhi r17,0x0
                            38: R_OR1K_GOT_AHI16    _ITM_deregisterTMCloneTable
      3c:   e2 31 98 00     l.add r17,r17,r19
      40:   1a 60 00 00     l.movhi r19,0x0
      44:   86 31 00 00     l.lwz r17,0(r17)
                            44: R_OR1K_GOT16        _ITM_deregisterTMCloneTable
      48:   e4 11 98 00     l.sfeq r17,r19
      4c:   10 00 00 04     l.bf 5c <deregister_tm_clones+0x5c>
      50:   85 21 00 00     l.lwz r9,0(r1)

    register_tm_clones:

      c0:   10 00 00 09     l.bf e4 <register_tm_clones+0x7c>
      c4:   1a 20 00 00     l.movhi r17,0x0
                            c4: R_OR1K_GOT_AHI16    _ITM_registerTMCloneTable
      c8:   e2 31 98 00     l.add r17,r17,r19
      cc:   86 31 00 00     l.lwz r17,0(r17)
                            cc: R_OR1K_GOT16        _ITM_registerTMCloneTable
      d0:   e4 11 a8 00     l.sfeq r17,r21

    __do_global_dtors_aux:

     150:   1a 20 00 00     l.movhi r17,0x0
                            150: R_OR1K_GOT_AHI16   __deregister_frame_info
     154:   e2 31 80 00     l.add r17,r17,r16
     158:   1a 60 00 00     l.movhi r19,0x0
     15c:   86 31 00 00     l.lwz r17,0(r17)
                            15c: R_OR1K_GOT16       __deregister_frame_info
     160:   e4 11 98 00     l.sfeq r17,r19
     164:   10 00 00 07     l.bf 180 <__do_global_dtors_aux+0x90>

IN buildroot/output/build/host-binutils-2.37/bfd/elf32-or1k.c:

   We have this bit of code which confirms we have the correct patches
   available in binutils.  This code shows we should be avoiding this
truncation
   if we have R_OR1K_GOT_AHI16 followed by R_OR1K_GOT16 which is what we have.

   Note, the comment above if (r_type == R_OR1K_GOT16 && saw_gotha) seems
   backwards.

            if (r_type == R_OR1K_GOT_AHI16)
              saw_gotha = true;

            /* If we have a R_OR1K_GOT16 followed by a R_OR1K_GOT_AHI16
               relocation we assume the code is doing the right thing to avoid
               overflows.  Here we mask the lower 16-bit of the relocation to
               avoid overflow validation failures.  */
            if (r_type == R_OR1K_GOT16 && saw_gotha)
              relocation &= 0xffff;

I will have to look at this more.

  parent reply	other threads:[~2021-12-31  0:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26  6:52 [Bug target/99783] New: " shorne at gcc dot gnu.org
2021-03-26  6:53 ` [Bug target/99783] " shorne at gcc dot gnu.org
2021-08-14 21:03 ` giulio.benetti at benettiengineering dot com
2021-08-14 22:23 ` cvs-commit at gcc dot gnu.org
2021-08-14 22:23 ` cvs-commit at gcc dot gnu.org
2021-12-30 20:34 ` giulio.benetti at benettiengineering dot com
2021-12-30 21:59 ` shorne at gmail dot com
2021-12-31  0:14 ` shorne at gmail dot com [this message]
2021-12-31 11:26 ` giulio.benetti at benettiengineering dot com
2022-01-01  7:23 ` shorne at gmail dot com
2022-01-02  0:04 ` shorne 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-99783-4-ubxiP0GIqY@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).