* bfd.c (bfd_get_size): New function that gets an upper bound
on the possible size of any object in a bfd. * elf.c (bfd_elf_find_section, elf_get_str_section, elf_get_symtab_upper_bound): Rewrite to avoid NULL pointer dereferences. * elf.c (elf_big_vec, elf_little_vec): Document last three members initialized to NULL.
This commit is contained in:
parent
51db232366
commit
e555d76415
|
@ -1,3 +1,13 @@
|
||||||
|
Sun Dec 27 17:45:05 1992 Fred Fish (fnf@cygnus.com)
|
||||||
|
|
||||||
|
* bfd.c (bfd_get_size): New function that gets an upper bound
|
||||||
|
on the possible size of any object in a bfd.
|
||||||
|
* elf.c (bfd_elf_find_section, elf_get_str_section,
|
||||||
|
elf_get_symtab_upper_bound): Rewrite to avoid NULL pointer
|
||||||
|
dereferences.
|
||||||
|
* elf.c (elf_big_vec, elf_little_vec): Document last three
|
||||||
|
members initialized to NULL.
|
||||||
|
|
||||||
Thu Dec 24 17:49:09 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
|
Thu Dec 24 17:49:09 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
|
||||||
|
|
||||||
* hppa.c: change a 'const' to 'CONST', or else HP C compiler dies
|
* hppa.c: change a 'const' to 'CONST', or else HP C compiler dies
|
||||||
|
|
107
bfd/elf.c
107
bfd/elf.c
|
@ -345,7 +345,7 @@ INTERNAL_FUNCTION
|
||||||
bfd_elf_find_section
|
bfd_elf_find_section
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
struct elf_internal_shdr *bfd_elf_find_section (bfd *abfd, char *name);
|
Elf_Internal_Shdr *bfd_elf_find_section (bfd *abfd, char *name);
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
Helper functions for GDB to locate the string tables.
|
Helper functions for GDB to locate the string tables.
|
||||||
|
@ -355,20 +355,34 @@ DESCRIPTION
|
||||||
mechanisms wouldn't work to find it, even if we had some.
|
mechanisms wouldn't work to find it, even if we had some.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct elf_internal_shdr *
|
Elf_Internal_Shdr *
|
||||||
DEFUN(bfd_elf_find_section, (abfd, name),
|
DEFUN(bfd_elf_find_section, (abfd, name),
|
||||||
bfd *abfd AND
|
bfd *abfd AND
|
||||||
char *name)
|
char *name)
|
||||||
{
|
{
|
||||||
Elf_Internal_Shdr *i_shdrp = elf_elfsections (abfd);
|
Elf_Internal_Shdr *i_shdrp;
|
||||||
char *shstrtab = elf_get_str_section (abfd, elf_elfheader (abfd)->e_shstrndx);
|
Elf_Internal_Shdr *gotit = NULL;
|
||||||
unsigned int max = elf_elfheader (abfd)->e_shnum;
|
char *shstrtab;
|
||||||
|
unsigned int max;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 1; i < max; i++)
|
i_shdrp = elf_elfsections (abfd);
|
||||||
if (!strcmp (&shstrtab[i_shdrp[i].sh_name], name))
|
if (i_shdrp != NULL)
|
||||||
return &i_shdrp[i];
|
{
|
||||||
return 0;
|
shstrtab = elf_get_str_section (abfd, elf_elfheader (abfd)->e_shstrndx);
|
||||||
|
if (shstrtab != NULL)
|
||||||
|
{
|
||||||
|
max = elf_elfheader (abfd)->e_shnum;
|
||||||
|
for (i = 1; i < max; i++)
|
||||||
|
{
|
||||||
|
if (!strcmp (&shstrtab[i_shdrp[i].sh_name], name))
|
||||||
|
{
|
||||||
|
gotit = &i_shdrp[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (gotit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of GDB support. */
|
/* End of GDB support. */
|
||||||
|
@ -378,20 +392,25 @@ DEFUN(elf_get_str_section, (abfd, shindex),
|
||||||
bfd *abfd AND
|
bfd *abfd AND
|
||||||
unsigned int shindex)
|
unsigned int shindex)
|
||||||
{
|
{
|
||||||
Elf_Internal_Shdr *i_shdrp = elf_elfsections (abfd);
|
Elf_Internal_Shdr *i_shdrp;
|
||||||
unsigned int shstrtabsize = i_shdrp[shindex].sh_size;
|
char *shstrtab = NULL;
|
||||||
unsigned int offset = i_shdrp[shindex].sh_offset;
|
unsigned int offset;
|
||||||
char *shstrtab = i_shdrp[shindex].rawdata;
|
unsigned int shstrtabsize;
|
||||||
|
|
||||||
if (shstrtab)
|
i_shdrp = elf_elfsections (abfd);
|
||||||
return shstrtab;
|
if (i_shdrp != NULL)
|
||||||
|
|
||||||
if ((shstrtab = elf_read (abfd, offset, shstrtabsize)) == NULL)
|
|
||||||
{
|
{
|
||||||
return (NULL);
|
shstrtab = i_shdrp[shindex].rawdata;
|
||||||
|
if (shstrtab == NULL)
|
||||||
|
{
|
||||||
|
/* No cached one, attempt to read, and cache what we read. */
|
||||||
|
offset = i_shdrp[shindex].sh_offset;
|
||||||
|
shstrtabsize = i_shdrp[shindex].sh_size;
|
||||||
|
shstrtab = elf_read (abfd, offset, shstrtabsize);
|
||||||
|
i_shdrp[shindex].rawdata = (void*) shstrtab;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
i_shdrp[shindex].rawdata = (void*)shstrtab;
|
return (shstrtab);
|
||||||
return shstrtab;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
@ -2059,12 +2078,17 @@ static unsigned int
|
||||||
DEFUN (elf_get_symtab_upper_bound, (abfd), bfd *abfd)
|
DEFUN (elf_get_symtab_upper_bound, (abfd), bfd *abfd)
|
||||||
{
|
{
|
||||||
unsigned int symcount;
|
unsigned int symcount;
|
||||||
unsigned int symtab_size;
|
unsigned int symtab_size = 0;
|
||||||
Elf_Internal_Shdr *i_shdrp = elf_elfsections (abfd);
|
Elf_Internal_Shdr *i_shdrp;
|
||||||
Elf_Internal_Shdr *hdr = i_shdrp + elf_onesymtab (abfd);
|
Elf_Internal_Shdr *hdr;
|
||||||
|
|
||||||
symcount = hdr->sh_size / sizeof (Elf_External_Sym);
|
i_shdrp = elf_elfsections (abfd);
|
||||||
symtab_size = (symcount - 1 + 1) * (sizeof (asymbol));
|
if (i_shdrp != NULL)
|
||||||
|
{
|
||||||
|
hdr = i_shdrp + elf_onesymtab (abfd);
|
||||||
|
symcount = hdr->sh_size / sizeof (Elf_External_Sym);
|
||||||
|
symtab_size = (symcount - 1 + 1) * (sizeof (asymbol));
|
||||||
|
}
|
||||||
return (symtab_size);
|
return (symtab_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2488,7 +2512,6 @@ bfd_target elf_big_vec =
|
||||||
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
|
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
|
||||||
SEC_CODE | SEC_DATA),
|
SEC_CODE | SEC_DATA),
|
||||||
|
|
||||||
|
|
||||||
/* leading_symbol_char: is the first char of a user symbol
|
/* leading_symbol_char: is the first char of a user symbol
|
||||||
predictable, and if so what is it */
|
predictable, and if so what is it */
|
||||||
0,
|
0,
|
||||||
|
@ -2535,12 +2558,20 @@ bfd_target elf_big_vec =
|
||||||
bfd_false
|
bfd_false
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Initialize a jump table with the standard macro. All names start
|
/* Initialize a jump table with the standard macro. All names start with
|
||||||
with "elf" */
|
"elf" */
|
||||||
JUMP_TABLE(elf),
|
JUMP_TABLE(elf),
|
||||||
|
|
||||||
/* SWAP_TABLE */
|
/* reloc_type_lookup: How applications can find out about amiga relocation
|
||||||
NULL, NULL, NULL
|
types (see documentation on reloc types). */
|
||||||
|
NULL,
|
||||||
|
|
||||||
|
/* _bfd_make_debug_symbol: Back-door to allow format aware applications to
|
||||||
|
create debug symbols while using BFD for everything else. */
|
||||||
|
NULL,
|
||||||
|
|
||||||
|
/* backend_data: */
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
bfd_target elf_little_vec =
|
bfd_target elf_little_vec =
|
||||||
|
@ -2611,10 +2642,18 @@ bfd_target elf_little_vec =
|
||||||
bfd_false
|
bfd_false
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Initialize a jump table with the standard macro. All names start
|
/* Initialize a jump table with the standard macro. All names start with
|
||||||
with "elf" */
|
"elf" */
|
||||||
JUMP_TABLE(elf),
|
JUMP_TABLE(elf),
|
||||||
|
|
||||||
/* SWAP_TABLE */
|
/* reloc_type_lookup: How applications can find out about amiga relocation
|
||||||
NULL, NULL, NULL
|
types (see documentation on reloc types). */
|
||||||
|
NULL,
|
||||||
|
|
||||||
|
/* _bfd_make_debug_symbol: Back-door to allow format aware applications to
|
||||||
|
create debug symbols while using BFD for everything else. */
|
||||||
|
NULL,
|
||||||
|
|
||||||
|
/* backend_data: */
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue