This moves the assert from being checked at runtime to being checked
at compile time.
* libdwfl/dwfl_segment_report_module.c (dwfl_segment_report_module):
Replace asserts with eu_static_assert.
* libdwfl/linux-core-attach.c (core_set_initial_registers):
Likewise.
* libdwfl/linux-kernel-modules.c (check_notes): Likewise.
* libebl/eblopenbackend.c (openbackend): Likewise.
* libelf/elf_begin.c (file_read_elf): Likewise.
(write_file): Likewise.
* libelf/elf_clone.c (elf_clone): Likewise.
* libelf/elf_getshdrstrndx.c (elf_getshdrstrndx): Likewise.
* libelf/elf_newscn.c (elf_newscn): Likewise.
* libelf/gelf_getauxv.c (gelf_getauxv): Likewise.
* libelf/gelf_getdyn.c (gelf_getdyn): Likewise.
* libelf/gelf_getlib.c (gelf_getlib): Likewise.
* libelf/gelf_getsym.c (gelf_getsym): Likewise.
* libelf/gelf_getsyminfo.c (gelf_getsyminfo): Likewise.
* libelf/gelf_getsymshndx.c (gelf_getsymshndx): Likewise.
* libelf/gelf_getverdaux.c (gelf_getverdaux): Likewise.
* libelf/gelf_getverdef.c (gelf_getverdef): Likewise.
* libelf/gelf_getvernaux.c (gelf_getvernaux): Likewise.
* libelf/gelf_getverneed.c (gelf_getverneed): Likewise.
* libelf/gelf_getversym.c (gelf_getversym): Likewise.
* libelf/gelf_update_syminfo.c (gelf_update_syminfo): Likewise.
* libelf/gelf_update_verdaux.c (gelf_update_verdaux): Likewise.
* libelf/gelf_update_verdef.c (gelf_update_verdef): Likewise.
* libelf/gelf_update_vernaux.c (gelf_update_vernaux): Likewise.
* libelf/gelf_update_verneed.c (gelf_update_verneed): Likewise.
* libelf/gelf_update_versym.c (gelf_update_versym): Likewise.
* libelf/note_xlate.h (elf_cvt_note): Likewise.
* libelf/version_xlate.h (elf_cvt_Verdef): Likewise.
(elf_cvt_Verneed): Likewise.
* src/arlib.c (arlib_init): Likewise.
(arlib_add_symref): Likewise.
* src/strip.c (handle_elf): Likewise.
* src/unstrip.c (adjust_relocs): Likewise.
Signed-off-by: Mark Wielaard <[email protected]>
---
libdwfl/dwfl_segment_report_module.c | 2 +-
libdwfl/linux-core-attach.c | 2 +-
libdwfl/linux-kernel-modules.c | 4 ++--
libebl/eblopenbackend.c | 12 ++++++------
libelf/elf_begin.c | 8 ++++----
libelf/elf_clone.c | 5 ++---
libelf/elf_getshdrstrndx.c | 17 ++++++++---------
libelf/elf_newscn.c | 12 ++++++------
libelf/gelf_getauxv.c | 3 +--
libelf/gelf_getdyn.c | 3 +--
libelf/gelf_getlib.c | 5 ++---
libelf/gelf_getsym.c | 3 +--
libelf/gelf_getsyminfo.c | 5 ++---
libelf/gelf_getsymshndx.c | 3 +--
libelf/gelf_getverdaux.c | 5 ++---
libelf/gelf_getverdef.c | 5 ++---
libelf/gelf_getvernaux.c | 9 ++++-----
libelf/gelf_getverneed.c | 9 ++++-----
libelf/gelf_getversym.c | 5 ++---
libelf/gelf_update_syminfo.c | 5 ++---
libelf/gelf_update_verdaux.c | 5 ++---
libelf/gelf_update_verdef.c | 5 ++---
libelf/gelf_update_vernaux.c | 5 ++---
libelf/gelf_update_verneed.c | 5 ++---
libelf/gelf_update_versym.c | 5 ++---
libelf/gnuhash_xlate.h | 1 -
libelf/note_xlate.h | 2 +-
libelf/version_xlate.h | 17 ++++++++---------
src/arlib.c | 6 +++---
src/strip.c | 20 ++++++++++++--------
src/unstrip.c | 4 ++--
31 files changed, 90 insertions(+), 107 deletions(-)
diff --git a/libdwfl/dwfl_segment_report_module.c
b/libdwfl/dwfl_segment_report_module.c
index f2f866c2c70f..8a485c062672 100644
--- a/libdwfl/dwfl_segment_report_module.c
+++ b/libdwfl/dwfl_segment_report_module.c
@@ -537,7 +537,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char
*name,
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
diff --git a/libdwfl/linux-core-attach.c b/libdwfl/linux-core-attach.c
index 75e3c2198873..509e92b7c5e0 100644
--- a/libdwfl/linux-core-attach.c
+++ b/libdwfl/linux-core-attach.c
@@ -275,7 +275,7 @@ core_set_initial_registers (Dwfl_Thread *thread, void
*thread_arg_voidp)
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:
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index e9faba26a720..dac64b3405c4 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -577,8 +577,8 @@ check_notes (Dwfl_Module *mod, const char *notesfile,
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;
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index b68dea7a0809..dbe4b94741d5 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -311,12 +311,12 @@ openbackend (Elf *elf, const char *emulation, GElf_Half
machine)
/* 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)
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index d22f107dd5a0..0c9b95ddc2b1 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -327,8 +327,8 @@ file_read_elf (int fildes, void *map_address, unsigned char
*e_ident,
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;
@@ -1159,8 +1159,8 @@ write_file (int fd, Elf_Cmd cmd)
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;
}
diff --git a/libelf/elf_clone.c b/libelf/elf_clone.c
index e6fe4729e68f..ff96fc2156b8 100644
--- a/libelf/elf_clone.c
+++ b/libelf/elf_clone.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <stddef.h>
#include "libelfP.h"
#include "common.h"
@@ -65,8 +64,8 @@ elf_clone (Elf *elf, Elf_Cmd cmd)
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;
diff --git a/libelf/elf_getshdrstrndx.c b/libelf/elf_getshdrstrndx.c
index 2391317bffe0..af9c3a1479fd 100644
--- a/libelf/elf_getshdrstrndx.c
+++ b/libelf/elf_getshdrstrndx.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <errno.h>
#include <gelf.h>
#include <stddef.h>
@@ -58,14 +57,14 @@ elf_getshdrstrndx (Elf *elf, size_t *dst)
/* 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))
{
diff --git a/libelf/elf_newscn.c b/libelf/elf_newscn.c
index ec731f759de4..f7b20ab7cb2d 100644
--- a/libelf/elf_newscn.c
+++ b/libelf/elf_newscn.c
@@ -51,12 +51,12 @@ elf_newscn (Elf *elf)
/* 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);
diff --git a/libelf/gelf_getauxv.c b/libelf/gelf_getauxv.c
index 1591be2a5686..405ec6465c83 100644
--- a/libelf/gelf_getauxv.c
+++ b/libelf/gelf_getauxv.c
@@ -30,7 +30,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
@@ -84,7 +83,7 @@ gelf_getauxv (Elf_Data *data, int ndx, GElf_auxv_t *dst)
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. */
diff --git a/libelf/gelf_getdyn.c b/libelf/gelf_getdyn.c
index a0090e147d54..32e75f9a888e 100644
--- a/libelf/gelf_getdyn.c
+++ b/libelf/gelf_getdyn.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
@@ -86,7 +85,7 @@ gelf_getdyn (Elf_Data *data, int ndx, GElf_Dyn *dst)
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. */
diff --git a/libelf/gelf_getlib.c b/libelf/gelf_getlib.c
index a8ac47850c5b..9a6c24165ece 100644
--- a/libelf/gelf_getlib.c
+++ b/libelf/gelf_getlib.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
@@ -56,8 +55,8 @@ gelf_getlib (Elf_Data *data, int ndx, GElf_Lib *dst)
/* 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. */
diff --git a/libelf/gelf_getsym.c b/libelf/gelf_getsym.c
index 01534d2ce8fd..bc1e7b56bdc5 100644
--- a/libelf/gelf_getsym.c
+++ b/libelf/gelf_getsym.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
@@ -91,7 +90,7 @@ gelf_getsym (Elf_Data *data, int ndx, GElf_Sym *dst)
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. */
diff --git a/libelf/gelf_getsyminfo.c b/libelf/gelf_getsyminfo.c
index 8360ed387ad0..d1ec9e7942c9 100644
--- a/libelf/gelf_getsyminfo.c
+++ b/libelf/gelf_getsyminfo.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
@@ -53,8 +52,8 @@ gelf_getsyminfo (Elf_Data *data, int ndx, GElf_Syminfo *dst)
}
/* 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);
diff --git a/libelf/gelf_getsymshndx.c b/libelf/gelf_getsymshndx.c
index 17c90fc6d082..534502e34f7a 100644
--- a/libelf/gelf_getsymshndx.c
+++ b/libelf/gelf_getsymshndx.c
@@ -32,7 +32,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
@@ -110,7 +109,7 @@ gelf_getsymshndx (Elf_Data *symdata, Elf_Data *shndxdata,
int ndx,
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. */
diff --git a/libelf/gelf_getverdaux.c b/libelf/gelf_getverdaux.c
index 739a7657d850..099c6612f5ad 100644
--- a/libelf/gelf_getverdaux.c
+++ b/libelf/gelf_getverdaux.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
@@ -54,8 +53,8 @@ gelf_getverdaux (Elf_Data *data, int offset, GElf_Verdaux
*dst)
/* 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);
diff --git a/libelf/gelf_getverdef.c b/libelf/gelf_getverdef.c
index 651f4fadc1cb..85be7caf4fa3 100644
--- a/libelf/gelf_getverdef.c
+++ b/libelf/gelf_getverdef.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
@@ -54,8 +53,8 @@ gelf_getverdef (Elf_Data *data, int offset, GElf_Verdef *dst)
/* 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);
diff --git a/libelf/gelf_getvernaux.c b/libelf/gelf_getvernaux.c
index e47fb0a22753..234543367606 100644
--- a/libelf/gelf_getvernaux.c
+++ b/libelf/gelf_getvernaux.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
@@ -55,10 +54,10 @@ gelf_getvernaux (Elf_Data *data, int offset, GElf_Vernaux
*dst)
/* 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);
diff --git a/libelf/gelf_getverneed.c b/libelf/gelf_getverneed.c
index c1f5d3409fca..ff3743ea3451 100644
--- a/libelf/gelf_getverneed.c
+++ b/libelf/gelf_getverneed.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
@@ -55,10 +54,10 @@ gelf_getverneed (Elf_Data *data, int offset, GElf_Verneed
*dst)
/* 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);
diff --git a/libelf/gelf_getversym.c b/libelf/gelf_getversym.c
index 68d23c72e9d1..aa2c0a0904e1 100644
--- a/libelf/gelf_getversym.c
+++ b/libelf/gelf_getversym.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
@@ -61,8 +60,8 @@ gelf_getversym (Elf_Data *data, int ndx, GElf_Versym *dst)
/* 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);
diff --git a/libelf/gelf_update_syminfo.c b/libelf/gelf_update_syminfo.c
index 6f7f30255a4f..a471e42983a9 100644
--- a/libelf/gelf_update_syminfo.c
+++ b/libelf/gelf_update_syminfo.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <stdlib.h>
@@ -56,8 +55,8 @@ gelf_update_syminfo (Elf_Data *data, int ndx, GElf_Syminfo
*src)
}
/* 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);
diff --git a/libelf/gelf_update_verdaux.c b/libelf/gelf_update_verdaux.c
index f3554fdcb6e4..9f4a43fad275 100644
--- a/libelf/gelf_update_verdaux.c
+++ b/libelf/gelf_update_verdaux.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
@@ -47,8 +46,8 @@ gelf_update_verdaux (Elf_Data *data, int offset, GElf_Verdaux
*src)
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)
diff --git a/libelf/gelf_update_verdef.c b/libelf/gelf_update_verdef.c
index adb5db146a7a..bd224bdba6f4 100644
--- a/libelf/gelf_update_verdef.c
+++ b/libelf/gelf_update_verdef.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
@@ -47,8 +46,8 @@ gelf_update_verdef (Elf_Data *data, int offset, GElf_Verdef
*src)
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)
diff --git a/libelf/gelf_update_vernaux.c b/libelf/gelf_update_vernaux.c
index 854afabbca45..f60429a65b88 100644
--- a/libelf/gelf_update_vernaux.c
+++ b/libelf/gelf_update_vernaux.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
@@ -47,8 +46,8 @@ gelf_update_vernaux (Elf_Data *data, int offset, GElf_Vernaux
*src)
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)
diff --git a/libelf/gelf_update_verneed.c b/libelf/gelf_update_verneed.c
index bf5af5a30568..43338a8f76d8 100644
--- a/libelf/gelf_update_verneed.c
+++ b/libelf/gelf_update_verneed.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <string.h>
@@ -47,8 +46,8 @@ gelf_update_verneed (Elf_Data *data, int offset, GElf_Verneed
*src)
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)
diff --git a/libelf/gelf_update_versym.c b/libelf/gelf_update_versym.c
index 9949dffb03e0..5dc46222e930 100644
--- a/libelf/gelf_update_versym.c
+++ b/libelf/gelf_update_versym.c
@@ -31,7 +31,6 @@
# include <config.h>
#endif
-#include <assert.h>
#include <gelf.h>
#include <stdlib.h>
@@ -47,8 +46,8 @@ gelf_update_versym (Elf_Data *data, int ndx, GElf_Versym *src)
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))
diff --git a/libelf/gnuhash_xlate.h b/libelf/gnuhash_xlate.h
index 3a00ae0ae18b..cf9d4b57b053 100644
--- a/libelf/gnuhash_xlate.h
+++ b/libelf/gnuhash_xlate.h
@@ -28,7 +28,6 @@
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"
diff --git a/libelf/note_xlate.h b/libelf/note_xlate.h
index 7e2784b0587f..dc3a35652157 100644
--- a/libelf/note_xlate.h
+++ b/libelf/note_xlate.h
@@ -32,7 +32,7 @@ elf_cvt_note (void *dest, const void *src, size_t len, int
encode,
{
/* 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))
{
diff --git a/libelf/version_xlate.h b/libelf/version_xlate.h
index 97f3b7303e16..f44cb0cef8c2 100644
--- a/libelf/version_xlate.h
+++ b/libelf/version_xlate.h
@@ -28,7 +28,6 @@
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"
@@ -48,10 +47,10 @@ elf_cvt_Verdef (void *dest, const void *src, size_t len,
int encode)
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;
@@ -171,10 +170,10 @@ elf_cvt_Verneed (void *dest, const void *src, size_t len,
int encode)
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;
diff --git a/src/arlib.c b/src/arlib.c
index b8f89ba7df87..80344389da36 100644
--- a/src/arlib.c
+++ b/src/arlib.c
@@ -64,7 +64,7 @@ arlib_init (void)
(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
@@ -81,7 +81,7 @@ arlib_init (void)
/* 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,
@@ -194,7 +194,7 @@ void
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;
diff --git a/src/strip.c b/src/strip.c
index 8d2bb7a959f0..20cc8a22e9ae 100644
--- a/src/strip.c
+++ b/src/strip.c
@@ -2600,10 +2600,12 @@ while computing checksum for debug information"));
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,
@@ -2620,10 +2622,12 @@ while computing checksum for debug information"));
}
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,
diff --git a/src/unstrip.c b/src/unstrip.c
index 6c2a98ef96f2..5585b0e25101 100644
--- a/src/unstrip.c
+++ b/src/unstrip.c
@@ -570,8 +570,8 @@ adjust_relocs (Elf_Scn *outscn, Elf_Scn *inscn, const
GElf_Shdr *shdr,
/* 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)
--
2.53.0