2770a5f
http://sourceware.org/ml/gdb-cvs/2010-03/msg00104.html
2770a5f
5855954454f19a801f76bbf7baafd11a693c5d33
2770a5f
2770a5f
Imported to sync gdb.base/break-interp.exp for gdb-pie-rerun.patch.
2770a5f
2770a5f
### src/gdb/ChangeLog	2010/03/11 03:45:48	1.11469
2770a5f
### src/gdb/ChangeLog	2010/03/11 22:07:00	1.11470
2770a5f
## -1,3 +1,9 @@
2770a5f
+2010-03-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
2770a5f
+
2770a5f
+	* solib-svr4.c (LM_ADDR_CHECK) <info_verbose>: Use printf_unfiltered
2770a5f
+	for the PIC displacement, print also the displacement value.
2770a5f
+	(svr4_exec_displacement):  Print DISPLACEMENT if INFO_VERBOSE.
2770a5f
+
2770a5f
 2010-03-10  Kevin Buettner  <kevinb@redhat.com>
2770a5f
 
2770a5f
 	* remote-mips.c (close_ports, mips_initialize_cleanups)
2770a5f
--- src/gdb/solib-svr4.c	2010/03/10 20:55:44	1.129
2770a5f
+++ src/gdb/solib-svr4.c	2010/03/11 22:07:02	1.130
2770a5f
@@ -243,12 +243,10 @@
2770a5f
 	      l_addr = l_dynaddr - dynaddr;
2770a5f
 
2770a5f
 	      if (info_verbose)
2770a5f
-		{
2770a5f
-		  warning (_(".dynamic section for \"%s\" "
2770a5f
-			     "is not at the expected address"), so->so_name);
2770a5f
-		  warning (_("difference appears to be caused by prelink, "
2770a5f
-			     "adjusting expectations"));
2770a5f
-		}
2770a5f
+		printf_unfiltered (_("Using PIC (Position Independent Code) "
2770a5f
+				     "prelink displacement %s for \"%s\".\n"),
2770a5f
+				   paddress (target_gdbarch, l_addr),
2770a5f
+				   so->so_name);
2770a5f
 	    }
2770a5f
 	  else
2770a5f
 	    warning (_(".dynamic section for \"%s\" "
2770a5f
@@ -1767,6 +1765,18 @@
2770a5f
 	return 0;
2770a5f
     }
2770a5f
 
2770a5f
+  if (info_verbose)
2770a5f
+    {
2770a5f
+      /* It can be printed repeatedly as there is no easy way to check
2770a5f
+	 the executable symbols/file has been already relocated to
2770a5f
+	 displacement.  */
2770a5f
+
2770a5f
+      printf_unfiltered (_("Using PIE (Position Independent Executable) "
2770a5f
+			   "displacement %s for \"%s\".\n"),
2770a5f
+			 paddress (target_gdbarch, displacement),
2770a5f
+			 bfd_get_filename (exec_bfd));
2770a5f
+    }
2770a5f
+
2770a5f
   *displacementp = displacement;
2770a5f
   return 1;
2770a5f
 }
2770a5f
### src/gdb/testsuite/ChangeLog	2010/03/11 00:20:29	1.2168
2770a5f
### src/gdb/testsuite/ChangeLog	2010/03/11 22:07:02	1.2169
2770a5f
## -1,3 +1,20 @@
2770a5f
+2010-03-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
2770a5f
+
2770a5f
+	* gdb.base/break-interp.exp: Create new displacement parameter value
2770a5f
+	for the test_ld calls.
2770a5f
+	(reach): New parameter displacement, verify its content.  New push of
2770a5f
+	pf_prefix "reach-$func:".  Import global expect_out.
2770a5f
+	(test_core): New parameter displacement, verify its content.  New push
2770a5f
+	of pf_prefix "core:".  New command "set verbose on".  Import global
2770a5f
+	expect_out.
2770a5f
+	(test_attach): New parameter displacement, verify its content.  New
2770a5f
+	push of pf_prefix "attach:".  New command "set verbose on".  Import
2770a5f
+	global expect_out.
2770a5f
+	(test_ld): New parameter displacement, pass it to the reach, test_core
2770a5f
+	and test_attach calls and verify its content in the "ld.so exit" test.
2770a5f
+	* gdb.base/prelink.exp: Remove gdb_exit and final return.
2770a5f
+	(prelink): Update expected text, use gdb_test.
2770a5f
+
2770a5f
 2010-03-10  Doug Evans  <dje@google.com>
2770a5f
 
2770a5f
 	* gdb.base/checkpoint.exp: Fix comment.
2770a5f
--- src/gdb/testsuite/gdb.base/break-interp.exp	2010/01/27 20:53:22	1.6
2770a5f
+++ src/gdb/testsuite/gdb.base/break-interp.exp	2010/03/11 22:07:03	1.7
2770a5f
@@ -221,30 +221,61 @@
2770a5f
 }
2770a5f
 
2770a5f
 # `runto' does not check we stopped really at the function we specified.
