]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libebl: Remove Ebl struct size check and MODVERSION string.
authorMark Wielaard <mark@klomp.org>
Wed, 10 Jun 2020 18:55:58 +0000 (20:55 +0200)
committerMark Wielaard <mark@klomp.org>
Wed, 10 Jun 2020 19:01:33 +0000 (21:01 +0200)
We used to do several sanity checks when the ebl backend libraries
were loaded to make sure there was no version mismatch. When initializing
the backend we passed the current Ebl struct size so the library could
check it supported the given Ebl struct and we checked that the init
method returned the correct build time module version string. Neither
are necessary now that the backends are builtin.

Remove both the struct size check and the MODVERSION string (which
wasn't actually checked anymore). Make the init function return the
given Ebl handle or NULL on error (no init function currently indicates
any error).

Signed-off-by: Mark Wielaard <mark@klomp.org>
23 files changed:
ChangeLog
backends/ChangeLog
backends/aarch64_init.c
backends/alpha_init.c
backends/arm_init.c
backends/bpf_init.c
backends/csky_init.c
backends/i386_init.c
backends/ia64_init.c
backends/libebl_CPU.h
backends/m68k_init.c
backends/ppc64_init.c
backends/ppc_init.c
backends/riscv_init.c
backends/s390_init.c
backends/sh_init.c
backends/sparc_init.c
backends/tilegx_init.c
backends/x86_64_init.c
configure.ac
libebl/ChangeLog
libebl/eblopenbackend.c
libebl/libeblP.h

index 854568e0be4650d6910a6f740d1136b1061e1920..c08af9d528376be7cef16bf38ea559842ffc0638 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2020-06-10  Mark Wielaard  <mark@klomp.org>
+
+       * configure.ac (MODVERSION): Remove.
+
 2020-03-30  Mark Wielaard  <mark@klomp.org>
 
        * configure.ac: Set version to 0.179.
index 3f5f9bb02d9855acfb5f78ea33121be1a0988149..7d3578b03826ebc022b48944cde7240dbb307881 100644 (file)
@@ -1,3 +1,23 @@
+2020-06-10  Mark Wielard  <mark@klomp.org>
+
+       * aarch64_init.c (aarch64_init): Remove ehlen, return eh.
+       * alpha_init.c (alpha_init): Likewise.
+       * arm_init.c (arm_init): Likewise.
+       * bpf_init.c (bpf_init): Likewise.
+       * csky_init.c (csky_init): Likewise.
+       * i386_init.c (i386_init): Likewise.
+       * ia64_init.c (ia64_init): Likewise.
+       * m68k_init.c (m68k_init): Likewise.
+       * ppc64_init.c (ppc64_init): Likewise.
+       * ppc_init.c (ppc_init): Likewise.
+       * riscv_init.c (riscv_init): Likewise.
+       * s390_init.c (s390_init): Likewise.
+       * sh_init.c (sh_init): Likewise.
+       * sparc_init.c (sparc_init): Likewise.
+       * tilegx_init.c (tilegx_init): Likewise.
+       * x86_64_init.c (x86_64_init): Likewise.
+       * libebl_CPU.h (init): Adjust EBLHOOK signature.
+
 2019-07-05  Omar Sandoval  <osandov@fb.com>
 
        * Makefile.am: Replace libcpu_{i386,x86_64,bpf}.a with libcpu.a.
index 95268ae036fb6b210fe679174804ddd98e351672..66bfae94233cf8d42e2e2e308609b4be0088f670 100644 (file)
 #include "common-reloc.c"
 
 
-const char *
+Ebl *
 aarch64_init (Elf *elf __attribute__ ((unused)),
              GElf_Half machine __attribute__ ((unused)),
-             Ebl *eh,
-             size_t ehlen)
+             Ebl *eh)
 {
-  /* Check whether the Elf_BH object has a sufficent size.  */
-  if (ehlen < sizeof (Ebl))
-    return NULL;
-
   /* We handle it.  */
   aarch64_init_reloc (eh);
   HOOK (eh, register_info);
@@ -65,5 +60,5 @@ aarch64_init (Elf *elf __attribute__ ((unused)),
   HOOK (eh, set_initial_registers_tid);
   HOOK (eh, unwind);
 
-  return MODVERSION;
+  return eh;
 }
index f66f40c51013554464c32c5305651d24731a24a9..c69aec6d4e841dd53fcd7ef1841c61dc3fa87391 100644 (file)
 #include "common-reloc.c"
 
 
-const char *
+Ebl *
 alpha_init (Elf *elf __attribute__ ((unused)),
            GElf_Half machine __attribute__ ((unused)),
-           Ebl *eh,
-           size_t ehlen)
+           Ebl *eh)
 {
-  /* Check whether the Elf_BH object has a sufficent size.  */
-  if (ehlen < sizeof (Ebl))
-    return NULL;
-
   /* We handle it.  */
   alpha_init_reloc (eh);
   HOOK (eh, dynamic_tag_name);
@@ -64,5 +59,5 @@ alpha_init (Elf *elf __attribute__ ((unused)),
   HOOK (eh, auxv_info);
   eh->sysvhash_entrysize = sizeof (Elf64_Xword);
 
-  return MODVERSION;
+  return eh;
 }
index af023f02ed2b7c36803879abb15b9076ff244650..edd53b753dac8247becae0516c867bfc9e1de920 100644 (file)
 #include "common-reloc.c"
 
 
-const char *
+Ebl *
 arm_init (Elf *elf __attribute__ ((unused)),
          GElf_Half machine __attribute__ ((unused)),
-         Ebl *eh,
-         size_t ehlen)
+         Ebl *eh)
 {
-  /* Check whether the Elf_BH object has a sufficent size.  */
-  if (ehlen < sizeof (Ebl))
-    return NULL;
-
   /* We handle it.  */
   arm_init_reloc (eh);
   HOOK (eh, segment_type_name);
@@ -72,5 +67,5 @@ arm_init (Elf *elf __attribute__ ((unused)),
   /* Bit zero encodes whether an function address is THUMB or ARM. */
   eh->func_addr_mask = ~(GElf_Addr)1;
 
-  return MODVERSION;
+  return eh;
 }
index d407d378bd9ae23d12be8012f7f87d3a5158c0c5..f20f339e321963b1249627ce87acd273c628eec2 100644 (file)
 #include "common-reloc.c"
 
 
-const char *
+Ebl *
 bpf_init (Elf *elf __attribute__ ((unused)),
          GElf_Half machine __attribute__ ((unused)),
-         Ebl *eh, size_t ehlen)
+         Ebl *eh)
 {
-  /* Check whether the Elf_BH object has a sufficent size.  */
-  if (ehlen < sizeof (Ebl))
-    return NULL;
-
   /* We handle it.  */
   bpf_init_reloc (eh);
   HOOK (eh, register_info);
   HOOK (eh, disasm);
   HOOK (eh, reloc_simple_type);
 
-  return MODVERSION;
+  return eh;
 }
