This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Check bfd_mach_x64_32 to set tdesc for x32 binary


On Mon, May 14, 2012 at 11:42 AM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>> Date: Fri, 11 May 2012 16:13:04 -0700
>> From: "H.J. Lu" <hjl.tools@gmail.com>
>>
>> On Fri, May 11, 2012 at 1:20 PM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>> >> Hi,
>> >>
>> >> This patch checks bfd_mach_x64_32 to set tdesc for x32 binary. ?Tested
>> >> on Linux/x86-64. ?OK to install?
>> >>
>> >> Thanks.
>> >>
>> >>
>> >> H.J.
>> >> ---
>> >> ? ? ? * amd64-linux-tdep.c: Include features/i386/x32-linux.c
>> >> ? ? ? and features/i386/x32-avx-linux.c.
>> >> ? ? ? (amd64_linux_init_abi): Check bfd_mach_x64_32 for x32 process.
>> >> ? ? ? (_initialize_amd64_linux_tdep): Register bfd_mach_x64_32. ?Call
>> >> ? ? ? initialize_tdesc_x32_linux and initialize_tdesc_x32_avx_linux.
>> >>
>> >> ? ? ? * amd64-linux-tdep.h (tdesc_x32_linux): New.
>> >> ? ? ? (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)
>> >> ?{
>> >> ? ?gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
>> >> ? ? ? ? ? ? ? ? ? ? ? ? GDB_OSABI_LINUX, amd64_linux_init_abi);
>> >> + ?gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x64_32,
>> >> + ? ? ? ? ? ? ? ? ? ? ? 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_abi() and ovverride the bits that are different for X32.
>>
>> I don't think I should override tdep->tdesc. ?Here is a different approach.
>> 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. ?Tested on Linux/x86-64.
>> OK to install?
>
> No. ?Sorry, but you missed my point. ?I 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 = tdesc_amd64_linux;
  tdep->tdesc = 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.


-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]