From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10619 invoked by alias); 27 Jul 2012 17:25:52 -0000 Received: (qmail 10603 invoked by uid 22791); 27 Jul 2012 17:25:50 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 Jul 2012 17:25:36 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6RHP6QI014406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 27 Jul 2012 13:25:06 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q6RHP2Sn019409; Fri, 27 Jul 2012 13:25:03 -0400 Message-ID: <5012CEEE.6080404@redhat.com> Date: Fri, 27 Jul 2012 17:25:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: Kai Tietz CC: Roland Schwingel , gdb-patches@sourceware.org, Joel Brobecker Subject: Re: [PATCH v4] Add dll trampoline code handling for windows 64bit References: <4F79BD71.4010703@onevision.com> <4F79CABA.8010009@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-07/txt/msg00701.txt.bz2 Hi Kai, On 07/25/2012 06:57 PM, Kai Tietz wrote: > Hello, > > I have now this patch for a while on my radar. I contacted Roland > Schwingel about the status of his paperwork with FSF, and he told me > that he completed it. Thanks. > So I want to ping this patch for him, as he > isn't able to ping on that patch himself for the next week(s). A patch with the comments addressed would have been better than just a ping. ;-) >>> 2012-04-02 Roland Schwingel >> >> Should be two spaces after your name. >> >>> +/* Check win64 DLL jmp trampolines and find jump destination. */ >> >> The correct spelling is "Win64" capitalized. >>> static void >>> amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) >>> { >>> struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); >>> >>> + /* Register trampoline handling code. */ >>> + set_gdbarch_skip_trampoline_code (gdbarch, amd64_windows_skip_trampoline_code); >> >> A nit, but it'd be cleaner/clearer to put this after the amd64_init_abi call, or >> better, near the end of the function, after set_gdbarch_skip_main_prologue. The current >> code reads "initialize the base arch, then install overrides.". This new call >> here breaks that flow. >> >>> + >>> amd64_init_abi (info, gdbarch); I confirm his paperwork is okay. I've done the changes mentioned above, and also a few other formatting fixes. I've checked it in, as below. 2012-07-27 Roland Schwingel * amd64-windows-tdep.c: Include "frame.h". (amd64_windows_skip_trampoline_code): New function. (amd64_windows_init_abi): Add trampoline registration. --- gdb/amd64-windows-tdep.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index 41e0efa..528fbb6 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -24,6 +24,7 @@ #include "gdbcore.h" #include "regcache.h" #include "windows-tdep.h" +#include "frame.h" /* The registers used to pass integer arguments during a function call. */ static int amd64_windows_dummy_call_integer_regs[] = @@ -154,6 +155,40 @@ amd64_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) return pc; } +/* Check Win64 DLL jmp trampolines and find jump destination. */ + +static CORE_ADDR +amd64_windows_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc) +{ + CORE_ADDR destination = 0; + struct gdbarch *gdbarch = get_frame_arch (frame); + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + + /* Check for jmp *(%rip) (jump near, absolute indirect (/4)). */ + if (pc && read_memory_unsigned_integer (pc, 2, byte_order) == 0x25ff) + { + /* Get opcode offset and see if we can find a reference in our data. */ + ULONGEST offset + = read_memory_unsigned_integer (pc + 2, 4, byte_order); + + /* Get address of function pointer at end of pc. */ + CORE_ADDR indirect_addr = pc + offset + 6; + + struct minimal_symbol *indsym + = indirect_addr ? lookup_minimal_symbol_by_pc (indirect_addr) : NULL; + const char *symname = indsym ? SYMBOL_LINKAGE_NAME (indsym) : NULL; + + if (symname) + { + if (strncmp (symname, "__imp_", 6) == 0 + || strncmp (symname, "_imp_", 5) == 0) + destination + = read_memory_unsigned_integer (indirect_addr, 8, byte_order); + } + } + + return destination; +} static void amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) @@ -174,6 +209,8 @@ amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) tdep->integer_param_regs_saved_in_caller_frame = 1; set_gdbarch_return_value (gdbarch, amd64_windows_return_value); set_gdbarch_skip_main_prologue (gdbarch, amd64_skip_main_prologue); + set_gdbarch_skip_trampoline_code (gdbarch, + amd64_windows_skip_trampoline_code); set_gdbarch_iterate_over_objfiles_in_search_order (gdbarch, windows_iterate_over_objfiles_in_search_order);