https://sourceware.org/bugzilla/show_bug.cgi?id=32507
Bug ID: 32507 Summary: Incorrect allocation size printed by 32-bit MinGW builds of BFD Product: binutils Version: unspecified Status: NEW Severity: normal Priority: P2 Component: binutils Assignee: unassigned at sourceware dot org Reporter: eliz at gnu dot org Target Milestone: --- When `bfd_get_full_section_contents` fails to allocate memory of the required size, due to `malloc` returning NULL, it prints bogus size when compiled with a 32-bit compiler (in this case, MinGW GCC 9.2.0). Here's an example, from a MinGW build of GDB on MS-Windows: warning: BFD: error: d:\gnu\gdb-16.0.90\gdb\gdb.exe(.debug_macro) is too large (0x9f585e077fdeba bytes) The correct size in hex is 0x077fdeba, so the high 32 bits are garbage. This comes from code like below: p = (bfd_byte *) bfd_malloc (allocsz); if (p == NULL) { /* PR 20801: Provide a more helpful error message. */ if (bfd_get_error () == bfd_error_no_memory) _bfd_error_handler /* xgettext:c-format */ (_("error: %pB(%pA) is too large (%#" PRIx64 " bytes)"), abfd, sec, (uint64_t) allocsz); return false; } It sounds like `_bfd_error_handler` treats 64-bit values in 32-bit builds of BFD incorrectly, or something. I ended up using the following kludge: if (bfd_get_error () == bfd_error_no_memory) { if (sizeof (allocsz ) > sizeof (int)) _bfd_error_handler /* xgettext:c-format */ (_("error: %pB(%pA) is too large (%#" PRIx64 " bytes)"), abfd, sec, (uint64_t) allocsz); else _bfd_error_handler /* xgettext:c-format */ (_("error: %pB(%pA) is too large (%#" PRIx32 " bytes)"), abfd, sec, allocsz); } return false; -- You are receiving this mail because: You are on the CC list for the bug.