binutils nm wrong output format breaks i386 nm work

Bug #1845190 reported by Gianfranco Costamagna
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
binutils
Fix Released
Medium
binutils (Ubuntu)
Fix Released
Wishlist
Matthias Klose

Bug Description

discovered with diffoscope autopkgregression, looks like a real bug, based on
https://salsa.debian.org/reproducible-builds/diffoscope/issues/69

Revision history for this message
In , Gianfranco Costamagna (costamagnagianfranco) wrote :

Created attachment 12001
example

This happens since binutils 2.32.51.20190611 (The Debian version mostly tracks svn)
and it was working on 2.32-8 (updated to 20190424)

to reproduce:
nm elfmix1.not_a
nm: 42-Mach-O.o: file format not recognized
nm: 43-Mach-O.o: file format not recognized
nm: Mach-O.o: file format not recognized

return42_or_3_long_name.o:
0000000000000000 T return42_or_3
nm: return42_or_3_long_name.c: file format not recognized
nm: regen_elfmix.sh: file format not recognized

return42_or_3_long_name.obj:
ffa49ce800000000 T return42_or_3

before, with old binutils it was printed correctly
 nm elfmix1.not_a
nm: 42-Mach-O.o: file format not recognized
nm: 43-Mach-O.o: file format not recognized
nm: Mach-O.o: file format not recognized

return42_or_3_long_name.o:
0000000000000000 T return42_or_3
nm: return42_or_3_long_name.c: file format not recognized
nm: regen_elfmix.sh: file format not recognized

return42_or_3_long_name.obj:
00000000 T return42_or_3

Looks like the returned output is half full of uninitialized values

on amd64 it works correctly

nm elfmix1.not_a
nm: 42-Mach-O.o: file format not recognized
nm: 43-Mach-O.o: file format not recognized
nm: Mach-O.o: file format not recognized

return42_or_3_long_name.o:
0000000000000000 T return42_or_3
nm: return42_or_3_long_name.c: file format not recognized
nm: regen_elfmix.sh: file format not recognized

return42_or_3_long_name.obj:
0000000000000000 T return42_or_3

Revision history for this message
In , Gianfranco Costamagna (costamagnagianfranco) wrote :

Please see this Debian discussion for more information
https://salsa.debian.org/reproducible-builds/diffoscope/issues/69

Changed in binutils:
importance: Unknown → Medium
status: Unknown → New
Revision history for this message
In , Cvs-commit (cvs-commit) wrote :

The master branch has been updated by Alan Modra <email address hidden>:

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

commit 352f6bc3e5b23e76d8e6f56fb7db4e57d8f5d5bd
Author: Alan Modra <email address hidden>
Date: Tue Sep 24 22:47:13 2019 +0930

    PR25031, nm reports wrong address on 32bit

    Using saved_format breaks when nm is presented with multiple object
    files, some 32-bit and some 64-bit.

     PR 25031
     * nm.c (print_format_string): New.
     (get_print_format): Delete saved_format. Move earlier.
     (set_print_width): Call get_print_format.
     (print_value): Use print_format_string.

tags: added: rls-ee-incoming
Revision history for this message
In , MarcH (marc-h38) wrote :

> on amd64 it works correctly:
>
> nm elfmix1.not_a
> return42_or_3_long_name.o:
> 0000000000000000 T return42_or_3
> return42_or_3_long_name.obj:
> 0000000000000000 T return42_or_3

No, on amd64 the bug is the same as on i386. The correct output on both i386 and amd64 must be:

return42_or_3_long_name.o:
0000000000000000 T return42_or_3
return42_or_3_long_name.obj:
00000000 T return42_or_3

Revision history for this message
In , Cvs-commit (cvs-commit) wrote :

The binutils-2_33-branch branch has been updated by Alan Modra <email address hidden>:

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

commit 895b6d98785ba89819820aa5f4abed17fbb28c37
Author: Alan Modra <email address hidden>
Date: Tue Sep 24 22:47:13 2019 +0930

    PR25031, nm reports wrong address on 32bit

    Using saved_format breaks when nm is presented with multiple object
    files, some 32-bit and some 64-bit.

     PR 25031
     * nm.c (print_format_string): New.
     (get_print_format): Delete saved_format. Move earlier.
     (set_print_width): Call get_print_format.
     (print_value): Use print_format_string.

    (cherry picked from commit 352f6bc3e5b23e76d8e6f56fb7db4e57d8f5d5bd)

Changed in binutils:
status: New → In Progress
Revision history for this message
In , Alan Modra (amodra-gmail) wrote :

Fixed.

Changed in binutils:
status: In Progress → Fix Released
Revision history for this message
In , Gianfranco Costamagna (costamagnagianfranco) wrote :

thanks a ton for the quick fixes!

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

I think this should land in Ubuntu as part of a regular snapshot upload of binutils. I.e. without any special cherrypicking.

This may or might not be fixed in Eoan or f-cycle.

Changed in binutils (Ubuntu):
importance: High → Wishlist
tags: added: rls-ee-notfixing
removed: rls-ee-incoming
Revision history for this message
In , Marc-herbert+sourceware (marc-herbert+sourceware) wrote :

Impressively quick fix indeed, thanks!

I haven't seen any test added though. While such ELF files shouldn't be common, it's a fairly basic feature and doesn't seem like requiring any complex test fixture, does it?
Relying on diffoscope's test suite doesn't feel right.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package binutils - 2.32.90.20190929-0ubuntu2

---------------
binutils (2.32.90.20190929-0ubuntu2) eoan; urgency=medium

  * Snapshot, taken from the 2.33 branch (20190929).
    - Fix PR25031, nm reports wrong address on 32bit. LP: #1845190.
    - Fix PR25018, readelf crash on 32bits. LP: #1844119.
    - [GOLD] Fix spurious "plugin needed to handle lto object" warnings.
    - GCC 10 related warning fixes.
    - i386: Adjust for new output format from readelf.
  * Include the test logs in the binutils-dev package.

 -- Matthias Klose <email address hidden> Sun, 29 Sep 2019 07:37:06 +0200

Changed in binutils (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.