4

I am running readelf -w on my (C++) executable to examine some debug sections and it prints the following warnings a couple of times:

$ readelf -w a.out
...
readelf: Warning: Corrupt offset (0x00000028) in range entry 1
readelf: Warning: Corrupt offset (0x00000044) in range entry 2
readelf: Warning: Corrupt offset (0x00000054) in range entry 3
...

I have no clue what this means and neither the manpage nor Google could help. Can anyone enlighten me?

andreee
  • 4,459
  • 22
  • 42

2 Answers2

3

The error comes from dwarf.c here:

  for (i = 0; i < num_range_list; i++)
...
      if (offset > (size_t) (finish - section_begin))
        {
          warn (_("Corrupt offset (%#" PRIx64 ") in range entry %u\n"),
                offset, i);
          continue;
        }

What this means is hard to say without seeing output from readelf --all. It could be that your compiler is producing bad debug info, but it could also be a bug in readelf, possibly this one.

You could try using eu-readelf from the elfutils package, which appears to be better maintained.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • Thanks for your answer. What particular information do you expect to be useful from `readelf --all`? – andreee Aug 29 '22 at 06:41
0

This could also mean that the binary was compiled with -ffunction-sections and then linked with ld --gc-sections which leaves dropped sections untouched with "corrupted ranges".

See https://maskray.me/blog/2021-02-28-linker-garbage-collection

Vser
  • 578
  • 4
  • 18