* Another BFD corefile issue
@ 2000-04-06 20:15 Michael Snyder
2001-09-05 0:12 ` Michael Snyder
0 siblings, 1 reply; 2+ messages in thread
From: Michael Snyder @ 2000-04-06 20:15 UTC (permalink / raw)
To: gdb
Also in elfcore.h, elf64_core_file_p may be called more than once from
bfd_check_format_matches. If an earlier call matches, and a later call
ALMOST matches, it may clobber the earlier allocated pointer for
elf_obj_data. I believe that the elf_zalloc call for elf_obj_data is done
too early, and I would like to move it down to just before it is actually
needed -- thus reducing the chance of it being called on a near-match.
The circumstance where this bites us is when elf64-sparc target comes
before elf64-big.
2000-04-06 Michael Snyder <msnyder@seadog.cygnus.com>
* elfcore.h (elf_core_file_p): delay allocating elf_obj_data
until it is needed, reducing the chances of memory leaks or
good data being clobbered unnecessarily.
Index: elfcore.h
===================================================================
RCS file: /cvs/src/src/bfd/elfcore.h,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 elfcore.h
*** elfcore.h 1999/05/03 07:28:57 1.1.1.1
--- elfcore.h 2000/04/07 03:04:12
***************
*** 124,137 ****
goto wrong;
}
- /* Give abfd an elf_obj_tdata. */
- elf_tdata (abfd) =
- (struct elf_obj_tdata *) bfd_zalloc (abfd, sizeof (struct
elf_obj_tdata));
- if (elf_tdata (abfd) == NULL)
- return NULL;
-
- /* FIXME: from here on down, "goto wrong" will leak memory. */
-
/* Swap in the rest of the header, now that we have the byte order. */
i_ehdrp = elf_elfheader (abfd);
elf_swap_ehdr_in (abfd, &x_ehdr, i_ehdrp);
--- 124,129 ----
***************
*** 191,196 ****
--- 183,197 ----
if (!i_phdrp)
return NULL;
+ /* Give abfd an elf_obj_tdata. */
+ elf_tdata (abfd) =
+ (struct elf_obj_tdata *) bfd_zalloc (abfd, sizeof (struct
elf_obj_tdata));
+ if (elf_tdata (abfd) == NULL)
+ return NULL;
+
+ /* FIXME: from here on down, "goto wrong" will leak memory.
+ As will "return NULL". */
+
elf_tdata (abfd)->phdr = i_phdrp;
/* Read and convert to internal form. */
^ permalink raw reply [flat|nested] 2+ messages in thread* Another BFD corefile issue
2000-04-06 20:15 Another BFD corefile issue Michael Snyder
@ 2001-09-05 0:12 ` Michael Snyder
0 siblings, 0 replies; 2+ messages in thread
From: Michael Snyder @ 2001-09-05 0:12 UTC (permalink / raw)
To: gdb
Also in elfcore.h, elf64_core_file_p may be called more than once from
bfd_check_format_matches. If an earlier call matches, and a later call
ALMOST matches, it may clobber the earlier allocated pointer for
elf_obj_data. I believe that the elf_zalloc call for elf_obj_data is done
too early, and I would like to move it down to just before it is actually
needed -- thus reducing the chance of it being called on a near-match.
The circumstance where this bites us is when elf64-sparc target comes
before elf64-big.
2000-04-06 Michael Snyder <msnyder@seadog.cygnus.com>
* elfcore.h (elf_core_file_p): delay allocating elf_obj_data
until it is needed, reducing the chances of memory leaks or
good data being clobbered unnecessarily.
Index: elfcore.h
===================================================================
RCS file: /cvs/src/src/bfd/elfcore.h,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 elfcore.h
*** elfcore.h 1999/05/03 07:28:57 1.1.1.1
--- elfcore.h 2000/04/07 03:04:12
***************
*** 124,137 ****
goto wrong;
}
- /* Give abfd an elf_obj_tdata. */
- elf_tdata (abfd) =
- (struct elf_obj_tdata *) bfd_zalloc (abfd, sizeof (struct
elf_obj_tdata));
- if (elf_tdata (abfd) == NULL)
- return NULL;
-
- /* FIXME: from here on down, "goto wrong" will leak memory. */
-
/* Swap in the rest of the header, now that we have the byte order. */
i_ehdrp = elf_elfheader (abfd);
elf_swap_ehdr_in (abfd, &x_ehdr, i_ehdrp);
--- 124,129 ----
***************
*** 191,196 ****
--- 183,197 ----
if (!i_phdrp)
return NULL;
+ /* Give abfd an elf_obj_tdata. */
+ elf_tdata (abfd) =
+ (struct elf_obj_tdata *) bfd_zalloc (abfd, sizeof (struct
elf_obj_tdata));
+ if (elf_tdata (abfd) == NULL)
+ return NULL;
+
+ /* FIXME: from here on down, "goto wrong" will leak memory.
+ As will "return NULL". */
+
elf_tdata (abfd)->phdr = i_phdrp;
/* Read and convert to internal form. */
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-09-05 0:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-06 20:15 Another BFD corefile issue Michael Snyder
2001-09-05 0:12 ` Michael Snyder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox