From nobody Mon Feb 9 01:20:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=1619280561; cv=none; d=zohomail.com; s=zohoarc; b=KBNhl82pbr6JR50Wu8lDMQxmstedGFz48kXidJG86qYFVMO9dMU/Cok/qZeigpYqv4ndpmyUVWwj5an1Cuq/5cRUXa47qC3Z00W6Dj+0/SupdjLwtRlNEdNmd8mUdfOcPoO7kiX04faxs3iLLSSTt6s4qwnOcXrti6/tlxmEObo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619280561; 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=eLSunyF7yqNE6jwrYnXqTpq83LjJhVTopLCSU9ZyU5Q=; b=acE7/vt8O4p+WacSvcVSaQzppVU6yeTIuk8cFa0l82XDTM9ewJVLRZotjX3qin0lgBAlm6Fiqnlg8hc/AVs6z6IXNxL8oGON3M8AktIWtD6F3J1s1HidLPuil+7sOSBGpb4bI9cEH7yr3aeQGakf6iTUtLyvocVvKriHfaOzJ6c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 1619280561272759.0069896481812; Sat, 24 Apr 2021 09:09:21 -0700 (PDT) Received: from localhost ([::1]:57950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1laKqO-0006US-1Z for importer@patchew.org; Sat, 24 Apr 2021 12:09:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1laKhw-0005SY-RH for qemu-devel@nongnu.org; Sat, 24 Apr 2021 12:00:36 -0400 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]:41516) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1laKhq-0004Br-52 for qemu-devel@nongnu.org; Sat, 24 Apr 2021 12:00:36 -0400 Received: by mail-io1-xd35.google.com with SMTP id f21so15648034ioh.8 for ; Sat, 24 Apr 2021 09:00:29 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id h4sm4055901ili.52.2021.04.24.09.00.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Apr 2021 09:00:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eLSunyF7yqNE6jwrYnXqTpq83LjJhVTopLCSU9ZyU5Q=; b=yEINUFVz4xH4Y1ikNC0Tyd6uoblZXafUr611Iy4jdeol480nBeh+iY1l44kOPPa72F m7Y91La7og1HqJQQYw/8R0kVSYCABG9K6dHWlFwno2DF9L2BsYK7xUZh7lYU4Xfa/8jU S9425HlrqXg6N9Oto1eEeDImZ0D9tVofBYQd1Eq5sW3JzWYi6eoYqjxK8oNoTS9zu1T2 b7HO69jjhSiwqHIisYpE6+va8+baVlgJij7PpBErB29ftF77W+1n0Fs4NjmdVOPm1p7Q oY+7M+G6/mPaMgRAl2MCVQ5ksiyUs+Ewo2X0UYtCiP1IoiDWpms/KDYSexsGoU7yieMt 1CAw== 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=eLSunyF7yqNE6jwrYnXqTpq83LjJhVTopLCSU9ZyU5Q=; b=CobvX2OnEcivIny73W3DgiuKh7jqgjVxz8EckK8skKB2SN/GjXPXQUJDxf1c8slAQM 56pQjPseKXcOlWgIt9W5r/I6CAPkRayicw6vA0hwX7UN/KJguCIzbTnDBYkO9y6thizZ cz+iAQiL8rWorj+mrBq4dQvJ53s75DYrgfVogZb9EKaTh8wv8eDlIKoJXhVmzRt7ZLhd Tby6cc+a3BYKMpRKIAq/eF14MS0BbbCYaI4ScXFWi7kq4uuYsUPqVPhg4B/8D0vp/E9g giEapJMNk23MHAxq2qYNmBqaooZ48g1Au3ZaH88HSBTSpDpaDl0NapReDvz8BMAmgrLs HqBA== X-Gm-Message-State: AOAM5336rsnzDof5+hDl0BF9GJJjjg/eM0G+JxxGUUx5JqKt8tM08ZlC tOCTJDhz0qjjpoRWoFyvmavx/5fekC/7oefY X-Google-Smtp-Source: ABdhPJziMkvyF9PF9KlByAyKne4kYEIVOZZizgVAfHzDqapQzr+alVdP98mwlGjRJCjLglS+OJvk8g== X-Received: by 2002:a5e:880c:: with SMTP id l12mr7484726ioj.195.1619280028320; Sat, 24 Apr 2021 09:00:28 -0700 (PDT) From: imp@bsdimp.com To: qemu-devel@nongnu.org Subject: [PATCH v2 02/48] bsd-user: whitespace changes Date: Sat, 24 Apr 2021 09:59:30 -0600 Message-Id: <20210424160016.15200-3-imp@bsdimp.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210424160016.15200-1-imp@bsdimp.com> References: <20210424160016.15200-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::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kevans@freebsd.org, Richard Henderson , arichardson@freebsd.org, Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Warner Losh Fix various whitespace-only issues from checkpatch: keyword space ( no space before ( on function calls spaces around operators suspect indentations (including one functions reindented) extra spaces around unary operators Reviewed-by: Richard Henderson Signed-off-by: Warner Losh --- bsd-user/elfload.c | 326 ++++++++++++++++++++++----------------------- 1 file changed, 163 insertions(+), 163 deletions(-) diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c index 5f4d824d78..3c9d8c2845 100644 --- a/bsd-user/elfload.c +++ b/bsd-user/elfload.c @@ -111,7 +111,7 @@ static uint32_t get_elf_hwcap(void) =20 #ifdef TARGET_X86_64 #define ELF_START_MMAP 0x2aaaaab000ULL -#define elf_check_arch(x) ( ((x) =3D=3D ELF_ARCH) ) +#define elf_check_arch(x) (((x) =3D=3D ELF_ARCH)) =20 #define ELF_CLASS ELFCLASS64 #define ELF_DATA ELFDATA2LSB @@ -134,7 +134,7 @@ static inline void init_thread(struct target_pt_regs *r= egs, struct image_info *i /* * This is used to ensure we don't load something for the wrong architectu= re. */ -#define elf_check_arch(x) ( ((x) =3D=3D EM_386) || ((x) =3D=3D EM_486) ) +#define elf_check_arch(x) (((x) =3D=3D EM_386) || ((x) =3D=3D EM_486)) =20 /* * These are used to set parameters in the core dumps. @@ -168,7 +168,7 @@ static inline void init_thread(struct target_pt_regs *r= egs, struct image_info *i =20 #define ELF_START_MMAP 0x80000000 =20 -#define elf_check_arch(x) ( (x) =3D=3D EM_ARM ) +#define elf_check_arch(x) ((x) =3D=3D EM_ARM) =20 #define ELF_CLASS ELFCLASS32 #ifdef TARGET_WORDS_BIGENDIAN @@ -184,7 +184,7 @@ static inline void init_thread(struct target_pt_regs *r= egs, struct image_info *i memset(regs, 0, sizeof(*regs)); regs->ARM_cpsr =3D 0x10; if (infop->entry & 1) - regs->ARM_cpsr |=3D CPSR_T; + regs->ARM_cpsr |=3D CPSR_T; regs->ARM_pc =3D infop->entry & 0xfffffffe; regs->ARM_sp =3D infop->start_stack; /* FIXME - what to for failure of get_user()? */ @@ -224,9 +224,9 @@ enum #define ELF_START_MMAP 0x80000000 =20 #ifndef TARGET_ABI32 -#define elf_check_arch(x) ( (x) =3D=3D EM_SPARCV9 || (x) =3D=3D EM_SPARC32= PLUS ) +#define elf_check_arch(x) ((x) =3D=3D EM_SPARCV9 || (x) =3D=3D EM_SPARC32P= LUS) #else -#define elf_check_arch(x) ( (x) =3D=3D EM_SPARC32PLUS || (x) =3D=3D EM_SPA= RC ) +#define elf_check_arch(x) ((x) =3D=3D EM_SPARC32PLUS || (x) =3D=3D EM_SPAR= C) #endif =20 #define ELF_CLASS ELFCLASS64 @@ -261,7 +261,7 @@ static inline void init_thread(struct target_pt_regs *r= egs, struct image_info *i #else #define ELF_START_MMAP 0x80000000 =20 -#define elf_check_arch(x) ( (x) =3D=3D EM_SPARC ) +#define elf_check_arch(x) ((x) =3D=3D EM_SPARC) =20 #define ELF_CLASS ELFCLASS32 #define ELF_DATA ELFDATA2MSB @@ -285,13 +285,13 @@ static inline void init_thread(struct target_pt_regs = *regs, struct image_info *i =20 #if defined(TARGET_PPC64) && !defined(TARGET_ABI32) =20 -#define elf_check_arch(x) ( (x) =3D=3D EM_PPC64 ) +#define elf_check_arch(x) ((x) =3D=3D EM_PPC64) =20 #define ELF_CLASS ELFCLASS64 =20 #else =20 -#define elf_check_arch(x) ( (x) =3D=3D EM_PPC ) +#define elf_check_arch(x) ((x) =3D=3D EM_PPC) =20 #define ELF_CLASS ELFCLASS32 =20 @@ -376,7 +376,7 @@ static inline void init_thread(struct target_pt_regs *_= regs, struct image_info * =20 #define ELF_START_MMAP 0x80000000 =20 -#define elf_check_arch(x) ( (x) =3D=3D EM_MIPS ) +#define elf_check_arch(x) ((x) =3D=3D EM_MIPS) =20 #ifdef TARGET_MIPS64 #define ELF_CLASS ELFCLASS64 @@ -406,7 +406,7 @@ static inline void init_thread(struct target_pt_regs *r= egs, struct image_info *i =20 #define ELF_START_MMAP 0x80000000 =20 -#define elf_check_arch(x) ( (x) =3D=3D EM_SH ) +#define elf_check_arch(x) ((x) =3D=3D EM_SH) =20 #define ELF_CLASS ELFCLASS32 #define ELF_DATA ELFDATA2LSB @@ -428,7 +428,7 @@ static inline void init_thread(struct target_pt_regs *r= egs, struct image_info *i =20 #define ELF_START_MMAP 0x80000000 =20 -#define elf_check_arch(x) ( (x) =3D=3D EM_CRIS ) +#define elf_check_arch(x) ((x) =3D=3D EM_CRIS) =20 #define ELF_CLASS ELFCLASS32 #define ELF_DATA ELFDATA2LSB @@ -448,7 +448,7 @@ static inline void init_thread(struct target_pt_regs *r= egs, struct image_info *i =20 #define ELF_START_MMAP 0x80000000 =20 -#define elf_check_arch(x) ( (x) =3D=3D EM_68K ) +#define elf_check_arch(x) ((x) =3D=3D EM_68K) =20 #define ELF_CLASS ELFCLASS32 #define ELF_DATA ELFDATA2MSB @@ -473,7 +473,7 @@ static inline void init_thread(struct target_pt_regs *r= egs, struct image_info *i =20 #define ELF_START_MMAP (0x30000000000ULL) =20 -#define elf_check_arch(x) ( (x) =3D=3D ELF_ARCH ) +#define elf_check_arch(x) ((x) =3D=3D ELF_ARCH) =20 #define ELF_CLASS ELFCLASS64 #define ELF_DATA ELFDATA2MSB @@ -538,8 +538,8 @@ struct exec =20 /* Necessary parameters */ #define TARGET_ELF_EXEC_PAGESIZE TARGET_PAGE_SIZE -#define TARGET_ELF_PAGESTART(_v) ((_v) & ~(unsigned long)(TARGET_ELF_EXEC_= PAGESIZE-1)) -#define TARGET_ELF_PAGEOFFSET(_v) ((_v) & (TARGET_ELF_EXEC_PAGESIZE-1)) +#define TARGET_ELF_PAGESTART(_v) ((_v) & ~(unsigned long)(TARGET_ELF_EXEC_= PAGESIZE - 1)) +#define TARGET_ELF_PAGEOFFSET(_v) ((_v) & (TARGET_ELF_EXEC_PAGESIZE - 1)) =20 #define INTERPRETER_NONE 0 #define INTERPRETER_AOUT 1 @@ -547,12 +547,12 @@ struct exec =20 #define DLINFO_ITEMS 12 =20 -static inline void memcpy_fromfs(void * to, const void * from, unsigned lo= ng n) +static inline void memcpy_fromfs(void *to, const void *from, unsigned long= n) { memcpy(to, from, n); } =20 -static int load_aout_interp(void * exptr, int interp_fd); +static int load_aout_interp(void *exptr, int interp_fd); =20 #ifdef BSWAP_NEEDED static void bswap_ehdr(struct elfhdr *ehdr) @@ -613,7 +613,7 @@ static void bswap_sym(struct elf_sym *sym) * to be put directly into the top of new user memory. * */ -static abi_ulong copy_elf_strings(int argc,char ** argv, void **page, +static abi_ulong copy_elf_strings(int argc, char **argv, void **page, abi_ulong p) { char *tmp, *tmp1, *pag =3D NULL; @@ -638,10 +638,10 @@ static abi_ulong copy_elf_strings(int argc,char ** ar= gv, void **page, --p; --tmp; --len; if (--offset < 0) { offset =3D p % TARGET_PAGE_SIZE; - pag =3D (char *)page[p/TARGET_PAGE_SIZE]; + pag =3D (char *)page[p / TARGET_PAGE_SIZE]; if (!pag) { pag =3D g_try_malloc0(TARGET_PAGE_SIZE); - page[p/TARGET_PAGE_SIZE] =3D pag; + page[p / TARGET_PAGE_SIZE] =3D pag; if (!pag) return 0; } @@ -672,8 +672,8 @@ static abi_ulong setup_arg_pages(abi_ulong p, struct li= nux_binprm *bprm, * it for args, we'll use it for something else... */ size =3D x86_stack_size; - if (size < MAX_ARG_PAGES*TARGET_PAGE_SIZE) - size =3D MAX_ARG_PAGES*TARGET_PAGE_SIZE; + if (size < MAX_ARG_PAGES * TARGET_PAGE_SIZE) + size =3D MAX_ARG_PAGES * TARGET_PAGE_SIZE; error =3D target_mmap(0, size + qemu_host_page_size, PROT_READ | PROT_WRITE, @@ -686,7 +686,7 @@ static abi_ulong setup_arg_pages(abi_ulong p, struct li= nux_binprm *bprm, /* we reserve one extra page at the top of the stack as guard */ target_mprotect(error + size, qemu_host_page_size, PROT_NONE); =20 - stack_base =3D error + size - MAX_ARG_PAGES*TARGET_PAGE_SIZE; + stack_base =3D error + size - MAX_ARG_PAGES * TARGET_PAGE_SIZE; p +=3D stack_base; =20 for (i =3D 0 ; i < MAX_ARG_PAGES ; i++) { @@ -708,7 +708,7 @@ static void set_brk(abi_ulong start, abi_ulong end) end =3D HOST_PAGE_ALIGN(end); if (end <=3D start) return; - if(target_mmap(start, end - start, + if (target_mmap(start, end - start, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0) =3D=3D -= 1) { perror("cannot mmap brk"); @@ -738,12 +738,12 @@ static void padzero(abi_ulong elf_bss, abi_ulong last= _bss) end_addr =3D HOST_PAGE_ALIGN(elf_bss); if (end_addr1 < end_addr) { mmap((void *)g2h_untagged(end_addr1), end_addr - end_addr1, - PROT_READ|PROT_WRITE|PROT_EXEC, - MAP_FIXED|MAP_PRIVATE|MAP_ANON, -1, 0); + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0); } } =20 - nbyte =3D elf_bss & (qemu_host_page_size-1); + nbyte =3D elf_bss & (qemu_host_page_size - 1); if (nbyte) { nbyte =3D qemu_host_page_size - nbyte; do { @@ -781,10 +781,10 @@ static abi_ulong create_elf_tables(abi_ulong p, int a= rgc, int envc, /* * Force 16 byte _final_ alignment here for generality. */ - sp =3D sp &~ (abi_ulong)15; + sp =3D sp & ~(abi_ulong)15; size =3D (DLINFO_ITEMS + 1) * 2; if (k_platform) - size +=3D 2; + size +=3D 2; #ifdef DLINFO_ARCH_ITEMS size +=3D DLINFO_ARCH_ITEMS * 2; #endif @@ -792,7 +792,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int arg= c, int envc, size +=3D (!ibcs ? 3 : 1); /* argc itself */ size *=3D n; if (size & 15) - sp -=3D 16 - (size & 15); + sp -=3D 16 - (size & 15); =20 /* This is correct because Linux defines * elf_addr_t as Elf32_Off / Elf64_Off @@ -800,13 +800,13 @@ static abi_ulong create_elf_tables(abi_ulong p, int a= rgc, int envc, #define NEW_AUX_ENT(id, val) do { \ sp -=3D n; put_user_ual(val, sp); \ sp -=3D n; put_user_ual(id, sp); \ - } while(0) + } while (0) =20 - NEW_AUX_ENT (AT_NULL, 0); + NEW_AUX_ENT(AT_NULL, 0); =20 /* There must be exactly DLINFO_ITEMS entries here. */ NEW_AUX_ENT(AT_PHDR, (abi_ulong)(load_addr + exec->e_phoff)); - NEW_AUX_ENT(AT_PHENT, (abi_ulong)(sizeof (struct elf_phdr))); + NEW_AUX_ENT(AT_PHENT, (abi_ulong)(sizeof(struct elf_phdr))); NEW_AUX_ENT(AT_PHNUM, (abi_ulong)(exec->e_phnum)); NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(TARGET_PAGE_SIZE)); NEW_AUX_ENT(AT_BASE, (abi_ulong)(interp_load_addr)); @@ -834,90 +834,90 @@ static abi_ulong create_elf_tables(abi_ulong p, int a= rgc, int envc, } =20 =20 -static abi_ulong load_elf_interp(struct elfhdr * interp_elf_ex, +static abi_ulong load_elf_interp(struct elfhdr *interp_elf_ex, int interpreter_fd, abi_ulong *interp_load_addr) { - struct elf_phdr *elf_phdata =3D NULL; - struct elf_phdr *eppnt; - abi_ulong load_addr =3D 0; - int load_addr_set =3D 0; - int retval; - abi_ulong last_bss, elf_bss; - abi_ulong error; - int i; + struct elf_phdr *elf_phdata =3D NULL; + struct elf_phdr *eppnt; + abi_ulong load_addr =3D 0; + int load_addr_set =3D 0; + int retval; + abi_ulong last_bss, elf_bss; + abi_ulong error; + int i; =20 - elf_bss =3D 0; - last_bss =3D 0; - error =3D 0; + elf_bss =3D 0; + last_bss =3D 0; + error =3D 0; =20 #ifdef BSWAP_NEEDED - bswap_ehdr(interp_elf_ex); + bswap_ehdr(interp_elf_ex); #endif - /* First of all, some simple consistency checks */ - if ((interp_elf_ex->e_type !=3D ET_EXEC && - interp_elf_ex->e_type !=3D ET_DYN) || - !elf_check_arch(interp_elf_ex->e_machine)) { - return ~((abi_ulong)0UL); - } + /* First of all, some simple consistency checks */ + if ((interp_elf_ex->e_type !=3D ET_EXEC && + interp_elf_ex->e_type !=3D ET_DYN) || + !elf_check_arch(interp_elf_ex->e_machine)) { + return ~((abi_ulong)0UL); + } =20 =20 - /* Now read in all of the header information */ + /* Now read in all of the header information */ =20 - if (sizeof(struct elf_phdr) * interp_elf_ex->e_phnum > TARGET_PAGE= _SIZE) - return ~(abi_ulong)0UL; + if (sizeof(struct elf_phdr) * interp_elf_ex->e_phnum > TARGET_PAGE_SIZ= E) + return ~(abi_ulong)0UL; =20 - elf_phdata =3D (struct elf_phdr *) - malloc(sizeof(struct elf_phdr) * interp_elf_ex->e_phnum); + elf_phdata =3D (struct elf_phdr *) + malloc(sizeof(struct elf_phdr) * interp_elf_ex->e_phnum); =20 - if (!elf_phdata) - return ~((abi_ulong)0UL); + if (!elf_phdata) + return ~((abi_ulong)0UL); =20 - /* - * If the size of this structure has changed, then punt, since - * we will be doing the wrong thing. - */ - if (interp_elf_ex->e_phentsize !=3D sizeof(struct elf_phdr)) { - free(elf_phdata); - return ~((abi_ulong)0UL); - } + /* + * If the size of this structure has changed, then punt, since + * we will be doing the wrong thing. + */ + if (interp_elf_ex->e_phentsize !=3D sizeof(struct elf_phdr)) { + free(elf_phdata); + return ~((abi_ulong)0UL); + } =20 - retval =3D lseek(interpreter_fd, interp_elf_ex->e_phoff, SEEK_SET); - if(retval >=3D 0) { - retval =3D read(interpreter_fd, - (char *) elf_phdata, - sizeof(struct elf_phdr) * interp_elf_ex->e_phnu= m); - } - if (retval < 0) { - perror("load_elf_interp"); - exit(-1); - free (elf_phdata); - return retval; - } + retval =3D lseek(interpreter_fd, interp_elf_ex->e_phoff, SEEK_SET); + if (retval >=3D 0) { + retval =3D read(interpreter_fd, + (char *) elf_phdata, + sizeof(struct elf_phdr) * interp_elf_ex->e_phnum); + } + if (retval < 0) { + perror("load_elf_interp"); + exit(-1); + free (elf_phdata); + return retval; + } #ifdef BSWAP_NEEDED - eppnt =3D elf_phdata; - for (i=3D0; ie_phnum; i++, eppnt++) { - bswap_phdr(eppnt); - } + eppnt =3D elf_phdata; + for (i =3D 0; ie_phnum; i++, eppnt++) { + bswap_phdr(eppnt); + } #endif =20 - if (interp_elf_ex->e_type =3D=3D ET_DYN) { - /* in order to avoid hardcoding the interpreter load - address in qemu, we allocate a big enough memory zone */ - error =3D target_mmap(0, INTERP_MAP_SIZE, - PROT_NONE, MAP_PRIVATE | MAP_ANON, - -1, 0); - if (error =3D=3D -1) { - perror("mmap"); - exit(-1); - } - load_addr =3D error; - load_addr_set =3D 1; + if (interp_elf_ex->e_type =3D=3D ET_DYN) { + /* in order to avoid hardcoding the interpreter load + address in qemu, we allocate a big enough memory zone */ + error =3D target_mmap(0, INTERP_MAP_SIZE, + PROT_NONE, MAP_PRIVATE | MAP_ANON, + -1, 0); + if (error =3D=3D -1) { + perror("mmap"); + exit(-1); } + load_addr =3D error; + load_addr_set =3D 1; + } =20 - eppnt =3D elf_phdata; - for(i=3D0; ie_phnum; i++, eppnt++) - if (eppnt->p_type =3D=3D PT_LOAD) { + eppnt =3D elf_phdata; + for (i =3D 0; i < interp_elf_ex->e_phnum; i++, eppnt++) + if (eppnt->p_type =3D=3D PT_LOAD) { int elf_type =3D MAP_PRIVATE | MAP_DENYWRITE; int elf_prot =3D 0; abi_ulong vaddr =3D 0; @@ -930,23 +930,23 @@ static abi_ulong load_elf_interp(struct elfhdr * inte= rp_elf_ex, elf_type |=3D MAP_FIXED; vaddr =3D eppnt->p_vaddr; } - error =3D target_mmap(load_addr+TARGET_ELF_PAGESTART(vaddr), - eppnt->p_filesz + TARGET_ELF_PAGEOFFSET(eppnt->p_vaddr), - elf_prot, - elf_type, - interpreter_fd, - eppnt->p_offset - TARGET_ELF_PAGEOFFSET(eppnt->p_vaddr)); + error =3D target_mmap(load_addr + TARGET_ELF_PAGESTART(vaddr), + eppnt->p_filesz + TARGET_ELF_PAGEOFFSET(ep= pnt->p_vaddr), + elf_prot, + elf_type, + interpreter_fd, + eppnt->p_offset - TARGET_ELF_PAGEOFFSET(ep= pnt->p_vaddr)); =20 if (error =3D=3D -1) { - /* Real error */ - close(interpreter_fd); - free(elf_phdata); - return ~((abi_ulong)0UL); + /* Real error */ + close(interpreter_fd); + free(elf_phdata); + return ~((abi_ulong)0UL); } =20 if (!load_addr_set && interp_elf_ex->e_type =3D=3D ET_DYN) { - load_addr =3D error; - load_addr_set =3D 1; + load_addr =3D error; + load_addr_set =3D 1; } =20 /* @@ -962,31 +962,31 @@ static abi_ulong load_elf_interp(struct elfhdr * inte= rp_elf_ex, */ k =3D load_addr + eppnt->p_memsz + eppnt->p_vaddr; if (k > last_bss) last_bss =3D k; - } + } =20 - /* Now use mmap to map the library into memory. */ + /* Now use mmap to map the library into memory. */ =20 - close(interpreter_fd); + close(interpreter_fd); =20 - /* - * Now fill out the bss section. First pad the last page up - * to the page boundary, and then perform a mmap to make sure - * that there are zeromapped pages up to and including the last - * bss page. - */ - padzero(elf_bss, last_bss); - elf_bss =3D TARGET_ELF_PAGESTART(elf_bss + qemu_host_page_size - 1= ); /* What we have mapped so far */ - - /* Map the last of the bss segment */ - if (last_bss > elf_bss) { - target_mmap(elf_bss, last_bss-elf_bss, - PROT_READ|PROT_WRITE|PROT_EXEC, - MAP_FIXED|MAP_PRIVATE|MAP_ANON, -1, 0); - } - free(elf_phdata); + /* + * Now fill out the bss section. First pad the last page up + * to the page boundary, and then perform a mmap to make sure + * that there are zeromapped pages up to and including the last + * bss page. + */ + padzero(elf_bss, last_bss); + elf_bss =3D TARGET_ELF_PAGESTART(elf_bss + qemu_host_page_size - 1); /= * What we have mapped so far */ + + /* Map the last of the bss segment */ + if (last_bss > elf_bss) { + target_mmap(elf_bss, last_bss - elf_bss, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0); + } + free(elf_phdata); =20 - *interp_load_addr =3D load_addr; - return ((abi_ulong) interp_elf_ex->e_entry) + load_addr; + *interp_load_addr =3D load_addr; + return ((abi_ulong) interp_elf_ex->e_entry) + load_addr; } =20 static int symfind(const void *s0, const void *s1) @@ -1102,7 +1102,7 @@ static void load_symbols(struct elfhdr *hdr, int fd) } continue; } -#if defined(TARGET_ARM) || defined (TARGET_MIPS) +#if defined(TARGET_ARM) || defined(TARGET_MIPS) /* The bottom address bit marks a Thumb or MIPS16 symbol. */ syms[i].st_value &=3D ~(target_ulong)1; #endif @@ -1143,8 +1143,8 @@ static void load_symbols(struct elfhdr *hdr, int fd) syminfos =3D s; } =20 -int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * re= gs, - struct image_info * info) +int load_elf_binary(struct linux_binprm *bprm, struct target_pt_regs *regs, + struct image_info *info) { struct elfhdr elf_ex; struct elfhdr interp_elf_ex; @@ -1178,13 +1178,13 @@ int load_elf_binary(struct linux_binprm * bprm, str= uct target_pt_regs * regs, =20 /* First of all, some simple consistency checks */ if ((elf_ex.e_type !=3D ET_EXEC && elf_ex.e_type !=3D ET_DYN) || - (! elf_check_arch(elf_ex.e_machine))) { + (!elf_check_arch(elf_ex.e_machine))) { return -ENOEXEC; } =20 bprm->p =3D copy_elf_strings(1, &bprm->filename, bprm->page, bprm->p); - bprm->p =3D copy_elf_strings(bprm->envc,bprm->envp,bprm->page,bprm->p); - bprm->p =3D copy_elf_strings(bprm->argc,bprm->argv,bprm->page,bprm->p); + bprm->p =3D copy_elf_strings(bprm->envc, bprm->envp, bprm->page,bprm->= p); + bprm->p =3D copy_elf_strings(bprm->argc, bprm->argv, bprm->page,bprm->= p); if (!bprm->p) { retval =3D -E2BIG; } @@ -1196,21 +1196,21 @@ int load_elf_binary(struct linux_binprm * bprm, str= uct target_pt_regs * regs, } =20 retval =3D lseek(bprm->fd, elf_ex.e_phoff, SEEK_SET); - if(retval > 0) { - retval =3D read(bprm->fd, (char *) elf_phdata, + if (retval > 0) { + retval =3D read(bprm->fd, (char *)elf_phdata, elf_ex.e_phentsize * elf_ex.e_phnum); } =20 if (retval < 0) { perror("load_elf_binary"); exit(-1); - free (elf_phdata); + free(elf_phdata); return -errno; } =20 #ifdef BSWAP_NEEDED elf_ppnt =3D elf_phdata; - for (i=3D0; ip_type =3D=3D PT_INTERP) { - if ( elf_interpreter !=3D NULL ) + if (elf_interpreter !=3D NULL) { - free (elf_phdata); + free(elf_phdata); free(elf_interpreter); close(bprm->fd); return -EINVAL; @@ -1245,16 +1245,16 @@ int load_elf_binary(struct linux_binprm * bprm, str= uct target_pt_regs * regs, elf_interpreter =3D (char *)malloc(elf_ppnt->p_filesz); =20 if (elf_interpreter =3D=3D NULL) { - free (elf_phdata); + free(elf_phdata); close(bprm->fd); return -ENOMEM; } =20 retval =3D lseek(bprm->fd, elf_ppnt->p_offset, SEEK_SET); - if(retval >=3D 0) { + if (retval >=3D 0) { retval =3D read(bprm->fd, elf_interpreter, elf_ppnt->p_fil= esz); } - if(retval < 0) { + if (retval < 0) { perror("load_elf_binary2"); exit(-1); } @@ -1265,8 +1265,8 @@ int load_elf_binary(struct linux_binprm * bprm, struc= t target_pt_regs * regs, =20 /* JRP - Need to add X86 lib dir stuff here... */ =20 - if (strcmp(elf_interpreter,"/usr/lib/libc.so.1") =3D=3D 0 || - strcmp(elf_interpreter,"/usr/lib/ld.so.1") =3D=3D 0) { + if (strcmp(elf_interpreter, "/usr/lib/libc.so.1") =3D=3D 0 || + strcmp(elf_interpreter, "/usr/lib/ld.so.1") =3D=3D 0) { ibcs2_interpreter =3D 1; } =20 @@ -1275,7 +1275,7 @@ int load_elf_binary(struct linux_binprm * bprm, struc= t target_pt_regs * regs, #endif if (retval >=3D 0) { retval =3D open(path(elf_interpreter), O_RDONLY); - if(retval >=3D 0) { + if (retval >=3D 0) { interpreter_fd =3D retval; } else { @@ -1287,8 +1287,8 @@ int load_elf_binary(struct linux_binprm * bprm, struc= t target_pt_regs * regs, =20 if (retval >=3D 0) { retval =3D lseek(interpreter_fd, 0, SEEK_SET); - if(retval >=3D 0) { - retval =3D read(interpreter_fd,bprm->buf,128); + if (retval >=3D 0) { + retval =3D read(interpreter_fd, bprm->buf, 128); } } if (retval >=3D 0) { @@ -1298,7 +1298,7 @@ int load_elf_binary(struct linux_binprm * bprm, struc= t target_pt_regs * regs, if (retval < 0) { perror("load_elf_binary3"); exit(-1); - free (elf_phdata); + free(elf_phdata); free(elf_interpreter); close(bprm->fd); return retval; @@ -1308,17 +1308,17 @@ int load_elf_binary(struct linux_binprm * bprm, str= uct target_pt_regs * regs, } =20 /* Some simple consistency checks for the interpreter */ - if (elf_interpreter){ + if (elf_interpreter) { interpreter_type =3D INTERPRETER_ELF | INTERPRETER_AOUT; =20 /* Now figure out which format our binary is */ if ((N_MAGIC(interp_ex) !=3D OMAGIC) && (N_MAGIC(interp_ex) !=3D Z= MAGIC) && (N_MAGIC(interp_ex) !=3D QMAGIC)) { - interpreter_type =3D INTERPRETER_ELF; + interpreter_type =3D INTERPRETER_ELF; } =20 if (interp_elf_ex.e_ident[0] !=3D 0x7f || - strncmp((char *)&interp_elf_ex.e_ident[1], "ELF",3) !=3D 0= ) { + strncmp((char *)&interp_elf_ex.e_ident[1], "ELF", 3) !=3D = 0) { interpreter_type &=3D ~INTERPRETER_ELF; } =20 @@ -1334,20 +1334,20 @@ int load_elf_binary(struct linux_binprm * bprm, str= uct target_pt_regs * regs, and then start this sucker up */ =20 { - char * passed_p; + char *passed_p; =20 if (interpreter_type =3D=3D INTERPRETER_AOUT) { snprintf(passed_fileno, sizeof(passed_fileno), "%d", bprm->fd); passed_p =3D passed_fileno; =20 if (elf_interpreter) { - bprm->p =3D copy_elf_strings(1,&passed_p,bprm->page,bprm->= p); + bprm->p =3D copy_elf_strings(1, &passed_p, bprm->page, bpr= m->p); bprm->argc++; } } if (!bprm->p) { free(elf_interpreter); - free (elf_phdata); + free(elf_phdata); close(bprm->fd); return -E2BIG; } @@ -1393,7 +1393,7 @@ int load_elf_binary(struct linux_binprm * bprm, struc= t target_pt_regs * regs, * address. */ =20 - for(i =3D 0, elf_ppnt =3D elf_phdata; i < elf_ex.e_phnum; i++, elf_ppn= t++) { + for (i =3D 0, elf_ppnt =3D elf_phdata; i < elf_ex.e_phnum; i++, elf_pp= nt++) { int elf_prot =3D 0; int elf_flags =3D 0; abi_ulong error; @@ -1538,7 +1538,7 @@ int load_elf_binary(struct linux_binprm * bprm, struc= t target_pt_regs * regs, printf("(brk) %x\n" , info->brk); #endif =20 - if ( info->personality =3D=3D PER_SVR4 ) + if (info->personality =3D=3D PER_SVR4) { /* Why this, you ask??? Well SVr4 maps page 0 as read-only, and some applications "depend" upon this behavior. @@ -1553,7 +1553,7 @@ int load_elf_binary(struct linux_binprm * bprm, struc= t target_pt_regs * regs, return 0; } =20 -static int load_aout_interp(void * exptr, int interp_fd) +static int load_aout_interp(void *exptr, int interp_fd) { printf("a.out interpreter not yet supported\n"); return(0); --=20 2.22.1