summaryrefslogtreecommitdiff
path: root/libelf/libelf_msize.m4
diff options
context:
space:
mode:
Diffstat (limited to 'libelf/libelf_msize.m4')
-rw-r--r--libelf/libelf_msize.m415
1 files changed, 14 insertions, 1 deletions
diff --git a/libelf/libelf_msize.m4 b/libelf/libelf_msize.m4
index 179880c43278f..2751f5be8b82c 100644
--- a/libelf/libelf_msize.m4
+++ b/libelf/libelf_msize.m4
@@ -30,7 +30,7 @@
#include "_libelf.h"
-ELFTC_VCSID("$Id: libelf_msize.m4 3174 2015-03-27 17:13:41Z emaste $");
+ELFTC_VCSID("$Id: libelf_msize.m4 3732 2019-04-22 11:08:38Z jkoshy $");
/* WARNING: GENERATED FROM __file__. */
@@ -87,6 +87,14 @@ static struct msize msize[ELF_T_NUM] = {
MSIZES(ELF_TYPE_LIST)
};
+/*
+ * Returns the memory size of the specified ELF type 't' of ELF
+ * class 'ec' and ELF version 'version'.
+ *
+ * If the specified combination of ELF type, class, and version is
+ * unsupported then a value of 0 will be returned and the appropriate
+ * library error code set.
+ */
size_t
_libelf_msize(Elf_Type t, int elfclass, unsigned int version)
{
@@ -102,5 +110,10 @@ _libelf_msize(Elf_Type t, int elfclass, unsigned int version)
sz = (elfclass == ELFCLASS32) ? msize[t].msz32 : msize[t].msz64;
+ if (sz == 0) {
+ LIBELF_SET_ERROR(UNIMPL, 0);
+ return (0);
+ }
+
return (sz);
}