From nobody Wed Oct 29 20:38:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1525383713487437.94587084042587; Thu, 3 May 2018 14:41:53 -0700 (PDT) Received: from localhost ([::1]:59212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fELz0-0006J0-2v for importer@patchew.org; Thu, 03 May 2018 17:41:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54821) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fELwo-0004jG-OF for qemu-devel@nongnu.org; Thu, 03 May 2018 17:39:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fELwk-00056a-Oe for qemu-devel@nongnu.org; Thu, 03 May 2018 17:39:30 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:57747) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fELwk-00054P-CN for qemu-devel@nongnu.org; Thu, 03 May 2018 17:39:26 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.183]) with ESMTPSA (Nemesis) id 0LjsL3-1ecY9Y1bSr-00br4p; Thu, 03 May 2018 23:39:13 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 3 May 2018 23:39:00 +0200 Message-Id: <20180503213903.30335-4-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180503213903.30335-1-laurent@vivier.eu> References: <20180503213903.30335-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:yBA/G5LEImaQWJL6v6bSgbdgQvbfcu8KAOUOv62KmN7fTFQje+B hs11zmJmz3aKd6zUbZ2RUL9m2ijeWURzvwLhFd4OFWE+hTmpQ+eMqjN3uEUZfTb0xU+P3FJ qNPzH3J+ATMjTpBEQkITIHZfnKsfvncjB3C/0/S8tPqkHSZ4p2Fi1pdXoN3DL7teOP5uUfc lxybrN8TV4SsKVQn0KjiA== X-UI-Out-Filterresults: notjunk:1;V01:K0:FTohLbnJRhY=:HGIMddToXBYOKfL2FC3586 UsRqH0pJNiYWB0iDOsb7YvX6ZU+Cyna8YPGkS1CxyWq1+hurGmS2Oi6hNtptPEp23WQHCmBT0 fTzONOeXnh6itPo5QhkYLdv2ujHLXfFIStHqJgiS1Lt596lyzM3QDBi3aXlEWD2rdffpob+Wv XznZs1aNmcTT0AUgPYRqckXXiNU8YPVoPN5WO4yVGBGHG57Ykec7GlU6m+mKD9nwW0VDGG9XW 4J1CmwXXNNlPO/BFqZl1xjJe1CrLSr2vH6W7t41Ng9NBLdvskvp67rX/XsVIg/8cFmpxKgQjX Rr+owldZF1vkMk74dIMs6WMyf5Ma24Xn69kKeeRhgRD0mrjC3jYFAZwJLWwex5o3l1e55U0P/ 4Ob9I+tWqkpVwpEHcDAS8YGTHWduJpnowN4I/nyAG9/9iyT5HQDzzA0WdUcnjZU4EYZcDWB9N iw7sjMc8BqXAfxxFth0FtZeTxrbpecrxvWpT6w7XXeqYodueUWadUK6fG1rlUg/GrKrJnF5xb nynOhu9y69VyhLDa3NjrKmocOkVxLt8iqMnAxCTkjHI3ZOhOjFE8wD6fJEMAqxBjjGGUwwyVO +RjtEqx6x6Y5J1oQEgs3LtYTl95U08q4gz1pCH5ILEfonwJemS1yTiLZr9G2HVba+XxILio1T oRK0Os0BjAQO/ihU7bYcDegq1DRx5HUP5N2xksBo3yLMlzxr+3PE5ShbdiO2FxBlJeyGhSRVZ h7QEsFUyCSJ767xd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.10 Subject: [Qemu-devel] [PULL 3/6] linux-user: ARM-FDPIC: Add support of FDPIC for ARM. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christophe Lyon , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Christophe Lyon Add FDPIC info into image_info structure since interpreter info is on stack and needs to be saved to be accessed later on. Co-Authored-By: Micka=C3=ABl Gu=C3=AAn=C3=A9 Signed-off-by: Christophe Lyon Reviewed-by: Peter Maydell Message-Id: <20180430080404.7323-4-christophe.lyon@st.com> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 29 +++++++++++++++++++++++++++++ linux-user/qemu.h | 9 +++++++++ 2 files changed, 38 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 76d7718b3d..36d52194bc 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -78,6 +78,11 @@ enum { */ #define personality(pers) (pers & PER_MASK) =20 +int info_is_fdpic(struct image_info *info) +{ + return info->personality =3D=3D PER_LINUX_FDPIC; +} + /* this flag is uneffective under linux too, should be deleted */ #ifndef MAP_DENYWRITE #define MAP_DENYWRITE 0 @@ -287,6 +292,25 @@ static inline void init_thread(struct target_pt_regs *= regs, /* For uClinux PIC binaries. */ /* XXX: Linux does this only on ARM with no MMU (do we care ?) */ regs->uregs[10] =3D infop->start_data; + + /* Support ARM FDPIC. */ + if (info_is_fdpic(infop)) { + /* As described in the ABI document, r7 points to the loadmap info + * prepared by the kernel. If an interpreter is needed, r8 points + * to the interpreter loadmap and r9 points to the interpreter + * PT_DYNAMIC info. If no interpreter is needed, r8 is zero, and + * r9 points to the main program PT_DYNAMIC info. + */ + regs->uregs[7] =3D infop->loadmap_addr; + if (infop->interpreter_loadmap_addr) { + /* Executable is dynamically loaded. */ + regs->uregs[8] =3D infop->interpreter_loadmap_addr; + regs->uregs[9] =3D infop->interpreter_pt_dynamic_addr; + } else { + regs->uregs[8] =3D 0; + regs->uregs[9] =3D infop->pt_dynamic_addr; + } + } } =20 #define ELF_NREG 18 @@ -1745,6 +1769,11 @@ static abi_ulong create_elf_tables(abi_ulong p, int = argc, int envc, if (interp_info) { interp_info->other_info =3D info; sp =3D loader_build_fdpic_loadmap(interp_info, sp); + info->interpreter_loadmap_addr =3D interp_info->loadmap_addr; + info->interpreter_pt_dynamic_addr =3D interp_info->pt_dynamic_= addr; + } else { + info->interpreter_loadmap_addr =3D 0; + info->interpreter_pt_dynamic_addr =3D 0; } } =20 diff --git a/linux-user/qemu.h b/linux-user/qemu.h index da3b51724c..c55c8e294b 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -57,6 +57,8 @@ struct image_info { uint16_t nsegs; void *loadsegs; abi_ulong pt_dynamic_addr; + abi_ulong interpreter_loadmap_addr; + abi_ulong interpreter_pt_dynamic_addr; struct image_info *other_info; }; =20 @@ -183,6 +185,13 @@ int loader_exec(int fdexec, const char *filename, char= **argv, char **envp, struct target_pt_regs * regs, struct image_info *infop, struct linux_binprm *); =20 +/* 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 + * that the program can be relocated adequately. This is also useful + * when handling signals. + */ +int info_is_fdpic(struct image_info *info); + 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); --=20 2.14.3