unconventional segment layout

Alan Modra amodra@bigpond.net.au
Wed Apr 30 04:32:00 GMT 2008


On Wed, Apr 30, 2008 at 01:04:22AM +0300, Yaakov Yaari wrote:
> I encountered a minor bug in readelf that prevents mapping a section to a
> program header, when invoked with -l, if the section is the last one in the
> section table :
> --- readelf.c   2007-10-16 09:58:16.000000000 +0200
> +++ readelf.c.fixed     2008-04-30 00:54:29.000000000 +0300
> @@ -3606,7 +3606,7 @@
> 
>           printf ("   %2.2d     ", i);
> 
> -         for (j = 1; j < elf_header.e_shnum; j++, section++)
> +         for (j = 1; j <= elf_header.e_shnum; j++, section++)
>             {
>               if (ELF_IS_SECTION_IN_SEGMENT_MEMORY(section, segment))
>                 printf ("%s ", SECTION_NAME (section));

I think the intent here was to skip the first SHT_NULL section.

	* readelf.c (process_program_headers): Correct section in segment
	display.

Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.407
diff -u -p -r1.407 readelf.c
--- binutils/readelf.c	15 Apr 2008 04:11:45 -0000	1.407
+++ binutils/readelf.c	30 Apr 2008 00:23:52 -0000
@@ -3682,7 +3682,7 @@ process_program_headers (FILE *file)
 	  Elf_Internal_Shdr *section;
 
 	  segment = program_headers + i;
-	  section = section_headers;
+	  section = section_headers + 1;
 
 	  printf ("   %2.2d     ", i);
 
-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list