index b34a03aa33423bfb00d090ea7998df0f6895d7ef..b2863ced821c6187ce32112770d74be84b02e444 100644 (file)
 /* This defines the common reloc hooks based on csky_reloc.def.  */
 #include "common-reloc.c"
 
-const char *
+Ebl *
 csky_init (Elf *elf __attribute__ ((unused)),
           GElf_Half machine __attribute__ ((unused)),
-          Ebl *eh,
-          size_t ehlen)
+          Ebl *eh)
 {
-  /* Check whether the Elf_BH object has a sufficent size.  */
-  if (ehlen < sizeof (Ebl))
-    return NULL;
-
   /* We handle it.  */
   csky_init_reloc (eh);
   HOOK (eh, abi_cfi);
@@ -61,5 +56,5 @@ csky_init (Elf *elf __attribute__ ((unused)),
   /* gcc/config/ #define DWARF_FRAME_REGISTERS.  */
   eh->frame_nregs = 38;
 
-  return MODVERSION;
+  return eh;
 }
index 67428b53739e4673b5c354633f48c1dd3e2cad2d..3f6b9ed19b41523417c74bdd34e87c3b80deff59 100644 (file)
 /* This defines the common reloc hooks based on i386_reloc.def.  */
 #include "common-reloc.c"
 
-const char *
+Ebl *
 i386_init (Elf *elf __attribute__ ((unused)),
           GElf_Half machine __attribute__ ((unused)),
-          Ebl *eh,
-          size_t ehlen)
+          Ebl *eh)
 {
-  /* Check whether the Elf_BH object has a sufficent size.  */
-  if (ehlen < sizeof (Ebl))
-    return NULL;
-
   /* We handle it.  */
   i386_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
@@ -66,5 +61,5 @@ i386_init (Elf *elf __attribute__ ((unused)),
   HOOK (eh, set_initial_registers_tid);
   HOOK (eh, unwind);
 
-  return MODVERSION;
+  return eh;
 }
index 2d1f43f211665ed2b42dc5efc8513fb502852f36..b46b35ccb21907c3186d293f8e47fb59eb806ddf 100644 (file)
 /* This defines the common reloc hooks based on ia64_reloc.def.  */
 #include "common-reloc.c"
 
-const char *
+Ebl *
 ia64_init (Elf *elf __attribute__ ((unused)),
           GElf_Half machine __attribute__ ((unused)),
-          Ebl *eh,
-          size_t ehlen)
+          Ebl *eh)
 {
-  /* Check whether the Elf_BH object has a sufficent size.  */
-  if (ehlen < sizeof (Ebl))
-    return NULL;
-
   /* We handle it.  */
   ia64_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
@@ -61,5 +56,5 @@ ia64_init (Elf *elf __attribute__ ((unused)),
   HOOK (eh, return_value_location);
   HOOK (eh, check_reloc_target_type);
 
-  return MODVERSION;
+  return eh;
 }
index ef2b922b99edd07536b22b7d24e694f7ea43c18a..0e507bd3924a5dbcf331dcb8d8c240b94a13afa0 100644 (file)
@@ -37,8 +37,7 @@
 #define EBLHOOK_2(a, b)        a##b
 
 /* Constructor.  */
-extern const char *EBLHOOK(init) (Elf *elf, GElf_Half machine,
-                                 Ebl *eh, size_t ehlen);
+extern Ebl *EBLHOOK(init) (Elf *elf, GElf_Half machine, Ebl *eh);
 
 #include "ebl-hooks.h"
 
index 05d544c10e078f252764a970d2b3ffd94216cbb5..7b94f23afdf8e78acdb3e5ddd026a71cc8b0795d 100644 (file)
 #include "common-reloc.c"
 
 
-const char *
+Ebl *
 m68k_init (Elf *elf __attribute__ ((unused)),
           GElf_Half machine __attribute__ ((unused)),
-          Ebl *eh,
-          size_t ehlen)
+          Ebl *eh)
 {
-  /* Check whether the Elf_BH object has a sufficent size.  */
-  if (ehlen < sizeof (Ebl))
-    return NULL;
-
   /* We handle it.  */
   m68k_init_reloc (eh);
   HOOK (eh, gotpc_reloc_check);
@@ -59,5 +54,5 @@ m68k_init (Elf *elf __attribute__ ((unused)),
   eh->frame_nregs = 25;
   HOOK (eh, set_initial_registers_tid);
 
-  return MODVERSION;
+  return eh;
 }
index c2e7043bcfbad3cb05bc54f9ec74e99749c57ed3..f509aef6244156e2d9b82b8d8f081a82d8b4e296 100644 (file)
 #include "common-reloc.c"
 
 
-const char *
+Ebl *
 ppc64_init (Elf *elf __attribute__ ((unused)),
            GElf_Half machine __attribute__ ((unused)),
-           Ebl *eh,
-           size_t ehlen)
+           Ebl *eh)
 {
-  /* Check whether the Elf_BH object has a sufficent size.  */
-  if (ehlen < sizeof (Ebl))
-    return NULL;
-
   /* We handle it.  */
   ppc64_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
@@ -107,5 +102,5 @@ ppc64_init (Elf *elf __attribute__ ((unused)),
        }
     }
 
