From nobody Mon Feb 9 04:46:25 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1630012980737232.29016411039765; Thu, 26 Aug 2021 14:23:00 -0700 (PDT) Received: from localhost ([::1]:36736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJMpv-0000O4-HA for importer@patchew.org; Thu, 26 Aug 2021 17:22:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJMfr-0005s8-Ug for qemu-devel@nongnu.org; Thu, 26 Aug 2021 17:12:35 -0400 Received: from mail-il1-x130.google.com ([2607:f8b0:4864:20::130]:34458) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mJMfq-0006oc-3d for qemu-devel@nongnu.org; Thu, 26 Aug 2021 17:12:35 -0400 Received: by mail-il1-x130.google.com with SMTP id j15so4766067ila.1 for ; Thu, 26 Aug 2021 14:12:33 -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 a17sm2348633ilp.75.2021.08.26.14.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 14:12:32 -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=JbEdUvbo/mrg2leYF7EcbjbkdggBVAu4KQwCBbiNYLY=; b=1vyhn53sri7br23ykNfZzKsgIDw/xs72fG8shsTgIpdr90npUEy1PwfnTmq+Qr8uJR 9QJE6k7JLKq84610e3DR3JbLWzE6978D6ZxOa340alEOpHv6BdNn4mqS3ImKPOqFlG9z VsgXXY+H41rToLZi1vB6XMTnR+BIPyX2kA7Igm9znMG4ZS8CJeTlObS2FU6uaM0gDeUW oAOFh89r+6l3c0Q7HQ1ZPaMlwioJAy44AafTwKeeDrA3jDob6iNIWkActmI3rYUBxCr2 xwpxCzBjWipmgt+gQ6g5nISYlnqgCGFel75SS6fiWR3HUfE14n4yFOe/FC9FuBwXZwH4 m9gw== 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=JbEdUvbo/mrg2leYF7EcbjbkdggBVAu4KQwCBbiNYLY=; b=K9UrJ5q+ihXRQfRE+lyfx0KlASlA+Y2dFKlTR9zeMuGLnH1Jmh/Q5+Dmy7EvcZhgiw oEtoBLmhGoAVQDJwU0HrrxdVu4vqm2YG0JKjTMP+xujmqolEORY/Jrj1RV1vachkf1o8 4iZJIo/LhgaPKE4awJkTWvA3ZvAqtYmrJyfTfI7WmzJnjnlO94k2yxxElcEGPkaArykZ Mm0Sb4buo5i7pVKQFCzozMWE+vLczQ3M95GpD/Owzkz65vMF8wFv7HtcW31B6Y/+Z9lj kHNiH0npqDPgWHXQS6xy4GHrPSLD0ykncU4iJsB01Wt2+X3XsdEERf+xpuiAn1QGCcW+ oh6A== X-Gm-Message-State: AOAM532cnRKB595teinGEqoejhe48NPfxdtX9JnFogK/BSWMGxusYNx0 xM6ZFUKVQW33VG08pksTbKo5XA6JzRQDSb1X X-Google-Smtp-Source: ABdhPJyJW7s8BpavmjfKFUnAjOSQC/o6z02OeVr8kd0lX9qTLb6KC+tnFF//JXahchrVwQaRW2uNjA== X-Received: by 2002:a05:6e02:e8b:: with SMTP id t11mr4056611ilj.175.1630012352869; Thu, 26 Aug 2021 14:12:32 -0700 (PDT) From: imp@bsdimp.com To: qemu-devel@nongnu.org Subject: [PATCH v2 11/43] bsd-user: Eliminate elf personality Date: Thu, 26 Aug 2021 15:11:29 -0600 Message-Id: <20210826211201.98877-12-imp@bsdimp.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210826211201.98877-1-imp@bsdimp.com> References: <20210826211201.98877-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::130; envelope-from=imp@bsdimp.com; helo=mail-il1-x130.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: Richard Henderson , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1630012981928100001 Content-Type: text/plain; charset="utf-8" From: Warner Losh The linux kernel supports a number of different ELF binaries. The Linux use= rland emulator inheritted some of that. And we inheritted it from there. However,= for BSD there's only one kind of ELF file supported per platform, so there's no= need to cope with historical quirks. Simply the code as a result. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/elfload.c | 87 ---------------------------------------------- bsd-user/qemu.h | 1 - 2 files changed, 88 deletions(-) diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c index 639673f5b7..e950732978 100644 --- a/bsd-user/elfload.c +++ b/bsd-user/elfload.c @@ -25,66 +25,6 @@ =20 #include "target_arch_elf.h" =20 -/* from personality.h */ - -/* - * Flags for bug emulation. - * - * These occupy the top three bytes. - */ -enum { - ADDR_NO_RANDOMIZE =3D 0x0040000, /* disable randomization= of VA space */ - FDPIC_FUNCPTRS =3D 0x0080000, /* userspace function pt= rs point to descriptors - * (signal handling) - */ - MMAP_PAGE_ZERO =3D 0x0100000, - ADDR_COMPAT_LAYOUT =3D 0x0200000, - READ_IMPLIES_EXEC =3D 0x0400000, - ADDR_LIMIT_32BIT =3D 0x0800000, - SHORT_INODE =3D 0x1000000, - WHOLE_SECONDS =3D 0x2000000, - STICKY_TIMEOUTS =3D 0x4000000, - ADDR_LIMIT_3GB =3D 0x8000000, -}; - -/* - * Personality types. - * - * These go in the low byte. Avoid using the top bit, it will - * conflict with error returns. - */ -enum { - PER_LINUX =3D 0x0000, - PER_LINUX_32BIT =3D 0x0000 | ADDR_LIMIT_32BIT, - PER_LINUX_FDPIC =3D 0x0000 | FDPIC_FUNCPTRS, - PER_SVR4 =3D 0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZER= O, - PER_SVR3 =3D 0x0002 | STICKY_TIMEOUTS | SHORT_INODE, - PER_SCOSVR3 =3D 0x0003 | STICKY_TIMEOUTS | - WHOLE_SECONDS | SHORT_INODE, - PER_OSR5 =3D 0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS, - PER_WYSEV386 =3D 0x0004 | STICKY_TIMEOUTS | SHORT_INODE, - PER_ISCR4 =3D 0x0005 | STICKY_TIMEOUTS, - PER_BSD =3D 0x0006, - PER_SUNOS =3D 0x0006 | STICKY_TIMEOUTS, - PER_XENIX =3D 0x0007 | STICKY_TIMEOUTS | SHORT_INODE, - PER_LINUX32 =3D 0x0008, - PER_LINUX32_3GB =3D 0x0008 | ADDR_LIMIT_3GB, - PER_IRIX32 =3D 0x0009 | STICKY_TIMEOUTS,/* IRIX5 32-bit= */ - PER_IRIXN32 =3D 0x000a | STICKY_TIMEOUTS,/* IRIX6 new 32= -bit */ - PER_IRIX64 =3D 0x000b | STICKY_TIMEOUTS,/* IRIX6 64-bit= */ - PER_RISCOS =3D 0x000c, - PER_SOLARIS =3D 0x000d | STICKY_TIMEOUTS, - PER_UW7 =3D 0x000e | STICKY_TIMEOUTS | MMAP_PAGE_ZER= O, - PER_OSF4 =3D 0x000f, /* OSF/1 v4 */ - PER_HPUX =3D 0x0010, - PER_MASK =3D 0x00ff, -}; - -/* - * Return the base personality without flags. - */ -#define personality(pers) (pers & PER_MASK) - /* this flag is uneffective under linux too, should be deleted */ #ifndef MAP_DENYWRITE #define MAP_DENYWRITE 0 @@ -750,7 +690,6 @@ int load_elf_binary(struct bsd_binprm *bprm, struct tar= get_pt_regs *regs, abi_ulong load_addr, load_bias; int load_addr_set =3D 0; unsigned int interpreter_type =3D INTERPRETER_NONE; - unsigned char ibcs2_interpreter; int i; struct elf_phdr * elf_ppnt; struct elf_phdr *elf_phdata; @@ -765,7 +704,6 @@ int load_elf_binary(struct bsd_binprm *bprm, struct tar= get_pt_regs *regs, #endif char passed_fileno[6]; =20 - ibcs2_interpreter =3D 0; load_addr =3D 0; load_bias =3D 0; elf_ex =3D *((struct elfhdr *) bprm->buf); /* exec-header */ @@ -856,20 +794,6 @@ int load_elf_binary(struct bsd_binprm *bprm, struct ta= rget_pt_regs *regs, exit(-1); } =20 - /* If the program interpreter is one of these two, - then assume an iBCS2 image. Otherwise assume - a native linux image. */ - - /* JRP - Need to add X86 lib dir stuff here... */ - - 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; - } - -#if 0 - printf("Using ELF interpreter %s\n", path(elf_interpreter)); -#endif if (retval >=3D 0) { retval =3D open(path(elf_interpreter), O_RDONLY); if (retval >=3D 0) { @@ -1099,7 +1023,6 @@ int load_elf_binary(struct bsd_binprm *bprm, struct t= arget_pt_regs *regs, load_symbols(&elf_ex, bprm->fd); =20 if (interpreter_type !=3D INTERPRETER_AOUT) close(bprm->fd); - info->personality =3D (ibcs2_interpreter ? PER_SVR4 : PER_LINUX); =20 #ifdef LOW_ELF_STACK info->start_stack =3D bprm->p =3D elf_stack - 4; @@ -1135,16 +1058,6 @@ int load_elf_binary(struct bsd_binprm *bprm, struct = target_pt_regs *regs, printf("(brk) %x\n" , info->brk); #endif =20 - 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. - Since we do not have the power to recompile these, we - emulate the SVr4 behavior. Sigh. */ - target_mmap(0, qemu_host_page_size, PROT_READ | PROT_EXEC, - MAP_FIXED | MAP_PRIVATE, -1, 0); - } - info->entry =3D elf_entry; =20 return 0; diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 6b601ce4b5..e85c164bab 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -66,7 +66,6 @@ struct image_info { abi_ulong entry; abi_ulong code_offset; abi_ulong data_offset; - int personality; }; =20 #define MAX_SIGQUEUE_SIZE 1024 --=20 2.32.0