[gdb/f14/master] - gcore/-Wl, -z, relro: Always write out all the pages until kernel gets a fix.

Jan Kratochvil jkratoch at fedoraproject.org
Thu Sep 23 21:41:56 UTC 2010


commit e542160e6c6512547042989f6d80561276f957d4
Author: Jan Kratochvil <jan.kratochvil at redhat.com>
Date:   Thu Sep 23 23:41:50 2010 +0200

    - gcore/-Wl,-z,relro: Always write out all the pages until kernel gets a fix.

 gdb-bz623749-gcore-relro-1of2.patch |  268 ---------------------
 gdb-bz623749-gcore-relro-2of2.patch |  449 -----------------------------------
 gdb-bz623749-gcore-relro.patch      |  169 +++++++++++++
 gdb.spec                            |    9 +-
 4 files changed, 174 insertions(+), 721 deletions(-)
---
diff --git a/gdb-bz623749-gcore-relro.patch b/gdb-bz623749-gcore-relro.patch
new file mode 100644
index 0000000..4015a7a
--- /dev/null
+++ b/gdb-bz623749-gcore-relro.patch
@@ -0,0 +1,169 @@
+gdb:
+https://bugzilla.redhat.com/show_bug.cgi?id=623749
+kernel:
+https://bugzilla.redhat.com/show_bug.cgi?id=636937
+
+http://sourceware.org/ml/gdb-patches/2010-09/msg00395.html
+Subject: Re: [patch] Fix gcore writer for -Wl,-z,relro (PR corefiles/11804)
+
+gdb/testsuite/
+2010-09-22  Jan Kratochvil  <jan.kratochvil at redhat.com>
+
+	Fix gcore writer for -Wl,-z,relro.
+	* gdb.base/gcore-relro.exp: New file.
+	* gdb.base/gcore-relro-main.c: New file.
+	* gdb.base/gcore-relro-lib.c: New file.
+
+--- ./gdb/gcore.c	2010-09-23 20:14:56.000000000 +0200
++++ ./gdb/gcore.c	2010-09-23 20:37:56.000000000 +0200
+@@ -401,6 +401,7 @@ gcore_create_callback (CORE_ADDR vaddr, 
+ 
+   if (write == 0 && !solib_keep_data_in_core (vaddr, size))
+     {
++#if 0 /* https://bugzilla.redhat.com/show_bug.cgi?id=636937  */
+       /* See if this region of memory lies inside a known file on disk.
+ 	 If so, we can avoid copying its contents by clearing SEC_LOAD.  */
+       struct objfile *objfile;
+@@ -433,6 +434,7 @@ gcore_create_callback (CORE_ADDR vaddr, 
+ 	}
+ 
+     keep:
++#endif
+       flags |= SEC_READONLY;
+     }
+ 
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/gcore-relro-lib.c
+@@ -0,0 +1,21 @@
++/* Copyright 2010 Free Software Foundation, Inc.
++
++   This file is part of GDB.
++
++   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/>.  */
++
++void
++lib (void)
++{
++}
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/gcore-relro-main.c
+@@ -0,0 +1,25 @@
++/* Copyright 2010 Free Software Foundation, Inc.
++
++   This file is part of GDB.
++
++   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/>.  */
++
++extern void lib (void);
++
++int
++main (void)
++{
++  lib ();
++  return 0;
++}
+--- /dev/null
++++ b/gdb/testsuite/gdb.base/gcore-relro.exp
+@@ -0,0 +1,80 @@
++# 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/>.
++
++if {[skip_shlib_tests]} {
++    return 0
++}
++
++set testfile "gcore-relro"
++set srcmainfile ${testfile}-main.c
++set srclibfile ${testfile}-lib.c
++set libfile ${objdir}/${subdir}/${testfile}-lib.so
++set objfile ${objdir}/${subdir}/${testfile}-main.o
++set executable ${testfile}-main
++set binfile ${objdir}/${subdir}/${executable}
++set gcorefile ${objdir}/${subdir}/${executable}.gcore
++
++if { [gdb_compile_shlib ${srcdir}/${subdir}/${srclibfile} ${libfile} {debug}] != ""
++     || [gdb_compile ${srcdir}/${subdir}/${srcmainfile} ${objfile} object {debug}] != "" } {
++     untested ${testfile}.exp
++     return -1
++}
++set opts [list debug shlib=${libfile} additional_flags=-Wl,-z,relro]
++if { [gdb_compile ${objfile} ${binfile} executable $opts] != "" } {
++     unsupported "-Wl,-z,relro compilation failed"
++     return -1
++}
++
++clean_restart $executable
++gdb_load_shlibs $libfile
++
++# Does this gdb support gcore?
++set test "help gcore"
++gdb_test_multiple $test $test {
++    -re "Undefined command: .gcore.*\r\n$gdb_prompt $" {
++	# gcore command not supported -- nothing to test here.
++	unsupported "gdb does not support gcore on this target"
++	return -1;
++    }
++    -re "Save a core file .*\r\n$gdb_prompt $" {
++	pass $test
++    }
++}
++
++if { ![runto lib] } then {
++    return -1
++}
++
++set escapedfilename [string_to_regexp ${gcorefile}]
++
++set test "save a corefile"
++gdb_test_multiple "gcore ${gcorefile}" $test {
++    -re "Saved corefile ${escapedfilename}\r\n$gdb_prompt $" {
++	pass $test
++    }
++    -re "Can't create a corefile\r\n$gdb_prompt $" {
++	unsupported $test
++	return -1
++    }
++}
++
++# Now restart gdb and load the corefile.
++
++clean_restart $executable
++gdb_load_shlibs $libfile
++
++gdb_test "core ${gcorefile}" "Core was generated by .*" "re-load generated corefile"
++
++gdb_test "frame" "#0 \[^\r\n\]* lib .*" "library got loaded"
diff --git a/gdb.spec b/gdb.spec
index e8dad99..62daf32 100644
--- a/gdb.spec
+++ b/gdb.spec
@@ -27,7 +27,7 @@ Version: 7.2
 
 # The release always contains a leading reserved number, start it at 1.
 # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
-Release: 9%{?_with_upstream:.upstream}%{dist}
+Release: 10%{?_with_upstream:.upstream}%{dist}
 
 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and GFDL and BSD and Public Domain
 Group: Development/Debuggers
@@ -436,8 +436,7 @@ Patch502: gdb-bz634660-gdbpy-load-on-attach.patch
 Patch503: gdb-pr12028-double-free.patch
 
 # Fix gcore writer for -Wl,-z,relro (PR corefiles/11804).
-Patch504: gdb-bz623749-gcore-relro-1of2.patch
-Patch505: gdb-bz623749-gcore-relro-2of2.patch
+Patch504: gdb-bz623749-gcore-relro.patch
 
 BuildRequires: ncurses-devel%{?_isa} texinfo gettext flex bison expat-devel%{?_isa}
 Requires: readline%{?_isa}
@@ -701,7 +700,6 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
 %patch502 -p1
 %patch503 -p1
 %patch504 -p1
-%patch505 -p1
 
 %patch393 -p1
 %patch335 -p1
@@ -1086,6 +1084,9 @@ fi
 %endif
 
 %changelog
+* Thu Sep 23 2010 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.2-10.fc14
+- gcore/-Wl,-z,relro: Always write out all the pages until kernel gets a fix.
+
 * Wed Sep 22 2010 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.2-9.fc14
 - Fix gcore writer for -Wl,-z,relro (PR corefiles/11804).
 


More information about the scm-commits mailing list