-  return MODVERSION;
+  return eh;
 }
index eb286c2569925368178e03bc1ab051628caebab4..ac440ab21537a56d90cc69def2b4d78f2fe85d99 100644 (file)
 #include "common-reloc.c"
 
 
-const char *
+Ebl *
 ppc_init (Elf *elf __attribute__ ((unused)),
          GElf_Half machine __attribute__ ((unused)),
-         Ebl *eh,
-         size_t ehlen)
+         Ebl *eh)
 {
-  /* Check whether the Elf_BH object has a sufficent size.  */
-  if (ehlen < sizeof (Ebl))
-    return NULL;
-
   /* We handle it.  */
   ppc_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
@@ -69,5 +64,5 @@ ppc_init (Elf *elf __attribute__ ((unused)),
   HOOK (eh, set_initial_registers_tid);
   HOOK (eh, dwarf_to_regno);
 
-  return MODVERSION;
+  return eh;
 }
index 9be5c6f29de034cf80870ea54dc78a6f21c86ca2..551e7bb6d34942222a1627e98de91208ef8261af 100644 (file)
@@ -43,16 +43,11 @@ extern __typeof (EBLHOOK (return_value_location))
 
 extern __typeof (EBLHOOK (core_note)) riscv64_core_note attribute_hidden;
 
-const char *
+Ebl *
 riscv_init (Elf *elf,
            GElf_Half machine __attribute__ ((unused)),
-           Ebl *eh,
-           size_t ehlen)
+           Ebl *eh)
 {
-  /* Check whether the Elf_BH object has a sufficent size.  */
-  if (ehlen < sizeof (Ebl))
-    return NULL;
-
   /* We handle it.  */
   riscv_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
@@ -73,5 +68,5 @@ riscv_init (Elf *elf,
          == EF_RISCV_FLOAT_ABI_DOUBLE))
     eh->return_value_location = riscv_return_value_location_lp64d;
 
