bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/31692] New: objdump fails .debug_info size check for compr


From: laanwj at gmail dot com
Subject: [Bug binutils/31692] New: objdump fails .debug_info size check for compressed debug information
Date: Thu, 02 May 2024 06:01:11 +0000

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

            Bug ID: 31692
           Summary: objdump fails .debug_info size check for compressed
                    debug information
           Product: binutils
           Version: 2.43 (HEAD)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: binutils
          Assignee: unassigned at sourceware dot org
          Reporter: laanwj at gmail dot com
  Target Milestone: ---

Versions: HEAD as of 75d933919d8e99c85054bdbf3a0bee0235f2bd3b and 2.42

objdump fails a .debug_info size check for large binaries produced by gcc/ld,
that have a compressed debug section.

To reproduce:
-------------
$ wget
https://bitcoincore.org/bin/bitcoin-core-27.0/bitcoin-27.0-x86_64-linux-gnu-debug.tar.gz
$ tar -zxvf bitcoin-27.0-x86_64-linux-gnu-debug.tar.gz
$ objdump -Wi bitcoin-27.0/bin/bitcoind.dbg
Section '.debug_info' has an invalid size: 0.
-------------

This issue is very similar to
https://sourceware.org/bugzilla/show_bug.cgi?id=24319 , which was closed as
FIXED RESOLVED, but there may be a similar issue left.

The error arises in the following code in binutils/objdump.c, a check for
32-bit systems (note that this happens on a 64-bit system):
-------------
  /* PR 24360: On 32-bit hosts sizeof (size_t) < sizeof (bfd_size_type). */
  alloced = amt = section->size + 1;
  if (alloced != amt
      || alloced == 0
      || (bfd_get_size (abfd) != 0 && alloced >= bfd_get_size (abfd)))
    {
      section->start = NULL;
      free_debug_section (debug);
      printf (_("\nSection '%s' has an invalid size: %#" PRIx64 ".\n"),
              sanitize_string (section->name),
              section->size);
      return false;
    }
-------------

Two problems with this:

- The reason it prints size 0 (and not the real value, 0x976cf8b) is that
`free_debug_section` sets section->size to 0.

- It compares the size of the section against `bfd_get_size` (0x5ed10b0) which
is (afaik) the size of the binary. But as this is a compressed section it can
legitly be larger than the binary.

Removing the check makes it work.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]