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: Sat, 01 Jan 2022 07:23:12 +0000	[thread overview]
Message-ID: <bug-99783-4-Nn6lvtpt0M@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 #9 from shorne at gmail dot com ---
I was able to debug this.

Basically, the code to avoid overflow by masking the relocation value with
0xffff fails if the relocation value has the 16-bit sign bit set. I.e. 0x90e4
has 0x8000 set when we see the overflow message.

It seems the number of GOT relocations in libgeos as gone beyond this limit and
triggered this bug.

This is an oversite and needs a further patch to OpenRISC binutils.  I will
think about how to patch it and post a patch in a few days


DEBUG:

x   1184          status = bfd_check_overflow (howto->complain_on_overflow,
x   1185                                       howto->bitsize,
x   1186                                       howto->rightshift,
x   1187                                       bfd_arch_bits_per_address
(input_bfd),
x   1188                                       value);
x   1189          value >>= howto->rightshift;
x   1190
x   1191          /* If we're overwriting the entire destination,
x   1192             then no need to read the current contents.  */
x  >1193          if (size == 0 || howto->dst_mask == N_ONES (size))
x   1194            x = 0;
x   1195          else
x   1196            {
x   1197              BFD_ASSERT (size == 4);
x   1198              x = bfd_get_32 (input_bfd, contents + offset);
x   1199            }
x   1200
x   1201          switch (howto->type)
x   1202            {
x   1203            case R_OR1K_SLO16:
x   1204            case R_OR1K_GOTOFF_SLO16:
x   1205            case R_OR1K_TLS_LE_SLO16:

native process 3648008 In: or1k_final_link_relocate                 L1193 PC:
0x43afb3
(gdb) n
or1k_final_link_relocate (howto=howto@entry=0x50fff0
<or1k_elf_howto_table+560>, input_bfd=input_bfd@entry=0x57ac90,
input_section=input_section@entry=0x593fb8,
    contents=contents@entry=0xb3e17b0 "\234!\377\374\030`", offset=68,
value=37092) at elf32-or1k.c:1189
(gdb) p status
$3 = bfd_reloc_overflow
(gdb) p/x value
$4 = 0x90e4

On Fri, Dec 31, 2021 at 11:26:06AM +0000, giulio.benetti at benettiengineering
dot com wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99783

  parent reply	other threads:[~2022-01-01  7:23 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
2021-12-31 11:26 ` giulio.benetti at benettiengineering dot com
2022-01-01  7:23 ` shorne at gmail dot com [this message]
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-Nn6lvtpt0M@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).