public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/99783] New: relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos
@ 2021-03-26  6:52 shorne at gcc dot gnu.org
  2021-03-26  6:53 ` [Bug target/99783] " shorne at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: shorne at gcc dot gnu.org @ 2021-03-26  6:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99783
           Summary: relocation truncated to fit: R_OR1K_GOT16 on OpenRISC,
                    building libgeos
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shorne at gcc dot gnu.org
  Target Milestone: ---

I confirm, when building with libgeos as described by Giulio

'''
# git clone git://git.busybox.net/buildroot
# wget https://git.busybox.net/buildroot-test/tree/utils/br-reproduce-build

- modify BASE_GIT=... with your buildroot path in br-reproduce-build then:
# chmod a+x br-reproduce-build
# ./br-reproduce-build 3eb9f9d0f6d8274b2d19753c006bd83f7d536e3c
'''

  - This issue is an overflow in the 16-bit immediate in the l.lwz load
instruction generated for R_OR1K_GOT16 by GCC.  So the fix has to start with
GCC.  I will need to have a bit further look on how to handle this.

Some of the errors:

linux-uclibc/9.3.0/crtbeginS.o: in function `__do_global_dtors_aux':
crtstuff.c:(.text+0x118): relocation truncated to fit: R_OR1K_GOT16 against
symbol `__cxa_finalize' defined in .text section in 
/home/shorne/work/openrisc/3eb9f9d0f6d8274b2d19753c006bd83f7d536e3c/output/host/or1k-buildroot-linux-uclibc/sysroot/lib/libc.so.
1
crtstuff.c:(.text+0x140): relocation truncated to fit: R_OR1K_GOT16 against
symbol `__deregister_frame_info@@GLIBC_2.0' defined 
in .text section in
/home/shorne/work/openrisc/3eb9f9d0f6d8274b2d19753c006bd83f7d536e3c/output/host/opt/ext-toolchain/bin/../lib
/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/lib/libgcc_s.so
/home/shorne/work/openrisc/3eb9f9d0f6d8274b2d19753c006bd83f7d536e3c/output/host/opt/ext-toolchain/bin/../lib/gcc/or1k-buildroot-
linux-uclibc/9.3.0/crtbeginS.o: in function `frame_dummy':
crtstuff.c:(.text+0x1a0): relocation truncated to fit: R_OR1K_GOT16 against
symbol `__register_frame_info@@GLIBC_2.0' defined in
 .text section in
/home/shorne/work/openrisc/3eb9f9d0f6d8274b2d19753c006bd83f7d536e3c/output/host/opt/ext-toolchain/bin/../lib/g
cc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/lib/libgcc_s.so
CMakeFiles/geos.dir/src/algorithm/BoundaryNodeRule.cpp.o: in function
`geos::algorithm::BoundaryNodeRule::~BoundaryNodeRule()':
BoundaryNodeRule.cpp:(.text._ZN4geos9algorithm16BoundaryNodeRuleD2Ev[_ZN4geos9algorithm16BoundaryNodeRuleD5Ev]+0x24):
relocation
 truncated to fit: R_OR1K_GOT16 against symbol `vtable for
