|
|
/* Get REL relocation information at given index. | /* Get REL relocation information at given index. |
Copyright (C) 2000, 2001, 2002 Red Hat, Inc. |
Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 2000. | Written by Ulrich Drepper <drepper@redhat.com>, 2000. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 38-49
gelf_getrel (data, ndx, dst)
|
Link Here
|
|---|
|
if (data_scn == NULL) | if (data_scn == NULL) |
return NULL; | return NULL; |
| |
if (unlikely (ndx < 0)) |
|
{ |
|
__libelf_seterrno (ELF_E_INVALID_INDEX); |
|
return NULL; |
|
} |
|
|
|
if (unlikely (data_scn->d.d_type != ELF_T_REL)) | if (unlikely (data_scn->d.d_type != ELF_T_REL)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_HANDLE); | __libelf_seterrno (ELF_E_INVALID_HANDLE); |
|
Lines 60-66
gelf_getrel (data, ndx, dst)
|
Link Here
|
|---|
|
if (scn->elf->class == ELFCLASS32) | if (scn->elf->class == ELFCLASS32) |
{ | { |
/* We have to convert the data. */ | /* We have to convert the data. */ |
if (unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf32_Rel) |
|
|| unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
result = NULL; | result = NULL; |
|
Lines 80-86
gelf_getrel (data, ndx, dst)
|
Link Here
|
|---|
|
{ | { |
/* Simply copy the data after we made sure we are actually getting | /* Simply copy the data after we made sure we are actually getting |
correct data. */ | correct data. */ |
if (unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf64_Rel) |
|
|| unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
result = NULL; | result = NULL; |
|
|
/* Get symbol information from symbol table at the given index. | /* Get symbol information from symbol table at the given index. |
Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc. |
Copyright (C) 1999, 2000, 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 1999. | Written by Ulrich Drepper <drepper@redhat.com>, 1999. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 57-63
gelf_getsym (data, ndx, dst)
|
Link Here
|
|---|
|
table entries has to be adopted. The user better has provided | table entries has to be adopted. The user better has provided |
a buffer where we can store the information. While copying the | a buffer where we can store the information. While copying the |
data we are converting the format. */ | data we are converting the format. */ |
if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data->d_size)) |
if (INVALID_NDX (ndx, Elf32_Sym) |
|
|| unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data->d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
Lines 86-92
gelf_getsym (data, ndx, dst)
|
Link Here
|
|---|
|
| |
/* The data is already in the correct form. Just make sure the | /* The data is already in the correct form. Just make sure the |
index is OK. */ | index is OK. */ |
if (unlikely ((ndx + 1) * sizeof (GElf_Sym) > data->d_size)) |
if (INVALID_NDX (ndx, GElf_Sym) |
|
|| unlikely ((ndx + 1) * sizeof (GElf_Sym) > data->d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
|
/* Update symbol information in symbol table at the given index. | /* Update symbol information in symbol table at the given index. |
Copyright (C) 2000, 2001, 2002 Red Hat, Inc. |
Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 2000. | Written by Ulrich Drepper <drepper@redhat.com>, 2000. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 39-50
gelf_update_sym (data, ndx, src)
|
Link Here
|
|---|
|
if (data == NULL) | if (data == NULL) |
return 0; | return 0; |
| |
if (unlikely (ndx < 0)) |
|
{ |
|
__libelf_seterrno (ELF_E_INVALID_INDEX); |
|
return 0; |
|
} |
|
|
|
if (unlikely (data_scn->d.d_type != ELF_T_SYM)) | if (unlikely (data_scn->d.d_type != ELF_T_SYM)) |
{ | { |
/* The type of the data better should match. */ | /* The type of the data better should match. */ |
|
Lines 69-75
gelf_update_sym (data, ndx, src)
|
Link Here
|
|---|
|
} | } |
| |
/* Check whether we have to resize the data buffer. */ | /* Check whether we have to resize the data buffer. */ |
if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf32_Sym) |
|
|| unlikely ((ndx + 1) * sizeof (Elf32_Sym) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
Lines 92-98
gelf_update_sym (data, ndx, src)
|
Link Here
|
|---|
|
else | else |
{ | { |
/* Check whether we have to resize the data buffer. */ | /* Check whether we have to resize the data buffer. */ |
if (unlikely ((ndx + 1) * sizeof (Elf64_Sym) > data_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf64_Sym) |
|
|| unlikely ((ndx + 1) * sizeof (Elf64_Sym) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
|
/* Get RELA relocation information at given index. | /* Get RELA relocation information at given index. |
Copyright (C) 2000, 2001, 2002 Red Hat, Inc. |
Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 2000. | Written by Ulrich Drepper <drepper@redhat.com>, 2000. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 38-49
gelf_getrela (data, ndx, dst)
|
Link Here
|
|---|
|
if (data_scn == NULL) | if (data_scn == NULL) |
return NULL; | return NULL; |
| |
if (unlikely (ndx < 0)) |
|
{ |
|
__libelf_seterrno (ELF_E_INVALID_INDEX); |
|
return NULL; |
|
} |
|
|
|
if (unlikely (data_scn->d.d_type != ELF_T_RELA)) | if (unlikely (data_scn->d.d_type != ELF_T_RELA)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_HANDLE); | __libelf_seterrno (ELF_E_INVALID_HANDLE); |
|
Lines 60-66
gelf_getrela (data, ndx, dst)
|
Link Here
|
|---|
|
if (scn->elf->class == ELFCLASS32) | if (scn->elf->class == ELFCLASS32) |
{ | { |
/* We have to convert the data. */ | /* We have to convert the data. */ |
if (unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf32_Rela) |
|
|| unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
result = NULL; | result = NULL; |
|
Lines 81-87
gelf_getrela (data, ndx, dst)
|
Link Here
|
|---|
|
{ | { |
/* Simply copy the data after we made sure we are actually getting | /* Simply copy the data after we made sure we are actually getting |
correct data. */ | correct data. */ |
if (unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf64_Rela) |
|
|| unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
result = NULL; | result = NULL; |
|
|
/* Update additional symbol information in symbol table at the given index. | /* Update additional symbol information in symbol table at the given index. |
Copyright (C) 2000, 2001, 2002 Red Hat, Inc. |
Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 2000. | Written by Ulrich Drepper <drepper@redhat.com>, 2000. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 39-50
gelf_update_syminfo (data, ndx, src)
|
Link Here
|
|---|
|
if (data == NULL) | if (data == NULL) |
return 0; | return 0; |
| |
if (unlikely (ndx < 0)) |
|
{ |
|
__libelf_seterrno (ELF_E_INVALID_INDEX); |
|
return 0; |
|
} |
|
|
|
if (unlikely (data_scn->d.d_type != ELF_T_SYMINFO)) | if (unlikely (data_scn->d.d_type != ELF_T_SYMINFO)) |
{ | { |
/* The type of the data better should match. */ | /* The type of the data better should match. */ |
|
Lines 60-66
gelf_update_syminfo (data, ndx, src)
|
Link Here
|
|---|
|
rwlock_wrlock (scn->elf->lock); | rwlock_wrlock (scn->elf->lock); |
| |
/* Check whether we have to resize the data buffer. */ | /* Check whether we have to resize the data buffer. */ |
if (unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data_scn->d.d_size)) |
if (INVALID_NDX (ndx, GElf_Syminfo) |
|
|| unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
|
/* Get additional symbol information from symbol table at the given index. | /* Get additional symbol information from symbol table at the given index. |
Copyright (C) 2000, 2001, 2002 Red Hat, Inc. |
Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 2000. | Written by Ulrich Drepper <drepper@redhat.com>, 2000. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 51-57
gelf_getsyminfo (data, ndx, dst)
|
Link Here
|
|---|
|
| |
/* The data is already in the correct form. Just make sure the | /* The data is already in the correct form. Just make sure the |
index is OK. */ | index is OK. */ |
if (unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data->d_size)) |
if (INVALID_NDX (ndx, GElf_Syminfo) |
|
|| unlikely ((ndx + 1) * sizeof (GElf_Syminfo) > data->d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
|
/* Append new section. | /* Append new section. |
Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 1998. | Written by Ulrich Drepper <drepper@redhat.com>, 1998. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
|
else | else |
{ | { |
/* We must allocate a new element. */ | /* We must allocate a new element. */ |
Elf_ScnList *newp; |
Elf_ScnList *newp = NULL; |
| |
assert (elf->state.elf.scnincr > 0); | assert (elf->state.elf.scnincr > 0); |
| |
newp = (Elf_ScnList *) calloc (sizeof (Elf_ScnList) |
if ( |
+ ((elf->state.elf.scnincr *= 2) |
#if SIZE_MAX <= 4294967295U |
* sizeof (Elf_Scn)), 1); |
likely (elf->state.elf.scnincr |
|
< SIZE_MAX / 2 / sizeof (Elf_Scn) - sizeof (Elf_ScnList)) |
|
#else |
|
1 |
|
#endif |
|
) |
|
newp = (Elf_ScnList *) calloc (sizeof (Elf_ScnList) |
|
+ ((elf->state.elf.scnincr *= 2) |
|
* sizeof (Elf_Scn)), 1); |
if (newp == NULL) | if (newp == NULL) |
{ | { |
__libelf_seterrno (ELF_E_NOMEM); | __libelf_seterrno (ELF_E_NOMEM); |
|
|
/* Update library in table at the given index. | /* Update library in table at the given index. |
Copyright (C) 2004 Red Hat, Inc. |
Copyright (C) 2004, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 2004. | Written by Ulrich Drepper <drepper@redhat.com>, 2004. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 35-46
gelf_update_lib (data, ndx, src)
|
Link Here
|
|---|
|
if (data == NULL) | if (data == NULL) |
return 0; | return 0; |
| |
if (unlikely (ndx < 0)) |
|
{ |
|
__libelf_seterrno (ELF_E_INVALID_INDEX); |
|
return 0; |
|
} |
|
|
|
Elf_Data_Scn *data_scn = (Elf_Data_Scn *) data; | Elf_Data_Scn *data_scn = (Elf_Data_Scn *) data; |
if (unlikely (data_scn->d.d_type != ELF_T_LIB)) | if (unlikely (data_scn->d.d_type != ELF_T_LIB)) |
{ | { |
|
Lines 54-60
gelf_update_lib (data, ndx, src)
|
Link Here
|
|---|
|
| |
/* Check whether we have to resize the data buffer. */ | /* Check whether we have to resize the data buffer. */ |
int result = 0; | int result = 0; |
if (unlikely ((ndx + 1) * sizeof (Elf64_Lib) > data_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf64_Lib) |
|
|| unlikely ((ndx + 1) * sizeof (Elf64_Lib) > data_scn->d.d_size)) |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
else | else |
{ | { |
|
|
/* Get move structure at the given index. | /* Get move structure at the given index. |
Copyright (C) 2000, 2001, 2002 Red Hat, Inc. |
Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 2000. | Written by Ulrich Drepper <drepper@redhat.com>, 2000. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 50-56
gelf_getmove (data, ndx, dst)
|
Link Here
|
|---|
|
| |
/* The data is already in the correct form. Just make sure the | /* The data is already in the correct form. Just make sure the |
index is OK. */ | index is OK. */ |
if (unlikely ((ndx + 1) * sizeof (GElf_Move) > data->d_size)) |
if (INVALID_NDX (ndx, GElf_Move) |
|
|| unlikely ((ndx + 1) * sizeof (GElf_Move) > data->d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
Lines 164-169
__elfw2(LIBELFBITS,updatemmap) (Elf *elf
|
Link Here
|
|---|
|
/* Write all the sections. Well, only those which are modified. */ | /* Write all the sections. Well, only those which are modified. */ |
if (shnum > 0) | if (shnum > 0) |
{ | { |
|
if (unlikely (shnum > SIZE_MAX / sizeof (Elf_Scn *))) |
|
return 1; |
|
|
ElfW2(LIBELFBITS,Shdr) *shdr_dest; | ElfW2(LIBELFBITS,Shdr) *shdr_dest; |
Elf_ScnList *list = &elf->state.ELFW(elf,LIBELFBITS).scns; | Elf_ScnList *list = &elf->state.ELFW(elf,LIBELFBITS).scns; |
Elf_Scn **scns = (Elf_Scn **) alloca (shnum * sizeof (Elf_Scn *)); | Elf_Scn **scns = (Elf_Scn **) alloca (shnum * sizeof (Elf_Scn *)); |
|
Lines 468-473
__elfw2(LIBELFBITS,updatefile) (Elf *elf
|
Link Here
|
|---|
|
/* Write all the sections. Well, only those which are modified. */ | /* Write all the sections. Well, only those which are modified. */ |
if (shnum > 0) | if (shnum > 0) |
{ | { |
|
if (unlikely (shnum > SIZE_MAX / (sizeof (Elf_Scn *) |
|
+ sizeof (ElfW2(LIBELFBITS,Shdr))))) |
|
return 1; |
|
|
off_t shdr_offset = elf->start_offset + ehdr->e_shoff; | off_t shdr_offset = elf->start_offset + ehdr->e_shoff; |
#if EV_NUM != 2 | #if EV_NUM != 2 |
xfct_t shdr_fctp = __elf_xfctstom[__libelf_version - 1][EV_CURRENT - 1][ELFW(ELFCLASS, LIBELFBITS) - 1][ELF_T_SHDR]; | xfct_t shdr_fctp = __elf_xfctstom[__libelf_version - 1][EV_CURRENT - 1][ELFW(ELFCLASS, LIBELFBITS) - 1][ELF_T_SHDR]; |
|
|
/* Get symbol information and separate section index from symbol table | /* Get symbol information and separate section index from symbol table |
at the given index. | at the given index. |
Copyright (C) 2000, 2001, 2002 Red Hat, Inc. |
Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 2000. | Written by Ulrich Drepper <drepper@redhat.com>, 2000. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 57-63
gelf_getsymshndx (symdata, shndxdata, nd
|
Link Here
|
|---|
|
section index table. */ | section index table. */ |
if (likely (shndxdata_scn != NULL)) | if (likely (shndxdata_scn != NULL)) |
{ | { |
if (unlikely ((ndx + 1) * sizeof (Elf32_Word) > shndxdata_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf32_Word) |
|
|| unlikely ((ndx + 1) * sizeof (Elf32_Word) |
|
> shndxdata_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
Lines 77-83
gelf_getsymshndx (symdata, shndxdata, nd
|
Link Here
|
|---|
|
table entries has to be adopted. The user better has provided | table entries has to be adopted. The user better has provided |
a buffer where we can store the information. While copying the | a buffer where we can store the information. While copying the |
data we are converting the format. */ | data we are converting the format. */ |
if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata->d_size)) |
if (INVALID_NDX (ndx, Elf32_Sym) |
|
|| unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata->d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
Lines 106-112
gelf_getsymshndx (symdata, shndxdata, nd
|
Link Here
|
|---|
|
| |
/* The data is already in the correct form. Just make sure the | /* The data is already in the correct form. Just make sure the |
index is OK. */ | index is OK. */ |
if (unlikely ((ndx + 1) * sizeof (GElf_Sym) > symdata->d_size)) |
if (INVALID_NDX (ndx, GElf_Sym) |
|
|| unlikely ((ndx + 1) * sizeof (GElf_Sym) > symdata->d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
|
/* Update move structure at the given index. | /* Update move structure at the given index. |
Copyright (C) 2000, 2001, 2002 Red Hat, Inc. |
Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 2000. | Written by Ulrich Drepper <drepper@redhat.com>, 2000. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 42-48
gelf_update_move (data, ndx, src)
|
Link Here
|
|---|
|
assert (sizeof (GElf_Move) == sizeof (Elf64_Move)); | assert (sizeof (GElf_Move) == sizeof (Elf64_Move)); |
| |
/* Check whether we have to resize the data buffer. */ | /* Check whether we have to resize the data buffer. */ |
if (unlikely (ndx < 0) |
if (INVALID_NDX (ndx, GElf_Move) |
|| unlikely ((ndx + 1) * sizeof (GElf_Move) > data_scn->d.d_size)) | || unlikely ((ndx + 1) * sizeof (GElf_Move) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
|
|
/* Update information in dynamic table at the given index. | /* Update information in dynamic table at the given index. |
Copyright (C) 2000, 2001, 2002 Red Hat, Inc. |
Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 2000. | Written by Ulrich Drepper <drepper@redhat.com>, 2000. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 38-49
gelf_update_dyn (data, ndx, src)
|
Link Here
|
|---|
|
if (data == NULL) | if (data == NULL) |
return 0; | return 0; |
| |
if (unlikely (ndx < 0)) |
|
{ |
|
__libelf_seterrno (ELF_E_INVALID_INDEX); |
|
return 0; |
|
} |
|
|
|
if (unlikely (data_scn->d.d_type != ELF_T_DYN)) | if (unlikely (data_scn->d.d_type != ELF_T_DYN)) |
{ | { |
/* The type of the data better should match. */ | /* The type of the data better should match. */ |
|
Lines 69-75
gelf_update_dyn (data, ndx, src)
|
Link Here
|
|---|
|
} | } |
| |
/* Check whether we have to resize the data buffer. */ | /* Check whether we have to resize the data buffer. */ |
if (unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf32_Dyn) |
|
|| unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
Lines 83-89
gelf_update_dyn (data, ndx, src)
|
Link Here
|
|---|
|
else | else |
{ | { |
/* Check whether we have to resize the data buffer. */ | /* Check whether we have to resize the data buffer. */ |
if (unlikely ((ndx + 1) * sizeof (Elf64_Dyn) > data_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf64_Dyn) |
|
|| unlikely ((ndx + 1) * sizeof (Elf64_Dyn) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
Lines 220-226
file_read_elf (int fildes, void *map_add
|
Link Here
|
|---|
|
| |
/* Determine the number of sections. */ | /* Determine the number of sections. */ |
scncnt = get_shnum (map_address, e_ident, fildes, offset, maxsize); | scncnt = get_shnum (map_address, e_ident, fildes, offset, maxsize); |
if (scncnt == (size_t) -1l) |
if (scncnt == (size_t) -1l || scncnt > SIZE_MAX / sizeof (Elf_Scn)) |
/* Could not determine the number of sections. */ | /* Could not determine the number of sections. */ |
return NULL; | return NULL; |
| |
|
|
/* Get symbol version information at the given index. | /* Get symbol version information at the given index. |
Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc. |
Copyright (C) 1999, 2000, 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 1999. | Written by Ulrich Drepper <drepper@redhat.com>, 1999. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 59-65
gelf_getversym (data, ndx, dst)
|
Link Here
|
|---|
|
| |
/* The data is already in the correct form. Just make sure the | /* The data is already in the correct form. Just make sure the |
index is OK. */ | index is OK. */ |
if (unlikely ((ndx + 1) * sizeof (GElf_Versym) > data->d_size)) |
if (INVALID_NDX (ndx, GElf_Versym) |
|
|| unlikely ((ndx + 1) * sizeof (GElf_Versym) > data->d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
result = NULL; | result = NULL; |
|
|
/* Create new ELF program header table. | /* Create new ELF program header table. |
Copyright (C) 1999, 2000, 2002 Red Hat, Inc. |
Copyright (C) 1999, 2000, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 1998. | Written by Ulrich Drepper <drepper@redhat.com>, 1998. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 91-96
elfw2(LIBELFBITS,newphdr) (elf, count)
|
Link Here
|
|---|
|
else if (elf->state.ELFW(elf,LIBELFBITS).ehdr->e_phnum != count | else if (elf->state.ELFW(elf,LIBELFBITS).ehdr->e_phnum != count |
|| elf->state.ELFW(elf,LIBELFBITS).phdr == NULL) | || elf->state.ELFW(elf,LIBELFBITS).phdr == NULL) |
{ | { |
|
if (unlikely (count > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Phdr)))) |
|
{ |
|
result = NULL; |
|
goto out; |
|
} |
|
|
/* Allocate a new program header with the appropriate number of | /* Allocate a new program header with the appropriate number of |
elements. */ | elements. */ |
result = (ElfW2(LIBELFBITS,Phdr) *) | result = (ElfW2(LIBELFBITS,Phdr) *) |
|
|
/* Get information from dynamic table at the given index. | /* Get information from dynamic table at the given index. |
Copyright (C) 2000, 2001, 2002 Red Hat, Inc. |
Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 2000. | Written by Ulrich Drepper <drepper@redhat.com>, 2000. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 60-66
gelf_getdyn (data, ndx, dst)
|
Link Here
|
|---|
|
table entries has to be adopted. The user better has provided | table entries has to be adopted. The user better has provided |
a buffer where we can store the information. While copying the | a buffer where we can store the information. While copying the |
data we are converting the format. */ | data we are converting the format. */ |
if (unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf32_Dyn) |
|
|| unlikely ((ndx + 1) * sizeof (Elf32_Dyn) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
Lines 81-87
gelf_getdyn (data, ndx, dst)
|
Link Here
|
|---|
|
| |
/* The data is already in the correct form. Just make sure the | /* The data is already in the correct form. Just make sure the |
index is OK. */ | index is OK. */ |
if (unlikely ((ndx + 1) * sizeof (GElf_Dyn) > data_scn->d.d_size)) |
if (INVALID_NDX (ndx, GElf_Dyn) |
|
|| unlikely ((ndx + 1) * sizeof (GElf_Dyn) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
Lines 144-149
elf_getarsym (elf, ptr)
|
Link Here
|
|---|
|
size_t index_size = atol (tmpbuf); | size_t index_size = atol (tmpbuf); |
| |
if (SARMAG + sizeof (struct ar_hdr) + index_size > elf->maximum_size | if (SARMAG + sizeof (struct ar_hdr) + index_size > elf->maximum_size |
|
#if SIZE_MAX <= 4294967295U |
|
|| n >= SIZE_MAX / sizeof (Elf_Arsym) |
|
#endif |
|| n * sizeof (uint32_t) > index_size) | || n * sizeof (uint32_t) > index_size) |
{ | { |
/* This index table cannot be right since it does not fit into | /* This index table cannot be right since it does not fit into |
|
Lines 531-534
extern uint32_t __libelf_crc32 (uint32_t
|
Link Here
|
|---|
|
} while (0) | } while (0) |
#endif | #endif |
| |
|
/* Convenience macro. Assumes int NDX and TYPE with size at least |
|
2 bytes. */ |
|
#if SIZE_MAX > 4294967295U |
|
# define INVALID_NDX(ndx, type) unlikely (ndx < 0) |
|
#else |
|
# define INVALID_NDX(ndx, type) \ |
|
unlikely ((unsigned int) (ndx) >= SIZE_MAX / sizeof (type)) |
|
#endif |
|
|
#endif /* libelfP.h */ | #endif /* libelfP.h */ |
|
|
/* Get library from table at the given index. | /* Get library from table at the given index. |
Copyright (C) 2004 Red Hat, Inc. |
Copyright (C) 2004, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 2004. | Written by Ulrich Drepper <drepper@redhat.com>, 2004. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 53-59
gelf_getlib (data, ndx, dst)
|
Link Here
|
|---|
|
/* The data is already in the correct form. Just make sure the | /* The data is already in the correct form. Just make sure the |
index is OK. */ | index is OK. */ |
GElf_Lib *result = NULL; | GElf_Lib *result = NULL; |
if (unlikely ((ndx + 1) * sizeof (GElf_Lib) > data->d_size)) |
if (INVALID_NDX (ndx, GElf_Lib) |
|
|| unlikely ((ndx + 1) * sizeof (GElf_Lib) > data->d_size)) |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
else | else |
{ | { |
|
|
/* Update symbol information and section index in symbol table at the | /* Update symbol information and section index in symbol table at the |
given index. | given index. |
Copyright (C) 2000, 2001, 2002 Red Hat, Inc. |
Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 2000. | Written by Ulrich Drepper <drepper@redhat.com>, 2000. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 44-55
gelf_update_symshndx (symdata, shndxdata
|
Link Here
|
|---|
|
if (symdata == NULL) | if (symdata == NULL) |
return 0; | return 0; |
| |
if (unlikely (ndx < 0)) |
|
{ |
|
__libelf_seterrno (ELF_E_INVALID_INDEX); |
|
return 0; |
|
} |
|
|
|
if (unlikely (symdata_scn->d.d_type != ELF_T_SYM)) | if (unlikely (symdata_scn->d.d_type != ELF_T_SYM)) |
{ | { |
/* The type of the data better should match. */ | /* The type of the data better should match. */ |
|
Lines 95-101
gelf_update_symshndx (symdata, shndxdata
|
Link Here
|
|---|
|
} | } |
| |
/* Check whether we have to resize the data buffer. */ | /* Check whether we have to resize the data buffer. */ |
if (unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf32_Sym) |
|
|| unlikely ((ndx + 1) * sizeof (Elf32_Sym) > symdata_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
Lines 118-124
gelf_update_symshndx (symdata, shndxdata
|
Link Here
|
|---|
|
else | else |
{ | { |
/* Check whether we have to resize the data buffer. */ | /* Check whether we have to resize the data buffer. */ |
if (unlikely ((ndx + 1) * sizeof (Elf64_Sym) > symdata_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf64_Sym) |
|
|| unlikely ((ndx + 1) * sizeof (Elf64_Sym) > symdata_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
Lines 66-72
elfw2(LIBELFBITS,getshdr) (scn)
|
Link Here
|
|---|
|
goto out; | goto out; |
| |
size_t shnum; | size_t shnum; |
if (INTUSE (elf_getshnum) (elf, &shnum) != 0) |
if (INTUSE (elf_getshnum) (elf, &shnum) != 0 |
|
|| shnum > SIZE_MAX / sizeof (ElfW2(LIBELFBITS,Shdr))) |
goto out; | goto out; |
size_t size = shnum * sizeof (ElfW2(LIBELFBITS,Shdr)); | size_t size = shnum * sizeof (ElfW2(LIBELFBITS,Shdr)); |
| |
|
|
/* Update RELA relocation information at given index. | /* Update RELA relocation information at given index. |
Copyright (C) 2000, 2001, 2002 Red Hat, Inc. |
Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 2000. | Written by Ulrich Drepper <drepper@redhat.com>, 2000. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 35-46
gelf_update_rela (Elf_Data *dst, int ndx
|
Link Here
|
|---|
|
if (dst == NULL) | if (dst == NULL) |
return 0; | return 0; |
| |
if (unlikely (ndx < 0)) |
|
{ |
|
__libelf_seterrno (ELF_E_INVALID_INDEX); |
|
return 0; |
|
} |
|
|
|
if (unlikely (data_scn->d.d_type != ELF_T_RELA)) | if (unlikely (data_scn->d.d_type != ELF_T_RELA)) |
{ | { |
/* The type of the data better should match. */ | /* The type of the data better should match. */ |
|
Lines 68-74
gelf_update_rela (Elf_Data *dst, int ndx
|
Link Here
|
|---|
|
} | } |
| |
/* Check whether we have to resize the data buffer. */ | /* Check whether we have to resize the data buffer. */ |
if (unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf32_Rela) |
|
|| unlikely ((ndx + 1) * sizeof (Elf32_Rela) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
Lines 84-90
gelf_update_rela (Elf_Data *dst, int ndx
|
Link Here
|
|---|
|
else | else |
{ | { |
/* Check whether we have to resize the data buffer. */ | /* Check whether we have to resize the data buffer. */ |
if (unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf64_Rela) |
|
|| unlikely ((ndx + 1) * sizeof (Elf64_Rela) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
|
/* Update symbol version information. | /* Update symbol version information. |
Copyright (C) 2001, 2002 Red Hat, Inc. |
Copyright (C) 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 2001. | Written by Ulrich Drepper <drepper@redhat.com>, 2001. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 42-48
gelf_update_versym (data, ndx, src)
|
Link Here
|
|---|
|
assert (sizeof (GElf_Versym) == sizeof (Elf64_Versym)); | assert (sizeof (GElf_Versym) == sizeof (Elf64_Versym)); |
| |
/* Check whether we have to resize the data buffer. */ | /* Check whether we have to resize the data buffer. */ |
if (unlikely (ndx < 0) |
if (INVALID_NDX (ndx, GElf_Versym) |
|| unlikely ((ndx + 1) * sizeof (GElf_Versym) > data_scn->d.d_size)) | || unlikely ((ndx + 1) * sizeof (GElf_Versym) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
|
|
/* Update REL relocation information at given index. | /* Update REL relocation information at given index. |
Copyright (C) 2000, 2001, 2002 Red Hat, Inc. |
Copyright (C) 2000, 2001, 2002, 2005 Red Hat, Inc. |
Written by Ulrich Drepper <drepper@redhat.com>, 2000. | Written by Ulrich Drepper <drepper@redhat.com>, 2000. |
| |
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify |
|
Lines 35-46
gelf_update_rel (Elf_Data *dst, int ndx,
|
Link Here
|
|---|
|
if (dst == NULL) | if (dst == NULL) |
return 0; | return 0; |
| |
if (unlikely (ndx < 0)) |
|
{ |
|
__libelf_seterrno (ELF_E_INVALID_INDEX); |
|
return 0; |
|
} |
|
|
|
if (unlikely (data_scn->d.d_type != ELF_T_REL)) | if (unlikely (data_scn->d.d_type != ELF_T_REL)) |
{ | { |
/* The type of the data better should match. */ | /* The type of the data better should match. */ |
|
Lines 66-72
gelf_update_rel (Elf_Data *dst, int ndx,
|
Link Here
|
|---|
|
} | } |
| |
/* Check whether we have to resize the data buffer. */ | /* Check whether we have to resize the data buffer. */ |
if (unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf32_Rel) |
|
|| unlikely ((ndx + 1) * sizeof (Elf32_Rel) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
Lines 81-87
gelf_update_rel (Elf_Data *dst, int ndx,
|
Link Here
|
|---|
|
else | else |
{ | { |
/* Check whether we have to resize the data buffer. */ | /* Check whether we have to resize the data buffer. */ |
if (unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size)) |
if (INVALID_NDX (ndx, Elf64_Rel) |
|
|| unlikely ((ndx + 1) * sizeof (Elf64_Rel) > data_scn->d.d_size)) |
{ | { |
__libelf_seterrno (ELF_E_INVALID_INDEX); | __libelf_seterrno (ELF_E_INVALID_INDEX); |
goto out; | goto out; |
|
Lines 111-116
static uint32_t shstrndx;
|
Link Here
|
|---|
|
/* Array to count references in section groups. */ | /* Array to count references in section groups. */ |
static int *scnref; | static int *scnref; |
| |
|
/* Number of sections. */ |
|
static unsigned int shnum; |
|
|
| |
int | int |
main (int argc, char *argv[]) | main (int argc, char *argv[]) |
|
Lines 300-309
section_name (Ebl *ebl, int idx)
|
Link Here
|
|---|
|
{ | { |
GElf_Shdr shdr_mem; | GElf_Shdr shdr_mem; |
GElf_Shdr *shdr; | GElf_Shdr *shdr; |
|
const char *ret; |
|
|
|
if ((unsigned int) idx > shnum) |
|
return "<invalid>"; |
| |
shdr = gelf_getshdr (elf_getscn (ebl->elf, idx), &shdr_mem); | shdr = gelf_getshdr (elf_getscn (ebl->elf, idx), &shdr_mem); |
| |
return elf_strptr (ebl->elf, shstrndx, shdr->sh_name); |
ret = elf_strptr (ebl->elf, shstrndx, shdr->sh_name); |
|
if (ret == NULL) |
|
return "<invalid>"; |
|
return ret; |
} | } |
| |
| |
|
Lines 325-334
static const int valid_e_machine[] =
|
Link Here
|
|---|
|
(sizeof (valid_e_machine) / sizeof (valid_e_machine[0])) | (sizeof (valid_e_machine) / sizeof (valid_e_machine[0])) |
| |
| |
/* Number of sections. */ |
|
static unsigned int shnum; |
|
|
|
|
|
static void | static void |
check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size) | check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size) |
{ | { |
|
Lines 608-614
check_symtab (Ebl *ebl, GElf_Ehdr *ehdr,
|
Link Here
|
|---|
|
xndxdata = NULL; | xndxdata = NULL; |
} | } |
| |
if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_SYM, 1, EV_CURRENT)) |
size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_SYM, 1, EV_CURRENT); |
|
if (shdr->sh_entsize != sh_entsize) |
ERROR (gettext ("\ | ERROR (gettext ("\ |
section [%2zu] '%s': entry size is does not match ElfXX_Sym\n"), | section [%2zu] '%s': entry size is does not match ElfXX_Sym\n"), |
cnt, section_name (ebl, cnt)); | cnt, section_name (ebl, cnt)); |
|
Lines 646-652
section [%2d] '%s': XINDEX for zeroth en
|
Link Here
|
|---|
|
xndxscnidx, section_name (ebl, xndxscnidx)); | xndxscnidx, section_name (ebl, xndxscnidx)); |
} | } |
| |
for (cnt = 1; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) |
for (cnt = 1; cnt < shdr->sh_size / sh_entsize; ++cnt) |
{ | { |
sym = gelf_getsymshndx (data, xndxdata, cnt, &sym_mem, &xndx); | sym = gelf_getsymshndx (data, xndxdata, cnt, &sym_mem, &xndx); |
if (sym == NULL) | if (sym == NULL) |
|
Lines 664-670
section [%2d] '%s': symbol %zu: invalid
|
Link Here
|
|---|
|
else | else |
{ | { |
name = elf_strptr (ebl->elf, shdr->sh_link, sym->st_name); | name = elf_strptr (ebl->elf, shdr->sh_link, sym->st_name); |
assert (name != NULL); |
assert (name != NULL |
|
|| strshdr->sh_type != SHT_STRTAB); |
} | } |
| |
if (sym->st_shndx == SHN_XINDEX) | if (sym->st_shndx == SHN_XINDEX) |
|
Lines 954-960
is_rel_dyn (Ebl *ebl, GElf_Ehdr *ehdr, i
|
Link Here
|
|---|
|
const GElf_Shdr *rcshdr = gelf_getshdr (scn, &rcshdr_mem); | const GElf_Shdr *rcshdr = gelf_getshdr (scn, &rcshdr_mem); |
assert (rcshdr != NULL); | assert (rcshdr != NULL); |
| |
if (rcshdr->sh_type == SHT_DYNAMIC) |
if (rcshdr->sh_type == SHT_DYNAMIC && rcshdr->sh_entsize) |
{ | { |
/* Found the dynamic section. Look through it. */ | /* Found the dynamic section. Look through it. */ |
Elf_Data *d = elf_getdata (scn, NULL); | Elf_Data *d = elf_getdata (scn, NULL); |
|
Lines 964-977
is_rel_dyn (Ebl *ebl, GElf_Ehdr *ehdr, i
|
Link Here
|
|---|
|
{ | { |
GElf_Dyn dyn_mem; | GElf_Dyn dyn_mem; |
GElf_Dyn *dyn = gelf_getdyn (d, cnt, &dyn_mem); | GElf_Dyn *dyn = gelf_getdyn (d, cnt, &dyn_mem); |
assert (dyn != NULL); |
|
|
if (dyn == NULL) |
|
break; |
| |
if (dyn->d_tag == DT_RELCOUNT) | if (dyn->d_tag == DT_RELCOUNT) |
{ | { |
/* Found it. One last check: does the number | /* Found it. One last check: does the number |
specified number of relative relocations exceed | specified number of relative relocations exceed |
the total number of relocations? */ | the total number of relocations? */ |
if (dyn->d_un.d_val > shdr->sh_size / shdr->sh_entsize) |
if (shdr->sh_entsize |
|
&& dyn->d_un.d_val > shdr->sh_size / shdr->sh_entsize) |
ERROR (gettext ("\ | ERROR (gettext ("\ |
section [%2d] '%s': DT_RELCOUNT value %d too high for this section\n"), | section [%2d] '%s': DT_RELCOUNT value %d too high for this section\n"), |
idx, section_name (ebl, idx), | idx, section_name (ebl, idx), |
|
Lines 1048-1054
section [%2d] '%s': no relocations for m
|
Link Here
|
|---|
|
} | } |
} | } |
| |
if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_RELA, 1, EV_CURRENT)) |
size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_RELA, 1, EV_CURRENT); |
|
if (shdr->sh_entsize != sh_entsize) |
ERROR (gettext ("\ | ERROR (gettext ("\ |
section [%2d] '%s': section entry size does not match ElfXX_Rela\n"), | section [%2d] '%s': section entry size does not match ElfXX_Rela\n"), |
idx, section_name (ebl, idx)); | idx, section_name (ebl, idx)); |
|
Lines 1058-1064
section [%2d] '%s': section entry size d
|
Link Here
|
|---|
|
GElf_Shdr *symshdr = gelf_getshdr (symscn, &symshdr_mem); | GElf_Shdr *symshdr = gelf_getshdr (symscn, &symshdr_mem); |
Elf_Data *symdata = elf_getdata (symscn, NULL); | Elf_Data *symdata = elf_getdata (symscn, NULL); |
| |
for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) |
for (cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) |
{ | { |
GElf_Rela rela_mem; | GElf_Rela rela_mem; |
GElf_Rela *rela; | GElf_Rela *rela; |
|
Lines 1183-1189
section [%2d] '%s': no relocations for m
|
Link Here
|
|---|
|
} | } |
} | } |
| |
if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_REL, 1, EV_CURRENT)) |
size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_REL, 1, EV_CURRENT); |
|
if (shdr->sh_entsize != sh_entsize) |
ERROR (gettext ("\ | ERROR (gettext ("\ |
section [%2d] '%s': section entry size does not match ElfXX_Rel\n"), | section [%2d] '%s': section entry size does not match ElfXX_Rel\n"), |
idx, section_name (ebl, idx)); | idx, section_name (ebl, idx)); |
|
Lines 1193-1199
section [%2d] '%s': section entry size d
|
Link Here
|
|---|
|
GElf_Shdr *symshdr = gelf_getshdr (symscn, &symshdr_mem); | GElf_Shdr *symshdr = gelf_getshdr (symscn, &symshdr_mem); |
Elf_Data *symdata = elf_getdata (symscn, NULL); | Elf_Data *symdata = elf_getdata (symscn, NULL); |
| |
for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) |
for (cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) |
{ | { |
GElf_Rel rel_mem; | GElf_Rel rel_mem; |
GElf_Rel *rel; | GElf_Rel *rel; |
|
Lines 1341-1347
section [%2d] '%s': referenced as string
|
Link Here
|
|---|
|
shdr->sh_link, section_name (ebl, shdr->sh_link), | shdr->sh_link, section_name (ebl, shdr->sh_link), |
idx, section_name (ebl, idx)); | idx, section_name (ebl, idx)); |
| |
if (shdr->sh_entsize != gelf_fsize (ebl->elf, ELF_T_DYN, 1, EV_CURRENT)) |
size_t sh_entsize = gelf_fsize (ebl->elf, ELF_T_DYN, 1, EV_CURRENT); |
|
if (shdr->sh_entsize != sh_entsize) |
ERROR (gettext ("\ | ERROR (gettext ("\ |
section [%2d] '%s': section entry size does not match ElfXX_Dyn\n"), | section [%2d] '%s': section entry size does not match ElfXX_Dyn\n"), |
idx, section_name (ebl, idx)); | idx, section_name (ebl, idx)); |
|
Lines 1351-1357
section [%2d] '%s': section entry size d
|
Link Here
|
|---|
|
idx, section_name (ebl, idx)); | idx, section_name (ebl, idx)); |
| |
bool non_null_warned = false; | bool non_null_warned = false; |
for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) |
for (cnt = 0; cnt < shdr->sh_size / sh_entsize; ++cnt) |
{ | { |
GElf_Dyn dyn_mem; | GElf_Dyn dyn_mem; |
GElf_Dyn *dyn; | GElf_Dyn *dyn; |
|
Lines 1502-1507
section [%2d] '%s': entry size does not
|
Link Here
|
|---|
|
idx, section_name (ebl, idx)); | idx, section_name (ebl, idx)); |
| |
if (symshdr != NULL | if (symshdr != NULL |
|
&& shdr->sh_entsize |
|
&& symshdr->sh_entsize |
&& (shdr->sh_size / shdr->sh_entsize | && (shdr->sh_size / shdr->sh_entsize |
< symshdr->sh_size / symshdr->sh_entsize)) | < symshdr->sh_size / symshdr->sh_entsize)) |
ERROR (gettext ("\ | ERROR (gettext ("\ |
|
Lines 1530-1535
section [%2d] '%s': extended section ind
|
Link Here
|
|---|
|
} | } |
| |
data = elf_getdata (scn, NULL); | data = elf_getdata (scn, NULL); |
|
if (data == NULL) |
|
{ |
|
ERROR (gettext ("section [%2d] '%s': cannot get section data\n"), |
|
idx, section_name (ebl, idx)); |
|
return; |
|
} |
| |
if (*((Elf32_Word *) data->d_buf) != 0) | if (*((Elf32_Word *) data->d_buf) != 0) |
ERROR (gettext ("symbol 0 should have zero extended section index\n")); | ERROR (gettext ("symbol 0 should have zero extended section index\n")); |
|
Lines 1613-1619
section [%2d] '%s': hash table section i
|
Link Here
|
|---|
|
idx, section_name (ebl, idx), (long int) shdr->sh_size, | idx, section_name (ebl, idx), (long int) shdr->sh_size, |
(long int) ((2 + nbucket + nchain) * shdr->sh_entsize)); | (long int) ((2 + nbucket + nchain) * shdr->sh_entsize)); |
| |
if (symshdr != NULL) |
if (symshdr != NULL && symshdr->sh_entsize) |
{ | { |
size_t symsize = symshdr->sh_size / symshdr->sh_entsize; | size_t symsize = symshdr->sh_size / symshdr->sh_entsize; |
size_t cnt; | size_t cnt; |
|
Lines 1910-1917
section [%2d] '%s' refers in sh_link to
|
Link Here
|
|---|
|
return; | return; |
} | } |
| |
if (shdr->sh_size / shdr->sh_entsize |
if (shdr->sh_entsize |
!= symshdr->sh_size / symshdr->sh_entsize) |
&& symshdr->sh_entsize |
|
&& shdr->sh_size / shdr->sh_entsize |
|
!= symshdr->sh_size / symshdr->sh_entsize) |
ERROR (gettext ("\ | ERROR (gettext ("\ |
section [%2d] '%s' has different number of entries than symbol table [%2d] '%s'\n"), | section [%2d] '%s' has different number of entries than symbol table [%2d] '%s'\n"), |
idx, section_name (ebl, idx), | idx, section_name (ebl, idx), |