0

I am building a cpp project, but the link fails, because the .debug_info segment is too large, exceeding 2^32-1. Is there a tool to locate which part of the code has a larger .debug_info segment, or is there a way to remove this limitation?

compiler version:

g++ (GCC) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.

error:

ld.lld: error: thread.cc:(.debug_info+0x90A0): relocation R_X86_64_32 out of range: 4306390516 is not in [0, 4294967295]; consider recompiling with -fdebug-types-section to reduce size of debug sections
zcfh
  • 101
  • 1
  • 9

2 Answers2

0

Add -mcmodel=medium to your compiler flags. This way it will not assume that symbols are addressable with 32-bit offsets, they can use the full 64-bit address space.

John Zwinck
  • 239,568
  • 38
  • 324
  • 436
0

Description

We had a similar problem

ld: error: name.cpp:(.debug_info+0x1FC1C): relocation R_X86_64_32 out of range: 4295177414 is not in [0, 4294967295]; consider recompiling with -fdebug-types-section to reduce size of debug sections
ld: error: second_name.cpp:(.debug_aranges+0x6): relocation R_X86_64_32...

In our case it is due to an overflow section .debug_info. To check this, you can try reducing the size of your code until it starts to build and use the readelf - utility. If you see that the section size is close to 0xfffffffffff, then you have the same problem

Possible solutions

This lists all the debug options available in gcc

  1. You can try changing the DWARF format from 32 to 64. Note that this may greatly increase the size of the original file (see -gdwarf64)
  2. It is also possible to divide the section into several parts (see -gsplit-dwarf)

You may also find the information from here helpful.