geos::algorithm::BoundaryNodeRule' defined in .data.rel.ro._ZTVN4geos
9algorithm16BoundaryNodeRuleE[_ZTVN4geos9algorithm16BoundaryNodeRuleE] section
in CMakeFiles/geos.dir/src/algorithm/BoundaryNode
Rule.cpp.o
CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o: in function
`geos::algorithm::CGAlgorithmsDD::orientationIndex(double, d
ouble, double, double, double, double)':
CGAlgorithmsDD.cpp:(.text+0x308): relocation truncated to fit: R_OR1K_GOT16
against symbol `geos::util::IllegalArgumentException
::~IllegalArgumentException()' defined in
.text._ZN4geos4util24IllegalArgumentExceptionD2Ev[_ZN4geos4util24IllegalArgumentExcept
ionD5Ev] section in CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o
CGAlgorithmsDD.cpp:(.text+0x310): relocation truncated to fit: R_OR1K_GOT16
against symbol `typeinfo for geos::util::IllegalArgu
mentException' defined in
.data.rel.ro._ZTIN4geos4util24IllegalArgumentExceptionE[_ZTIN4geos4util24IllegalArgumentExceptionE]
se
ction in CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o
CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o: in function
`geos::algorithm::CGAlgorithmsDD::signOfDet2x2(double, doubl
e, double, double)':
CGAlgorithmsDD.cpp:(.text+0xa34): relocation truncated to fit: R_OR1K_GOT16
against symbol `geos::util::IllegalArgumentException
::~IllegalArgumentException()' defined in
.text._ZN4geos4util24IllegalArgumentExceptionD2Ev[_ZN4geos4util24IllegalArgumentExcept
ionD5Ev] section in CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o
CGAlgorithmsDD.cpp:(.text+0xa3c): relocation truncated to fit: R_OR1K_GOT16
against symbol `typeinfo for geos::util::IllegalArgu
mentException' defined in
.data.rel.ro._ZTIN4geos4util24IllegalArgumentExceptionE[_ZTIN4geos4util24IllegalArgumentExceptionE]
se
ction in CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o
CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o: in function
`geos::util::GEOSException::GEOSException(std::__cxx11::basi
c_string<char, std::char_traits<char>, std::allocator<char> > const&,
std::__cxx11::basic_string<char, std::char_traits<char>, s
td::allocator<char> > const&)':
CGAlgorithmsDD.cpp:(.text._ZN4geos4util13GEOSExceptionC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_[_ZN4geos4util
13GEOSExceptionC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_]+0xc0):
additional relocation overflows omitted from
 the output
collect2: error: ld returned 1 exit status
make[4]: *** [CMakeFiles/geos.dir/build.make:5369: lib/libgeos.so.3.9.0] Error
1
make[3]: *** [CMakeFiles/Makefile2:359: CMakeFiles/geos.dir/all] Error 2
make[2]: *** [Makefile:172: all] Error 2
make[1]: *** [package/pkg-generic.mk:250:
/home/shorne/work/openrisc/3eb9f9d0f6d8274b2d19753c006bd83f7d536e3c/output/build/libge
os-3.9.0/.stamp_built] Error 2
make: *** [Makefile:23: _all] Error 2

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/99783] relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos
  2021-03-26  6:52 [Bug target/99783] New: relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos shorne at gcc dot gnu.org
@ 2021-03-26  6:53 ` shorne at gcc dot gnu.org
  2021-08-14 21:03 ` giulio.benetti at benettiengineering dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: shorne at gcc dot gnu.org @ 2021-03-26  6:53 UTC (permalink / raw)
  To: gcc-bugs

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

Stafford Horne <shorne at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |or1k-*-*
           Assignee|unassigned at gcc dot gnu.org      |shorne at gcc dot gnu.org
             Status|UNCONFIRMED                 |ASSIGNED
                 CC|                            |giulio.benetti@micronovasrl
                   |                            |.com, shorne at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-03-26

--- Comment #1 from Stafford Horne <shorne at gcc dot gnu.org> ---
Reported originally in binutils.

https://sourceware.org/bugzilla/show_bug.cgi?id=21464

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/99783] relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos
  2021-03-26  6:52 [Bug target/99783] New: relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos 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
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: giulio.benetti at benettiengineering dot com @ 2021-08-14 21:03 UTC (permalink / raw)
  To: gcc-bugs

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

Giulio Benetti <giulio.benetti at benettiengineering dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |giulio.benetti@benettiengin
                   |                            |eering.com

--- Comment #2 from Giulio Benetti <giulio.benetti at benettiengineering dot com> ---
This bug is fixed by this patchset and passing -mcmodel=large to CFLAGS:
https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg259303.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/99783] relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos
  2021-03-26  6:52 [Bug target/99783] New: relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos 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
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-14 22:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Stafford Horne <shorne@gcc.gnu.org>:

https://gcc.gnu.org/g:eff8110674ef193481d3657456a262beeb9951ff

commit r12-2909-geff8110674ef193481d3657456a262beeb9951ff
Author: Stafford Horne <shorne@gmail.com>
Date:   Tue Apr 6 05:47:17 2021 +0900

    or1k: Add mcmodel option to handle large GOTs

    When building libgeos we get an error with:

        linux-uclibc/9.3.0/crtbeginS.o: in function `__do_global_dtors_aux':
        crtstuff.c:(.text+0x118): relocation truncated to fit: R_OR1K_GOT16