2770a5f
-proc reach {func command} {
2770a5f
-    global gdb_prompt
2770a5f
+# DISPLACEMENT can be "NONE", "ZERO" or "NONZERO"
2770a5f
+proc reach {func command displacement} {
2770a5f
+    global gdb_prompt expect_out
2770a5f
+
2770a5f
+    global pf_prefix
2770a5f
+    set old_ldprefix $pf_prefix
2770a5f
+    lappend pf_prefix "reach-$func:"
2770a5f
 
2770a5f
     if [gdb_breakpoint $func allow-pending] {
2770a5f
-	set test "reach $func"
2770a5f
+	set test "reach"
2770a5f
+	set test_displacement "seen displacement message as $displacement"
2770a5f
 	gdb_test_multiple $command $test {
2770a5f
+	    -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
2770a5f
+		# Missing "$gdb_prompt $" is intentional.
2770a5f
+		if {$expect_out(1,string) == "0x0"} {
2770a5f
+		    set case "ZERO"
2770a5f
+		} else {
2770a5f
+		    set case "NONZERO"
2770a5f
+		}
2770a5f
+		if {$displacement == $case} {
2770a5f
+		    pass $test_displacement
2770a5f
+		    # Permit multiple such messages.
2770a5f
+		    set displacement "FOUND-$displacement"
2770a5f
+		} elseif {$displacement != "FOUND-$case"} {
2770a5f
+		    fail $test_displacement
2770a5f
+		}
2770a5f
+		exp_continue
2770a5f
+	    }
2770a5f
 	    -re "Breakpoint \[0-9\]+, $func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" {
2770a5f
 		pass $test
2770a5f
 	    }
2770a5f
-	    -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in $func \\(\\)( from .*)?\r\n$gdb_prompt $" { 
2770a5f
+	    -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in $func \\(\\)( from .*)?\r\n$gdb_prompt $" {
2770a5f
 		pass $test
2770a5f
 	    }
2770a5f
 	}
2770a5f
+	if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
2770a5f
+	    fail $test_displacement
2770a5f
+	}
2770a5f
     }
2770a5f
+
2770a5f
+    set pf_prefix $old_ldprefix
2770a5f
 }
2770a5f
 
2770a5f
-proc test_core {file} {
2770a5f
-    global srcdir subdir gdb_prompt
2770a5f
+proc test_core {file displacement} {
2770a5f
+    global srcdir subdir gdb_prompt expect_out
2770a5f
 
2770a5f
     set corefile [core_find $file {} "segv"]
2770a5f
     if {$corefile == ""} {
2770a5f
 	return
2770a5f
     }
2770a5f
 
2770a5f
+    global pf_prefix
2770a5f
+    set old_ldprefix $pf_prefix
2770a5f
+    lappend pf_prefix "core:"
2770a5f
+
2770a5f
     gdb_exit
2770a5f
     gdb_start
2770a5f
     # Clear it to never find any separate debug infos in $debug_root.
2770a5f
@@ -252,14 +283,44 @@
2770a5f
     gdb_reinitialize_dir $srcdir/$subdir
2770a5f
     gdb_load $file
2770a5f
 
2770a5f
-    # Do not check the binary filename as it may be truncated.
2770a5f
-    gdb_test "core-file $corefile" "Core was generated by .*\r\n#0 .*" "core loaded"
2770a5f
+    # Print the "PIE (Position Independent Executable) displacement" message.
2770a5f
+    gdb_test "set verbose on"
2770a5f
+
2770a5f
+    set test "core loaded"
2770a5f
+    set test_displacement "seen displacement message"
2770a5f
+    gdb_test_multiple "core-file $corefile" $test {
2770a5f
+	-re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
2770a5f
+	    # Missing "$gdb_prompt $" is intentional.
2770a5f
+	    if {$expect_out(1,string) == "0x0"} {
2770a5f
+		set case "ZERO"
2770a5f
+	    } else {
2770a5f
+		set case "NONZERO"
2770a5f
+	    }
2770a5f
+	    if {$displacement == $case} {
2770a5f
+		pass $test_displacement
2770a5f
+		# Permit multiple such messages.
2770a5f
+		set displacement "FOUND-$displacement"
2770a5f
+	    } elseif {$displacement != "FOUND-$case"} {
2770a5f
+		fail $test_displacement
2770a5f
+	    }
2770a5f
+	    exp_continue
2770a5f
+	}
2770a5f
+	-re "Core was generated by .*\r\n#0 .*$gdb_prompt $" {
2770a5f
+	    # Do not check the binary filename as it may be truncated.
2770a5f
+	    pass $test
2770a5f
+	}
2770a5f
+    }
2770a5f
+    if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
2770a5f
+	fail $test_displacement
2770a5f
+    }
2770a5f
 
2770a5f
     gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "core main bt"
2770a5f
+
2770a5f
+    set pf_prefix $old_ldprefix
2770a5f
 }
2770a5f
 
2770a5f
-proc test_attach {file} {
2770a5f
-    global board_info
2770a5f
+proc test_attach {file displacement} {
2770a5f
+    global board_info gdb_prompt expect_out
2770a5f
 
2770a5f
     gdb_exit
2770a5f
 
2770a5f
@@ -287,17 +348,61 @@
2770a5f
 	}
2770a5f
     }
2770a5f
 
2770a5f
+    global pf_prefix
2770a5f
+    set old_ldprefix $pf_prefix
2770a5f
+    lappend pf_prefix "attach:"
2770a5f
+
2770a5f
     gdb_exit
2770a5f
     gdb_start
2770a5f
-    gdb_test "attach $pid" "Attaching to process $pid\r\n.*" "attach"
2770a5f
+
2770a5f
+    # Print the "PIE (Position Independent Executable) displacement" message.
2770a5f
+    gdb_test "set verbose on"
2770a5f
+
2770a5f
+    set test "attach"
2770a5f
+    gdb_test_multiple "attach $pid" $test {
2770a5f
+	-re "Attaching to process $pid\r\n" {
2770a5f
+	    # Missing "$gdb_prompt $" is intentional.
2770a5f
+	    pass $test
2770a5f
+	}
2770a5f
+    }
2770a5f
+
2770a5f
+    set test "attach final prompt"
2770a5f
+    set test_displacement "seen displacement message"
2770a5f
+    gdb_test_multiple "" $test {
2770a5f
+	-re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
2770a5f
+	    # Missing "$gdb_prompt $" is intentional.
2770a5f
+	    if {$expect_out(1,string) == "0x0"} {
2770a5f
+		set case "ZERO"
2770a5f
+	    } else {
2770a5f
+		set case "NONZERO"
2770a5f
+	    }
2770a5f
+	    if {$displacement == $case} {
2770a5f
+		pass $test_displacement
2770a5f
+		# Permit multiple such messages.
2770a5f
+		set displacement "FOUND-$displacement"
2770a5f
+	    } elseif {$displacement != "FOUND-$case"} {
2770a5f
+		fail $test_displacement
2770a5f
+	    }
2770a5f
+	    exp_continue
2770a5f
+	}
2770a5f
+	-re "$gdb_prompt $" {
2770a5f
+	    pass $test
2770a5f
+	}
2770a5f
+    }
2770a5f
+    if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
2770a5f
+	fail $test_displacement
2770a5f
+    }
2770a5f
+
2770a5f
     gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "attach main bt"
2770a5f
     gdb_exit
2770a5f
 
2770a5f
     remote_exec host "kill -9 $pid"
2770a5f
+
2770a5f
+    set pf_prefix $old_ldprefix
2770a5f
 }
2770a5f
 
2770a5f
-proc test_ld {file ifmain trynosym} {
2770a5f
-    global srcdir subdir gdb_prompt
2770a5f
+proc test_ld {file ifmain trynosym displacement} {
2770a5f
+    global srcdir subdir gdb_prompt expect_out
2770a5f
 
2770a5f
     # First test normal `file'-command loaded $FILE with symbols.
2770a5f
 
2770a5f
@@ -308,20 +413,31 @@
2770a5f
     gdb_reinitialize_dir $srcdir/$subdir
2770a5f
     gdb_load $file
2770a5f
 
2770a5f
-    reach "dl_main" "run segv"
2770a5f
+    # Print the "PIE (Position Independent Executable) displacement" message.
2770a5f
+    gdb_test "set verbose on"
2770a5f
+
2770a5f
+    reach "dl_main" "run segv" $displacement
2770a5f
 
2770a5f
     gdb_test "bt" "#0 +\[^\r\n\]*\\mdl_main\\M.*" "dl bt"
2770a5f
 
2770a5f
     if $ifmain {
2770a5f
-	reach "main" continue
2770a5f
+	# Displacement message will be printed the second time on initializing
2770a5f
+	# the linker from svr4_special_symbol_handling.  If any ANOFFSET has
2770a5f
+	# been already set as non-zero the detection will no longer be run.
2770a5f
+	if {$displacement == "NONZERO"} {
2770a5f
+	    set displacement_main "NONE"
2770a5f
+	} else {
2770a5f
+	    set displacement_main $displacement
2770a5f
+	}
2770a5f
+	reach "main" continue $displacement_main
2770a5f
 
2770a5f
-	reach "libfunc" continue
2770a5f
+	reach "libfunc" continue "NONE"
2770a5f
 
2770a5f
 	gdb_test "bt" "#0 +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#1 +\[^\r\n\]*\\mmain\\M.*" "main bt"
2770a5f
 
2770a5f
-	test_core $file
2770a5f
+	test_core $file $displacement
2770a5f
 
2770a5f
-	test_attach $file
2770a5f
+	test_attach $file $displacement
2770a5f
     }
2770a5f
 
2770a5f
     if !$trynosym {
2770a5f
@@ -341,18 +457,21 @@
2770a5f
     gdb_test "set debug-file-directory"
2770a5f
     gdb_reinitialize_dir $srcdir/$subdir
2770a5f
 
2770a5f
+    # Print the "PIE (Position Independent Executable) displacement" message.
2770a5f
+    gdb_test "set verbose on"
2770a5f
+
2770a5f
     # Test no (error) message has been printed by `exec-file'.
2770a5f
     set escapedfile [string_to_regexp $file]
2770a5f
     gdb_test "exec-file $file" "exec-file $escapedfile" "load"
2770a5f
 
2770a5f
     if $ifmain {
2770a5f
-	reach "dl_main" run
2770a5f
+	reach "dl_main" run $displacement
2770a5f
 
2770a5f
 	set test "info files"
2770a5f
 	set entrynohex ""
2770a5f
 	gdb_test_multiple $test $test {
2770a5f
 	    -re "\r\n\[\t \]*Entry point:\[\t \]*0x(\[0-9a-f\]+)\r\n.*$gdb_prompt $" {
2770a5f
-		set entrynohex $expect_out(1,string) 
2770a5f
+		set entrynohex $expect_out(1,string)
2770a5f
 		pass $test
2770a5f
 	    }
2770a5f
 	}
2770a5f
@@ -363,7 +482,34 @@
2770a5f
     } else {
2770a5f
 	# There is no symbol to break at ld.so.  Moreover it can exit with an
2770a5f
 	# error code.
2770a5f
-	gdb_test "run" "Program exited (normally|with code \[0-9\]+)\\." "ld.so exit"
2770a5f
+
2770a5f
+	set test "ld.so exit"
2770a5f
+	set test_displacement "seen displacement message"
2770a5f
+	gdb_test_multiple "run" $test {
2770a5f
+	    -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
2770a5f
+		# Missing "$gdb_prompt $" is intentional.
2770a5f
+		if {$expect_out(1,string) == "0x0"} {
2770a5f
+		    set case "ZERO"
2770a5f
+		} else {
2770a5f
+		    set case "NONZERO"
2770a5f
+		}
2770a5f
+		if {$displacement == $case} {
2770a5f
+		    pass $test_displacement
2770a5f
+		    # Permit multiple such messages.
2770a5f
+		    set displacement "FOUND-$displacement"
2770a5f
+		} elseif {$displacement != "FOUND-$case"} {
2770a5f
+		    fail $test_displacement
2770a5f
+		}
2770a5f
+		exp_continue
2770a5f
+	    }
2770a5f
+	    -re "Program exited (normally|with code \[0-9\]+)\\.\r\n$gdb_prompt $" {
2770a5f
+		# Do not check the binary filename as it may be truncated.
2770a5f
+		pass $test
2770a5f
+	    }
2770a5f
+	}
2770a5f
+	if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
2770a5f
+	    fail $test_displacement
2770a5f
+	}
2770a5f
     }
2770a5f
 
2770a5f
     set pf_prefix $old_ldprefix
2770a5f
@@ -450,7 +596,12 @@
2770a5f
 	if ![prelink$ldprelink $interp] {
2770a5f
 	    continue
2770a5f
 	}
2770a5f
-	test_ld $interp 0 [expr {$ldsepdebug == "NO"}]
2770a5f
+	if {$ldprelink == "NO"} {
2770a5f
+	    set displacement "NONZERO"
2770a5f
+	} else {
2770a5f
+	    set displacement "ZERO"
2770a5f
+	}
2770a5f
+	test_ld $interp 0 [expr {$ldsepdebug == "NO"}] $displacement
2770a5f
 
2770a5f
 	if ![copy $interp $interp_saved] {
2770a5f
 	    continue
2770a5f
@@ -531,7 +682,14 @@
2770a5f
 
2770a5f
 		    if {[prelink$binprelink "--dynamic-linker=$interp --ld-library-path=$dir $exec $interp [concat $dests]" [file tail $exec]]
2770a5f
 		        && [copy $interp_saved $interp]} {
2770a5f
-			test_ld $exec 1 [expr {$binsepdebug == "NO"}]
2770a5f
+			if {$binpie == "NO"} {
2770a5f
+			    set displacement "NONE"
2770a5f
+			} elseif {$binprelink == "NO"} {
2770a5f
+			    set displacement "NONZERO"
2770a5f
+			} else {
2770a5f
+			    set displacement "ZERO"
2770a5f
+			}
2770a5f
+			test_ld $exec 1 [expr {$binsepdebug == "NO"}] $displacement
2770a5f
 		    }
2770a5f
 		}
2770a5f
 	    }
2770a5f
--- src/gdb/testsuite/gdb.base/prelink.exp	2010/02/13 12:02:29	1.11
2770a5f
+++ src/gdb/testsuite/gdb.base/prelink.exp	2010/03/11 22:07:03	1.12
2770a5f
@@ -112,15 +112,4 @@
2770a5f
 # Print the "adjusting expectations" message.
2770a5f
 gdb_test "set verbose on"
2770a5f
 
2770a5f
-set test "prelink"
2770a5f
-global gdb_prompt
2770a5f
-gdb_test_multiple "core-file $objdir/$subdir/prelink.core" "$test" {
2770a5f
-    -re "warning: \.dynamic section.*not at the expected address.*warning: difference.*caused by prelink, adjusting expectations.*$gdb_prompt $" {
2770a5f
-	pass "$test"
2770a5f
-    }
2770a5f
-}
2770a5f
-
2770a5f
-gdb_exit
2770a5f
-
2770a5f
-return 0
2770a5f
-
2770a5f
+gdb_test "core-file $objdir/$subdir/prelink.core" {Using PIC \(Position Independent Code\) prelink displacement.*} "prelink"
2770a5f
2770a5f
2770a5f
2770a5f
http://sourceware.org/ml/gdb-cvs/2010-03/msg00066.html
2770a5f
16558457783d71e2856ff2b9ceaa83199d2d9811
2770a5f
2770a5f
### src/gdb/ChangeLog	2010/03/08 07:45:49	1.11442
2770a5f
### src/gdb/ChangeLog	2010/03/08 08:32:49	1.11443
2770a5f
## -1,3 +1,8 @@
2770a5f
+2010-03-08  Jan Kratochvil  <jan.kratochvil@redhat.com>
2770a5f
+
2770a5f
+	* symfile.c (addr_info_make_relative): New variable sect_name, use it.
2770a5f
+	Do not warn on ".gnu.liblist" and ".gnu.conflict".
2770a5f
+
2770a5f
 2010-03-08  Joel Brobecker  <brobecker@adacore.com>
2770a5f
 
2770a5f
 	Memory error when reading wrong core file.
2770a5f
--- src/gdb/symfile.c	2010/03/05 19:32:44	1.275
2770a5f
+++ src/gdb/symfile.c	2010/03/08 08:32:49	1.276
2770a5f
@@ -592,7 +592,8 @@
2770a5f
 
2770a5f
   for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++)
2770a5f
     {
2770a5f
-      asection *sect = bfd_get_section_by_name (abfd, addrs->other[i].name);
2770a5f
+      const char *sect_name = addrs->other[i].name;
2770a5f
+      asection *sect = bfd_get_section_by_name (abfd, sect_name);
2770a5f
 
2770a5f
       if (sect)
2770a5f
 	{
2770a5f
@@ -609,8 +610,22 @@
2770a5f
 	}
2770a5f
       else
2770a5f
 	{
2770a5f
-	  warning (_("section %s not found in %s"), addrs->other[i].name,
2770a5f
-		   bfd_get_filename (abfd));
2770a5f
+	  /* This section does not exist in ABFD, which is normally
2770a5f
+	     unexpected and we want to issue a warning.
2770a5f
+
2770a5f
+	     However, the ELF prelinker does create a couple of sections
2770a5f
+	     (".gnu.liblist" and ".gnu.conflict") which are marked in the main
2770a5f
+	     executable as loadable (they are loaded in memory from the
2770a5f
+	     DYNAMIC segment) and yet are not present in separate debug info
2770a5f
+	     files.  This is fine, and should not cause a warning.  Shared
2770a5f
+	     libraries contain just the section ".gnu.liblist" but it is not
2770a5f
+	     marked as loadable there.  */
2770a5f
+
2770a5f
+	  if (!(strcmp (sect_name, ".gnu.liblist") == 0
2770a5f
+		|| strcmp (sect_name, ".gnu.conflict") == 0))
2770a5f
+	    warning (_("section %s not found in %s"), sect_name,
2770a5f
+		     bfd_get_filename (abfd));
2770a5f
+
2770a5f
 	  addrs->other[i].addr = 0;
2770a5f
 
2770a5f
 	  /* SECTINDEX is invalid if ADDR is zero.  */
2770a5f
2770a5f
2770a5f
2770a5f
http://sourceware.org/ml/gdb-cvs/2010-03/msg00138.html
2770a5f
http://sourceware.org/ml/gdb-patches/2010-03/msg00535.html
2770a5f
cc3e71651e2fd0168a2d3dd4efc2d3e15fd508dd
2770a5f
2770a5f
### src/gdb/ChangeLog	2010/03/15 03:48:46	1.11479
2770a5f
### src/gdb/ChangeLog	2010/03/15 09:31:30	1.11480
2770a5f
## -1,3 +1,8 @@
2770a5f
+2010-03-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
2770a5f
+
2770a5f
+	* symfile.c (addr_info_make_relative): Ignore also missing ".dynbss"
2770a5f
+	and ".sdynbss".  Update the comment.
2770a5f
+
2770a5f
 2010-03-15  Jie Zhang  <jie@codesourcery.com>
2770a5f
 
2770a5f
 	* MAINTAINERS: Update my email address.
2770a5f
--- src/gdb/symfile.c	2010/03/10 18:20:07	1.277
2770a5f
+++ src/gdb/symfile.c	2010/03/15 09:31:34	1.278
2770a5f
@@ -576,16 +576,19 @@
2770a5f
 	  /* This section does not exist in ABFD, which is normally
2770a5f
 	     unexpected and we want to issue a warning.
2770a5f
 
2770a5f
-	     However, the ELF prelinker does create a couple of sections
2770a5f
-	     (".gnu.liblist" and ".gnu.conflict") which are marked in the main
2770a5f
-	     executable as loadable (they are loaded in memory from the
2770a5f
-	     DYNAMIC segment) and yet are not present in separate debug info
2770a5f
-	     files.  This is fine, and should not cause a warning.  Shared
2770a5f
-	     libraries contain just the section ".gnu.liblist" but it is not
2770a5f
-	     marked as loadable there.  */
2770a5f
+	     However, the ELF prelinker does create a few sections which are
2770a5f
+	     marked in the main executable as loadable (they are loaded in
2770a5f
+	     memory from the DYNAMIC segment) and yet are not present in
2770a5f
+	     separate debug info files.  This is fine, and should not cause
2770a5f
+	     a warning.  Shared libraries contain just the section
2770a5f
+	     ".gnu.liblist" but it is not marked as loadable there.  There is
2770a5f
+	     no other way to identify them than by their name as the sections
2770a5f
+	     created by prelink have no special flags.  */
2770a5f
 
2770a5f
 	  if (!(strcmp (sect_name, ".gnu.liblist") == 0
2770a5f
-		|| strcmp (sect_name, ".gnu.conflict") == 0))
2770a5f
+		|| strcmp (sect_name, ".gnu.conflict") == 0
2770a5f
+		|| strcmp (sect_name, ".dynbss") == 0
2770a5f
+		|| strcmp (sect_name, ".sdynbss") == 0))
2770a5f
 	    warning (_("section %s not found in %s"), sect_name,
2770a5f
 		     bfd_get_filename (abfd));
2770a5f
 
2770a5f
2770a5f
2770a5f
2770a5f
http://sourceware.org/ml/gdb-patches/2010-03/msg00799.html
2770a5f
Subject: [patch] Fix separate-debug with non-unique section names (PR 11409)
2770a5f
2770a5f
A different version was checked-in but they are interchangeable:
2770a5f
	http://sourceware.org/ml/gdb-patches/2010-03/msg00799.html
2770a5f
	http://sourceware.org/ml/gdb-cvs/2010-03/msg00241.html
2770a5f
2770a5f
Hi,
2770a5f
2770a5f
gdb-7.1 is now broken for example for debugging /usr/bin/emacs due to:
2770a5f
http://sourceware.org/bugzilla/show_bug.cgi?id=11409
2770a5f
  [22] .data   PROGBITS 00000000007fe8a0 1fe8a0 215068 00  WA  0   0 32
2770a5f
  [23] .data   PROGBITS 0000000000a13920 413920 68c6e0 00  WA  0   0 32
2770a5f
2770a5f
It is in fact a regression against gdb-7.0 by me due to:
2770a5f
2770a5f
commit 71d0069a9f238a11f7f455bf6ad2adfc25683521
2770a5f
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
2770a5f
Date:   Tue Jan 5 15:51:01 2010 +0000
2770a5f
2770a5f
gdb/
2770a5f
        * symfile.c (syms_from_objfile): Remove the !MAINLINE conditional.
2770a5f
2770a5f
as while the code was broken even before the broken relocation was not applied
2770a5f
to mainline binary (before PIE+OSX patches went in).
2770a5f
2770a5f
2770a5f
No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.
2770a5f
2770a5f
OK to check-in also for gdb-7.1 (7.1.1)?
2770a5f
2770a5f
2770a5f
Thanks,
2770a5f
Jan
2770a5f
2770a5f
2770a5f
gdb/
2770a5f
2010-03-23  Jan Kratochvil  <jan.kratochvil@redhat.com>
2770a5f
2770a5f
	* symfile.c (addr_info_make_relative): Move sect declaration to the
2770a5f
	outer block.  Initialize it to NULL.  Prefer SECT->next more than
2770a5f
	bfd_get_section_by_name.
2770a5f
2770a5f
gdb/testsuite/
2770a5f
2010-03-23  Jan Kratochvil  <jan.kratochvil@redhat.com>
2770a5f
2770a5f
	* gdb.base/dup-sect.exp, gdb.base/dup-sect.S: New.
2770a5f
2770a5f
--- a/gdb/symfile.c
2770a5f
+++ b/gdb/symfile.c
2770a5f
@@ -529,6 +529,7 @@ addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd)
2770a5f
   asection *lower_sect;
2770a5f
   CORE_ADDR lower_offset;
2770a5f
   int i;
2770a5f
+  asection *sect;
2770a5f
 
2770a5f
   /* Find lowest loadable section to be used as starting point for
2770a5f
      continguous sections.  */
2770a5f
@@ -553,11 +554,23 @@ addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd)
2770a5f
      (the loadable section directly below it in memory).
2770a5f
      this_offset = lower_offset = lower_addr - lower_orig_addr */
2770a5f
 
2770a5f
+  sect = NULL;
2770a5f
   for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++)
2770a5f
     {
2770a5f
       const char *sect_name = addrs->other[i].name;
2770a5f
-      asection *sect = bfd_get_section_by_name (abfd, sect_name);
2770a5f
 
2770a5f
+      /* Prefer the next section of that we have found last.  The separate
2770a5f
+	 debug info files have either the same section layout or just a few
2770a5f
+	 sections are missing there.  On the other hand the section name is not
2770a5f
+	 unique and we could find an inappropraite section by its name.  */
2770a5f
+
2770a5f
+      if (sect)
2770a5f
+	sect = sect->next;
2770a5f
+      if (sect && strcmp (sect_name, bfd_get_section_name (abfd, sect)) != 0)
2770a5f
+	sect = NULL;
2770a5f
+
2770a5f
+      if (sect == NULL)
2770a5f
+	sect = bfd_get_section_by_name (abfd, sect_name);
2770a5f
       if (sect)
2770a5f
 	{
2770a5f
 	  /* This is the index used by BFD. */
2770a5f
--- /dev/null
2770a5f
+++ b/gdb/testsuite/gdb.base/dup-sect.S
2770a5f
@@ -0,0 +1,22 @@
2770a5f
+/* This testcase is part of GDB, the GNU debugger.
2770a5f
+
2770a5f
+   Copyright 2010 Free Software Foundation, Inc.
2770a5f
+
2770a5f
+   This program is free software; you can redistribute it and/or modify
2770a5f
+   it under the terms of the GNU General Public License as published by
2770a5f
+   the Free Software Foundation; either version 3 of the License, or
2770a5f
+   (at your option) any later version.
2770a5f
+
2770a5f
+   This program is distributed in the hope that it will be useful,
2770a5f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
2770a5f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2770a5f
+   GNU General Public License for more details.
2770a5f
+
2770a5f
+   You should have received a copy of the GNU General Public License
2770a5f
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
2770a5f
+
2770a5f
+	.section	sect1, "a"
2770a5f
+var1:	.byte	1
2770a5f
+
2770a5f
+	.section	sect2, "a"
2770a5f
+var2:	.byte	2
2770a5f
--- /dev/null
2770a5f
+++ b/gdb/testsuite/gdb.base/dup-sect.exp
2770a5f
@@ -0,0 +1,79 @@
2770a5f
+# This testcase is part of GDB, the GNU debugger.
2770a5f
+
2770a5f
+# Copyright 2010 Free Software Foundation, Inc.
2770a5f
+
2770a5f
+# This program is free software; you can redistribute it and/or modify
2770a5f
+# it under the terms of the GNU General Public License as published by
2770a5f
+# the Free Software Foundation; either version 3 of the License, or
2770a5f
+# (at your option) any later version.
2770a5f
+#
2770a5f
+# This program is distributed in the hope that it will be useful,
2770a5f
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2770a5f
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2770a5f
+# GNU General Public License for more details.
2770a5f
+#
2770a5f
+# You should have received a copy of the GNU General Public License
2770a5f
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2770a5f
+
2770a5f
+# Test inappropriate offseting of multiple sections with the same name.
2770a5f
+# When kept in object file (before final executable link) it still works.
2770a5f
+# When separate debug info file is not used it still works.
2770a5f
+# When the ELF symbol table is kept in the main binary it still works.
2770a5f
+# Used .S file as in .c file we would need __attriute__((section)) which is
2770a5f
+# a GCC extension.
2770a5f
+
2770a5f
+# This test can only be run on targets which support ELF and use gas.
2770a5f
+# For now pick a sampling of likely targets.
2770a5f
+if {![istarget *-*-linux*]
2770a5f
+    && ![istarget *-*-gnu*]
2770a5f
+    && ![istarget *-*-elf*]
2770a5f
+    && ![istarget arm-*-eabi*]
2770a5f
+    && ![istarget powerpc-*-eabi*]} {
2770a5f
+    return 0
2770a5f
+}
2770a5f
+
2770a5f
+set testfile dup-sect
2770a5f
+set srcfile ${testfile}.S
2770a5f
+set srcmainfile start.c
2770a5f
+set executable ${testfile}
2770a5f
+set binfile ${objdir}/${subdir}/${executable}
2770a5f
+
2770a5f
+if {[build_executable ${testfile}.exp $executable [list ${srcfile} ${srcmainfile}] {}] == -1} {
2770a5f
+    return -1
2770a5f
+}
2770a5f
+
2770a5f
+set test "rename section"
2770a5f
+set objcopy_program [transform objcopy]
2770a5f
+set result [catch "exec $objcopy_program --rename-section sect2=sect1 $binfile" output]
2770a5f
+verbose "result is $result"
2770a5f
+verbose "output is $output"
2770a5f
+if {$result != 0} {
2770a5f
+    fail $test
2770a5f
+    return
2770a5f
+}
2770a5f
+pass $test
2770a5f
+
2770a5f
+set test "split"
2770a5f
+if {[gdb_gnu_strip_debug $binfile] != 0} {
2770a5f
+    fail $test
2770a5f
+} else {
2770a5f
+    pass $test
2770a5f
+}
2770a5f
+
2770a5f
+# gdb_gnu_strip_debug uses only --strip-debug and keeps the ELF symbol table
2770a5f
+# in $binfile.
2770a5f
+set test "strip"
2770a5f
+set strip_program [transform strip]
2770a5f
+set result [catch "exec $strip_program $binfile" output]
2770a5f
+verbose "result is $result"
2770a5f
+verbose "output is $output"
2770a5f
+if {$result != 0} {
2770a5f
+    fail $test
2770a5f
+    return
2770a5f
+}
2770a5f
+pass $test
2770a5f
+
2770a5f
+clean_restart $executable
2770a5f
+
2770a5f
+gdb_test "p/d *(const char *) &var1" " = 1" "var1 after strip"
2770a5f
+gdb_test "p/d *(const char *) &var2" " = 2" "var2 after strip"
2770a5f
e8eaf64
e8eaf64
e8eaf64
[patch] Fix breakpoint at *_start
e8eaf64
http://sourceware.org/ml/gdb-patches/2010-04/msg00059.html
e8eaf64
http://sourceware.org/ml/gdb-cvs/2010-04/msg00029.html
e8eaf64
e8eaf64
### src/gdb/ChangeLog	2010/04/04 13:54:42	1.11568
e8eaf64
### src/gdb/ChangeLog	2010/04/04 22:12:04	1.11569
e8eaf64
## -1,5 +1,10 @@
e8eaf64
 2010-04-04  Jan Kratochvil  <jan.kratochvil@redhat.com>
e8eaf64
 
e8eaf64
+	* infcmd.c (run_command_1): Call proceed with regcache_read_pc address.
e8eaf64
+	* config/djgpp/fnchange.lst: Add translation for break-entry.exp.
e8eaf64
+
e8eaf64
+2010-04-04  Jan Kratochvil  <jan.kratochvil@redhat.com>
e8eaf64
+
e8eaf64
 	* breakpoint.c (bpstat_find_step_resume_breakpoint): Remove.
e8eaf64
 	* breakpoint.h (bpstat_find_step_resume_breakpoint): Remove.
e8eaf64
 
e8eaf64
--- src/gdb/infcmd.c	2010/03/25 20:48:53	1.263
e8eaf64
+++ src/gdb/infcmd.c	2010/04/04 22:12:04	1.264
e8eaf64
@@ -580,8 +580,9 @@
e8eaf64
      has done its thing; now we are setting up the running program.  */
e8eaf64
   post_create_inferior (&current_target, 0);
e8eaf64
 
e8eaf64
-  /* Start the target running.  */
e8eaf64
-  proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
e8eaf64
+  /* Start the target running.  Do not use -1 continuation as it would skip
e8eaf64
+     breakpoint right at the entry point.  */
e8eaf64
+  proceed (regcache_read_pc (get_current_regcache ()), TARGET_SIGNAL_0, 0);
e8eaf64
 
e8eaf64
   /* Since there was no error, there's no need to finish the thread
e8eaf64
      states here.  */
e8eaf64
--- src/gdb/config/djgpp/fnchange.lst	2010/02/01 19:27:55	1.108
e8eaf64
+++ src/gdb/config/djgpp/fnchange.lst	2010/04/04 22:12:07	1.109
e8eaf64
@@ -371,6 +371,7 @@
e8eaf64
 @V@/gdb/testsuite/gdb.arch/powerpc-prologue.exp @V@/gdb/testsuite/gdb.arch/ppc-prologue.exp
e8eaf64
 @V@/gdb/testsuite/gdb.base/bitfields2.c @V@/gdb/testsuite/gdb.base/bitfiel2.c
e8eaf64
 @V@/gdb/testsuite/gdb.base/bitfields2.exp @V@/gdb/testsuite/gdb.base/bitfiel2.exp
e8eaf64
+@V@/gdb/testsuite/gdb.base/break-entry.exp @V@/gdb/testsuite/gdb.base/brkentry.exp
e8eaf64
 @V@/gdb/testsuite/gdb.base/coremaker2.c @V@/gdb/testsuite/gdb.base/core2maker.c
e8eaf64
 @V@/gdb/testsuite/gdb.base/hashline1.exp @V@/gdb/testsuite/gdb.base/hash1line.exp
e8eaf64
 @V@/gdb/testsuite/gdb.base/hashline2.exp @V@/gdb/testsuite/gdb.base/hash2line.exp
e8eaf64
### src/gdb/testsuite/ChangeLog	2010/04/02 05:13:07	1.2218
e8eaf64
### src/gdb/testsuite/ChangeLog	2010/04/04 22:12:09	1.2219
e8eaf64
## -1,3 +1,7 @@
e8eaf64
+2010-04-04  Jan Kratochvil  <jan.kratochvil@redhat.com>
e8eaf64
+
e8eaf64
+	* gdb.base/break-entry.exp: New.
e8eaf64
+
e8eaf64
 2010-04-02  Hui Zhu  <teawater@gmail.com>
e8eaf64
             Michael Snyder <msnyder@vmware.com>
e8eaf64
 
e8eaf64
--- src/gdb/testsuite/gdb.base/break-entry.exp
e8eaf64
+++ src/gdb/testsuite/gdb.base/break-entry.exp	2010-04-05 20:17:39.234684000 +0000
e8eaf64
@@ -0,0 +1,43 @@
e8eaf64
+# Copyright (C) 2010 Free Software Foundation, Inc.
e8eaf64
+
e8eaf64
+# This program is free software; you can redistribute it and/or modify
e8eaf64
+# it under the terms of the GNU General Public License as published by
e8eaf64
+# the Free Software Foundation; either version 3 of the License, or
e8eaf64
+# (at your option) any later version.
e8eaf64
+#
e8eaf64
+# This program is distributed in the hope that it will be useful,
e8eaf64
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
e8eaf64
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e8eaf64
+# GNU General Public License for more details.
e8eaf64
+#
e8eaf64
+# You should have received a copy of the GNU General Public License
e8eaf64
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
e8eaf64
+
e8eaf64
+# Test inferior can stop at its very first instruction, usually "_start".
e8eaf64
+# Dynamic executables have first instruction in ld.so.
e8eaf64
+
e8eaf64
+set testfile break-entry
e8eaf64
+if { [prepare_for_testing ${testfile}.exp ${testfile} start.c {additional_flags=-static}] } {
e8eaf64
+    return -1
e8eaf64
+}
e8eaf64
+
e8eaf64
+set test "info files"
e8eaf64
+set entry ""
e8eaf64
+gdb_test_multiple $test $test {
e8eaf64
+    -re "\r\n\[\t \]*Entry point:\[\t \]*(0x\[0-9a-f\]+)\r\n.*$gdb_prompt $" {
e8eaf64
+	set entry $expect_out(1,string)
e8eaf64
+	pass $test
e8eaf64
+    }
e8eaf64
+}
e8eaf64
+if {$entry == ""} {
e8eaf64
+    untested ${testfile}.exp
e8eaf64
+    return
e8eaf64
+}
e8eaf64
+
e8eaf64
+if ![runto "*$entry"] {
e8eaf64
+    return
e8eaf64
+}
e8eaf64
+gdb_test {p/x $pc} " = $entry"
e8eaf64
+
e8eaf64
+gdb_breakpoint "main"
e8eaf64
+gdb_continue_to_breakpoint "main" "main.*"