summaryrefslogtreecommitdiff
path: root/exec
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2022-04-12 22:36:14 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-04-12 22:36:28 +0200
commit88ee4ae44bd64e869bca79d0a6c6e6d4577b7170 (patch)
tree0b53f8b4e88b2b94859d432bba9b35dcffd2d24c /exec
parent866371cd8b06f20989eff1c58dff71535b3a0fa7 (diff)
exec: Support ELIBEXEC error
So users get a "Cannot exec a shared library directly" error message instead of a segfault.
Diffstat (limited to 'exec')
-rw-r--r--exec/exec.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/exec/exec.c b/exec/exec.c
index a50ea632..9827cbe8 100644
--- a/exec/exec.c
+++ b/exec/exec.c
@@ -556,6 +556,13 @@ check_elf (struct execdata *e)
/* Extract all this information now, while EHDR is mapped.
The `map' call below for the phdrs may reuse the mapping window. */
e->entry = ehdr->e_entry;
+#ifdef ELIBEXEC
+ if (e->entry == 0)
+ {
+ e->error = ELIBEXEC;
+ return;
+ }
+#endif
e->info.elf.anywhere = (ehdr->e_type == ET_DYN ||
ehdr->e_type == ET_REL);
e->info.elf.loadbase = 0;