[Bug target/99783] relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos
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-bugzi...@gcc.gnu.org> wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99783 > > --- Comment #5 from Giulio Benetti 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
[Bug target/99783] relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos
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 +, 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 50: 85 21 00 00 l.lwz r9,0(r1) register_tm_clones: c0: 10 00 00 09 l.bf e4 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 &= 0x; I will have to look at this more.
[Bug target/99783] relocation truncated to fit: R_OR1K_GOT16 on OpenRISC, building libgeos
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 0x 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 1194x = 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 1203case R_OR1K_SLO16: x 1204case R_OR1K_GOTOFF_SLO16: x 1205case 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 , 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 +, giulio.benetti at benettiengineering dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99783