~ubuntu-branches/debian/jessie/gdb/jessie

« back to all changes in this revision

Viewing changes to bfd/elfcore.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Jacobowitz
  • Date: 2010-03-20 01:21:29 UTC
  • mfrom: (1.3.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20100320012129-t7h25y8zgr8c2369
Tags: 7.1-1
* New upstream release, including:
  - PIE support (Closes: #346409).
  - C++ improvements, including static_cast<> et al, namespace imports,
    and bug fixes in printing virtual base classes.
  - Multi-program debugging.  One GDB can now debug multiple programs
    at the same time.
  - Python scripting improvements, including gdb.parse_and_eval.
  - Updated MIPS Linux signal frame layout (Closes: #570875).
  - No internal error stepping over _dl_debug_state (Closes: #569551).
* Update to Standards-Version: 3.8.4 (no changes required).
* Include more relevant (and smaller) docs in the gdbserver package
  (Closes: #571132).
* Do not duplicate documentation in gdb64, gdb-source, and libgdb-dev.
* Fix crash when switching into TUI mode (Closes: #568489).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* ELF core file support for BFD.
2
2
   Copyright 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2005, 2007,
3
 
   2008 Free Software Foundation, Inc.
 
3
   2008, 2010 Free Software Foundation, Inc.
4
4
 
5
5
   This file is part of BFD, the Binary File Descriptor library.
6
6
 
184
184
  if (i_ehdrp->e_phentsize != sizeof (Elf_External_Phdr))
185
185
    goto wrong;
186
186
 
 
187
  /* If the program header count is PN_XNUM(0xffff), the actual
 
188
     count is in the first section header.  */
 
189
  if (i_ehdrp->e_shoff != 0 && i_ehdrp->e_phnum == PN_XNUM)
 
190
    {
 
191
      Elf_External_Shdr x_shdr;
 
192
      Elf_Internal_Shdr i_shdr;
 
193
      bfd_signed_vma where = i_ehdrp->e_shoff;
 
194
 
 
195
      if (where != (file_ptr) where)
 
196
        goto wrong;
 
197
 
 
198
      /* Seek to the section header table in the file.  */
 
199
      if (bfd_seek (abfd, (file_ptr) where, SEEK_SET) != 0)
 
200
        goto fail;
 
201
 
 
202
      /* Read the first section header at index 0, and convert to internal
 
203
         form.  */
 
204
      if (bfd_bread (&x_shdr, sizeof (x_shdr), abfd) != sizeof (x_shdr))
 
205
        goto fail;
 
206
      elf_swap_shdr_in (abfd, &x_shdr, &i_shdr);
 
207
 
 
208
      if (i_shdr.sh_info != 0)
 
209
        {
 
210
          i_ehdrp->e_phnum = i_shdr.sh_info;
 
211
          if (i_ehdrp->e_phnum != i_shdr.sh_info)
 
212
            goto wrong;
 
213
        }
 
214
    }
 
215
 
 
216
  /* Sanity check that we can read all of the program headers.
 
217
     It ought to be good enough to just read the last one.  */
 
218
  if (i_ehdrp->e_phnum > 1)
 
219
    {
 
220
      Elf_External_Phdr x_phdr;
 
221
      Elf_Internal_Phdr i_phdr;
 
222
      bfd_signed_vma where;
 
223
 
 
224
      /* Check that we don't have a totally silly number of
 
225
         program headers.  */
 
226
      if (i_ehdrp->e_phnum > (unsigned int) -1 / sizeof (x_phdr)
 
227
          || i_ehdrp->e_phnum > (unsigned int) -1 / sizeof (i_phdr))
 
228
        goto wrong;
 
229
 
 
230
      where = i_ehdrp->e_phoff + (i_ehdrp->e_phnum - 1) * sizeof (x_phdr);
 
231
      if (where != (file_ptr) where)
 
232
        goto wrong;
 
233
      if ((bfd_size_type) where <= i_ehdrp->e_phoff)
 
234
        goto wrong;
 
235
 
 
236
      if (bfd_seek (abfd, (file_ptr) where, SEEK_SET) != 0)
 
237
        goto fail;
 
238
      if (bfd_bread (&x_phdr, sizeof (x_phdr), abfd) != sizeof (x_phdr))
 
239
        goto fail;
 
240
    }
 
241
 
187
242
  /* Move to the start of the program headers.  */
188
243
  if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_phoff, SEEK_SET) != 0)
189
244
    goto wrong;