* readelf.c (process_version_sections): Check if VERDEF or VERNEED

sections are present before using them.  Remove code duplication.
	(process_symbol_table): Check if VERDEF or VERNEED sections are
	present before using them.
This commit is contained in:
Jakub Jelinek 2001-01-23 13:49:37 +00:00
parent 015c05c1d0
commit 00d93f3435
2 changed files with 28 additions and 106 deletions

View File

@ -1,3 +1,10 @@
2001-11-23 Jakub Jelinek <jakub@redhat.com>
* readelf.c (process_version_sections): Check if VERDEF or VERNEED
sections are present before using them. Remove code duplication.
(process_symbol_table): Check if VERDEF or VERNEED sections are
present before using them.
2001-01-17 Nick Clifton <nickc@redhat.com> 2001-01-17 Nick Clifton <nickc@redhat.com>
* objcopy.c (copy_object): Fail if attempting to convert the * objcopy.c (copy_object): Fail if attempting to convert the

View File

@ -3997,6 +3997,7 @@ process_version_sections (file)
for (cnt = 0; cnt < total; cnt += 4) for (cnt = 0; cnt < total; cnt += 4)
{ {
int j, nn; int j, nn;
int check_def, check_need;
char * name; char * name;
printf (" %03x:", cnt); printf (" %03x:", cnt);
@ -4016,111 +4017,20 @@ process_version_sections (file)
nn = printf ("%4x%c", data [cnt + j] & 0x7fff, nn = printf ("%4x%c", data [cnt + j] & 0x7fff,
data [cnt + j] & 0x8000 ? 'h' : ' '); data [cnt + j] & 0x8000 ? 'h' : ' ');
if (symbols [cnt + j].st_shndx < SHN_LORESERVE check_def = 1;
&& section_headers[symbols [cnt + j].st_shndx].sh_type check_need = 1;
== SHT_NOBITS) if (symbols [cnt + j].st_shndx >= SHN_LORESERVE
|| section_headers[symbols [cnt + j].st_shndx].sh_type
!= SHT_NOBITS)
{ {
/* We must test both. */ if (symbols [cnt + j].st_shndx == SHN_UNDEF)
Elf_Internal_Verneed ivn; check_def = 0;
unsigned long offset;
offset = version_info [DT_VERSIONTAGIDX (DT_VERNEED)]
- loadaddr;
do
{
Elf_External_Verneed evn;
Elf_External_Vernaux evna;
Elf_Internal_Vernaux ivna;
unsigned long vna_off;
GET_DATA (offset, evn, "version need");
ivn.vn_aux = BYTE_GET (evn.vn_aux);
ivn.vn_next = BYTE_GET (evn.vn_next);
vna_off = offset + ivn.vn_aux;
do
{
GET_DATA (vna_off, evna,
"version need aux (1)");
ivna.vna_next = BYTE_GET (evna.vna_next);
ivna.vna_other = BYTE_GET (evna.vna_other);
vna_off += ivna.vna_next;
}
while (ivna.vna_other != data [cnt + j]
&& ivna.vna_next != 0);
if (ivna.vna_other == data [cnt + j])
{
ivna.vna_name = BYTE_GET (evna.vna_name);
name = strtab + ivna.vna_name;
nn += printf ("(%s%-*s",
name,
12 - (int) strlen (name),
")");
break;
}
else if (ivn.vn_next == 0)
{
if (data [cnt + j] != 0x8001)
{
Elf_Internal_Verdef ivd;
Elf_External_Verdef evd;
offset = version_info
[DT_VERSIONTAGIDX (DT_VERDEF)]
- loadaddr;
do
{
GET_DATA (offset, evd,
"version definition");
ivd.vd_next = BYTE_GET (evd.vd_next);
ivd.vd_ndx = BYTE_GET (evd.vd_ndx);
offset += ivd.vd_next;
}
while (ivd.vd_ndx
!= (data [cnt + j] & 0x7fff)
&& ivd.vd_next != 0);
if (ivd.vd_ndx
== (data [cnt + j] & 0x7fff))
{
Elf_External_Verdaux evda;
Elf_Internal_Verdaux ivda;
ivd.vd_aux = BYTE_GET (evd.vd_aux);
GET_DATA (offset + ivd.vd_aux, evda,
"version definition aux");
ivda.vda_name =
BYTE_GET (evda.vda_name);
name = strtab + ivda.vda_name;
nn +=
printf ("(%s%-*s",
name,
12 - (int) strlen (name),
")");
}
}
break;
}
else else
offset += ivn.vn_next; check_need = 0;
} }
while (ivn.vn_next);
} if (check_need
else if (symbols [cnt + j].st_shndx == SHN_UNDEF) && version_info [DT_VERSIONTAGIDX (DT_VERNEED)])
{ {
Elf_Internal_Verneed ivn; Elf_Internal_Verneed ivn;
unsigned long offset; unsigned long offset;
@ -4164,6 +4074,7 @@ process_version_sections (file)
name, name,
12 - (int) strlen (name), 12 - (int) strlen (name),
")"); ")");
check_def = 0;
break; break;
} }
@ -4171,7 +4082,9 @@ process_version_sections (file)
} }
while (ivn.vn_next); while (ivn.vn_next);
} }
else if (data [cnt + j] != 0x8001)
if (check_def && data [cnt + j] != 0x8001
&& version_info [DT_VERSIONTAGIDX (DT_VERDEF)])
{ {
Elf_Internal_Verdef ivd; Elf_Internal_Verdef ivd;
Elf_External_Verdef evd; Elf_External_Verdef evd;
@ -4548,7 +4461,8 @@ process_symbol_table (file)
if ((vers_data & 0x8000) || vers_data > 1) if ((vers_data & 0x8000) || vers_data > 1)
{ {
if (is_nobits || ! check_def) if (version_info [DT_VERSIONTAGIDX (DT_VERNEED)]
&& (is_nobits || ! check_def))
{ {
Elf_External_Verneed evn; Elf_External_Verneed evn;
Elf_Internal_Verneed ivn; Elf_Internal_Verneed ivn;
@ -4606,7 +4520,8 @@ process_symbol_table (file)
if (check_def) if (check_def)
{ {
if (vers_data != 0x8001) if (vers_data != 0x8001
&& version_info [DT_VERSIONTAGIDX (DT_VERDEF)])
{ {
Elf_Internal_Verdef ivd; Elf_Internal_Verdef ivd;
Elf_Internal_Verdaux ivda; Elf_Internal_Verdaux ivda;