against symbol `__cxa_finalize' defined in .text section in
       
/home/shorne/work/openrisc/3eb9f9d0f6d8274b2d19753c006bd83f7d536e3c/output/host/or1k-buildroot-linux-uclibc/sysroot/lib/libc.so.

    This is caused by GOT code having a limit of 64k.  In OpenRISC this
    looks to be the only relocation code pattern to be limited to 64k.

    This patch allows specifying a new option -mcmodel=large which can be
    used to generate 2 more instructions to construct 32-bit addresses for
    up to 4G GOTs.

    gcc/ChangeLog:

            PR target/99783
            * config/or1k/or1k-opts.h: New file.
            * config/or1k/or1k.c (or1k_legitimize_address_1, print_reloc):
            Support generating gotha relocations if -mcmodel=large is
            specified.
            * config/or1k/or1k.h (TARGET_CMODEL_SMALL, TARGET_CMODEL_LARGE):
            New macros.
            * config/or1k/or1k.opt (mcmodel=): New option.
            * doc/invoke.texi (OpenRISC Options): Document mcmodel.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/99783] relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos
  2021-03-26  6:52 [Bug target/99783] New: relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos shorne at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  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
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-14 22:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Stafford Horne <shorne@gcc.gnu.org>:

https://gcc.gnu.org/g:da8a9d695b3c4b9397b5d9a27660bfa48af8d707

commit r12-2910-gda8a9d695b3c4b9397b5d9a27660bfa48af8d707
Author: Stafford Horne <shorne@gmail.com>
Date:   Wed Apr 21 05:33:15 2021 +0900

    or1k: Use cmodel=large when building crtstuff

    When linking gcc runtime objects into large binaries the link may fail
    with the below errors.  This will happen even if we are building with
    -mcmodel=large.

       
/home/shorne/work/openrisc/output/host/lib/gcc/or1k-buildroot-linux-uclibc/10.3.0/crtbeginS.o:
in function `deregister_tm_clones':
        crtstuff.c:(.text+0x3c): relocation truncated to fit: R_OR1K_GOT16
against undefined symbol `_ITM_deregisterTMCloneTable'
       
/home/shorne/work/openrisc/output/host/lib/gcc/or1k-buildroot-linux-uclibc/10.3.0/crtbeginS.o:
in function `register_tm_clones':
        crtstuff.c:(.text+0xc0): relocation truncated to fit: R_OR1K_GOT16
against undefined symbol `_ITM_registerTMCloneTable'

    This patch builds the gcc crtstuff binaries always with the
    -mcmodel=large option to ensure they can be linked into large binaries.

    libgcc/ChangeLog:

            PR target/99783
            * config.host (or1k-*, tmake_file): Add or1k/t-crtstuff.
            * config/or1k/t-crtstuff: New file.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/99783] relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos
  2021-03-26  6:52 [Bug target/99783] New: relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos shorne at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: giulio.benetti at benettiengineering dot com @ 2021-12-30 20:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Giulio Benetti <giulio.benetti at benettiengineering dot com> ---
Dear Stafford,

here we go again, after updating libgeos to version 3.10.1 the same bug shows
up. This happens with libgeos but not with protobuf that is fixed. I'm sure
i pass -mcmodel=large.
Can you help me and fix it?

Here are the instructions to reproduce the bug:
```
1) # git clone git://git.busybox.net/buildroot
2) # cd buildroot
3) copy the content of https://pastebin.com/tgDVcv6v into
buildroot/or1k_libgeos_defconfig
4) # make libgeos
```

That way it builds the entire toolchain and it fails on building libgeos with:
```
/home/giuliobenetti/git/upstream/output-or1k-br-stable/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'
/home/giuliobenetti/git/upstream/output-or1k-br-stable/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'
/home/giuliobenetti/git/upstream/output-or1k-br-stable/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
/home/giuliobenetti/git/upstream/output-or1k-br-stable/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
/home/giuliobenetti/git/upstream/output-or1k-br-stable/host/lib/gcc/or1k-buildroot-linux-uclibc/11.2.0/../../../../or1k-buildroot-linux-uclibc/lib/libgcc_s.so
/home/giuliobenetti/git/upstream/output-or1k-br-stable/host/lib/gcc/or1k-buildroot-linux-uclibc/11.2.0/crtbeginS.o:
in function `frame_dummy':
crtstuff.c:(.text+0x1c4): relocation truncated to fit: R_OR1K_GOT16 against
symbol `__register_frame_info@@GLIBC_2.0' defined in .text section in
/home/giuliobenetti/git/upstream/output-or1k-br-stable/host/lib/gcc/or1k-buildroot-linux-uclibc/11.2.0/../../../../or1k-buildroot-linux-uclibc/lib/libgcc_s.so
CMakeFiles/geos.dir/src/algorithm/BoundaryNodeRule.cpp.o: in function
`geos::algorithm::BoundaryNodeRule::~BoundaryNodeRule()':
BoundaryNodeRule.cpp:(.text._ZN4geos9algorithm16BoundaryNodeRuleD2Ev[_ZN4geos9algorithm16BoundaryNodeRuleD5Ev]+0x2c):
relocation truncated to fit: R_OR1K_GOT16 against symbol `vtable for
geos::algorithm::BoundaryNodeRule' defined in
.data.rel.ro._ZTVN4geos9algorithm16BoundaryNodeRuleE[_ZTVN4geos9algorithm16BoundaryNodeRuleE]
section in CMakeFiles/geos.dir/src/algorithm/BoundaryNodeRule.cpp.o
CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o: in function
`geos::algorithm::CGAlgorithmsDD::orientationIndex(double, double, double,
double, double, double)':
CGAlgorithmsDD.cpp:(.text+0x310): relocation truncated to fit: R_OR1K_GOT16
against symbol
`geos::util::IllegalArgumentException::~IllegalArgumentException()' defined in
.text._ZN4geos4util24IllegalArgumentExceptionD2Ev[_ZN4geos4util24IllegalArgumentExceptionD5Ev]
section in CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o
CGAlgorithmsDD.cpp:(.text+0x320): relocation truncated to fit: R_OR1K_GOT16
against symbol `typeinfo for geos::util::IllegalArgumentException' defined in
.data.rel.ro._ZTIN4geos4util24IllegalArgumentExceptionE[_ZTIN4geos4util24IllegalArgumentExceptionE]
section in CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o
CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o: in function
`geos::algorithm::CGAlgorithmsDD::signOfDet2x2(double, double, double,
double)':
CGAlgorithmsDD.cpp:(.text+0xb1c): relocation truncated to fit: R_OR1K_GOT16
against symbol
`geos::util::IllegalArgumentException::~IllegalArgumentException()' defined in
.text._ZN4geos4util24IllegalArgumentExceptionD2Ev[_ZN4geos4util24IllegalArgumentExceptionD5Ev]
section in CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o
CGAlgorithmsDD.cpp:(.text+0xb2c): relocation truncated to fit: R_OR1K_GOT16
against symbol `typeinfo for geos::util::IllegalArgumentException' defined in
.data.rel.ro._ZTIN4geos4util24IllegalArgumentExceptionE[_ZTIN4geos4util24IllegalArgumentExceptionE]
section in CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o
CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o: in function
`geos::util::GEOSException::GEOSException(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&,
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&)':
CGAlgorithmsDD.cpp:(.text._ZN4geos4util13GEOSExceptionC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_[_ZN4geos4util13GEOSExceptionC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_]+0xc8):
additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
make[4]: *** [CMakeFiles/geos.dir/build.make:5639: lib/libgeos.so.3.10.1] Error
1
make[3]: *** [CMakeFiles/Makefile2:381: CMakeFiles/geos.dir/all] Error 2
make[2]: *** [Makefile:155: all] Error 2
make[1]: *** [package/pkg-generic.mk:295:
/home/giuliobenetti/git/upstream/output-or1k-br-stable/build/libgeos-3.10.1/.stamp_built]
Error 2
make: *** [Makefile:23: _all] Error 2
```

