keiths / rpms / gdb

Forked from rpms/gdb 5 months ago
Clone
Blob Blame History Raw
http://sourceware.org/ml/gdb-cvs/2010-03/msg00104.html
5855954454f19a801f76bbf7baafd11a693c5d33

Imported to sync gdb.base/break-interp.exp for gdb-pie-rerun.patch.

### src/gdb/ChangeLog	2010/03/11 03:45:48	1.11469
### src/gdb/ChangeLog	2010/03/11 22:07:00	1.11470
## -1,3 +1,9 @@
+2010-03-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* solib-svr4.c (LM_ADDR_CHECK) <info_verbose>: Use printf_unfiltered
+	for the PIC displacement, print also the displacement value.
+	(svr4_exec_displacement):  Print DISPLACEMENT if INFO_VERBOSE.
+
 2010-03-10  Kevin Buettner  <kevinb@redhat.com>
 
 	* remote-mips.c (close_ports, mips_initialize_cleanups)
--- src/gdb/solib-svr4.c	2010/03/10 20:55:44	1.129
+++ src/gdb/solib-svr4.c	2010/03/11 22:07:02	1.130
@@ -243,12 +243,10 @@
 	      l_addr = l_dynaddr - dynaddr;
 
 	      if (info_verbose)
-		{
-		  warning (_(".dynamic section for \"%s\" "
-			     "is not at the expected address"), so->so_name);
-		  warning (_("difference appears to be caused by prelink, "
-			     "adjusting expectations"));
-		}
+		printf_unfiltered (_("Using PIC (Position Independent Code) "
+				     "prelink displacement %s for \"%s\".\n"),
+				   paddress (target_gdbarch, l_addr),
+				   so->so_name);
 	    }
 	  else
 	    warning (_(".dynamic section for \"%s\" "
@@ -1767,6 +1765,18 @@
 	return 0;
     }
 
+  if (info_verbose)
+    {
+      /* It can be printed repeatedly as there is no easy way to check
+	 the executable symbols/file has been already relocated to
+	 displacement.  */
+
+      printf_unfiltered (_("Using PIE (Position Independent Executable) "
+			   "displacement %s for \"%s\".\n"),
+			 paddress (target_gdbarch, displacement),
+			 bfd_get_filename (exec_bfd));
+    }
+
   *displacementp = displacement;
   return 1;
 }
### src/gdb/testsuite/ChangeLog	2010/03/11 00:20:29	1.2168
### src/gdb/testsuite/ChangeLog	2010/03/11 22:07:02	1.2169
## -1,3 +1,20 @@
+2010-03-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* gdb.base/break-interp.exp: Create new displacement parameter value
+	for the test_ld calls.
+	(reach): New parameter displacement, verify its content.  New push of
+	pf_prefix "reach-$func:".  Import global expect_out.
+	(test_core): New parameter displacement, verify its content.  New push
+	of pf_prefix "core:".  New command "set verbose on".  Import global
+	expect_out.
+	(test_attach): New parameter displacement, verify its content.  New
+	push of pf_prefix "attach:".  New command "set verbose on".  Import
+	global expect_out.
+	(test_ld): New parameter displacement, pass it to the reach, test_core
+	and test_attach calls and verify its content in the "ld.so exit" test.
+	* gdb.base/prelink.exp: Remove gdb_exit and final return.
+	(prelink): Update expected text, use gdb_test.
+
 2010-03-10  Doug Evans  <dje@google.com>
 
 	* gdb.base/checkpoint.exp: Fix comment.
--- src/gdb/testsuite/gdb.base/break-interp.exp	2010/01/27 20:53:22	1.6
+++ src/gdb/testsuite/gdb.base/break-interp.exp	2010/03/11 22:07:03	1.7
@@ -221,30 +221,61 @@
 }
 
 # `runto' does not check we stopped really at the function we specified.
