Bug 21013

Summary: objdump memory exhausted on several 8k demos
Product: binutils Reporter: Aaron Paden <aaronbpaden>
Component: binutilsAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: nickc
Priority: P2    
Version: 2.27   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed: 2017-01-04 00:00:00
Attachments: Proposed patch

Description Aaron Paden 2016-12-31 20:07:22 UTC
When using objdump to examine several of the executables found here:
http://www.pouet.net/prodlist.php?order=thumbup&type%5B%5D=8k&platform%5B%5D=Windows&page=1

objdump reports exhausted memory when trying to read the symbol table. Note that these executables are certainly going to be using some crazy compression techniques to keep themselves within 8 kilobytes.
Comment 1 Nick Clifton 2017-01-04 11:12:29 UTC
Created attachment 9738 [details]
Proposed patch

Hi Aaron,

  Please could you try out this patch.  It only adds an extra error message,
  explaining why space could not be found to allocate the symbol table.  It
  does not make any attempt to allow objdump to continue working after detecting
  the error.  I felt that doing so would likely add more bugs to objdump, 
  which would be bad.

  I only tested one file from the repository you indicated, so there may be
  others that cause objdump to run out of memory in other ways.  If you find
  any like this, please feel free to update this bug report with their names
  and I will investigate further.

Cheers
  Nick
Comment 2 Aaron Paden 2017-01-08 04:32:27 UTC
Huh, every exe I've tried said it failed because there were roughly 18.4 quintillion symbols. That... definitely doesn't seem right. :P
Comment 3 Sourceware Commits 2017-01-09 09:29:07 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

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

commit 98f02962fefbacf1b805e93fb7bddeb58ec6ff70
Author: Nick Clifton <nickc@redhat.com>
Date:   Mon Jan 9 09:27:46 2017 +0000

    Improve objdump's behaviour when it encounters a corrupt binary with an excessively large symbol table.
    
    	PR binutils/21013
    	* coffgen.c (_bfd_coff_get_external_symbols): Generate an error
    	message if there are too many symbols to load.
Comment 4 Nick Clifton 2017-01-09 09:30:45 UTC
Yeah - whoever created those binaries is doing some funky things with the COFF/PE headers.  Anyway I have now checked the patch into the sources.

Cheers
  Nick