if (filesz > SIZE_MAX / sizeof (Elf32_Nhdr))
continue;
- assert (sizeof (Elf32_Nhdr) == sizeof (Elf64_Nhdr));
+ eu_static_assert (sizeof (Elf32_Nhdr) == sizeof (Elf64_Nhdr));
void *notes;
if (ei_data == MY_ELFDATA
reg_desc += sizeof val64;
val64 = (elf_getident (core, NULL)[EI_DATA] == ELFDATA2MSB
? be64toh (val64) : le64toh (val64));
- assert (sizeof (*thread->unwound->regs) == sizeof val64);
+ eu_static_assert (sizeof (*thread->unwound->regs) == sizeof val64);
val = val64;
break;
default:
if (fd < 0)
return 1;
- assert (sizeof (Elf32_Nhdr) == sizeof (GElf_Nhdr));
- assert (sizeof (Elf64_Nhdr) == sizeof (GElf_Nhdr));
+ eu_static_assert (sizeof (Elf32_Nhdr) == sizeof (GElf_Nhdr));
+ eu_static_assert (sizeof (Elf64_Nhdr) == sizeof (GElf_Nhdr));
union
{
GElf_Nhdr nhdr;
/* We access some data structures directly. Make sure the 32 and
64 bit variants are laid out the same. */
- assert (offsetof (Elf32_Ehdr, e_machine)
- == offsetof (Elf64_Ehdr, e_machine));
- assert (sizeof (((Elf32_Ehdr *) 0)->e_machine)
- == sizeof (((Elf64_Ehdr *) 0)->e_machine));
- assert (offsetof (Elf, state.elf32.ehdr)
- == offsetof (Elf, state.elf64.ehdr));
+ eu_static_assert (offsetof (Elf32_Ehdr, e_machine)
+ == offsetof (Elf64_Ehdr, e_machine));
+ eu_static_assert (sizeof (((Elf32_Ehdr *) 0)->e_machine)
+ == sizeof (((Elf64_Ehdr *) 0)->e_machine));
+ eu_static_assert (offsetof (Elf, state.elf32.ehdr)
+ == offsetof (Elf, state.elf64.ehdr));
/* Prefer taking the information from the ELF file. */
if (elf == NULL)
return NULL;
assert ((unsigned int) scncnt == scncnt);
- assert (offsetof (struct Elf, state.elf32.scns)
- == offsetof (struct Elf, state.elf64.scns));
+ eu_static_assert (offsetof (struct Elf, state.elf32.scns)
+ == offsetof (struct Elf, state.elf64.scns));
elf->state.elf32.scns.cnt = scncnt;
elf->state.elf32.scns.max = scnmax;
result->state.elf.scnincr = NSCNSALLOC;
/* We have allocated room for some sections. */
- assert (offsetof (struct Elf, state.elf32.scns)
- == offsetof (struct Elf, state.elf64.scns));
+ eu_static_assert (offsetof (struct Elf, state.elf32.scns)
+ == offsetof (struct Elf, state.elf64.scns));
result->state.elf.scns_last = &result->state.elf32.scns;
result->state.elf32.scns.max = NSCNSALLOC;
}
# include <config.h>
#endif
-#include <assert.h>
#include <stddef.h>
#include "libelfP.h"
#include "common.h"
retval->state.elf.scnincr = 10;
/* We have allocated room for some sections. */
- assert (offsetof (struct Elf, state.elf32.scns)
- == offsetof (struct Elf, state.elf64.scns));
+ eu_static_assert (offsetof (struct Elf, state.elf32.scns)
+ == offsetof (struct Elf, state.elf64.scns));
retval->state.elf.scns_last = &retval->state.elf32.scns;
retval->state.elf32.scns.max = elf->state.elf32.scns.max;
# include <config.h>
#endif
-#include <assert.h>
#include <errno.h>
#include <gelf.h>
#include <stddef.h>
/* We rely here on the fact that the `elf' element is a common prefix
of `elf32' and `elf64'. */
- assert (offsetof (struct Elf, state.elf.ehdr)
- == offsetof (struct Elf, state.elf32.ehdr));
- assert (sizeof (elf->state.elf.ehdr)
- == sizeof (elf->state.elf32.ehdr));
- assert (offsetof (struct Elf, state.elf.ehdr)
- == offsetof (struct Elf, state.elf64.ehdr));
- assert (sizeof (elf->state.elf.ehdr)
- == sizeof (elf->state.elf64.ehdr));
+ eu_static_assert (offsetof (struct Elf, state.elf.ehdr)
+ == offsetof (struct Elf, state.elf32.ehdr));
+ eu_static_assert (sizeof (elf->state.elf.ehdr)
+ == sizeof (elf->state.elf32.ehdr));
+ eu_static_assert (offsetof (struct Elf, state.elf.ehdr)
+ == offsetof (struct Elf, state.elf64.ehdr));
+ eu_static_assert (sizeof (elf->state.elf.ehdr)
+ == sizeof (elf->state.elf64.ehdr));
if (unlikely (elf->state.elf.ehdr == NULL))
{
/* We rely on the prefix of the `elf', `elf32', and `elf64' element
being the same. */
- assert (offsetof (Elf, state.elf.scns_last)
- == offsetof (Elf, state.elf32.scns_last));
- assert (offsetof (Elf, state.elf.scns_last)
- == offsetof (Elf, state.elf64.scns_last));
- assert (offsetof (Elf, state.elf32.scns)
- == offsetof (Elf, state.elf64.scns));
+ eu_static_assert (offsetof (Elf, state.elf.scns_last)
+ == offsetof (Elf, state.elf32.scns_last));
+ eu_static_assert (offsetof (Elf, state.elf.scns_last)
+ == offsetof (Elf, state.elf64.scns_last));
+ eu_static_assert (offsetof (Elf, state.elf32.scns)
+ == offsetof (Elf, state.elf64.scns));
rwlock_wrlock (elf->lock);
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
else
{
/* If this is a 64 bit object it's easy. */
- assert (sizeof (GElf_auxv_t) == sizeof (Elf64_auxv_t));
+ eu_static_assert (sizeof (GElf_auxv_t) == sizeof (Elf64_auxv_t));
/* The data is already in the correct form. Just make sure the
index is OK. */
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
else
{
/* If this is a 64 bit object it's easy. */
- assert (sizeof (GElf_Dyn) == sizeof (Elf64_Dyn));
+ eu_static_assert (sizeof (GElf_Dyn) == sizeof (Elf64_Dyn));
/* The data is already in the correct form. Just make sure the
index is OK. */
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
/* The on disk format of Elf32_Lib and Elf64_Lib is identical. So
we can simplify things significantly. */
- assert (sizeof (GElf_Lib) == sizeof (Elf32_Lib));
- assert (sizeof (GElf_Lib) == sizeof (Elf64_Lib));
+ eu_static_assert (sizeof (GElf_Lib) == sizeof (Elf32_Lib));
+ eu_static_assert (sizeof (GElf_Lib) == sizeof (Elf64_Lib));
/* The data is already in the correct form. Just make sure the
index is OK. */
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
else
{
/* If this is a 64 bit object it's easy. */
- assert (sizeof (GElf_Sym) == sizeof (Elf64_Sym));
+ eu_static_assert (sizeof (GElf_Sym) == sizeof (Elf64_Sym));
/* The data is already in the correct form. Just make sure the
index is OK. */
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
}
/* The types for 32 and 64 bit are the same. Lucky us. */
- assert (sizeof (GElf_Syminfo) == sizeof (Elf32_Syminfo));
- assert (sizeof (GElf_Syminfo) == sizeof (Elf64_Syminfo));
+ eu_static_assert (sizeof (GElf_Syminfo) == sizeof (Elf32_Syminfo));
+ eu_static_assert (sizeof (GElf_Syminfo) == sizeof (Elf64_Syminfo));
rwlock_rdlock (((Elf_Data_Scn *) data)->s->elf->lock);
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
else
{
/* If this is a 64 bit object it's easy. */
- assert (sizeof (GElf_Sym) == sizeof (Elf64_Sym));
+ eu_static_assert (sizeof (GElf_Sym) == sizeof (Elf64_Sym));
/* The data is already in the correct form. Just make sure the
index is OK. */
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
/* It's easy to handle this type. It has the same size for 32 and
64 bit objects. */
- assert (sizeof (GElf_Verdaux) == sizeof (Elf32_Verdaux));
- assert (sizeof (GElf_Verdaux) == sizeof (Elf64_Verdaux));
+ eu_static_assert (sizeof (GElf_Verdaux) == sizeof (Elf32_Verdaux));
+ eu_static_assert (sizeof (GElf_Verdaux) == sizeof (Elf64_Verdaux));
rwlock_rdlock (((Elf_Data_Scn *) data)->s->elf->lock);
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
/* It's easy to handle this type. It has the same size for 32 and
64 bit objects. */
- assert (sizeof (GElf_Verdef) == sizeof (Elf32_Verdef));
- assert (sizeof (GElf_Verdef) == sizeof (Elf64_Verdef));
+ eu_static_assert (sizeof (GElf_Verdef) == sizeof (Elf32_Verdef));
+ eu_static_assert (sizeof (GElf_Verdef) == sizeof (Elf64_Verdef));
rwlock_rdlock (((Elf_Data_Scn *) data)->s->elf->lock);
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
/* It's easy to handle this type. It has the same size for 32 and
64 bit objects. And fortunately the `ElfXXX_Vernaux' records
also have the same size. */
- assert (sizeof (GElf_Vernaux) == sizeof (Elf32_Verneed));
- assert (sizeof (GElf_Vernaux) == sizeof (Elf64_Verneed));
- assert (sizeof (GElf_Vernaux) == sizeof (Elf32_Vernaux));
- assert (sizeof (GElf_Vernaux) == sizeof (Elf64_Vernaux));
+ eu_static_assert (sizeof (GElf_Vernaux) == sizeof (Elf32_Verneed));
+ eu_static_assert (sizeof (GElf_Vernaux) == sizeof (Elf64_Verneed));
+ eu_static_assert (sizeof (GElf_Vernaux) == sizeof (Elf32_Vernaux));
+ eu_static_assert (sizeof (GElf_Vernaux) == sizeof (Elf64_Vernaux));
rwlock_rdlock (((Elf_Data_Scn *) data)->s->elf->lock);
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
/* It's easy to handle this type. It has the same size for 32 and
64 bit objects. And fortunately the `ElfXXX_Vernaux' records
also have the same size. */
- assert (sizeof (GElf_Verneed) == sizeof (Elf32_Verneed));
- assert (sizeof (GElf_Verneed) == sizeof (Elf64_Verneed));
- assert (sizeof (GElf_Verneed) == sizeof (Elf32_Vernaux));
- assert (sizeof (GElf_Verneed) == sizeof (Elf64_Vernaux));
+ eu_static_assert (sizeof (GElf_Verneed) == sizeof (Elf32_Verneed));
+ eu_static_assert (sizeof (GElf_Verneed) == sizeof (Elf64_Verneed));
+ eu_static_assert (sizeof (GElf_Verneed) == sizeof (Elf32_Vernaux));
+ eu_static_assert (sizeof (GElf_Verneed) == sizeof (Elf64_Vernaux));
rwlock_rdlock (((Elf_Data_Scn *) data)->s->elf->lock);
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
/* It's easy to handle this type. It has the same size for 32 and
64 bit objects. */
- assert (sizeof (GElf_Versym) == sizeof (Elf32_Versym));
- assert (sizeof (GElf_Versym) == sizeof (Elf64_Versym));
+ eu_static_assert (sizeof (GElf_Versym) == sizeof (Elf32_Versym));
+ eu_static_assert (sizeof (GElf_Versym) == sizeof (Elf64_Versym));
rwlock_rdlock (scn->elf->lock);
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <stdlib.h>
}
/* The types for 32 and 64 bit are the same. Lucky us. */
- assert (sizeof (GElf_Syminfo) == sizeof (Elf32_Syminfo));
- assert (sizeof (GElf_Syminfo) == sizeof (Elf64_Syminfo));
+ eu_static_assert (sizeof (GElf_Syminfo) == sizeof (Elf32_Syminfo));
+ eu_static_assert (sizeof (GElf_Syminfo) == sizeof (Elf64_Syminfo));
scn = data_scn->s;
rwlock_wrlock (scn->elf->lock);
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
return 0;
/* The types for 32 and 64 bit are the same. Lucky us. */
- assert (sizeof (GElf_Verdaux) == sizeof (Elf32_Verdaux));
- assert (sizeof (GElf_Verdaux) == sizeof (Elf64_Verdaux));
+ eu_static_assert (sizeof (GElf_Verdaux) == sizeof (Elf32_Verdaux));
+ eu_static_assert (sizeof (GElf_Verdaux) == sizeof (Elf64_Verdaux));
/* Check whether we have to resize the data buffer. */
if (unlikely (offset < 0)
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
return 0;
/* The types for 32 and 64 bit are the same. Lucky us. */
- assert (sizeof (GElf_Verdef) == sizeof (Elf32_Verdef));
- assert (sizeof (GElf_Verdef) == sizeof (Elf64_Verdef));
+ eu_static_assert (sizeof (GElf_Verdef) == sizeof (Elf32_Verdef));
+ eu_static_assert (sizeof (GElf_Verdef) == sizeof (Elf64_Verdef));
/* Check whether we have to resize the data buffer. */
if (unlikely (offset < 0)
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
return 0;
/* The types for 32 and 64 bit are the same. Lucky us. */
- assert (sizeof (GElf_Vernaux) == sizeof (Elf32_Vernaux));
- assert (sizeof (GElf_Vernaux) == sizeof (Elf64_Vernaux));
+ eu_static_assert (sizeof (GElf_Vernaux) == sizeof (Elf32_Vernaux));
+ eu_static_assert (sizeof (GElf_Vernaux) == sizeof (Elf64_Vernaux));
/* Check whether we have to resize the data buffer. */
if (unlikely (offset < 0)
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
return 0;
/* The types for 32 and 64 bit are the same. Lucky us. */
- assert (sizeof (GElf_Verneed) == sizeof (Elf32_Verneed));
- assert (sizeof (GElf_Verneed) == sizeof (Elf64_Verneed));
+ eu_static_assert (sizeof (GElf_Verneed) == sizeof (Elf32_Verneed));
+ eu_static_assert (sizeof (GElf_Verneed) == sizeof (Elf64_Verneed));
/* Check whether we have to resize the data buffer. */
if (unlikely (offset < 0)
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <stdlib.h>
return 0;
/* The types for 32 and 64 bit are the same. Lucky us. */
- assert (sizeof (GElf_Versym) == sizeof (Elf32_Versym));
- assert (sizeof (GElf_Versym) == sizeof (Elf64_Versym));
+ eu_static_assert (sizeof (GElf_Versym) == sizeof (Elf32_Versym));
+ eu_static_assert (sizeof (GElf_Versym) == sizeof (Elf64_Versym));
/* Check whether we have to resize the data buffer. */
if (INVALID_NDX (ndx, GElf_Versym, &data_scn->d))
the GNU Lesser General Public License along with this program. If
not, see <http://www.gnu.org/licenses/>. */
-#include <assert.h>
#include <gelf.h>
#include "libelfP.h"
{
/* Note that the header is always the same size, but the padding
differs for GNU Property notes. */
- assert (sizeof (Elf32_Nhdr) == sizeof (Elf64_Nhdr));
+ eu_static_assert (sizeof (Elf32_Nhdr) == sizeof (Elf64_Nhdr));
while (len >= sizeof (Elf32_Nhdr))
{
the GNU Lesser General Public License along with this program. If
not, see <http://www.gnu.org/licenses/>. */
-#include <assert.h>
#include <gelf.h>
#include "libelfP.h"
GElf_Verdef *dsrc;
/* We rely on the types being all the same size. */
- assert (sizeof (GElf_Verdef) == sizeof (Elf32_Verdef));
- assert (sizeof (GElf_Verdaux) == sizeof (Elf32_Verdaux));
- assert (sizeof (GElf_Verdef) == sizeof (Elf64_Verdef));
- assert (sizeof (GElf_Verdaux) == sizeof (Elf64_Verdaux));
+ eu_static_assert (sizeof (GElf_Verdef) == sizeof (Elf32_Verdef));
+ eu_static_assert (sizeof (GElf_Verdaux) == sizeof (Elf32_Verdaux));
+ eu_static_assert (sizeof (GElf_Verdef) == sizeof (Elf64_Verdef));
+ eu_static_assert (sizeof (GElf_Verdaux) == sizeof (Elf64_Verdaux));
if (len == 0)
return;
GElf_Verneed *nsrc;
/* We rely on the types being all the same size. */
- assert (sizeof (GElf_Verneed) == sizeof (Elf32_Verneed));
- assert (sizeof (GElf_Vernaux) == sizeof (Elf32_Vernaux));
- assert (sizeof (GElf_Verneed) == sizeof (Elf64_Verneed));
- assert (sizeof (GElf_Vernaux) == sizeof (Elf64_Vernaux));
+ eu_static_assert (sizeof (GElf_Verneed) == sizeof (Elf32_Verneed));
+ eu_static_assert (sizeof (GElf_Vernaux) == sizeof (Elf32_Vernaux));
+ eu_static_assert (sizeof (GElf_Verneed) == sizeof (Elf64_Verneed));
+ eu_static_assert (sizeof (GElf_Vernaux) == sizeof (Elf64_Vernaux));
if (len == 0)
return;
(arlib_deterministic_output ? 0
: (long long int) time (NULL)));
memcpy (ar_hdr.ar_date, tmpbuf, s);
- assert ((sizeof (struct ar_hdr) % sizeof (uint32_t)) == 0);
+ eu_static_assert ((sizeof (struct ar_hdr) % sizeof (uint32_t)) == 0);
/* Note the string for the ar_uid and ar_gid cases is longer than
necessary. This does not matter since we copy only as much as
/* The first word in the offset table specifies the size. Create
such an entry now. The real value will be filled-in later. For
all supported platforms the following is true. */
- assert (sizeof (uint32_t) == sizeof (int));
+ eu_static_assert (sizeof (uint32_t) == sizeof (int));
obstack_int_grow (&symtab.symsoffob, 0);
/* The long name obstack also gets its archive header. As above,
arlib_add_symref (const char *symname, off_t symoff)
{
/* For all supported platforms the following is true. */
- assert (sizeof (uint32_t) == sizeof (int));
+ eu_static_assert (sizeof (uint32_t) == sizeof (int));
obstack_int_grow (&symtab.symsoffob, (int) le_bswap_32 (symoff));
size_t symname_len = strlen (symname) + 1;
if (newehdr->e_ident[EI_CLASS] == ELFCLASS32)
{
- assert (offsetof (Elf32_Ehdr, e_shentsize) + sizeof (Elf32_Half)
- == offsetof (Elf32_Ehdr, e_shnum));
- assert (offsetof (Elf32_Ehdr, e_shnum) + sizeof (Elf32_Half)
- == offsetof (Elf32_Ehdr, e_shstrndx));
+ eu_static_assert (offsetof (Elf32_Ehdr, e_shentsize)
+ + sizeof (Elf32_Half)
+ == offsetof (Elf32_Ehdr, e_shnum));
+ eu_static_assert (offsetof (Elf32_Ehdr, e_shnum)
+ + sizeof (Elf32_Half)
+ == offsetof (Elf32_Ehdr, e_shstrndx));
const Elf32_Off zero_off = 0;
const Elf32_Half zero[3] = { 0, 0, SHN_UNDEF };
if (pwrite_retry (fd, &zero_off, sizeof zero_off,
}
else
{
- assert (offsetof (Elf64_Ehdr, e_shentsize) + sizeof (Elf64_Half)
- == offsetof (Elf64_Ehdr, e_shnum));
- assert (offsetof (Elf64_Ehdr, e_shnum) + sizeof (Elf64_Half)
- == offsetof (Elf64_Ehdr, e_shstrndx));
+ eu_static_assert (offsetof (Elf64_Ehdr, e_shentsize)
+ + sizeof (Elf64_Half)
+ == offsetof (Elf64_Ehdr, e_shnum));
+ eu_static_assert (offsetof (Elf64_Ehdr, e_shnum)
+ +sizeof (Elf64_Half)
+ == offsetof (Elf64_Ehdr, e_shstrndx));
const Elf64_Off zero_off = 0;
const Elf64_Half zero[3] = { 0, 0, SHN_UNDEF };
if (pwrite_retry (fd, &zero_off, sizeof zero_off,
/* We don't bother using gelf_update_versym because there is
really no conversion to be done. */
- assert (sizeof (Elf32_Versym) == sizeof (GElf_Versym));
- assert (sizeof (Elf64_Versym) == sizeof (GElf_Versym));
+ eu_static_assert (sizeof (Elf32_Versym) == sizeof (GElf_Versym));
+ eu_static_assert (sizeof (Elf64_Versym) == sizeof (GElf_Versym));
GElf_Versym *versym = xcalloc (nent, sizeof versym[0]);
for (size_t i = 1; i < onent; ++i)