This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Fix for readelf hex-dump SHT_NOBITS bug
- From: Marshall T. Vandegrift <llasram at wuli dot nu>
- To: binutils at sources dot redhat dot com
- Date: Thu, 23 Oct 2003 22:57:59 -0400
- Subject: [PATCH] Fix for readelf hex-dump SHT_NOBITS bug
- Cancel-lock: sha1:OeVhAgFyTW/nbtgBXcryvqomWR4=
Hi,
This looks like an obvious fix to me. Currently, `readelf --hex-dump'
on a SHT_NOBITS section will attempt to dump the section's sh_size
bytes from the file (failing cleanly if the file is too small). This
patch makes it treat SHT_NOBITS sections as zero bytes in size.
2003-10-23 Marshall T. Vandegrift <llasram@wuli.nu>
* readelf.c (dump_section): Correctly treat SHT_NOBITS sections as
zero bytes in size.
diff -aurpE binutils/binutils/readelf.c binutils-modified/binutils/readelf.c
--- binutils/binutils/readelf.c 2003-10-23 22:34:41.000000000 -0400
+++ binutils-modified/binutils/readelf.c 2003-10-23 22:30:25.000000000 -0400
@@ -6055,7 +6055,7 @@ dump_section (Elf_Internal_Shdr *section
bytes = section->sh_size;
- if (bytes == 0)
+ if (bytes == 0 || section->sh_type == SHT_NOBITS)
{
printf (_("\nSection '%s' has no data to dump.\n"),
SECTION_NAME (section));
--
Marshall T. Vandegrift <llasram@wuli.nu>
A lie which has the air of truth is preferable to
an accurate statement which seems to be false.
-- Kai KÄ'Ås ibn Iskandar, the /QÄbÅs-nÄma/