• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修訂0ab2f69a4317b0c133eebac46f1f3eb39f3f7b77 (tree)
時間2000-04-08 05:27:29
作者Michael Snyder <msnyder@vmwa...>
CommiterMichael Snyder

Log Message

2000-04-06 Michael Snyder <msnyder@seadog.cygnus.com>

        • elfcore.h (elf_core_file_p): preserve value of tdata at entry,
          and restore it on failure. Release newly allocated tdata on
          failure.

Change Summary

差異

--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
1+2000-04-06 Michael Snyder <msnyder@seadog.cygnus.com>
2+
3+ * elfcore.h (elf_core_file_p): preserve value of tdata at entry,
4+ and restore it on failure. Release newly allocated tdata on
5+ failure.
6+
17 Fri Apr 7 11:33:47 2000 Jim Wilson <wilson@cygnus.com>
28
39 * dwarf2.c (struct dwarf2_debug): New field dwarf_line_size.
--- a/bfd/elfcore.h
+++ b/bfd/elfcore.h
@@ -83,9 +83,11 @@ elf_core_file_p (abfd)
8383 {
8484 Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
8585 Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
86- Elf_Internal_Phdr *i_phdrp; /* Elf program header, internal form */
86+ Elf_Internal_Phdr *i_phdrp = NULL; /* Elf program header, internal form */
8787 unsigned int phindex;
8888 struct elf_backend_data *ebd;
89+ struct elf_obj_tdata *preserved_tdata = elf_tdata (abfd);
90+ struct elf_obj_tdata *new_tdata = NULL;
8991
9092 /* Read in the ELF header in external format. */
9193 if (bfd_read ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd) != sizeof (x_ehdr))
@@ -98,9 +100,7 @@ elf_core_file_p (abfd)
98100 /* Check the magic number. */
99101 if (elf_file_p (&x_ehdr) == false)
100102 {
101- wrong:
102- bfd_set_error (bfd_error_wrong_format);
103- return NULL;
103+ goto wrong;
104104 }
105105
106106 /* FIXME: Check EI_VERSION here ! */
@@ -125,12 +125,11 @@ elf_core_file_p (abfd)
125125 }
126126
127127 /* Give abfd an elf_obj_tdata. */
128- elf_tdata (abfd) =
128+ new_tdata =
129129 (struct elf_obj_tdata *) bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
130- if (elf_tdata (abfd) == NULL)
130+ if (new_tdata == NULL)
131131 return NULL;
132-
133- /* FIXME: from here on down, "goto wrong" will leak memory. */
132+ elf_tdata (abfd) = new_tdata;
134133
135134 /* Swap in the rest of the header, now that we have the byte order. */
136135 i_ehdrp = elf_elfheader (abfd);
@@ -189,7 +188,7 @@ elf_core_file_p (abfd)
189188 i_phdrp = (Elf_Internal_Phdr *)
190189 bfd_alloc (abfd, sizeof (*i_phdrp) * i_ehdrp->e_phnum);
191190 if (!i_phdrp)
192- return NULL;
191+ goto fail;
193192
194193 elf_tdata (abfd)->phdr = i_phdrp;
195194
@@ -199,7 +198,7 @@ elf_core_file_p (abfd)
199198 Elf_External_Phdr x_phdr;
200199 if (bfd_read ((PTR) &x_phdr, sizeof (x_phdr), 1, abfd)
201200 != sizeof (x_phdr))
202- return NULL;
201+ goto fail;
203202
204203 elf_swap_phdr_in (abfd, &x_phdr, i_phdrp + phindex);
205204 }
@@ -208,7 +207,7 @@ elf_core_file_p (abfd)
208207 for (phindex = 0; phindex < i_ehdrp->e_phnum; ++phindex)
209208 {
210209 if (!_bfd_elfcore_section_from_phdr (abfd, i_phdrp + phindex, phindex))
211- return NULL;
210+ goto fail;
212211 }
213212
214213 /* Set the machine architecture. */
@@ -216,7 +215,7 @@ elf_core_file_p (abfd)
216215 {
217216 /* It's OK if this fails for the generic target. */
218217 if (ebd->elf_machine_code != EM_NONE)
219- return NULL;
218+ goto fail;
220219 }
221220
222221 /* Save the entry point from the ELF header. */
@@ -231,4 +230,14 @@ elf_core_file_p (abfd)
231230 }
232231
233232 return abfd->xvec;
233+
234+wrong:
235+ bfd_set_error (bfd_error_wrong_format);
236+fail:
237+ if (i_phdrp != NULL)
238+ bfd_release (abfd, i_phdrp);
239+ if (new_tdata != NULL)
240+ bfd_release (abfd, new_tdata);
241+ elf_tdata (abfd) = preserved_tdata;
242+ return NULL;
234243 }