0

I'm encoutering a Relocation truncated to fit: secrel32 against `.debug_frame$_......... issue in my C++ project.

I have already seen the links below but it doesn't seem to match the behavior of the build issue :

What does this GCC error "... relocation truncated to fit..." mean?

https://www.technovelty.org/c/relocation-truncated-to-fit-wtf.html

This issue only appears in debug mode. My project builds with no error in release mode.

Also commenting random portion of code in the main function "solves" the build issue.

My project is configured in a Qt environment using a msys2-mingw64 toolchain and gcc version 10.2.0 (Rev6, Built by MSYS2 project).

Compilation logs output :

g++ -Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high -Wl,-subsystem,console -mthreads -o debug\program.exe @object_script.program.Debug  -LC:\Users\user\Desktop\build-project-Qt_5_15_0_MinGW_64_bit_msys2-Debug\src\libs\common\debug -lcommon C:\msys64\mingw64\lib\libQt5Core.dll.a   

debug/main.o:main.cpp:(.debug_frame$_ZSt13__invoke_implIvRZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS3_6entityENS3_9exclude_tIJEEEK4CellK8PositionK18GeographicPositionEE13view_iteratorESF_ZN28SatelliteBeamSelectionSystem6systemERNS0_7SubflowERNS3_14basic_registryIS5_EEEUlS5_E_iEENS0_4TaskEOT_OT0_OT1_OT2_EUlSI_E_JSI_EESO_St14__invoke_otherSR_DpOT1_+0x1c): relocation truncated to fit: secrel32 against `.debug_frame$_ZSt13__invoke_implIvRZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS3_6entityENS3_9exclude_tIJEEEK4CellK8PositionK18GeographicPositionEE13view_iteratorESF_ZN28SatelliteBeamSelectionSystem6systemERNS0_7SubflowERNS3_14basic_registryIS5_EEEUlS5_E_iEENS0_4TaskEOT_OT0_OT1_OT2_EUlSI_E_JSI_EESO_St14__invoke_otherSR_DpOT1_'
debug/main.o:main.cpp:(.debug_frame$_ZNSt14_Function_base13_Base_managerIZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS4_6entityENS4_9exclude_tIJEEEK4CellK8PositionK18GeographicPositionEE13view_iteratorESG_ZN28SatelliteBeamSelectionSystem6systemERNS1_7SubflowERNS4_14basic_registryIS6_EEEUlS6_E_iEENS1_4TaskEOT_OT0_OT1_OT2_EUlSJ_E_E8_M_cloneERSt9_Any_dataRKSZ_St17integral_constantIbLb0EE+0x1c): relocation truncated to fit: secrel32 against `.debug_frame$_ZNSt14_Function_base13_Base_managerIZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS4_6entityENS4_9exclude_tIJEEEK4CellK8PositionK18GeographicPositionEE13view_iteratorESG_ZN28SatelliteBeamSelectionSystem6systemERNS1_7SubflowERNS4_14basic_registryIS6_EEEUlS6_E_iEENS1_4TaskEOT_OT0_OT1_OT2_EUlSJ_E_E8_M_cloneERSt9_Any_dataRKSZ_St17integral_constantIbLb0EE'
debug/main.o:main.cpp:(.debug_frame$_ZNSt14_Function_base13_Base_managerIZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS4_6entityENS4_9exclude_tIJEEEK4CellK8PositionK18GeographicPositionEE13view_iteratorESG_ZN28SatelliteBeamSelectionSystem6systemERNS1_7SubflowERNS4_14basic_registryIS6_EEEUlS6_E_iEENS1_4TaskEOT_OT0_OT1_OT2_EUlSJ_E_E10_M_destroyERSt9_Any_dataSt17integral_constantIbLb0EE+0x1c): relocation truncated to fit: secrel32 against `.debug_frame$_ZNSt14_Function_base13_Base_managerIZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS4_6entityENS4_9exclude_tIJEEEK4CellK8PositionK18GeographicPositionEE13view_iteratorESG_ZN28SatelliteBeamSelectionSystem6systemERNS1_7SubflowERNS4_14basic_registryIS6_EEEUlS6_E_iEENS1_4TaskEOT_OT0_OT1_OT2_EUlSJ_E_E10_M_destroyERSt9_Any_dataSt17integral_constantIbLb0EE'
debug/main.o:main.cpp:(.debug_frame$_ZNKSt9_Any_data9_M_accessIPZZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS4_6entityENS4_9exclude_tIJEEEK9Satellite8Position18GeographicPosition8VelocityEE13view_iteratorESF_ZN29SatelliteMobilityUpdateSystem6systemERNS1_7SubflowERNS4_14basic_registryIS6_EEEUlS6_E_iEENS1_4TaskEOT_OT0_OT1_OT2_ENUlSI_E_clESI_EUlvE_EERKSO_v+0x1c): relocation truncated to fit: secrel32 against `.debug_frame$_ZNKSt9_Any_data9_M_accessIPZZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS4_6entityENS4_9exclude_tIJEEEK9Satellite8Position18GeographicPosition8VelocityEE13view_iteratorESF_ZN29SatelliteMobilityUpdateSystem6systemERNS1_7SubflowERNS4_14basic_registryIS6_EEEUlS6_E_iEENS1_4TaskEOT_OT0_OT1_OT2_ENUlSI_E_clESI_EUlvE_EERKSO_v'
debug/main.o:main.cpp:(.debug_frame$_ZSt7forwardIRZZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS3_6entityENS3_9exclude_tIJEEEK9Satellite8Position18GeographicPosition8VelocityEE13view_iteratorESE_ZN29SatelliteMobilityUpdateSystem6systemERNS0_7SubflowERNS3_14basic_registryIS5_EEEUlS5_E_iEENS0_4TaskEOT_OT0_OT1_OT2_ENUlSH_E_clESH_EUlvE_ESO_RNSt16remove_referenceISN_E4typeE+0x1c): relocation truncated to fit: secrel32 against `.debug_frame$_ZSt7forwardIRZZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS3_6entityENS3_9exclude_tIJEEEK9Satellite8Position18GeographicPosition8VelocityEE13view_iteratorESE_ZN29SatelliteMobilityUpdateSystem6systemERNS0_7SubflowERNS3_14basic_registryIS5_EEEUlS5_E_iEENS0_4TaskEOT_OT0_OT1_OT2_ENUlSH_E_clESH_EUlvE_ESO_RNSt16remove_referenceISN_E4typeE'
debug/main.o:main.cpp:(.debug_frame$_ZSt13__invoke_implIvRZZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS3_6entityENS3_9exclude_tIJEEEK9Satellite8Position18GeographicPosition8VelocityEE13view_iteratorESE_ZN29SatelliteMobilityUpdateSystem6systemERNS0_7SubflowERNS3_14basic_registryIS5_EEEUlS5_E_iEENS0_4TaskEOT_OT0_OT1_OT2_ENUlSH_E_clESH_EUlvE_JEESN_St14__invoke_otherSQ_DpOT1_+0x1c): relocation truncated to fit: secrel32 against `.debug_frame$_ZSt13__invoke_implIvRZZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS3_6entityENS3_9exclude_tIJEEEK9Satellite8Position18GeographicPosition8VelocityEE13view_iteratorESE_ZN29SatelliteMobilityUpdateSystem6systemERNS0_7SubflowERNS3_14basic_registryIS5_EEEUlS5_E_iEENS0_4TaskEOT_OT0_OT1_OT2_ENUlSH_E_clESH_EUlvE_JEESN_St14__invoke_otherSQ_DpOT1_'
debug/main.o:main.cpp:(.debug_frame$_ZNSt14_Function_base13_Base_managerIZZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS4_6entityENS4_9exclude_tIJEEEK9Satellite8Position18GeographicPosition8VelocityEE13view_iteratorESF_ZN29SatelliteMobilityUpdateSystem6systemERNS1_7SubflowERNS4_14basic_registryIS6_EEEUlS6_E_iEENS1_4TaskEOT_OT0_OT1_OT2_ENUlSI_E_clESI_EUlvE_E8_M_cloneERSt9_Any_dataRKSZ_St17integral_constantIbLb0EE+0x1c): relocation truncated to fit: secrel32 against `.debug_frame$_ZNSt14_Function_base13_Base_managerIZZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS4_6entityENS4_9exclude_tIJEEEK9Satellite8Position18GeographicPosition8VelocityEE13view_iteratorESF_ZN29SatelliteMobilityUpdateSystem6systemERNS1_7SubflowERNS4_14basic_registryIS6_EEEUlS6_E_iEENS1_4TaskEOT_OT0_OT1_OT2_ENUlSI_E_clESI_EUlvE_E8_M_cloneERSt9_Any_dataRKSZ_St17integral_constantIbLb0EE'
debug/main.o:main.cpp:(.debug_frame$_ZNSt14_Function_base13_Base_managerIZZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS4_6entityENS4_9exclude_tIJEEEK9Satellite8Position18GeographicPosition8VelocityEE13view_iteratorESF_ZN29SatelliteMobilityUpdateSystem6systemERNS1_7SubflowERNS4_14basic_registryIS6_EEEUlS6_E_iEENS1_4TaskEOT_OT0_OT1_OT2_ENUlSI_E_clESI_EUlvE_E10_M_destroyERSt9_Any_dataSt17integral_constantIbLb0EE+0x1c): relocation truncated to fit: secrel32 against `.debug_frame$_ZNSt14_Function_base13_Base_managerIZZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS4_6entityENS4_9exclude_tIJEEEK9Satellite8Position18GeographicPosition8VelocityEE13view_iteratorESF_ZN29SatelliteMobilityUpdateSystem6systemERNS1_7SubflowERNS4_14basic_registryIS6_EEEUlS6_E_iEENS1_4TaskEOT_OT0_OT1_OT2_ENUlSI_E_clESI_EUlvE_E10_M_destroyERSt9_Any_dataSt17integral_constantIbLb0EE'
debug/main.o:main.cpp:(.debug_frame$_ZNKSt9_Any_data9_M_accessIPZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS4_6entityENS4_9exclude_tIJEEEK9Satellite8Position18GeographicPosition8VelocityEE13view_iteratorESF_ZN29SatelliteMobilityUpdateSystem6systemERNS1_7SubflowERNS4_14basic_registryIS6_EEEUlS6_E_iEENS1_4TaskEOT_OT0_OT1_OT2_EUlSI_E_EERKSO_v+0x1c): relocation truncated to fit: secrel32 against `.debug_frame$_ZNKSt9_Any_data9_M_accessIPZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS4_6entityENS4_9exclude_tIJEEEK9Satellite8Position18GeographicPosition8VelocityEE13view_iteratorESF_ZN29SatelliteMobilityUpdateSystem6systemERNS1_7SubflowERNS4_14basic_registryIS6_EEEUlS6_E_iEENS1_4TaskEOT_OT0_OT1_OT2_EUlSI_E_EERKSO_v'
debug/main.o:main.cpp:(.debug_frame$_ZSt7forwardIRZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS3_6entityENS3_9exclude_tIJEEEK9Satellite8Position18GeographicPosition8VelocityEE13view_iteratorESE_ZN29SatelliteMobilityUpdateSystem6systemERNS0_7SubflowERNS3_14basic_registryIS5_EEEUlS5_E_iEENS0_4TaskEOT_OT0_OT1_OT2_EUlSH_E_ESO_RNSt16remove_referenceISN_E4typeE+0x1c): relocation truncated to fit: secrel32 against `.debug_frame$_ZSt7forwardIRZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS3_6entityENS3_9exclude_tIJEEEK9Satellite8Position18GeographicPosition8VelocityEE13view_iteratorESE_ZN29SatelliteMobilityUpdateSystem6systemERNS0_7SubflowERNS3_14basic_registryIS5_EEEUlS5_E_iEENS0_4TaskEOT_OT0_OT1_OT2_EUlSH_E_ESO_RNSt16remove_referenceISN_E4typeE'
debug/main.o:main.cpp:(.debug_frame$_ZSt13__invoke_implIvRZN2tf11FlowBuilder15for_each_guidedIN4entt10basic_viewIJNS3_6entityENS3_9exclude_tIJEEEK9Satellite8Position18GeographicPosition8VelocityEE13view_iteratorESE_ZN29SatelliteMobilityUpdateSystem6systemERNS0_7SubflowERNS3_14basic_registryIS5_EEEUlS5_E_iEENS0_4TaskEOT_OT0_OT1_OT2_EUlSH_E_JSH_EESN_St14__invoke_otherSQ_DpOT1_+0x1c): additional relocation overflows omitted from the output
collect2.exe: error: ld returned 1 exit status

