Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Cc: Ulrich Weigand <uweigand@de.ibm.com>
Subject: [patch] Extend PIC displacement check by minpagesize
Date: Sat, 13 Feb 2010 16:09:00 -0000	[thread overview]
Message-ID: <20100213160944.GB6115@host0.dyn.jankratochvil.net> (raw)

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;
 


             reply	other threads:[~2010-02-13 16:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-13 16:09 Jan Kratochvil [this message]
2010-02-15 17:28 ` Ulrich Weigand
2010-02-15 17:40   ` Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100213160944.GB6115@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=uweigand@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox