From: Warner Losh <imp@bsdimp.com>
To: qemu-devel@nongnu.org
Cc: Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>,
Jessica Clarke <jrtc27@jrtc27.com>
Subject: [PATCH 10/17] bsd-user: Pass image name down the stack
Date: Fri, 2 Aug 2024 17:56:10 -0600 [thread overview]
Message-ID: <20240802235617.7971-11-imp@bsdimp.com> (raw)
In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com>
Pass the image name down the stack so that we can give better error
messages. Inspired by similar work in linux-user, and more likely to
come.
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/elfload.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c
index caf8a1adf2d..dba03f17465 100644
--- a/bsd-user/elfload.c
+++ b/bsd-user/elfload.c
@@ -36,8 +36,8 @@ abi_ulong target_stksiz;
abi_ulong target_stkbas;
static int elf_core_dump(int signr, CPUArchState *env);
-static int load_elf_sections(const struct elfhdr *hdr, struct elf_phdr *phdr,
- int fd, abi_ulong rbase, abi_ulong *baddrp);
+static int load_elf_sections(const char *image_name, const struct elfhdr *hdr,
+ struct elf_phdr *phdr, int fd, abi_ulong rbase, abi_ulong *baddrp);
static inline void memcpy_fromfs(void *to, const void *from, unsigned long n)
{
@@ -268,7 +268,8 @@ static void padzero(abi_ulong elf_bss, abi_ulong last_bss)
}
}
-static abi_ulong load_elf_interp(struct elfhdr *interp_elf_ex,
+static abi_ulong load_elf_interp(const char *elf_interpreter,
+ struct elfhdr *interp_elf_ex,
int interpreter_fd,
abi_ulong *interp_load_addr)
{
@@ -335,7 +336,7 @@ static abi_ulong load_elf_interp(struct elfhdr *interp_elf_ex,
}
}
- error = load_elf_sections(interp_elf_ex, elf_phdata, interpreter_fd, rbase,
+ error = load_elf_sections(elf_interpreter, interp_elf_ex, elf_phdata, interpreter_fd, rbase,
&baddr);
if (error != 0) {
perror("load_elf_sections");
@@ -526,8 +527,9 @@ int is_target_elf_binary(int fd)
}
static int
-load_elf_sections(const struct elfhdr *hdr, struct elf_phdr *phdr, int fd,
- abi_ulong rbase, abi_ulong *baddrp)
+load_elf_sections(const char *image_name, const struct elfhdr *hdr,
+ struct elf_phdr *phdr, int fd, abi_ulong rbase,
+ abi_ulong *baddrp)
{
struct elf_phdr *elf_ppnt;
abi_ulong baddr;
@@ -764,7 +766,7 @@ int load_elf_binary(struct bsd_binprm *bprm, struct image_info *info)
info->elf_flags = elf_ex.e_flags;
- error = load_elf_sections(&elf_ex, elf_phdata, bprm->fd, et_dyn_addr,
+ error = load_elf_sections(bprm->filename, &elf_ex, elf_phdata, bprm->fd, et_dyn_addr,
&load_addr);
for (i = 0, elf_ppnt = elf_phdata; i < elf_ex.e_phnum; i++, elf_ppnt++) {
if (elf_ppnt->p_type != PT_LOAD) {
@@ -780,7 +782,8 @@ int load_elf_binary(struct bsd_binprm *bprm, struct image_info *info)
}
if (elf_interpreter) {
- elf_entry = load_elf_interp(&interp_elf_ex, interpreter_fd,
+ elf_entry = load_elf_interp(elf_interpreter,
+ &interp_elf_ex, interpreter_fd,
&interp_load_addr);
reloc_func_desc = interp_load_addr;
--
2.45.1
next prev parent reply other threads:[~2024-08-02 23:59 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-02 23:56 [PATCH 00/17] For 9.2: A bunch of cleanups and work towards variable pagesize support Warner Losh
2024-08-02 23:56 ` [PATCH 01/17] bsd-user: Delete TaskState next member Warner Losh
2024-08-04 7:07 ` Richard Henderson
2024-08-02 23:56 ` [PATCH 02/17] bsd-user: Make init_task_state global Warner Losh
2024-08-04 7:08 ` Richard Henderson
2024-08-02 23:56 ` [PATCH 03/17] bsd-user: Make cpu_model and cpu_type file scope Warner Losh
2024-08-04 7:22 ` Richard Henderson
2024-08-02 23:56 ` [PATCH 04/17] bsd-user: Implement cpu_copy() Warner Losh
2024-08-04 7:24 ` Richard Henderson
2024-08-02 23:56 ` [PATCH 05/17] bsd-user: Eliminate unused regs arg in load_elf_binary Warner Losh
2024-08-04 7:26 ` Richard Henderson
2024-08-02 23:56 ` [PATCH 06/17] bsd-user: Remove load_flt_binary prototype Warner Losh
2024-08-04 7:26 ` Richard Henderson
2024-08-02 23:56 ` [PATCH 07/17] bsd-user: Remove deprecated -p argument Warner Losh
2024-08-04 7:26 ` Richard Henderson
2024-08-02 23:56 ` [PATCH 08/17] bsd-user: Eliminate unused qemu_uname_release Warner Losh
2024-08-04 7:27 ` Richard Henderson
2024-08-02 23:56 ` [PATCH 09/17] bsd-user: target_msync unused, remove it Warner Losh
2024-08-04 7:28 ` Richard Henderson
2024-08-02 23:56 ` Warner Losh [this message]
2024-08-04 7:29 ` [PATCH 10/17] bsd-user: Pass image name down the stack Richard Henderson
2024-08-02 23:56 ` [PATCH 11/17] bsd-user: Replace set_brk and padzero with zerobss from linux-user Warner Losh
2024-08-04 11:38 ` Richard Henderson
2024-08-02 23:56 ` [PATCH 12/17] bsd-user: Use guest_range_valid_untagged to validate range Warner Losh
2024-08-04 21:30 ` Richard Henderson
2024-08-02 23:56 ` [PATCH 13/17] bsd-user: target_mprotect: rename prot to target_prot Warner Losh
2024-08-04 21:31 ` Richard Henderson
2024-08-02 23:56 ` [PATCH 14/17] bsd-user: target_mmap*: change " Warner Losh
2024-08-04 21:32 ` Richard Henderson
2024-08-02 23:56 ` [PATCH 15/17] bsd-user: target_mprotect: use helper host_page_size local Warner Losh
2024-08-04 21:33 ` Richard Henderson
2024-08-02 23:56 ` [PATCH 16/17] bsd-user: Define validate_prot_to_pageflags and use in mprotect Warner Losh
2024-08-04 21:44 ` Richard Henderson
2024-08-02 23:56 ` [PATCH 17/17] bsd-user: copy linux-user target_mprotect impl Warner Losh
2024-08-04 21:47 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240802235617.7971-11-imp@bsdimp.com \
--to=imp@bsdimp.com \
--cc=jrtc27@jrtc27.com \
--cc=kevans@freebsd.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.