-  return MODVERSION;
+  return eh;
 }
index b4f3e7f88befc73b3a54342ce5a2eda2a3a5170e..fd79502d8bac769ddb74c1fd2477547a65add23d 100644 (file)
 extern __typeof (s390_core_note) s390x_core_note;
 
 
-const char *
+Ebl *
 s390_init (Elf *elf __attribute__ ((unused)),
           GElf_Half machine __attribute__ ((unused)),
-          Ebl *eh,
-          size_t ehlen)
+          Ebl *eh)
 {
-  /* Check whether the Elf_BH object has a sufficent size.  */
-  if (ehlen < sizeof (Ebl))
-    return NULL;
-
   /* We handle it.  */
   s390_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
@@ -75,5 +70,5 @@ s390_init (Elf *elf __attribute__ ((unused)),
   if (eh->class == ELFCLASS64)
     eh->sysvhash_entrysize = sizeof (Elf64_Xword);
 
-  return MODVERSION;
+  return eh;
 }
index 24f4d4a4bee5ec4b4514a27b37a858fa59d8ec02..05cf8b1805d60286ddb95388649d60c00ab37d6d 100644 (file)
 #include "common-reloc.c"
 
 
-const char *
+Ebl *
 sh_init (Elf *elf __attribute__ ((unused)),
         GElf_Half machine __attribute__ ((unused)),
-        Ebl *eh,
-        size_t ehlen)
+        Ebl *eh)
 {
-  /* Check whether the Elf_BH object has a sufficent size.  */
-  if (ehlen < sizeof (Ebl))
-    return NULL;
-
   /* We handle it.  */
   sh_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
@@ -58,5 +53,5 @@ sh_init (Elf *elf __attribute__ ((unused)),
   HOOK (eh, register_info);
   HOOK (eh, return_value_location);
 
-  return MODVERSION;
+  return eh;
 }
index 6daff114a3b1d937b10b4a52445481a66172b943..647a7897d4943d88a65b9d2fe81787ed59288215 100644 (file)
 
 extern __typeof (EBLHOOK (core_note)) sparc64_core_note attribute_hidden;
 
-const char *
+Ebl *
 sparc_init (Elf *elf __attribute__ ((unused)),
            GElf_Half machine __attribute__ ((unused)),
-           Ebl *eh,
-           size_t ehlen)
+           Ebl *eh)
 {
-  /* Check whether the Elf_BH object has a sufficent size.  */
-  if (ehlen < sizeof (Ebl))
-    return NULL;
-
   /* We handle it.  */
   sparc_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
@@ -79,5 +74,5 @@ sparc_init (Elf *elf __attribute__ ((unused)),
   eh->ra_offset = 8;
   HOOK (eh, set_initial_registers_tid);
 
-  return MODVERSION;
+  return eh;
 }
index 66df9318a79c3ad324a2247aed5fa3a3e0cd94f8..0f79542afcbded7f46e853ac215d1a21b9f8996c 100644 (file)
 /* This defines the common reloc hooks based on tilegx_reloc.def.  */
 #include "common-reloc.c"
 
-const char *
+Ebl *
 tilegx_init (Elf *elf __attribute__ ((unused)),
             GElf_Half machine __attribute__ ((unused)),
-            Ebl *eh,
-            size_t ehlen)
+            Ebl *eh)
 {
-  /* Check whether the Elf_BH object has a sufficent size.  */
-  if (ehlen < sizeof (Ebl))
-    return NULL;
-
   /* We handle it.  */
   tilegx_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
@@ -54,5 +49,5 @@ tilegx_init (Elf *elf __attribute__ ((unused)),
   HOOK (eh, register_info);
   HOOK (eh, core_note);
 
-  return MODVERSION;
+  return eh;
 }
index 8abafb7f118646f25301ef4b87ec8c211d406995..44c1ad2881085c3fb1f996afe961ea6cd9c2839e 100644 (file)
 
 extern __typeof (EBLHOOK (core_note)) x32_core_note attribute_hidden;
 
-const char *
+Ebl *
 x86_64_init (Elf *elf __attribute__ ((unused)),
             GElf_Half machine __attribute__ ((unused)),
-            Ebl *eh,
-            size_t ehlen)
+            Ebl *eh)
 {
-  /* Check whether the Elf_BH object has a sufficent size.  */
-  if (ehlen < sizeof (Ebl))
-    return NULL;
-
   /* We handle it.  */
   x86_64_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
@@ -70,5 +65,5 @@ x86_64_init (Elf *elf __attribute__ ((unused)),
   HOOK (eh, set_initial_registers_tid);
   HOOK (eh, unwind);
 
-  return MODVERSION;
+  return eh;
 }
index a39e800f70e1112ca096228751e0dfdef2c4b738..c2c6890a1150d33eee07884edba71f1ad7f35339 100644 (file)
@@ -627,12 +627,6 @@ esac
 # Round up to the next release API (x.y) version.
 eu_version=$(( (eu_version + 999) / 1000 ))
 
-dnl Unique ID for this build.
-MODVERSION="Build for ${eu_version} ${ac_cv_build}"
-AC_SUBST([MODVERSION])
-AC_DEFINE_UNQUOTED(MODVERSION, "$MODVERSION")
-AH_TEMPLATE([MODVERSION], [Identifier for modules in the build.])
-
 AC_CHECK_SIZEOF(long)
 
 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
index 75aa1ab84dd3d2ed1f4dc31684b046100d57887e..fa6dd0373af3a58dbdb8083b5ed4caec43726388 100644 (file)
@@ -1,3 +1,12 @@
+2020-06-10  Mark Wielaard  <mark@klomp.org>
+
+       * eblopenbackend.c (i386_init, sh_init, x86_64_init, ia64_init,
+       alpha_init, arm_init, aarch64_init, sparc_init, ppc_init,
+       ppc64_init, s390_init, tilegx_init, m68k_init, bpf_init,
+       riscv_init, csky_init): Adjust signature.
+       (openbackend): Call init without sizeof(Ebl).
+       * libeblP.h (ebl_bhinit_t): Adjust signature.
+
 2020-06-04  Mark Wielaard  <mark@klomp.org>
 
        * eblsegmenttypename.c (ebl_segment_type_name): Remove
index 4ebde45f24f845efd1ae237ba8cc9595b788be81..b3b6fc01a18b539a175f585043873e05a7798bbb 100644 (file)
 #include <system.h>
 #include <libeblP.h>
 
-const char *i386_init (Elf *, GElf_Half, Ebl *, size_t);
-const char *sh_init (Elf *, GElf_Half, Ebl *, size_t);
-const char *x86_64_init (Elf *, GElf_Half, Ebl *, size_t);
-const char *ia64_init (Elf *, GElf_Half, Ebl *, size_t);
-const char *alpha_init (Elf *, GElf_Half, Ebl *, size_t);
-const char *arm_init (Elf *, GElf_Half, Ebl *, size_t);
-const char *aarch64_init (Elf *, GElf_Half, Ebl *, size_t);
-const char *sparc_init (Elf *, GElf_Half, Ebl *, size_t);
-const char *ppc_init (Elf *, GElf_Half, Ebl *, size_t);
-const char *ppc64_init (Elf *, GElf_Half, Ebl *, size_t);
-const char *s390_init (Elf *, GElf_Half, Ebl *, size_t);
-const char *tilegx_init (Elf *, GElf_Half, Ebl *, size_t);
-const char *m68k_init (Elf *, GElf_Half, Ebl *, size_t);
-const char *bpf_init (Elf *, GElf_Half, Ebl *, size_t);
-const char *riscv_init (Elf *, GElf_Half, Ebl *, size_t);
-const char *csky_init (Elf *, GElf_Half, Ebl *, size_t);
+Ebl *i386_init (Elf *, GElf_Half, Ebl *);
+Ebl *sh_init (Elf *, GElf_Half, Ebl *);
+Ebl *x86_64_init (Elf *, GElf_Half, Ebl *);
+Ebl *ia64_init (Elf *, GElf_Half, Ebl *);
+Ebl *alpha_init (Elf *, GElf_Half, Ebl *);
+Ebl *arm_init (Elf *, GElf_Half, Ebl *);
+Ebl *aarch64_init (Elf *, GElf_Half, Ebl *);
+Ebl *sparc_init (Elf *, GElf_Half, Ebl *);
+Ebl *ppc_init (Elf *, GElf_Half, Ebl *);
+Ebl *ppc64_init (Elf *, GElf_Half, Ebl *);
+Ebl *s390_init (Elf *, GElf_Half, Ebl *);
+Ebl *tilegx_init (Elf *, GElf_Half, Ebl *);
+Ebl *m68k_init (Elf *, GElf_Half, Ebl *);
+Ebl *bpf_init (Elf *, GElf_Half, Ebl *);
+Ebl *riscv_init (Elf *, GElf_Half, Ebl *);
+Ebl *csky_init (Elf *, GElf_Half, Ebl *);
 
 /* This table should contain the complete list of architectures as far
    as the ELF specification is concerned.  */
@@ -330,7 +330,7 @@ openbackend (Elf *elf, const char *emulation, GElf_Half machine)
          }
 
         if (machines[cnt].init &&
-            machines[cnt].init (elf, machine, result, sizeof(Ebl)))
+            machines[cnt].init (elf, machine, result))
           {
             result->elf = elf;
             /* A few entries are mandatory.  */
index fd0fcc98a7bb93247f50d58e21ebd04c4a3c58ca..599f6378aa824435fb84c7595a79ce0b339c018c 100644 (file)
@@ -80,8 +80,10 @@ struct ebl
 };
 
 
-/* Type of the initialization functions in the backend modules.  */
-typedef const char *(*ebl_bhinit_t) (Elf *, GElf_Half, Ebl *, size_t);
+/* Type of the initialization functions in the backend modules.
+   The init function returns the given Ebl * or NULL if it couldn't
+   initialize for the given Elf or machine.  */
+typedef Ebl *(*ebl_bhinit_t) (Elf *, GElf_Half, Ebl *);
 
 
 /* gettext helper macros.  */