I checked section sizes of the main object with GNU size tool. I added the "-fstack-usage" flag to check stack usage. I added the "fPIC" flag to the common library. It didn't fix the issue.

I am looking for some hints.

Thank you by advance !

  • 1
    What compilation options are used when you build in release mode? Perhaps you can investigate the differences? – Ted Lyngmo Jan 08 '21 at 09:28
  • Following your advice, I added the flag to the linker `-Wl,-s` with `QMAKE_LFLAGS += -Wl,-s`. This flag appears in the release mode and it is used to compile the source with static linking. It solves the build issue in debug mode with the flag. Thank you a lot ! What would be the next step to completly solve my issue ? How could I use dynamic linking ? – Quentin Baradat Jan 08 '21 at 10:01
  • 1
    You're welcome. I don't know what you need to do to use dynamic linking. Does it work if you remove `-Wl,-s` when compiling in release mode? If it does, it's probably one of the other options used in debug mode that causes the problem. – Ted Lyngmo Jan 08 '21 at 10:11
  • 1/ It works if I remove `-Wl,-s` in release mode. 2/ It works in debug mode if I remove the `-g` flag in the build process. It is used to generate debug information for GDB debugger. – Quentin Baradat Jan 08 '21 at 10:29
  • Hmm, that's odd. Perhaps the debug compiled shared libraries have come "out of sync" with the static versions somehow. A sidenote: Since you use `gdb`, I think you'll get even better debugging information with `-ggdb` instead of just `-g`. – Ted Lyngmo Jan 08 '21 at 11:43
  • Does it work without `-Wl,--dynamicbase,--high-entropy-va,--nxcompat,--default-image-base-high`? – ssbssa Jan 09 '21 at 13:37

0 Answers0