* [patch] Extend PIC displacement check by minpagesize
@ 2010-02-13 16:09 Jan Kratochvil
2010-02-15 17:28 ` Ulrich Weigand
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2010-02-13 16:09 UTC (permalink / raw)
To: gdb-patches; +Cc: Ulrich Weigand
Hi,
this is a minor patch not blocking anything I just found while working on PIE.
It just makes the PIC heuristics there a small bit more reliable.
This is a dissected part from the original patch:
[patch] Sanity check PIE displacement (like the PIC one)
http://sourceware.org/ml/gdb-patches/2010-02/msg00000.html
It is a follow-up to the change:
[rfa] Fix detection of prelinked libraries on PPC
http://sourceware.org/ml/gdb-patches/2007-07/msg00109.html
http://sourceware.org/ml/gdb-cvs/2007-07/msg00055.html
fc5294c8de7ee77ec3ed9e0ca2dff670d0e7789f
One needs for a reproducibility Linux kernel with:
# CONFIG_PPC_64K_PAGES is not set
Verified on gdb.ppc64 it stil works for inferior.ppc32 + core.ppc32:
minpagesize = 0x1000
align = 0xffff
l_addr = 0xff8f000
l_dynaddr = 0xff9f648
dynaddr = 0xffa0648
l_dynaddr-dynaddr = 0xfffff000
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x0ff90000 0x0ff90000 0x0060c 0x0060c R E 0x10000
LOAD 0x00060c 0x0ffa060c 0x0ffa060c 0x0011c 0x00124 RW 0x10000
ELF_MINPAGESIZE is always at least 1 in bfd/*.
No regressions on {ppc64-m32}-fedora12-linux-gnu (that is
host=powerpc64-fedora12-linux-gnu target=powerpc-fedora12-linux-gnu) and
on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.
Thanks,
Jan
2010-02-13 Jan Kratochvil <jan.kratochvil@redhat.com>
* solib-svr4.c (LM_ADDR_CHECK): New variable minpagesize. Optionally
initialize it from ELF BFD. Extend the prelink condition by it.
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -194,6 +194,7 @@ LM_ADDR_CHECK (struct so_list *so, bfd *abfd)
if (dynaddr + l_addr != l_dynaddr)
{
CORE_ADDR align = 0x1000;
+ CORE_ADDR minpagesize = align;
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
{
@@ -206,6 +207,8 @@ LM_ADDR_CHECK (struct so_list *so, bfd *abfd)
for (i = 0; i < ehdr->e_phnum; i++)
if (phdr[i].p_type == PT_LOAD && phdr[i].p_align > align)
align = phdr[i].p_align;
+
+ minpagesize = get_elf_backend_data (abfd)->minpagesize;
}
/* Turn it into a mask. */
@@ -230,9 +233,12 @@ LM_ADDR_CHECK (struct so_list *so, bfd *abfd)
mapping of the library may not actually happen on a 64k boundary!
(In the usual case where (l_addr & align) == 0, this check is
- equivalent to the possibly expected check above.) */
+ equivalent to the possibly expected check above.)
+
+ Even on PPC it must be zero-aligned at least for MINPAGESIZE. */
- if ((l_addr & align) == ((l_dynaddr - dynaddr) & align))
+ if ((l_addr & (minpagesize - 1)) == 0
+ && (l_addr & align) == ((l_dynaddr - dynaddr) & align))
{
l_addr = l_dynaddr - dynaddr;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] Extend PIC displacement check by minpagesize
2010-02-13 16:09 [patch] Extend PIC displacement check by minpagesize Jan Kratochvil
@ 2010-02-15 17:28 ` Ulrich Weigand
2010-02-15 17:40 ` Jan Kratochvil
0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Weigand @ 2010-02-15 17:28 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
Jan Kratochvil wrote:
> 2010-02-13 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * solib-svr4.c (LM_ADDR_CHECK): New variable minpagesize. Optionally
> initialize it from ELF BFD. Extend the prelink condition by it.
Seems reasonable to me.
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] Extend PIC displacement check by minpagesize
2010-02-15 17:28 ` Ulrich Weigand
@ 2010-02-15 17:40 ` Jan Kratochvil
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2010-02-15 17:40 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
On Mon, 15 Feb 2010 18:28:17 +0100, Ulrich Weigand wrote:
> Jan Kratochvil wrote:
>
> > 2010-02-13 Jan Kratochvil <jan.kratochvil@redhat.com>
> >
> > * solib-svr4.c (LM_ADDR_CHECK): New variable minpagesize. Optionally
> > initialize it from ELF BFD. Extend the prelink condition by it.
>
> Seems reasonable to me.
Checked-in:
http://sourceware.org/ml/gdb-cvs/2010-02/msg00110.html
It also defends the minpagesize usage in:
Re: [patch] Sanity check PIE displacement #2
http://sourceware.org/ml/gdb-patches/2010-02/msg00346.html
Thanks,
Jan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-02-15 17:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-13 16:09 [patch] Extend PIC displacement check by minpagesize Jan Kratochvil
2010-02-15 17:28 ` Ulrich Weigand
2010-02-15 17:40 ` Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox