* [patch] Fix PIE for 64bit gdb -> 32bit inferior
@ 2010-02-11 15:07 Jan Kratochvil
2010-02-16 23:34 ` Tom Tromey
0 siblings, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2010-02-11 15:07 UTC (permalink / raw)
To: gdb-patches; +Cc: Mark Kettenis
Hi,
according to the suggestion by Mark Kettenis the fix for biarch PIE is in fact
simple.
The displacement for cross-arch inferiors can use 64bit math operations if its
bits 32..63 are properly set to either 0x00000000 << 32 or 0xffffffff << 32 as
appropriate.
No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu. It fixes some
FAILs of gdb.base/break-interp.exp on {x86_64-m32}-fedora12-linux-gnu
(therefore host=x86_64-fedora12-linux-gnu target=i686-fedora12-linux-gnu).
Thanks,
Jan
2010-02-11 Jan Kratochvil <jan.kratochvil@redhat.com>
* solib-svr4.c (enable_break <target_auxv_search>): New variable
addr_bit. Adjust LOAD_ADDR sign for cross-arch inferiors.
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1428,7 +1428,32 @@ enable_break (struct svr4_info *info, int from_tty)
from our so_list, then try using the AT_BASE auxilliary entry. */
if (!load_addr_found)
if (target_auxv_search (¤t_target, AT_BASE, &load_addr) > 0)
- load_addr_found = 1;
+ {
+ int addr_bit = gdbarch_addr_bit (target_gdbarch);
+
+ /* Ensure LOAD_ADDR has proper sign in its possible upper bits so
+ that `+ load_addr' will overflow CORE_ADDR width not creating
+ invalid addresses like 0x101234567 for 32bit inferiors on 64bit
+ GDB. */
+
+ if (addr_bit < (sizeof (ULONGEST) * HOST_CHAR_BIT))
+ {
+ CORE_ADDR space_size = (ULONGEST) 1 << addr_bit;
+ CORE_ADDR tmp_entry_point = exec_entry_point (tmp_bfd,
+ tmp_bfd_target);
+
+ gdb_assert (load_addr < space_size);
+
+ /* TMP_ENTRY_POINT exceeding SPACE_SIZE would be for prelinked
+ 64bit ld.so with 32bit executable, it should not happen. */
+
+ if (tmp_entry_point < space_size
+ && tmp_entry_point + load_addr >= space_size)
+ load_addr -= space_size;
+ }
+
+ load_addr_found = 1;
+ }
/* Otherwise we find the dynamic linker's base address by examining
the current pc (which should point at the entry point for the
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] Fix PIE for 64bit gdb -> 32bit inferior
2010-02-11 15:07 [patch] Fix PIE for 64bit gdb -> 32bit inferior Jan Kratochvil
@ 2010-02-16 23:34 ` Tom Tromey
2010-02-17 11:38 ` Jan Kratochvil
0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2010-02-16 23:34 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches, Mark Kettenis
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> according to the suggestion by Mark Kettenis the fix for biarch PIE
Jan> is in fact simple.
Thanks.
Jan> 2010-02-11 Jan Kratochvil <jan.kratochvil@redhat.com>
Jan> * solib-svr4.c (enable_break <target_auxv_search>): New variable
Jan> addr_bit. Adjust LOAD_ADDR sign for cross-arch inferiors.
This is ok.
Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] Fix PIE for 64bit gdb -> 32bit inferior
2010-02-16 23:34 ` Tom Tromey
@ 2010-02-17 11:38 ` Jan Kratochvil
2010-02-17 19:57 ` H.J. Lu
0 siblings, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2010-02-17 11:38 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches, Mark Kettenis
On Wed, 17 Feb 2010 00:34:29 +0100, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> Jan> 2010-02-11 Jan Kratochvil <jan.kratochvil@redhat.com>
> Jan> * solib-svr4.c (enable_break <target_auxv_search>): New variable
> Jan> addr_bit. Adjust LOAD_ADDR sign for cross-arch inferiors.
>
> This is ok.
Checked-in:
http://sourceware.org/ml/gdb-cvs/2010-02/msg00135.html
Thanks,
Jan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] Fix PIE for 64bit gdb -> 32bit inferior
2010-02-17 11:38 ` Jan Kratochvil
@ 2010-02-17 19:57 ` H.J. Lu
0 siblings, 0 replies; 4+ messages in thread
From: H.J. Lu @ 2010-02-17 19:57 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Tom Tromey, gdb-patches, Mark Kettenis
On Wed, Feb 17, 2010 at 3:38 AM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> On Wed, 17 Feb 2010 00:34:29 +0100, Tom Tromey wrote:
>> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
>> Jan> 2010-02-11 Jan Kratochvil <jan.kratochvil@redhat.com>
>> Jan> * solib-svr4.c (enable_break <target_auxv_search>): New variable
>> Jan> addr_bit. Adjust LOAD_ADDR sign for cross-arch inferiors.
>>
>> This is ok.
>
> Checked-in:
> http://sourceware.org/ml/gdb-cvs/2010-02/msg00135.html
>
I think it caused:
http://www.sourceware.org/bugzilla/show_bug.cgi?id=11293
--
H.J.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-02-17 19:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-11 15:07 [patch] Fix PIE for 64bit gdb -> 32bit inferior Jan Kratochvil
2010-02-16 23:34 ` Tom Tromey
2010-02-17 11:38 ` Jan Kratochvil
2010-02-17 19:57 ` H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox