From patchwork Wed Sep 11 06:49:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11140461 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B345D1395 for ; Wed, 11 Sep 2019 07:08:04 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 93E77222BF for ; Wed, 11 Sep 2019 07:08:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93E77222BF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:47192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7wjT-0000kC-3P for patchwork-qemu-devel@patchwork.kernel.org; Wed, 11 Sep 2019 03:08:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40905) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i7wRk-00068w-J5 for qemu-devel@nongnu.org; Wed, 11 Sep 2019 02:49:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i7wRj-0004Qc-13 for qemu-devel@nongnu.org; Wed, 11 Sep 2019 02:49:44 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:53909) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i7wRi-0004Pv-P2 for qemu-devel@nongnu.org; Wed, 11 Sep 2019 02:49:42 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MF3Y8-1hsYDp3EXQ-00FVtr; Wed, 11 Sep 2019 08:49:30 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Wed, 11 Sep 2019 08:49:13 +0200 Message-Id: <20190911064920.1718-9-laurent@vivier.eu> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190911064920.1718-1-laurent@vivier.eu> References: <20190911064920.1718-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:XctwPDcSm58FR8JIA/1GR/JKYqhEdsyYJBACwt7866Wxq36LhJo ExXa6FP1Ijad+wIKMsSoixv//jNPBC7RCf4cIQJUopfC49nf2dd89CgDlOIWfSieVZ5v3KT ZY1HadVsoeM7cbeqMsC2yAXBXYsSm0V/+CTRQ9XVEbK5zBx8o/J3USqFKkbWI/mj8BX9WSM ystkQ6HLtL36d3Mt5bGcQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:Nh4AoSULLbY=:fhqEHJHpeFd6iS5Zi5PAAm O3lIEH2Az+zEY1X262R1pymeaOz89mU+NkjHhulGCl2AcpoOFlcc8oKTv5xJrcnmgYCDfrk9W nuiQyLrpGviSvq2tL3JAQoC37c/MgfxFAzjck7try7SIIzxltH4Mg9juY8fkgWvP5mABR/qmg YQ8GFc2kRE4CJfMo10HN8q+o6I//7Olgtjj/NH/bZBX8wVyIxKzOYa8EofRjdVHyDGwWIV/Tz heAxCN3AKHzqDgOHJphvgHmS2UxHcV87cwfDvEBOdZ698W8lY4YoBawfzieZuwX4UjqBB3bA+ kuI8f9fguUwLCvqr09qc+VQrxFVYANDn1H0ozvsxZITzUihYxtgks2HQ1K4ZyoGw25cGfxNvz M3xsk0uphvhgw+4OA6ObVlnNucobcwMItlDf60hX4GWLXfQuYvgVucOna4NdRd8IAfqF1ydPe Jw8s9Md83QsvFKYjYyMbkCds1nJBB0b+2zp9QqxRVPpUxrAZNLaIKX3ksOQBQVWR3VpO2NtNz 8KPxhqdKliYiZhIr1fgIF27Y20nnxRnlNWZab79WzPAfza6hKiy1XV+wg3eAARY+zos1NaNU/ 2+dwmH0wVwF12EAIlWNthay6G4smddkVLvpTWAkeH9ct4v/3FGknPwMgQwjTteJUKglHUZhH2 Ho1p7o7zlAUOvYkp8e4k/hINrf1i2x7qKEYzR9mqPX56x5xIH8Z4tNtpbngHOUjtYW6pgjm3M wOfkws0l54thgqKIEkzIpG7tsydALHWbVhyAkOkA4Z3Gd9NErpJ09uOf4GfoRfEWl162g5WRP uo+hnX4o3wqGOvFXKg+5cfvc/yunovhw+d1HQUu9mGfgBYSNDA= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.130 Subject: [Qemu-devel] [PULL v2 08/15] linux-user: Support gdb 'qOffsets' query for ELF 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: Max Filippov , Riku Voipio , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Laurent Vivier , Josh Kunz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Josh Kunz This is needed to support debugging PIE ELF binaries running under QEMU user mode. Currently, `code_offset` and `data_offset` remain unset for all ELF binaries, so GDB is unable to correctly locate the position of the binary's text and data. The fields `code_offset`, and `data_offset` were originally added way back in 2006 to support debugging of bFMT executables (978efd6aac6), and support was just never added for ELF. Since non-PIE binaries are loaded at exactly the address specified in the binary, GDB does not need to relocate any symbols, so the buggy behavior is not normally observed. http://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#index-qOffsets-packet Buglink: https://bugs.launchpad.net/qemu/+bug/1528239 Signed-off-by: Josh Kunz Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20190816233422.16715-1-jkz@google.com> [lv: added link to documentation] Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 43c16a846d33..f6693e576098 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2403,6 +2403,8 @@ static void load_elf_image(const char *image_name, int image_fd, } info->load_bias = load_bias; + info->code_offset = load_bias; + info->data_offset = load_bias; info->load_addr = load_addr; info->entry = ehdr->e_entry + load_bias; info->start_code = -1;