-proc reach {func command} {
-    global gdb_prompt
+# DISPLACEMENT can be "NONE", "ZERO" or "NONZERO"
+proc reach {func command displacement} {
+    global gdb_prompt expect_out
+
+    global pf_prefix
+    set old_ldprefix $pf_prefix
+    lappend pf_prefix "reach-$func:"
 
     if [gdb_breakpoint $func allow-pending] {
-	set test "reach $func"
+	set test "reach"
+	set test_displacement "seen displacement message as $displacement"
 	gdb_test_multiple $command $test {
+	    -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
+		# Missing "$gdb_prompt $" is intentional.
+		if {$expect_out(1,string) == "0x0"} {
+		    set case "ZERO"
+		} else {
+		    set case "NONZERO"
+		}
+		if {$displacement == $case} {
+		    pass $test_displacement
+		    # Permit multiple such messages.
+		    set displacement "FOUND-$displacement"
+		} elseif {$displacement != "FOUND-$case"} {
+		    fail $test_displacement
+		}
+		exp_continue
+	    }
 	    -re "Breakpoint \[0-9\]+, $func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" {
 		pass $test
 	    }
-	    -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in $func \\(\\)( from .*)?\r\n$gdb_prompt $" { 
+	    -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in $func \\(\\)( from .*)?\r\n$gdb_prompt $" {
 		pass $test
 	    }
 	}
+	if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
+	    fail $test_displacement
+	}
     }
+
+    set pf_prefix $old_ldprefix
 }
 
-proc test_core {file} {
-    global srcdir subdir gdb_prompt
+proc test_core {file displacement} {
+    global srcdir subdir gdb_prompt expect_out
 
     set corefile [core_find $file {} "segv"]
     if {$corefile == ""} {
 	return
     }
 
+    global pf_prefix
+    set old_ldprefix $pf_prefix
+    lappend pf_prefix "core:"
+
     gdb_exit
     gdb_start
     # Clear it to never find any separate debug infos in $debug_root.
@@ -252,14 +283,44 @@
     gdb_reinitialize_dir $srcdir/$subdir
     gdb_load $file
 
-    # Do not check the binary filename as it may be truncated.
-    gdb_test "core-file $corefile" "Core was generated by .*\r\n#0 .*" "core loaded"
+    # Print the "PIE (Position Independent Executable) displacement" message.
+    gdb_test "set verbose on"
+
+    set test "core loaded"
+    set test_displacement "seen displacement message"
+    gdb_test_multiple "core-file $corefile" $test {
+	-re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
+	    # Missing "$gdb_prompt $" is intentional.
+	    if {$expect_out(1,string) == "0x0"} {
+		set case "ZERO"
+	    } else {
+		set case "NONZERO"
+	    }
+	    if {$displacement == $case} {
+		pass $test_displacement
+		# Permit multiple such messages.
+		set displacement "FOUND-$displacement"
+	    } elseif {$displacement != "FOUND-$case"} {
+		fail $test_displacement
+	    }
+	    exp_continue
+	}
+	-re "Core was generated by .*\r\n#0 .*$gdb_prompt $" {
+	    # Do not check the binary filename as it may be truncated.
+	    pass $test
+	}
+    }
+    if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
+	fail $test_displacement
+    }
 
     gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "core main bt"
+
+    set pf_prefix $old_ldprefix
 }
 
-proc test_attach {file} {
-    global board_info
+proc test_attach {file displacement} {
+    global board_info gdb_prompt expect_out
 
     gdb_exit
 
@@ -287,17 +348,61 @@
 	}
     }
 
+    global pf_prefix
+    set old_ldprefix $pf_prefix
+    lappend pf_prefix "attach:"
+
     gdb_exit
     gdb_start
