Bug 23931 - objdump -r often fails on pdp11 files
Summary: objdump -r often fails on pdp11 files
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.31
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-28 19:25 UTC by Paul Koning
Modified: 2018-11-29 15:10 UTC (History)
1 user (show)

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


Attachments
crt0.o for pdp11 (163 bytes, application/octet-stream)
2018-11-28 19:25 UTC, Paul Koning
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Koning 2018-11-28 19:25:01 UTC
Created attachment 11417 [details]
crt0.o for pdp11

Function dump_relocs_in_section in objdump.c checks that the relic count is valid by comparing the size of the reloc data against the file size.  That check is incorrect because "relsize" is the decoded (canonical) reloc data size, not the size of the reloc data encoded in the file.  In the case of pdp11, sizeof (arelent) is 8, while the size in the file is 2 bytes per entry, so the check can easily fail.
The attached file shows the issue.  If I comment out the check at objdump.c:3465, it works.
Comment 1 Sourceware Commits 2018-11-29 10:59:42 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

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

commit 8936f76804c2908e4abe911441dd03641204df9d
Author: Nick Clifton <nickc@redhat.com>
Date:   Thu Nov 29 10:57:54 2018 +0000

    objdump: Fix check for corrupt reloc information, to allow for the fact that PDP11 relocs are bigger when in internal format.
    
    	PR 23931
    	* objdump.c (dump_relocs_in_section): When checking for an
    	unreasonable amount of relocs in a bfd, allow for the fact that
    	the internal representation of a reloc may be bigger than the
    	external representation.
Comment 2 Nick Clifton 2018-11-29 11:01:55 UTC
Hi Paul,

  Thanks for reporting this problem.  Rather than disabling the check however,
  I thought it better to tweak it to allow for the fact that the internal
  representation of thr PDP11 relocs is larger than the external representation.

Cheers
  Nick
Comment 3 Paul Koning 2018-11-29 15:10:05 UTC
Great.  I agree fixing the check is best.  I looked at the code but it wasn't clear to me how to do that, so I did the disable as a crude test.