Thanks a lot!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/99783] relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos
  2021-03-26  6:52 [Bug target/99783] New: relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos shorne at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: shorne at gmail dot com @ 2021-12-30 21:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from shorne at gmail dot com ---
Ok, let me have a look.

On Fri, Dec 31, 2021, 5:34 AM giulio.benetti at benettiengineering dot com <
gcc-bugzilla@gcc.gnu.org> wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99783
>
> --- Comment #5 from Giulio Benetti <giulio.benetti at benettiengineering
> dot com> ---
> Dear Stafford,
>
> here we go again, after updating libgeos to version 3.10.1 the same bug
> shows
> up. This happens with libgeos but not with protobuf that is fixed. I'm sure
> i pass -mcmodel=large.
> Can you help me and fix it?
>
> Here are the instructions to reproduce the bug:
> ```
> 1) # git clone git://git.busybox.net/buildroot
> 2) # cd buildroot
> 3) copy the content of https://pastebin.com/tgDVcv6v into
> buildroot/or1k_libgeos_defconfig
> 4) # make libgeos
> ```
>
> That way it builds the entire toolchain and it fails on building libgeos
> with:
> ```
>
> /home/giuliobenetti/git/upstream/output-or1k-br-stable/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'
>
> /home/giuliobenetti/git/upstream/output-or1k-br-stable/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'
>
> /home/giuliobenetti/git/upstream/output-or1k-br-stable/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
>
> /home/giuliobenetti/git/upstream/output-or1k-br-stable/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
>
> /home/giuliobenetti/git/upstream/output-or1k-br-stable/host/lib/gcc/or1k-buildroot-linux-uclibc/11.2.0/../../../../or1k-buildroot-linux-uclibc/lib/libgcc_s.so
>
> /home/giuliobenetti/git/upstream/output-or1k-br-stable/host/lib/gcc/or1k-buildroot-linux-uclibc/11.2.0/crtbeginS.o:
> in function `frame_dummy':
> crtstuff.c:(.text+0x1c4): relocation truncated to fit: R_OR1K_GOT16 against
> symbol `__register_frame_info@@GLIBC_2.0' defined in .text section in
>
> /home/giuliobenetti/git/upstream/output-or1k-br-stable/host/lib/gcc/or1k-buildroot-linux-uclibc/11.2.0/../../../../or1k-buildroot-linux-uclibc/lib/libgcc_s.so
> CMakeFiles/geos.dir/src/algorithm/BoundaryNodeRule.cpp.o: in function
> `geos::algorithm::BoundaryNodeRule::~BoundaryNodeRule()':
>
> BoundaryNodeRule.cpp:(.text._ZN4geos9algorithm16BoundaryNodeRuleD2Ev[_ZN4geos9algorithm16BoundaryNodeRuleD5Ev]+0x2c):
> relocation truncated to fit: R_OR1K_GOT16 against symbol `vtable for
> geos::algorithm::BoundaryNodeRule' defined in
>
> .data.rel.ro._ZTVN4geos9algorithm16BoundaryNodeRuleE[_ZTVN4geos9algorithm16BoundaryNodeRuleE]
> section in CMakeFiles/geos.dir/src/algorithm/BoundaryNodeRule.cpp.o
> CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o: in function
> `geos::algorithm::CGAlgorithmsDD::orientationIndex(double, double, double,
> double, double, double)':
> CGAlgorithmsDD.cpp:(.text+0x310): relocation truncated to fit: R_OR1K_GOT16
> against symbol
> `geos::util::IllegalArgumentException::~IllegalArgumentException()'
> defined in
>
> .text._ZN4geos4util24IllegalArgumentExceptionD2Ev[_ZN4geos4util24IllegalArgumentExceptionD5Ev]
> section in CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o
> CGAlgorithmsDD.cpp:(.text+0x320): relocation truncated to fit: R_OR1K_GOT16
> against symbol `typeinfo for geos::util::IllegalArgumentException' defined
> in
>
> .data.rel.ro._ZTIN4geos4util24IllegalArgumentExceptionE[_ZTIN4geos4util24IllegalArgumentExceptionE]
> section in CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o
> CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o: in function
> `geos::algorithm::CGAlgorithmsDD::signOfDet2x2(double, double, double,
> double)':
> CGAlgorithmsDD.cpp:(.text+0xb1c): relocation truncated to fit: R_OR1K_GOT16
> against symbol
> `geos::util::IllegalArgumentException::~IllegalArgumentException()'
> defined in
>
> .text._ZN4geos4util24IllegalArgumentExceptionD2Ev[_ZN4geos4util24IllegalArgumentExceptionD5Ev]
> section in CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o
> CGAlgorithmsDD.cpp:(.text+0xb2c): relocation truncated to fit: R_OR1K_GOT16
> against symbol `typeinfo for geos::util::IllegalArgumentException' defined
> in
>
> .data.rel.ro._ZTIN4geos4util24IllegalArgumentExceptionE[_ZTIN4geos4util24IllegalArgumentExceptionE]
> section in CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o
> CMakeFiles/geos.dir/src/algorithm/CGAlgorithmsDD.cpp.o: in function
> `geos::util::GEOSException::GEOSException(std::__cxx11::basic_string<char,
> std::char_traits<char>, std::allocator<char> > const&,
> std::__cxx11::basic_string<char, std::char_traits<char>,
> std::allocator<char> >
> const&)':
>
> CGAlgorithmsDD.cpp:(.text._ZN4geos4util13GEOSExceptionC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_[_ZN4geos4util13GEOSExceptionC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_]+0xc8):
> additional relocation overflows omitted from the output
> collect2: error: ld returned 1 exit status
> make[4]: *** [CMakeFiles/geos.dir/build.make:5639: lib/libgeos.so.3.10.1]
> Error
> 1
> make[3]: *** [CMakeFiles/Makefile2:381: CMakeFiles/geos.dir/all] Error 2
> make[2]: *** [Makefile:155: all] Error 2
> make[1]: *** [package/pkg-generic.mk:295:
>
> /home/giuliobenetti/git/upstream/output-or1k-br-stable/build/libgeos-3.10.1/.stamp_built]
> Error 2
> make: *** [Makefile:23: _all] Error 2
> ```
>
> Thanks a lot!
>
> --
> You are receiving this mail because:
> You reported the bug.
> You are the assignee for the bug.
> You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/99783] relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos
  2021-03-26  6:52 [Bug target/99783] New: relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos shorne at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: shorne at gmail dot com @ 2021-12-31  0:14 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/99783] relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos
  2021-03-26  6:52 [Bug target/99783] New: relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos shorne at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  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
  2022-01-02  0:04 ` shorne at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: giulio.benetti at benettiengineering dot com @ 2021-12-31 11:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Giulio Benetti <giulio.benetti at benettiengineering dot com> ---
Thanks a lot Stafford

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/99783] relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos
  2021-03-26  6:52 [Bug target/99783] New: relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos shorne at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  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
  9 siblings, 0 replies; 11+ messages in thread
From: shorne at gmail dot com @ 2022-01-01  7:23 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/99783] relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos
  2021-03-26  6:52 [Bug target/99783] New: relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos shorne at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2022-01-01  7:23 ` shorne at gmail dot com
@ 2022-01-02  0:04 ` shorne at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: shorne at gcc dot gnu.org @ 2022-01-02  0:04 UTC (permalink / raw)
  To: gcc-bugs

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

Stafford Horne <shorne at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |MOVED
             Status|ASSIGNED                    |RESOLVED

--- Comment #10 from Stafford Horne <shorne at gcc dot gnu.org> ---
Closing this as its a binutils issue.  I have opened:
https://sourceware.org/bugzilla/show_bug.cgi?id=28735

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-01-02  0:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-26  6:52 [Bug target/99783] New: relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos 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
2022-01-02  0:04 ` shorne at gcc dot gnu.org

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).