-    gdb_test "attach $pid" "Attaching to process $pid\r\n.*" "attach"
+
+    # Print the "PIE (Position Independent Executable) displacement" message.
+    gdb_test "set verbose on"
+
+    set test "attach"
+    gdb_test_multiple "attach $pid" $test {
+	-re "Attaching to process $pid\r\n" {
+	    # Missing "$gdb_prompt $" is intentional.
+	    pass $test
+	}
+    }
+
+    set test "attach final prompt"
+    set test_displacement "seen displacement message"
+    gdb_test_multiple "" $test {
+	-re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
+	    # Missing "$gdb_prompt $" is intentional.
+	    if {$expect_out(1,string) == "0x0"} {
+		set case "ZERO"
+	    } else {
+		set case "NONZERO"
+	    }
+	    if {$displacement == $case} {
+		pass $test_displacement
+		# Permit multiple such messages.
+		set displacement "FOUND-$displacement"
+	    } elseif {$displacement != "FOUND-$case"} {
+		fail $test_displacement
+	    }
+	    exp_continue
+	}
+	-re "$gdb_prompt $" {
+	    pass $test
+	}
+    }
+    if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
+	fail $test_displacement
+    }
+
     gdb_test "bt" "#\[0-9\]+ +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#\[0-9\]+ +\[^\r\n\]*\\mmain\\M.*" "attach main bt"
     gdb_exit
 
     remote_exec host "kill -9 $pid"
+
+    set pf_prefix $old_ldprefix
 }
 
