#1050483 /usr/bin/x86_64-linux-gnu-objdump: objdump and nm choke on fully stripped ELF executables

Package:
binutils-x86-64-linux-gnu
Source:
binutils-x86-64-linux-gnu
Description:
GNU binary utilities, for x86-64-linux-gnu target
Submitter:
Joshua
Date:
2023-08-25 16:27:05 UTC
Severity:
normal
#1050483#5
Date:
2023-08-25 00:42:31 UTC
From:
To:
Dear Maintainer,

   * What led up to the situation?

Originally, trying to figure out why these programs would not load. Ultimately,
discovering that nm (my normal go-to tool) and objdump could not handle these.
I'm not exactly sure what the problem is, but it appears to be the tools cannot
handle binaries that have less than two sections.

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

After discovering that readelf could cope with the problem I was able to repair
the binary headers; however even so, objdump and nm cannot cope.

   * What outcome did you expect instead?

A more sane error message than a section that doesn't exist has an offset outside
the file repeated twice.

Diagnostic output:

$ objdump --all ./mv
objdump: warning: ./mv has a corrupt section with a size (7ba002000) larger than the file size
objdump: warning: ./mv has a corrupt section with a size (7ba002000) larger than the file size
objdump: ./mv: file format not recognized
$ readelf --all ./mv
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 03 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - GNU
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x200078
  Start of program headers:          64 (bytes into file)
  Start of section headers:          120 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         1
  Size of section headers:           0 (bytes)
  Number of section headers:         0
  Section header string table index: 0
readelf: Warning: possibly corrupt ELF file header - it has a non-zero section header offset, but no section headers

There are no sections to group in this file.

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000000000 0x0000000000200000 0x0000000000000000
                 0x00000000000000ee 0x00000000000000ee  R E    0x1000

There is no dynamic section in this file.
$

Here are three binaries with which to reproduce the problem:

begin-base64 755 chmod
f0VMRgIBAQMAAAAAAAAAAAIAPgABAAAAeAAgAAAAAABAAAAAAAAAAHgAAAAA
AAAAAAAAAEAAOAABAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAACAAAAAAAAAA
AAAAAAAADQEAAAAAAAANAQAAAAAAAAAQAAAAAAAAWEiD+AN1S15eMckxwKw8
AHQPLDByPDwIczjB4QMJwevsic5fuFoAAAAPBffYdBtQvwIAAABIjTQlBgEg
ALoHAAAAuAEAAAAPBViXuDwAAAAPBb8CAAAASI00Je8AIAC6FwAAALgBAAAA
DwW/DgAAALg8AAAADwVVc2FnZTogY2htb2Qgbm5ubiBmaWxlCkVycm9yIQo=
====

begin-base64 755 mv
f0VMRgIBAQMAAAAAAAAAAAIAPgABAAAAeAAgAAAAAABAAAAAAAAAAHgAAAAA
AAAAAAAAAEAAOAABAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAACAAAAAAAAAA
AAAAAAAA7gAAAAAAAADuAAAAAAAAAAAQAAAAAAAAWEiD+AN1MV9fXrhSAAAA
DwX32HQbUL8CAAAASI00JecAIAC6BwAAALgBAAAADwVYl7g8AAAADwW/AgAA
AEiNNCXVACAAuhIAAAC4AQAAAA8Fvw4AAAC4PAAAAA8FVXNhZ2U6IG12IHNy
YyBkc3QKRXJyb3IhCg==
====

begin-base64 755 sln
f0VMRgIBAQMAAAAAAAAAAAIAPgABAAAAeAAgAAAAAABAAAAAAAAAAHgAAAAA
AAAAAAAAAEAAOAABAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAACAAAAAAAAAA
AAAAAAAA7wAAAAAAAADvAAAAAAAAAAAQAAAAAAAAWEiD+AN1MV9fXrhYAAAA
DwX32HQbUL8CAAAASI00JegAIAC6BwAAALgBAAAADwVYl7g8AAAADwW/AgAA
AEiNNCXVACAAuhMAAAC4AQAAAA8Fvw4AAAC4PAAAAA8FVXNhZ2U6IHNsbiBz
cmMgZHN0CkVycm9yIQo=
====

#1050483#10
Date:
2023-08-25 16:22:34 UTC
From:
To:
objdump version from sid: GNU objdump (GNU Binutils for Debian) 2.41