From patchwork Sat Jul 2 01:07:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 643362 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rhFXc5cknz9t0J for ; Sat, 2 Jul 2016 11:08:48 +1000 (AEST) Received: from localhost ([::1]:36506 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ9QM-0005UC-Ma for incoming@patchwork.ozlabs.org; Fri, 01 Jul 2016 21:08:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ9P8-0004ge-Ag for qemu-devel@nongnu.org; Fri, 01 Jul 2016 21:07:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bJ9P4-0001v4-5z for qemu-devel@nongnu.org; Fri, 01 Jul 2016 21:07:29 -0400 Received: from mail-cys01nam02on0067.outbound.protection.outlook.com ([104.47.37.67]:26624 helo=NAM02-CY1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bJ9P3-0001v0-UD for qemu-devel@nongnu.org; Fri, 01 Jul 2016 21:07:26 -0400 Received: from CY1NAM02FT055.eop-nam02.prod.protection.outlook.com (10.152.74.59) by CY1NAM02HT208.eop-nam02.prod.protection.outlook.com (10.152.75.53) with Microsoft SMTP Server (TLS) id 15.1.523.9; Sat, 2 Jul 2016 01:07:24 +0000 Authentication-Results: spf=fail (sender IP is 149.199.60.96) smtp.mailfrom=xilinx.com; redhat.com; dkim=none (message not signed) header.d=none; redhat.com; dmarc=none action=none header.from=xilinx.com; Received-SPF: Fail (protection.outlook.com: domain of xilinx.com does not designate 149.199.60.96 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.96; helo=xsj-tvapsmtpgw01; Received: from xsj-tvapsmtpgw01 (149.199.60.96) by CY1NAM02FT055.mail.protection.outlook.com (10.152.74.80) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.534.7 via Frontend Transport; Sat, 2 Jul 2016 01:07:23 +0000 Received: from 172-16-1-203.xilinx.com ([172.16.1.203]:39520 helo=xsj-tvapsmtp02.xilinx.com) by xsj-tvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1bJ9P1-0006cH-0v; Fri, 01 Jul 2016 18:07:23 -0700 Received: from [127.0.0.1] (port=48360 helo=tsj-smtp-dlp1.xlnx.xilinx.com) by xsj-tvapsmtp02.xilinx.com with esmtp (Exim 4.63) (envelope-from ) id 1bJ9P0-0003bA-U4; Fri, 01 Jul 2016 18:07:22 -0700 Received: from xsj-tvapsmtp02 (smtptest.xilinx.com [172.16.1.203]) by tsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u6210lhA007057; Fri, 1 Jul 2016 18:00:47 -0700 Received: from [172.19.74.182] (port=38972 helo=xsjalistai50.xilinx.com) by xsj-tvapsmtp02 with esmtp (Exim 4.63) (envelope-from ) id 1bJ9P0-0003b7-52; Fri, 01 Jul 2016 18:07:22 -0700 From: Alistair Francis To: , Date: Fri, 1 Jul 2016 18:07:04 -0700 Message-ID: <8be6c03a245859be421fb38ffa6dfa3d29945ecf.1467417982.git.alistair.francis@xilinx.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-RCIS-Action: ALLOW X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-8.0.0.1202-22424.005 X-TM-AS-Result: No--4.183-7.0-31-10 X-imss-scan-details: No--4.183-7.0-31-10 X-TMASE-MatchedRID: P4k0k3s6QU3Hz0i32AeJEVVN8laWo90M9Nx/wC/5BIDfUZT83lbkEI90 GxaR8c3t2Jk1Lg0m0bmN/3dDbj3CNY9oUcx9VMLgFEUknJ/kEl5q8/xv2Um1avoLR4+zsDTtrXT /QMyU2Nw6K/v0nbLXAq6bxZ9VTnw/fYtTEv5mb8SiFuwC5LrQ3lV7dTsdCQdxP+cBvcylTj6Zib AWv9vv65u9aNlianKnH+AFWGDPB/PyDBYNCJzj6s+YAJ5mo7zlOKgonZY9TFPBiRYum5A768C+k sT6a9fy X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.96; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(106466001)(47776003)(7696003)(50466002)(118296001)(85426001)(36756003)(5003600100003)(19580395003)(64026002)(19580405001)(105606002)(48376002)(71366001)(305945005)(4326007)(7846002)(81166006)(356003)(81156014)(2906002)(86362001)(8676002)(5003940100001)(189998001)(50226002)(77096005)(92566002)(9786002)(5001770100001)(586003)(87936001)(33646002)(76176999)(2950100001)(229853001)(50986999)(8936002)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1NAM02HT208; H:xsj-tvapsmtpgw01; FPR:; SPF:Fail; PTR:unknown-60-96.xilinx.com; A:1; MX:1; CAT:NONE; LANG:en; CAT:NONE; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 5aa26016-0c2f-46da-8f65-08d3a21539d9 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1NAM02HT208; X-Microsoft-Antispam-PRVS: <9b1570e4ec634fca8447dadfa360dc2d@CY1NAM02HT208.eop-nam02.prod.protection.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(13017025)(13024025)(13023025)(13015025)(13018025)(3002001)(10201501046)(6055026); SRVR:CY1NAM02HT208; BCL:0; PCL:0; RULEID:; SRVR:CY1NAM02HT208; X-Forefront-PRVS: 0991CAB7B3 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2016 01:07:23.4350 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.96]; Helo=[xsj-tvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1NAM02HT208 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.37.67 Subject: [Qemu-devel] [PATCH v8 1/5] loader: Allow ELF loader to auto-detect the ELF arch 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: cov@codeaurora.org, crosthwaitepeter@gmail.com, pbonzini@redhat.com, armbru@redhat.com, alistair.francis@xilinx.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" If the caller didn't specify an architecture for the ELF machine the load_elf() function will auto detect it based on the ELF file. Signed-off-by: Alistair Francis --- V8: - Move into load_elf64/load_elf32 V7: - Fix typo include/hw/elf_ops.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h index f510e7e..db70c11 100644 --- a/include/hw/elf_ops.h +++ b/include/hw/elf_ops.h @@ -280,6 +280,11 @@ static int glue(load_elf, SZ)(const char *name, int fd, glue(bswap_ehdr, SZ)(&ehdr); } + if (elf_machine < 1) { + /* The caller didn't specify an ARCH, we can figure it out */ + elf_machine = ehdr.e_machine; + } + switch (elf_machine) { case EM_PPC64: if (ehdr.e_machine != EM_PPC64) {