-proc test_ld {file ifmain trynosym} {
-    global srcdir subdir gdb_prompt
+proc test_ld {file ifmain trynosym displacement} {
+    global srcdir subdir gdb_prompt expect_out
 
     # First test normal `file'-command loaded $FILE with symbols.
 
@@ -308,20 +413,31 @@
     gdb_reinitialize_dir $srcdir/$subdir
     gdb_load $file
 
-    reach "dl_main" "run segv"
+    # Print the "PIE (Position Independent Executable) displacement" message.
+    gdb_test "set verbose on"
+
+    reach "dl_main" "run segv" $displacement
 
     gdb_test "bt" "#0 +\[^\r\n\]*\\mdl_main\\M.*" "dl bt"
 
     if $ifmain {
-	reach "main" continue
+	# Displacement message will be printed the second time on initializing
+	# the linker from svr4_special_symbol_handling.  If any ANOFFSET has
+	# been already set as non-zero the detection will no longer be run.
+	if {$displacement == "NONZERO"} {
+	    set displacement_main "NONE"
+	} else {
+	    set displacement_main $displacement
+	}
+	reach "main" continue $displacement_main
 
-	reach "libfunc" continue
+	reach "libfunc" continue "NONE"
 
 	gdb_test "bt" "#0 +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#1 +\[^\r\n\]*\\mmain\\M.*" "main bt"
 
-	test_core $file
+	test_core $file $displacement
 
-	test_attach $file
+	test_attach $file $displacement
     }
 
     if !$trynosym {
@@ -341,18 +457,21 @@
     gdb_test "set debug-file-directory"
     gdb_reinitialize_dir $srcdir/$subdir
 
+    # Print the "PIE (Position Independent Executable) displacement" message.
+    gdb_test "set verbose on"
+
     # Test no (error) message has been printed by `exec-file'.
     set escapedfile [string_to_regexp $file]
     gdb_test "exec-file $file" "exec-file $escapedfile" "load"
 
     if $ifmain {
-	reach "dl_main" run
+	reach "dl_main" run $displacement
 
 	set test "info files"
 	set entrynohex ""
 	gdb_test_multiple $test $test {
 	    -re "\r\n\[\t \]*Entry point:\[\t \]*0x(\[0-9a-f\]+)\r\n.*$gdb_prompt $" {
-		set entrynohex $expect_out(1,string) 
+		set entrynohex $expect_out(1,string)
 		pass $test
 	    }
 	}
@@ -363,7 +482,34 @@
     } else {
 	# There is no symbol to break at ld.so.  Moreover it can exit with an
 	# error code.
-	gdb_test "run" "Program exited (normally|with code \[0-9\]+)\\." "ld.so exit"
+
+	set test "ld.so exit"
+	set test_displacement "seen displacement message"
+	gdb_test_multiple "run" $test {
+	    -re "Using PIE \\(Position Independent Executable\\) displacement (0x\[0-9a-f\]+) " {
+		# Missing "$gdb_prompt $" is intentional.
+		if {$expect_out(1,string) == "0x0"} {
+		    set case "ZERO"
+		} else {
+		    set case "NONZERO"
+		}
+		if {$displacement == $case} {
+		    pass $test_displacement
+		    # Permit multiple such messages.
+		    set displacement "FOUND-$displacement"
+		} elseif {$displacement != "FOUND-$case"} {
+		    fail $test_displacement
+		}
+		exp_continue
+	    }
+	    -re "Program exited (normally|with code \[0-9\]+)\\.\r\n$gdb_prompt $" {
+		# Do not check the binary filename as it may be truncated.
+		pass $test
+	    }
+	}
+	if ![regexp {^(NONE|FOUND-.*)$} $displacement] {
+	    fail $test_displacement
+	}
     }
 
     set pf_prefix $old_ldprefix
@@ -450,7 +596,12 @@
 	if ![prelink$ldprelink $interp] {
 	    continue
 	}
-	test_ld $interp 0 [expr {$ldsepdebug == "NO"}]
+	if {$ldprelink == "NO"} {
+	    set displacement "NONZERO"
+	} else {
+	    set displacement "ZERO"
+	}
+	test_ld $interp 0 [expr {$ldsepdebug == "NO"}] $displacement
 
 	if ![copy $interp $interp_saved] {
 	    continue
@@ -531,7 +682,14 @@
 
 		    if {[prelink$binprelink "--dynamic-linker=$interp --ld-library-path=$dir $exec $interp [concat $dests]" [file tail $exec]]
 		        && [copy $interp_saved $interp]} {
-			test_ld $exec 1 [expr {$binsepdebug == "NO"}]
+			if {$binpie == "NO"} {
+			    set displacement "NONE"
+			} elseif {$binprelink == "NO"} {
+			    set displacement "NONZERO"
+			} else {
+			    set displacement "ZERO"
+			}
+			test_ld $exec 1 [expr {$binsepdebug == "NO"}] $displacement
 		    }
 		}
 	    }
--- src/gdb/testsuite/gdb.base/prelink.exp	2010/02/13 12:02:29	1.11
+++ src/gdb/testsuite/gdb.base/prelink.exp	2010/03/11 22:07:03	1.12
@@ -112,15 +112,4 @@
 # Print the "adjusting expectations" message.
 gdb_test "set verbose on"
 
-set test "prelink"
-global gdb_prompt
-gdb_test_multiple "core-file $objdir/$subdir/prelink.core" "$test" {
-    -re "warning: \.dynamic section.*not at the expected address.*warning: difference.*caused by prelink, adjusting expectations.*$gdb_prompt $" {
-	pass "$test"
-    }
-}
-
-gdb_exit
-
-return 0
-
+gdb_test "core-file $objdir/$subdir/prelink.core" {Using PIC \(Position Independent Code\) prelink displacement.*} "prelink"



http://sourceware.org/ml/gdb-cvs/2010-03/msg00066.html
16558457783d71e2856ff2b9ceaa83199d2d9811

### src/gdb/ChangeLog	2010/03/08 07:45:49	1.11442
### src/gdb/ChangeLog	2010/03/08 08:32:49	1.11443
## -1,3 +1,8 @@
+2010-03-08  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* symfile.c (addr_info_make_relative): New variable sect_name, use it.
+	Do not warn on ".gnu.liblist" and ".gnu.conflict".
+
 2010-03-08  Joel Brobecker  <brobecker@adacore.com>
 
 	Memory error when reading wrong core file.
--- src/gdb/symfile.c	2010/03/05 19:32:44	1.275
+++ src/gdb/symfile.c	2010/03/08 08:32:49	1.276
@@ -592,7 +592,8 @@
 
   for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++)
     {
-      asection *sect = bfd_get_section_by_name (abfd, addrs->other[i].name);
+      const char *sect_name = addrs->other[i].name;
+      asection *sect = bfd_get_section_by_name (abfd, sect_name);
 
       if (sect)
 	{
@@ -609,8 +610,22 @@
 	}
       else
 	{
-	  warning (_("section %s not found in %s"), addrs->other[i].name,
-		   bfd_get_filename (abfd));
+	  /* This section does not exist in ABFD, which is normally
+	     unexpected and we want to issue a warning.
+
+	     However, the ELF prelinker does create a couple of sections
+	     (".gnu.liblist" and ".gnu.conflict") which are marked in the main
+	     executable as loadable (they are loaded in memory from the
+	     DYNAMIC segment) and yet are not present in separate debug info
+	     files.  This is fine, and should not cause a warning.  Shared
+	     libraries contain just the section ".gnu.liblist" but it is not
+	     marked as loadable there.  */
+
+	  if (!(strcmp (sect_name, ".gnu.liblist") == 0
+		|| strcmp (sect_name, ".gnu.conflict") == 0))
+	    warning (_("section %s not found in %s"), sect_name,
+		     bfd_get_filename (abfd));
+
 	  addrs->other[i].addr = 0;
 
 	  /* SECTINDEX is invalid if ADDR is zero.  */



http://sourceware.org/ml/gdb-cvs/2010-03/msg00138.html
http://sourceware.org/ml/gdb-patches/2010-03/msg00535.html
cc3e71651e2fd0168a2d3dd4efc2d3e15fd508dd

### src/gdb/ChangeLog	2010/03/15 03:48:46	1.11479
### src/gdb/ChangeLog	2010/03/15 09:31:30	1.11480
## -1,3 +1,8 @@
+2010-03-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* symfile.c (addr_info_make_relative): Ignore also missing ".dynbss"
+	and ".sdynbss".  Update the comment.
+
 2010-03-15  Jie Zhang  <jie@codesourcery.com>
 
 	* MAINTAINERS: Update my email address.
--- src/gdb/symfile.c	2010/03/10 18:20:07	1.277
+++ src/gdb/symfile.c	2010/03/15 09:31:34	1.278
@@ -576,16 +576,19 @@
 	  /* This section does not exist in ABFD, which is normally
 	     unexpected and we want to issue a warning.
 
-	     However, the ELF prelinker does create a couple of sections
-	     (".gnu.liblist" and ".gnu.conflict") which are marked in the main
-	     executable as loadable (they are loaded in memory from the
-	     DYNAMIC segment) and yet are not present in separate debug info
-	     files.  This is fine, and should not cause a warning.  Shared
-	     libraries contain just the section ".gnu.liblist" but it is not
-	     marked as loadable there.  */
+	     However, the ELF prelinker does create a few sections which are
+	     marked in the main executable as loadable (they are loaded in
+	     memory from the DYNAMIC segment) and yet are not present in
+	     separate debug info files.  This is fine, and should not cause
+	     a warning.  Shared libraries contain just the section
+	     ".gnu.liblist" but it is not marked as loadable there.  There is
+	     no other way to identify them than by their name as the sections
+	     created by prelink have no special flags.  */
 
 	  if (!(strcmp (sect_name, ".gnu.liblist") == 0
-		|| strcmp (sect_name, ".gnu.conflict") == 0))
+		|| strcmp (sect_name, ".gnu.conflict") == 0
+		|| strcmp (sect_name, ".dynbss") == 0
+		|| strcmp (sect_name, ".sdynbss") == 0))
 	    warning (_("section %s not found in %s"), sect_name,
 		     bfd_get_filename (abfd));
 



http://sourceware.org/ml/gdb-patches/2010-03/msg00799.html
Subject: [patch] Fix separate-debug with non-unique section names (PR 11409)

A different version was checked-in but they are interchangeable:
	http://sourceware.org/ml/gdb-patches/2010-03/msg00799.html
	http://sourceware.org/ml/gdb-cvs/2010-03/msg00241.html

Hi,

gdb-7.1 is now broken for example for debugging /usr/bin/emacs due to:
http://sourceware.org/bugzilla/show_bug.cgi?id=11409
  [22] .data   PROGBITS 00000000007fe8a0 1fe8a0 215068 00  WA  0   0 32
  [23] .data   PROGBITS 0000000000a13920 413920 68c6e0 00  WA  0   0 32

It is in fact a regression against gdb-7.0 by me due to:

commit 71d0069a9f238a11f7f455bf6ad2adfc25683521
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Tue Jan 5 15:51:01 2010 +0000

gdb/
        * symfile.c (syms_from_objfile): Remove the !MAINLINE conditional.

as while the code was broken even before the broken relocation was not applied
to mainline binary (before PIE+OSX patches went in).


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

OK to check-in also for gdb-7.1 (7.1.1)?


Thanks,
Jan


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

	* symfile.c (addr_info_make_relative): Move sect declaration to the
	outer block.  Initialize it to NULL.  Prefer SECT->next more than
	bfd_get_section_by_name.

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

	* gdb.base/dup-sect.exp, gdb.base/dup-sect.S: New.

--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -529,6 +529,7 @@ addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd)
   asection *lower_sect;
   CORE_ADDR lower_offset;
   int i;
