bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: readelf [PATCH]


From: Nick Clifton
Subject: Re: readelf [PATCH]
Date: 14 Nov 2002 15:39:26 +0000
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.1

Hi Sergei,

> short example with readelf binary.
> The readelf version is 2.13.90 (20021009).
> 
> with hexedit open readelf and go to 0x21 position in file.
> replace value, 0x61 in my case, with 0xFF and save file.
> after little destroy in elf header try launch normal, not changed
> readelf, with option '-a /tmp/readelf'
> and see some errors, segfaults and mistakes.

Ah - thanks very much.  Using this method I was able to make readelf
seg fault as you predicted.  I am going to apply the patch below to
fix this.

I decided that rather than check section_headers everywhere that it is
used, (and similarly program_headers), I would just check the return
code from process_section_headers, and if necessary, disable any tests
that relied upon it.  This seemed to be a simpler solution.

Cheers
        Nick

2002-11-14  Nick Clifton  <address@hidden>

        * readelf.c (process_program_headers): Add comment about return
        value.  Ensure that 0 is returned if the headers are not loaded.
        (process_file): If process_section_headers failed to load the
        headers disable any tests that rely upon them.  Similarly for
        process_program_headers.

Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.180
diff -c -3 -p -w -r1.180 readelf.c
*** binutils/readelf.c  7 Nov 2002 08:33:15 -0000       1.180
--- binutils/readelf.c  14 Nov 2002 14:31:33 -0000
*************** get_64bit_program_headers (file, program
*** 2886,2891 ****
--- 2886,2893 ----
    return 1;
  }
  
+ /* Returns 1 if the program headers were loaded.  */
+ 
  static int
  process_program_headers (file)
       FILE * file;
*************** process_program_headers (file)
*** 2898,2904 ****
      {
        if (do_segments)
        printf (_("\nThere are no program headers in this file.\n"));
!       return 1;
      }
  
    if (do_segments && !do_header)
--- 2900,2906 ----
      {
        if (do_segments)
        printf (_("\nThere are no program headers in this file.\n"));
!       return 0;
      }
  
    if (do_segments && !do_header)
*************** process_file (file_name)
*** 10053,10062 ****
        return 1;
      }
  
!   process_section_headers (file);
  
!   process_program_headers (file);
  
    process_dynamic_segment (file);
  
    process_relocs (file);
--- 10055,10071 ----
        return 1;
      }
  
!   if (! process_section_headers (file))
!     {
!       /* Without loaded section headers we
!        cannot process lots of things.  */
!       do_unwind = do_version = do_dump = do_arch = 0;
  
!       if (! do_using_dynamic)
!       do_syms = do_reloc = 0;
!     }
  
+   if (process_program_headers (file))
      process_dynamic_segment (file);
  
    process_relocs (file);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]