From 88ee4ae44bd64e869bca79d0a6c6e6d4577b7170 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 12 Apr 2022 22:36:14 +0200 Subject: exec: Support ELIBEXEC error So users get a "Cannot exec a shared library directly" error message instead of a segfault. --- exec/exec.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'exec/exec.c') 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; -- cgit v1.2.3