+  asection *sect;
 
   /* Find lowest loadable section to be used as starting point for
      continguous sections.  */
@@ -553,11 +554,23 @@ addr_info_make_relative (struct section_addr_info *addrs, bfd *abfd)
      (the loadable section directly below it in memory).
      this_offset = lower_offset = lower_addr - lower_orig_addr */
 
+  sect = NULL;
   for (i = 0; i < addrs->num_sections && addrs->other[i].name; i++)
     {
       const char *sect_name = addrs->other[i].name;
-      asection *sect = bfd_get_section_by_name (abfd, sect_name);
 
+      /* Prefer the next section of that we have found last.  The separate
+	 debug info files have either the same section layout or just a few
+	 sections are missing there.  On the other hand the section name is not
+	 unique and we could find an inappropraite section by its name.  */
+
+      if (sect)
+	sect = sect->next;
+      if (sect && strcmp (sect_name, bfd_get_section_name (abfd, sect)) != 0)
+	sect = NULL;
+
+      if (sect == NULL)
+	sect = bfd_get_section_by_name (abfd, sect_name);
       if (sect)
 	{
 	  /* This is the index used by BFD. */
--- /dev/null
+++ b/gdb/testsuite/gdb.base/dup-sect.S
@@ -0,0 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2010 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+	.section	sect1, "a"
+var1:	.byte	1
+
+	.section	sect2, "a"
+var2:	.byte	2
--- /dev/null
+++ b/gdb/testsuite/gdb.base/dup-sect.exp
@@ -0,0 +1,79 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test inappropriate offseting of multiple sections with the same name.
+# When kept in object file (before final executable link) it still works.
+# When separate debug info file is not used it still works.
+# When the ELF symbol table is kept in the main binary it still works.
+# Used .S file as in .c file we would need __attriute__((section)) which is
+# a GCC extension.
+
+# This test can only be run on targets which support ELF and use gas.
+# For now pick a sampling of likely targets.
+if {![istarget *-*-linux*]
+    && ![istarget *-*-gnu*]
+    && ![istarget *-*-elf*]
+    && ![istarget arm-*-eabi*]
+    && ![istarget powerpc-*-eabi*]} {
+    return 0
+}
+
+set testfile dup-sect
+set srcfile ${testfile}.S
+set srcmainfile start.c
+set executable ${testfile}
+set binfile ${objdir}/${subdir}/${executable}
+
+if {[build_executable ${testfile}.exp $executable [list ${srcfile} ${srcmainfile}] {}] == -1} {
+    return -1
+}
+
+set test "rename section"
+set objcopy_program [transform objcopy]
+set result [catch "exec $objcopy_program --rename-section sect2=sect1 $binfile" output]
+verbose "result is $result"
+verbose "output is $output"
+if {$result != 0} {
+    fail $test
+    return
+}
+pass $test
+
+set test "split"
+if {[gdb_gnu_strip_debug $binfile] != 0} {
+    fail $test
+} else {
+    pass $test
+}
+
+# gdb_gnu_strip_debug uses only --strip-debug and keeps the ELF symbol table
+# in $binfile.
+set test "strip"
+set strip_program [transform strip]
+set result [catch "exec $strip_program $binfile" output]
+verbose "result is $result"
+verbose "output is $output"
+if {$result != 0} {
+    fail $test
+    return
+}
+pass $test
+
+clean_restart $executable
+
+gdb_test "p/d *(const char *) &var1" " = 1" "var1 after strip"
+gdb_test "p/d *(const char *) &var2" " = 2" "var2 after strip"



[patch] Fix breakpoint at *_start
http://sourceware.org/ml/gdb-patches/2010-04/msg00059.html
http://sourceware.org/ml/gdb-cvs/2010-04/msg00029.html

### src/gdb/ChangeLog	2010/04/04 13:54:42	1.11568
### src/gdb/ChangeLog	2010/04/04 22:12:04	1.11569
## -1,5 +1,10 @@
 2010-04-04  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
+	* infcmd.c (run_command_1): Call proceed with regcache_read_pc address.
+	* config/djgpp/fnchange.lst: Add translation for break-entry.exp.
+
+2010-04-04  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
 	* breakpoint.c (bpstat_find_step_resume_breakpoint): Remove.
 	* breakpoint.h (bpstat_find_step_resume_breakpoint): Remove.
 
--- src/gdb/infcmd.c	2010/03/25 20:48:53	1.263
+++ src/gdb/infcmd.c	2010/04/04 22:12:04	1.264
@@ -580,8 +580,9 @@
      has done its thing; now we are setting up the running program.  */
   post_create_inferior (&current_target, 0);
 
-  /* Start the target running.  */
-  proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
+  /* Start the target running.  Do not use -1 continuation as it would skip
+     breakpoint right at the entry point.  */
+  proceed (regcache_read_pc (get_current_regcache ()), TARGET_SIGNAL_0, 0);
 
   /* Since there was no error, there's no need to finish the thread
      states here.  */
--- src/gdb/config/djgpp/fnchange.lst	2010/02/01 19:27:55	1.108
+++ src/gdb/config/djgpp/fnchange.lst	2010/04/04 22:12:07	1.109
@@ -371,6 +371,7 @@
 @V@/gdb/testsuite/gdb.arch/powerpc-prologue.exp @V@/gdb/testsuite/gdb.arch/ppc-prologue.exp
 @V@/gdb/testsuite/gdb.base/bitfields2.c @V@/gdb/testsuite/gdb.base/bitfiel2.c
 @V@/gdb/testsuite/gdb.base/bitfields2.exp @V@/gdb/testsuite/gdb.base/bitfiel2.exp
+@V@/gdb/testsuite/gdb.base/break-entry.exp @V@/gdb/testsuite/gdb.base/brkentry.exp
 @V@/gdb/testsuite/gdb.base/coremaker2.c @V@/gdb/testsuite/gdb.base/core2maker.c
 @V@/gdb/testsuite/gdb.base/hashline1.exp @V@/gdb/testsuite/gdb.base/hash1line.exp
 @V@/gdb/testsuite/gdb.base/hashline2.exp @V@/gdb/testsuite/gdb.base/hash2line.exp
### src/gdb/testsuite/ChangeLog	2010/04/02 05:13:07	1.2218
### src/gdb/testsuite/ChangeLog	2010/04/04 22:12:09	1.2219
## -1,3 +1,7 @@
+2010-04-04  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* gdb.base/break-entry.exp: New.
+
 2010-04-02  Hui Zhu  <teawater@gmail.com>
             Michael Snyder <msnyder@vmware.com>
 
--- src/gdb/testsuite/gdb.base/break-entry.exp
+++ src/gdb/testsuite/gdb.base/break-entry.exp	2010-04-05 20:17:39.234684000 +0000
@@ -0,0 +1,43 @@
+# Copyright (C) 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test inferior can stop at its very first instruction, usually "_start".
+# Dynamic executables have first instruction in ld.so.
+
+set testfile break-entry
+if { [prepare_for_testing ${testfile}.exp ${testfile} start.c {additional_flags=-static}] } {
+    return -1
+}
+
+set test "info files"
+set entry ""
+gdb_test_multiple $test $test {
+    -re "\r\n\[\t \]*Entry point:\[\t \]*(0x\[0-9a-f\]+)\r\n.*$gdb_prompt $" {
+	set entry $expect_out(1,string)
+	pass $test
+    }
+}
+if {$entry == ""} {
+    untested ${testfile}.exp
+    return
+}
+
+if ![runto "*$entry"] {
+    return
+}
+gdb_test {p/x $pc} " = $entry"
+
+gdb_breakpoint "main"
+gdb_continue_to_breakpoint "main" "main.*"