From nobody Sun Nov 24 14:45:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1722643174; cv=none; d=zohomail.com; s=zohoarc; b=d+EFc3EzY0tfSU0INanbb+pRUq5o8q4tPheTpciC4KZ7b6+08Kqjaqcb3gmZ1ls9DwbzulFWP5aPQdi0oYUHCNC5JXgArkOsZ82se/e9QXb4NkyI0V6X+hMLu7NOUcUIrIy5cchCewv955ntzZL7VQ71+thZ4uNY4qR+h/LH2HE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722643174; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=h8/T8Zg48KUN7dtjWNUDu011IwEcHhj9Ls+BvEab5T4=; b=N1Aw/gN+rHuE2W2gXWo6PoyYoWuNOW7O5jh/cxSy0/8vVvMyJ8RcblalPPK7p52MU1nxGkG3cflbE7eLuqecbi6vt5F894j+GJe4vddTUtpVC10pYgvuS5bPG7BerT2un3tn/r5VgLDOCwq66xF7ZyrRhnuquTyFecllEmf+Y0g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722643174760575.8965095932124; Fri, 2 Aug 2024 16:59:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sa29p-0002M6-Kl; Fri, 02 Aug 2024 19:58:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sa29h-0001pz-97 for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:53 -0400 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sa29f-0004IU-FV for qemu-devel@nongnu.org; Fri, 02 Aug 2024 19:57:52 -0400 Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-81f8f0198beso363089939f.1 for ; Fri, 02 Aug 2024 16:57:51 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4c8d69a8227sm683131173.47.2024.08.02.16.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Aug 2024 16:57:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1722643070; x=1723247870; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h8/T8Zg48KUN7dtjWNUDu011IwEcHhj9Ls+BvEab5T4=; b=iP5jsyp48iBDvkuhUy7ioYtn6RFziXLGpW9UuMy/P0R7npximG3M464GeGEUiuEA+5 okbqoIL6VD/qA3RhmM29CfaDcdeKrgrtTLOmtPxlr9IJ2Qj4wmtNehQMLXZNP76TJfaR Xa6AB6f6H2p4G9ZKnsghhgzaqOvYCfEYz21Jd8ObYmWkxzLzONlfdW+bIALj5NZ1deGn Xx/z4ByoLC/2dldT2Cl7RIMfv22QXQ5p+amlgANyVFbmMXMXQNbSUOtbffMNydF3Zi/D DMyRQWf34XCzC2JugX2mkN7dQO9no1DIU/sD8Qi7dK6yuzs6q9ayE+gda6VPaEwNtc6t 7V8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722643070; x=1723247870; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h8/T8Zg48KUN7dtjWNUDu011IwEcHhj9Ls+BvEab5T4=; b=bjs5HI9kprb1Lejl9BbKXJg/9emtOSajV03MzfmX4Cr5tXoUwrg4ccW08dZbn+OVN1 e5OLLf2KJoEdqO0WPqeRyOiSpf7QwmXSZl9AAFU1xOEurP0shg5jSYOrEaq8svPoVi8A HRD3FSzzxciT2pg3IlOmoJvo2SQDF40/5nYlNgt8OC1NMJr7YuD/1A4ery9/c26OwLfl BjkBgj6Kgi4QleTNbz7iUUmt+vrzOgX9GzJal+2dSmvf9qQ+f2WU8+pStK219J96c5ZS ZFnTnvXZXS95Q3lUWYb/BfU80ecZ0UxGt5X3syjI4YmEO5MXAvXH0rssb3oWG8J9XM8z J9hw== X-Gm-Message-State: AOJu0YyTB35YcV/K74zngfji3EuHgPB3IAjvsGPQ/c3T7YCoQfkYY+hI SL+kI8qemYeJ5ucgqecZJcKAz5xwlERxjjTEwYpl/VpwWw4avdW5jCdFTvaX0znND4T7MX1XzdS 4Vro= X-Google-Smtp-Source: AGHT+IFypnwCX92FWsXd9Iwc3Ip+JeDls2I4arRl7Tzy3Hr7pVFB8PfUcwlFTGxdjuPbwqi8Vdp2Wg== X-Received: by 2002:a05:6602:6d17:b0:81f:9328:9631 with SMTP id ca18e2360f4ac-81fd434decdmr572602639f.2.1722643069922; Fri, 02 Aug 2024 16:57:49 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Warner Losh , Kyle Evans , Jessica Clarke Subject: [PATCH 10/17] bsd-user: Pass image name down the stack Date: Fri, 2 Aug 2024 17:56:10 -0600 Message-ID: <20240802235617.7971-11-imp@bsdimp.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240802235617.7971-1-imp@bsdimp.com> References: <20240802235617.7971-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2b; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1722643175054116600 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Richard Henderson --- 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; =20 static int elf_core_dump(int signr, CPUArchState *env); -static int load_elf_sections(const struct elfhdr *hdr, struct elf_phdr *ph= dr, - 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); =20 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_b= ss) } } =20 -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, } } =20 - error =3D load_elf_sections(interp_elf_ex, elf_phdata, interpreter_fd,= rbase, + error =3D load_elf_sections(elf_interpreter, interp_elf_ex, elf_phdata= , interpreter_fd, rbase, &baddr); if (error !=3D 0) { perror("load_elf_sections"); @@ -526,8 +527,9 @@ int is_target_elf_binary(int fd) } =20 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 ima= ge_info *info) =20 info->elf_flags =3D elf_ex.e_flags; =20 - error =3D load_elf_sections(&elf_ex, elf_phdata, bprm->fd, et_dyn_addr, + error =3D load_elf_sections(bprm->filename, &elf_ex, elf_phdata, bprm-= >fd, et_dyn_addr, &load_addr); for (i =3D 0, elf_ppnt =3D elf_phdata; i < elf_ex.e_phnum; i++, elf_pp= nt++) { if (elf_ppnt->p_type !=3D PT_LOAD) { @@ -780,7 +782,8 @@ int load_elf_binary(struct bsd_binprm *bprm, struct ima= ge_info *info) } =20 if (elf_interpreter) { - elf_entry =3D load_elf_interp(&interp_elf_ex, interpreter_fd, + elf_entry =3D load_elf_interp(elf_interpreter, + &interp_elf_ex, interpreter_fd, &interp_load_addr); reloc_func_desc =3D interp_load_addr; =20 --=20 2.45.1