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]

[patch] Extend PIC displacement check by minpagesize


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;
 


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