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: RFC: Verify AT_ENTRY before using it


On Wed, 10 Mar 2010 22:11:38 +0100, Jan Kratochvil wrote:
> It has been checked-in without the warning() calls.
[...]
> http://sourceware.org/ml/gdb-cvs/2010-03/msg00096.html
> 
> --- src/gdb/ChangeLog	2010/03/10 18:41:37	1.11466
> +++ src/gdb/ChangeLog	2010/03/10 20:50:48	1.11467
> @@ -1,3 +1,16 @@
> +2010-03-10  Jan Kratochvil  <jan.kratochvil@redhat.com>
> +	    Daniel Jacobowitz  <dan@codesourcery.com>
> +
> +	* solib-svr4.c (read_program_header): Support type == -1 to read
> +	all program headers.
> +	(read_program_headers_from_bfd): New function.
> +	(svr4_static_exec_displacement): Remove and move the comment ...
> +	(svr4_exec_displacement): ... here.  Remove variable found.  New
> +	variable displacement.  Check also DYNAMIC.  Verify DISPLACEMENT
> +	alignment for ELF targets.  Compare target vs. exec_bfd PHDRs for ELF
> +	targets using read_program_headers_from_bfd.  Remove the call of
> +	svr4_static_exec_displacement.

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]