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] svr4_exec_displacement success indicator [Re: PIE question]


On Mon, 08 Mar 2010 22:59:13 +0100, Daniel Jacobowitz wrote:
> On Mon, Mar 08, 2010 at 10:53:58PM +0100, Jan Kratochvil wrote:
> > OK to check-in?
> 
> Yes, these are OK.  [Sorry, should have checked this folder first.]

-> http://sourceware.org/ml/gdb-cvs/2010-03/msg00097.html
#  2010-03-10  Jan Kratochvil  <jan.kratochvil@redhat.com>
# +
# +	* solib-svr4.c (svr4_exec_displacement): Return now success, new
# +	parameter displacementp.  Update comment.
# +	(svr4_relocate_main_executable): Return if non-zero SECTION_OFFSETS
# +	element exists.  Return if svr4_exec_displacement was not successful.
# +	Update comment.


Is it OK also for gdb_7_1-branch?

Otherwise the minimized attached patch also works for me.  Still I would
prefer the full patch from the master branch.

No regressions on {x86_64,x86_64-m32,i686}-fedora13-linux-gnu.


Thanks,
Jan


gdb/
2010-03-12  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* solib-svr4.c (svr4_relocate_main_executable): Delay the
	svr4_exec_displacement call.  Return on non-DYNAMIC exec_bfd.

--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1719,7 +1719,15 @@ svr4_exec_displacement (void)
 static void
 svr4_relocate_main_executable (void)
 {
-  CORE_ADDR displacement = svr4_exec_displacement ();
+  CORE_ADDR displacement;
+
+  /* Therefore for ELF it is ET_EXEC and not ET_DYN.  Both shared libraries
+     being executed themselves and PIE (Position Independent Executable)
+     executables are ET_DYN.  */
+  if (exec_bfd && (bfd_get_file_flags (exec_bfd) & DYNAMIC) == 0)
+    return;
+
+  displacement = svr4_exec_displacement ();
 
   /* Even if DISPLACEMENT is 0 still try to relocate it as this is a new
      difference of in-memory vs. in-file addresses and we could already


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