public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* failed reading "Smallest x86 ELF Hello World"
@ 2017-09-28 19:06 Josh Stone
  2017-10-04 18:55 ` Mark Wielaard
  0 siblings, 1 reply; 5+ messages in thread
From: Josh Stone @ 2017-09-28 19:06 UTC (permalink / raw)
  To: elfutils-devel

From http://timelessname.com/elfbin/

Elfutils completely fails to read the file:

$ eu-readelf --version
eu-readelf (elfutils) 0.169
Copyright [...]
$ eu-readelf -a hello
eu-readelf: failed reading 'hello': invalid file descriptor

It's not clear that we should care, since that page even says it's "a
completely corrupted x86 ELF Binary that still runs."  But since it's
good enough for the kernel to run it, I'd hope for *something* from tools.

It also seems weird to get the message "invalid file descriptor", from
ELF_E_INVALID_FILE, which makes it sound like more like EBADF.  The file
descriptor itself is fine - it just doesn't like the ELF within.
(DWARF_E_INVALID_FILE's message is just "invalid file".)


FWIW, binutils readelf does better:

$ readelf --version
GNU readelf version 2.27-24.fc26
Copyright [...]
$ readelf -a hello
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 48 69 20 57 6f 72 6c 64 0a
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            <unknown: 48>
  ABI Version:                       105
  Type:                              EXEC (Executable file)
  Machine:                           Intel 80386
  Version:                           0x1
  Entry point address:               0x8048080
  Start of program headers:          52 (bytes into file)
  Start of section headers:          309248 (bytes into file)
  Flags:                             0x80cd0000
  Size of this header:               22763 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         2
  Size of section headers:           40 (bytes)
  Number of section headers:         5
  Section header string table index: 4
readelf: hello: Error: Reading 0xc8 bytes extends past end of file for
section headers
readelf: hello: Error: Section headers are not available!

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000000 0x08048000 0x08048000 0x000a2 0x000a2 R E 0x1000
  LOAD           0x0000a4 0x080490a4 0x080490a4 0x00009 0x00009  W
0x9007b900

There is no dynamic section in this file.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-10-13 15:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-28 19:06 failed reading "Smallest x86 ELF Hello World" Josh Stone
2017-10-04 18:55 ` Mark Wielaard
2017-10-04 18:57   ` [PATCH 1/2] libelf: Add ELF_E_INVALID_ELF error value Mark Wielaard
2017-10-04 18:57     ` [PATCH 2/2] libelf: Don't error out when sanity checking e_shoff if scncnt is zero Mark Wielaard
2017-10-13 15:09   ` failed reading "Smallest x86 ELF Hello World" Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).