From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1514 invoked by alias); 14 May 2012 19:02:42 -0000 Received: (qmail 1503 invoked by uid 22791); 14 May 2012 19:02:41 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_AV X-Spam-Check-By: sourceware.org Received: from mail-qc0-f169.google.com (HELO mail-qc0-f169.google.com) (209.85.216.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 May 2012 19:02:28 +0000 Received: by qcsd16 with SMTP id d16so4318756qcs.0 for ; Mon, 14 May 2012 12:02:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.135.203 with SMTP id o11mr4605686qct.80.1337022147241; Mon, 14 May 2012 12:02:27 -0700 (PDT) Received: by 10.229.169.130 with HTTP; Mon, 14 May 2012 12:02:27 -0700 (PDT) In-Reply-To: <201205141842.q4EIgXAV016110@glazunov.sibelius.xs4all.nl> References: <20120511192949.GA5070@intel.com> <201205112020.q4BKKAbT010335@glazunov.sibelius.xs4all.nl> <201205141842.q4EIgXAV016110@glazunov.sibelius.xs4all.nl> Date: Mon, 14 May 2012 19:02:00 -0000 Message-ID: Subject: Re: PATCH: Check bfd_mach_x64_32 to set tdesc for x32 binary From: "H.J. Lu" To: Mark Kettenis Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes 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-05/txt/msg00537.txt.bz2 On Mon, May 14, 2012 at 11:42 AM, Mark Kettenis w= rote: >> Date: Fri, 11 May 2012 16:13:04 -0700 >> From: "H.J. Lu" >> >> On Fri, May 11, 2012 at 1:20 PM, Mark Kettenis = wrote: >> >> Hi, >> >> >> >> This patch checks bfd_mach_x64_32 to set tdesc for x32 binary. =A0Tes= ted >> >> on Linux/x86-64. =A0OK to install? >> >> >> >> Thanks. >> >> >> >> >> >> H.J. >> >> --- >> >> =A0 =A0 =A0 * amd64-linux-tdep.c: Include features/i386/x32-linux.c >> >> =A0 =A0 =A0 and features/i386/x32-avx-linux.c. >> >> =A0 =A0 =A0 (amd64_linux_init_abi): Check bfd_mach_x64_32 for x32 pro= cess. >> >> =A0 =A0 =A0 (_initialize_amd64_linux_tdep): Register bfd_mach_x64_32.= =A0Call >> >> =A0 =A0 =A0 initialize_tdesc_x32_linux and initialize_tdesc_x32_avx_l= inux. >> >> >> >> =A0 =A0 =A0 * amd64-linux-tdep.h (tdesc_x32_linux): New. >> >> =A0 =A0 =A0 (tdesc_x32_avx_linux): Likewise. >> >> >> >> diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c >> >> index acc7303..601ce20 100644 >> >> --- a/gdb/amd64-linux-tdep.c >> >> +++ b/gdb/amd64-linux-tdep.c >> >> @@ -1545,8 +1578,12 @@ _initialize_amd64_linux_tdep (void) >> >> =A0{ >> >> =A0 =A0gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 GDB_OSABI_LINUX, amd6= 4_linux_init_abi); >> >> + =A0gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x64_32, >> >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 GDB_OSABI_LINUX, amd64_= linux_init_abi); >> > >> > Instead of doing this, you should introduce an >> > amd64_x32_linux_init_abi() function, make that call amd64_linix_init_a= bi() and ovverride the bits that are different for X32. >> >> I don't think I should override tdep->tdesc. =A0Here is a different appr= oach. >> I updated amd64_linux_init_abi to take amd64_linux_tdesc and fetch_func. >> I also added amd64_lp64_linux_init_abi and amd64_ilp32_linux_init_abi >> to pass the right ones to amd64_linux_init_abi. =A0Tested on Linux/x86-6= 4. >> OK to install? > > No. =A0Sorry, but you missed my point. =A0I want you to introduce a > seperate function such that it will be easy to override stuff > specifically for x32 without adding lots of if statements that turn > the code into spaghetti. > The current amd64_linux_init_abi has if (! tdesc_has_registers (tdesc)) tdesc =3D tdesc_amd64_linux; tdep->tdesc =3D tdesc; If tdesc_has_registers is false, and tdesc field is set to tdesc_amd64_linux, how can x32 override it safely since it can be set to something else if tdesc_has_registers is true? Thanks. --=20 H.J.