aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfcode.h
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1995-11-29 22:05:37 +0000
committerIan Lance Taylor <ian@airs.com>1995-11-29 22:05:37 +0000
commita9713b91a74c2cc05db65ec58573f388d2c41cc0 (patch)
treec786fa623034d37112d9290b9380d06ff0c36a5c /bfd/elfcode.h
parent8f2bdc203241c910f5ddd969a5ebb5f7199f7edd (diff)
downloadgdb-a9713b91a74c2cc05db65ec58573f388d2c41cc0.zip
gdb-a9713b91a74c2cc05db65ec58573f388d2c41cc0.tar.gz
gdb-a9713b91a74c2cc05db65ec58573f388d2c41cc0.tar.bz2
* opncls.c (bfd_alloc_by_size_t): Set bfd_error_no_memory if
obstack_alloc fails. (bfd_alloc_finish): Set bfd_error_no_memory if obstack_finish fails. * libbfd.c (bfd_zmalloc): Set bfd_error_no_memory if malloc fails. * Many files: don't set bfd_error_no_memory if one of the above routines fails.
Diffstat (limited to 'bfd/elfcode.h')
-rw-r--r--bfd/elfcode.h51
1 files changed, 33 insertions, 18 deletions
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index 740ddda..0b28608 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -495,7 +495,7 @@ elf_object_p (abfd)
new_tdata = ((struct elf_obj_tdata *)
bfd_zalloc (abfd, sizeof (struct elf_obj_tdata)));
if (new_tdata == NULL)
- goto got_no_memory_error;
+ goto got_no_match;
elf_tdata (abfd) = new_tdata;
/* Now that we know the byte order, swap in the rest of the header */
@@ -569,7 +569,7 @@ elf_object_p (abfd)
bfd_alloc (abfd,
sizeof (i_shdrp) * i_ehdrp->e_shnum));
if (!i_shdrp || !elf_elfsections (abfd))
- goto got_no_memory_error;
+ goto got_no_match;
if (bfd_seek (abfd, i_ehdrp->e_shoff, SEEK_SET) != 0)
goto got_no_match;
for (shindex = 0; shindex < i_ehdrp->e_shnum; shindex++)
@@ -585,6 +585,34 @@ elf_object_p (abfd)
goto got_no_match;
}
+ /* Read in the program headers. */
+ if (i_ehdrp->e_phnum == 0)
+ elf_tdata (abfd)->phdr = NULL;
+ else
+ {
+ Elf_Internal_Phdr *i_phdr;
+ unsigned int i;
+
+ elf_tdata (abfd)->phdr = ((Elf_Internal_Phdr *)
+ bfd_alloc (abfd,
+ (i_ehdrp->e_phnum
+ * sizeof (Elf_Internal_Phdr))));
+ if (elf_tdata (abfd)->phdr == NULL)
+ goto got_no_match;
+ if (bfd_seek (abfd, i_ehdrp->e_phoff, SEEK_SET) != 0)
+ goto got_no_match;
+ i_phdr = elf_tdata (abfd)->phdr;
+ for (i = 0; i < i_ehdrp->e_phnum; i++, i_phdr++)
+ {
+ Elf_External_Phdr x_phdr;
+
+ if (bfd_read ((PTR) &x_phdr, sizeof x_phdr, 1, abfd)
+ != sizeof x_phdr)
+ goto got_no_match;
+ elf_swap_phdr_in (abfd, &x_phdr, i_phdr);
+ }
+ }
+
/* Read in the string table containing the names of the sections. We
will need the base pointer to this table later. */
/* We read this inline now, so that we don't have to go through
@@ -618,9 +646,6 @@ elf_object_p (abfd)
got_wrong_format_error:
bfd_set_error (bfd_error_wrong_format);
goto got_no_match;
-got_no_memory_error:
- bfd_set_error (bfd_error_no_memory);
- goto got_no_match;
got_no_match:
if (new_tdata != NULL
&& new_tdata->elf_sect_ptr != NULL)
@@ -671,7 +696,6 @@ write_relocs (abfd, sec, data)
rela_hdr->contents = (PTR) bfd_alloc (abfd, rela_hdr->sh_size);
if (rela_hdr->contents == NULL)
{
- bfd_set_error (bfd_error_no_memory);
*failedp = true;
return;
}
@@ -799,10 +823,7 @@ write_shdrs_and_ehdr (abfd)
x_shdrp = (Elf_External_Shdr *)
bfd_alloc (abfd, sizeof (*x_shdrp) * (i_ehdrp->e_shnum));
if (!x_shdrp)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
+ return false;
for (count = 0; count < i_ehdrp->e_shnum; count++)
{
@@ -865,10 +886,7 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic)
symbase = ((elf_symbol_type *)
bfd_zalloc (abfd, symcount * sizeof (elf_symbol_type)));
if (symbase == (elf_symbol_type *) NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return -1;
- }
+ return -1;
sym = symbase;
/* Temporarily allocate room for the raw ELF symbols. */
@@ -1052,10 +1070,7 @@ elf_slurp_reloc_table (abfd, asect, symbols)
relents = ((arelent *)
bfd_alloc (abfd, asect->reloc_count * sizeof (arelent)));
if (relents == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- goto error_return;
- }
+ goto error_return;
entsize = d->rel_hdr.sh_entsize;
BFD_ASSERT (entsize == sizeof (Elf_External_Rel)