Bug 23966 - objcopy fails on mingw32 target for files bigger than 2GB
Summary: objcopy fails on mingw32 target for files bigger than 2GB
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.31
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-09 04:40 UTC by Marcin Undak
Modified: 2018-12-28 05:16 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcin Undak 2018-12-09 04:40:24 UTC
On Windows objcopy fails to split debug info with --only-keep-debug when this debug information is bigger than 2 GB.

This is because of the following code in bfd_malloc():

  if (size != sz
      /* This is to pacify memory checkers like valgrind.  */
      || ((signed long) sz) < 0)
    {
      bfd_set_error (bfd_error_no_memory);
      return NULL;
    }

On mingw32 target sizeof(long) is 4 bytes which makes < 0 condition invalid.
Comment 1 Sourceware Commits 2018-12-28 04:34:06 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cb87d9f1a49986b2eb92ac381444f4cc7c9d8a4f

commit cb87d9f1a49986b2eb92ac381444f4cc7c9d8a4f
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Dec 28 09:34:28 2018 +1030

    PR23966, mingw failure due to 32-bit long
    
    	PR 23966
    	* libbfd.c (SSIZE_MAX): Define.
    	(bfd_malloc, bfd_realloc): Don't cast size to long to check for
    	"negative" values, compare against SSIZE_MAX instead.
Comment 2 Alan Modra 2018-12-28 05:16:30 UTC
The bfd_malloc bug is now fixed.