From nobody Mon Feb 9 02:28:36 2026 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1626564401; cv=none; d=zohomail.com; s=zohoarc; b=h0X/FpDhsssmSI4723UHbM2iaZ3Pt6Ho5Hc6uAZCroldhN7W1PFxHnbw8Z7DIexjR5ZXgZqTvyJI6HsnJ2eu5EUS9UEbElxcVPwffT5ambzQBwDxtzxhn6Pzs1AaBzoWxfzITBTKrkZR03ojtjw+GOkrK0URPno3gHzAZTwiC8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626564401; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XbAAYE6Aac70j4yIiLHKaxeoua1xFwIBoeMXuqVsKZg=; b=mT/I2Ko2cmXJUnbt3yfetFAcM26oPRb3t41ZHSO0wmzqfDTGTflKzwCeLz6Yas8oC7MqJ3cOVIaMh2qhPJtSQROpDWgS4IJ4XB/GcfZL4GHYQwyTIM5l7JGBNILVR73C2rLxnphCTn8GX9l4gFqL3lpZdz8JyETJmY6EidyZ5AA= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626564401011924.8392705329695; Sat, 17 Jul 2021 16:26:41 -0700 (PDT) Received: from localhost ([::1]:43760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4thg-00058V-05 for importer@patchew.org; Sat, 17 Jul 2021 19:26:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4tcP-0001h1-50 for qemu-devel@nongnu.org; Sat, 17 Jul 2021 19:21:13 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:33519) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m4tcL-0000hh-SV for qemu-devel@nongnu.org; Sat, 17 Jul 2021 19:21:12 -0400 Received: by mail-wr1-x42f.google.com with SMTP id d2so16558963wrn.0 for ; Sat, 17 Jul 2021 16:21:09 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id o15sm7082517wmh.40.2021.07.17.16.21.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Jul 2021 16:21:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XbAAYE6Aac70j4yIiLHKaxeoua1xFwIBoeMXuqVsKZg=; b=om0feABhM2wU2LWP7j9hPmaI8/9v1RPy0emiBAr+2Jrdtjk6btswltzhh3y+H+Stym icySxoTyv+/2A+qVcABP0Z8LETwP66JZlF0nStdP7QYaqRVsknrH48lfrG7tM4mLOhNF RPCGRCG1SZaE+P0/CfQAgzcyfP3ssBRpav/+WRhpHmNjumJ7VavmpL4d9X1Wu5y3FLEY WSPEGaN8wCEsKFcvMFth6ci7WdJSAQdHZN15a6ig98ezRw/a03C8nDGFhqSnSLarZw9N uC4yK/IY7KaQtPjd7TQcSi5x8vOf+cExhuDy4S/oNelK4ZI85HkwtZ6/KebWUusi3UGX liqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XbAAYE6Aac70j4yIiLHKaxeoua1xFwIBoeMXuqVsKZg=; b=cxXYA5rLI9P6LwgwdvgLMhvRq94s2nDd5xc/K83TVn5mwhIvAYcCUoxV9xovIWGop1 l1asae6nwUV5Cuwh5GmcYR5NqVCRjcDYlnPbiTrZ5k+fOOH4zaKTK7swQlauCRQihVKE HYqsNS03XYdMjgtB9e1a65Q6eyJorCd8B74WQvfRmnJdFgTL/Lyj6T6d4KdWfyC5NJJE 4jUJ6i0PlLXOZlvnHEUjxSKBujatIT+5+qe6P6byL/09wq04MO63ANL+worNfg0RA0IQ 896mtfjlBZoLwCDXJ6Pi0Nn5faK1ZlodtrsAqg/4uT+c8B++w9bcZje8rV6AIVnBu87p dmmw== X-Gm-Message-State: AOAM533dSzXqthSraiPMEZ8Ssn/J5TecXwjmEYr9oZw35qFRnJoH4yKe +Q8jjETX7cLFpUK7093YVF4KYMBasPP2hQ== X-Google-Smtp-Source: ABdhPJyrcp7Xy8+Fc+Vb9aaS06m5fUdKk5GAxAYiKBmAnW7at8FaY7unLcZ5mwTxCfIm/gxwU37p3w== X-Received: by 2002:a5d:414b:: with SMTP id c11mr21677452wrq.162.1626564068523; Sat, 17 Jul 2021 16:21:08 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH for-6.2 04/10] linux-user: Split loader-related prototypes into loader.h Date: Sun, 18 Jul 2021 00:20:57 +0100 Message-Id: <20210717232103.18047-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210717232103.18047-1-peter.maydell@linaro.org> References: <20210717232103.18047-1-peter.maydell@linaro.org> 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: pass client-ip=2a00:1450:4864:20::42f; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1626564402443100003 Content-Type: text/plain; charset="utf-8" Split guest-binary loader prototypes out into a new header loader.h which we include only where required. Signed-off-by: Peter Maydell --- linux-user/loader.h | 59 ++++++++++++++++++++++++++++++++++++++++++ linux-user/qemu.h | 34 ------------------------ linux-user/elfload.c | 1 + linux-user/flatload.c | 1 + linux-user/linuxload.c | 1 + linux-user/main.c | 1 + linux-user/signal.c | 1 + linux-user/syscall.c | 1 + 8 files changed, 65 insertions(+), 34 deletions(-) create mode 100644 linux-user/loader.h diff --git a/linux-user/loader.h b/linux-user/loader.h new file mode 100644 index 00000000000..f375ee0679b --- /dev/null +++ b/linux-user/loader.h @@ -0,0 +1,59 @@ +/* + * loader.h: prototypes for linux-user guest binary loader + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef LINUX_USER_LOADER_H +#define LINUX_USER_LOADER_H + +/* + * Read a good amount of data initially, to hopefully get all the + * program headers loaded. + */ +#define BPRM_BUF_SIZE 1024 + +/* + * This structure is used to hold the arguments that are + * used when loading binaries. + */ +struct linux_binprm { + char buf[BPRM_BUF_SIZE] __attribute__((aligned)); + abi_ulong p; + int fd; + int e_uid, e_gid; + int argc, envc; + char **argv; + char **envp; + char *filename; /* Name of binary */ + int (*core_dump)(int, const CPUArchState *); /* coredump routine */ +}; + +void do_init_thread(struct target_pt_regs *regs, struct image_info *infop); +abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp, + abi_ulong stringp, int push_ptr); +int loader_exec(int fdexec, const char *filename, char **argv, char **envp, + struct target_pt_regs *regs, struct image_info *infop, + struct linux_binprm *); + +uint32_t get_elf_eflags(int fd); +int load_elf_binary(struct linux_binprm *bprm, struct image_info *info); +int load_flt_binary(struct linux_binprm *bprm, struct image_info *info); + +abi_long memcpy_to_target(abi_ulong dest, const void *src, + unsigned long len); + +extern unsigned long guest_stack_size; + +#endif /* LINUX_USER_LOADER_H */ diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 76d3f5e7eb9..9e700d3af18 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -173,30 +173,6 @@ void stop_all_tasks(void); extern const char *qemu_uname_release; extern unsigned long mmap_min_addr; =20 -/* ??? See if we can avoid exposing so much of the loader internals. */ - -/* - * Read a good amount of data initially, to hopefully get all the - * program headers loaded. - */ -#define BPRM_BUF_SIZE 1024 - -/* - * This structure is used to hold the arguments that are - * used when loading binaries. - */ -struct linux_binprm { - char buf[BPRM_BUF_SIZE] __attribute__((aligned)); - abi_ulong p; - int fd; - int e_uid, e_gid; - int argc, envc; - char **argv; - char **envp; - char *filename; /* Name of binary */ - int (*core_dump)(int, const CPUArchState *); /* coredump routine */ -}; - typedef struct IOCTLEntry IOCTLEntry; =20 typedef abi_long do_ioctl_fn(const IOCTLEntry *ie, uint8_t *buf_temp, @@ -217,13 +193,6 @@ extern IOCTLEntry ioctl_entries[]; #define IOC_W 0x0002 #define IOC_RW (IOC_R | IOC_W) =20 -void do_init_thread(struct target_pt_regs *regs, struct image_info *infop); -abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp, - abi_ulong stringp, int push_ptr); -int loader_exec(int fdexec, const char *filename, char **argv, char **envp, - struct target_pt_regs *regs, struct image_info *infop, - struct linux_binprm *); - /* * Returns true if the image uses the FDPIC ABI. If this is the case, * we have to provide some information (loadmap, pt_dynamic_info) such @@ -440,9 +409,6 @@ abi_ulong mmap_find_vma(abi_ulong, abi_ulong, abi_ulong= ); void mmap_fork_start(void); void mmap_fork_end(int child); =20 -/* main.c */ -extern unsigned long guest_stack_size; - /* user access */ =20 #define VERIFY_READ PAGE_READ diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 42ef2a11485..d56e00c18b4 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -6,6 +6,7 @@ #include =20 #include "qemu.h" +#include "loader.h" #include "disas/disas.h" #include "qemu/bitops.h" #include "qemu/path.h" diff --git a/linux-user/flatload.c b/linux-user/flatload.c index 3e5594cf894..7484a4a3543 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -36,6 +36,7 @@ #include "qemu/osdep.h" =20 #include "qemu.h" +#include "loader.h" #include "flat.h" #include "target_flat.h" =20 diff --git a/linux-user/linuxload.c b/linux-user/linuxload.c index 9d4eb5e94b9..27be7090d8f 100644 --- a/linux-user/linuxload.c +++ b/linux-user/linuxload.c @@ -2,6 +2,7 @@ =20 #include "qemu/osdep.h" #include "qemu.h" +#include "loader.h" =20 #define NGROUPS 32 =20 diff --git a/linux-user/main.c b/linux-user/main.c index c10e3ccf135..4ec0e2ad55d 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -50,6 +50,7 @@ #include "crypto/init.h" #include "fd-trans.h" #include "sighandling.h" +#include "loader.h" =20 #ifndef AT_FLAGS_PRESERVE_ARGV0 #define AT_FLAGS_PRESERVE_ARGV0_BIT 0 diff --git a/linux-user/signal.c b/linux-user/signal.c index bbfe250baa3..7abcec9166e 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -24,6 +24,7 @@ #include "qemu.h" #include "strace.h" #include "sighandling.h" +#include "loader.h" #include "trace.h" #include "signal-common.h" =20 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e2dd799134e..d6019b1c4c2 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -129,6 +129,7 @@ #include "qemu.h" #include "strace.h" #include "sighandling.h" +#include "loader.h" #include "qemu/guest-random.h" #include "qemu/selfmap.h" #include "user/syscall-trace.h" --=20 2.20.1