From patchwork Tue May 27 19:12:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 353086 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 E4292140093 for ; Wed, 28 May 2014 05:19:11 +1000 (EST) Received: from localhost ([::1]:37325 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpMtw-0002et-MF for incoming@patchwork.ozlabs.org; Tue, 27 May 2014 15:19:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpMol-0004HR-1P for qemu-devel@nongnu.org; Tue, 27 May 2014 15:13:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WpMof-0007SL-1f for qemu-devel@nongnu.org; Tue, 27 May 2014 15:13:46 -0400 Received: from mail-ve0-x22b.google.com ([2607:f8b0:400c:c01::22b]:59135) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpMoe-0007S7-K4 for qemu-devel@nongnu.org; Tue, 27 May 2014 15:13:40 -0400 Received: by mail-ve0-f171.google.com with SMTP id oz11so11238537veb.16 for ; Tue, 27 May 2014 12:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=V4+W457PqBC+fLU/HjwPaz3Ff3K6zFGIY75xMiYHVR4=; b=EUQfcSGtezJ/9OWltdHTgHSFBZxoS845GpFOC0/r3SEV3SD74N5I6WOUzKQLRlwsK3 /PgWSMKUaJxz4l0YxE3hX10i6zcdkOHCzJRgJYX3mPkSB7vJ5vv/rfdP5mPnHEl8Z7r6 hT+JTY96z/AfVpyBhtDEEdbxVvzNmxcXEciZ+R36o4B4sNDCpCddpepmrJqZ5JbsdzSj lgTTjJvpsrbZz69tCnOt4C7n2frmYYaV7tkx71922vDoa6MOQECnLIdWSwOhly1nK697 jBHSHmZkGNTfVu/bFZ5xyly9eKrz1ufU9BhKcYEkVVEwmu06Pyk6NbrrVGitHygaz6EM u9Fg== X-Received: by 10.52.75.40 with SMTP id z8mr2453640vdv.90.1401218019740; Tue, 27 May 2014 12:13:39 -0700 (PDT) Received: from anchor.com (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPSA id c7sm16924148vei.16.2014.05.27.12.13.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 May 2014 12:13:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 27 May 2014 12:12:38 -0700 Message-Id: <1401217965-28228-12-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1401217965-28228-1-git-send-email-rth@twiddle.net> References: <1401217965-28228-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400c:c01::22b Cc: peter.maydell@linaro.org Subject: [Qemu-devel] [PULL 11/18] tcg: Allow the debug_frame data structure to be constant X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Adjust the FDE to point to the code_buffer after we've copied it to the image, rather than requiring that the backend set it prior. This allows the backend to use read-only storage for its data. Signed-off-by: Richard Henderson --- tcg/tcg.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 219c995..e73b403 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -86,8 +86,14 @@ typedef struct QEMU_PACKED { uintptr_t func_len; } DebugFrameFDEHeader; +typedef struct QEMU_PACKED { + DebugFrameCIE cie; + DebugFrameFDEHeader fde; +} DebugFrameHeader; + static void tcg_register_jit_int(void *buf, size_t size, - void *debug_frame, size_t debug_frame_size) + const void *debug_frame, + size_t debug_frame_size) __attribute__((unused)); /* Forward declarations for functions declared and used in tcg-target.c. */ @@ -2777,7 +2783,8 @@ static int find_string(const char *strtab, const char *str) } static void tcg_register_jit_int(void *buf_ptr, size_t buf_size, - void *debug_frame, size_t debug_frame_size) + const void *debug_frame, + size_t debug_frame_size) { struct __attribute__((packed)) DebugInfo { uint32_t len; @@ -2915,10 +2922,10 @@ static void tcg_register_jit_int(void *buf_ptr, size_t buf_size, uintptr_t buf = (uintptr_t)buf_ptr; size_t img_size = sizeof(struct ElfImage) + debug_frame_size; + DebugFrameHeader *dfh; img = g_malloc(img_size); *img = img_template; - memcpy(img + 1, debug_frame, debug_frame_size); img->phdr.p_vaddr = buf; img->phdr.p_paddr = buf; @@ -2946,6 +2953,11 @@ static void tcg_register_jit_int(void *buf_ptr, size_t buf_size, img->di.fn_low_pc = buf; img->di.fn_high_pc = buf + buf_size; + dfh = (DebugFrameHeader *)(img + 1); + memcpy(dfh, debug_frame, debug_frame_size); + dfh->fde.func_start = buf; + dfh->fde.func_len = buf_size; + #ifdef DEBUG_JIT /* Enable this block to be able to debug the ELF image file creation. One can use readelf, objdump, or other inspection utilities. */