]> git.ipfire.org Git - ipfire-3.x.git/blob - gdb/patches/gdb-bz623749-gcore-relro.patch
4015a7a6d52016ba6cdae95e169519806d5391db
[ipfire-3.x.git] / gdb / patches / gdb-bz623749-gcore-relro.patch
1 gdb:
2 https://bugzilla.redhat.com/show_bug.cgi?id=623749
3 kernel:
4 https://bugzilla.redhat.com/show_bug.cgi?id=636937
5
6 http://sourceware.org/ml/gdb-patches/2010-09/msg00395.html
7 Subject: Re: [patch] Fix gcore writer for -Wl,-z,relro (PR corefiles/11804)
8
9 gdb/testsuite/
10 2010-09-22 Jan Kratochvil <jan.kratochvil@redhat.com>
11
12 Fix gcore writer for -Wl,-z,relro.
13 * gdb.base/gcore-relro.exp: New file.
14 * gdb.base/gcore-relro-main.c: New file.
15 * gdb.base/gcore-relro-lib.c: New file.
16
17 --- ./gdb/gcore.c 2010-09-23 20:14:56.000000000 +0200
18 +++ ./gdb/gcore.c 2010-09-23 20:37:56.000000000 +0200
19 @@ -401,6 +401,7 @@ gcore_create_callback (CORE_ADDR vaddr,
20
21 if (write == 0 && !solib_keep_data_in_core (vaddr, size))
22 {
23 +#if 0 /* https://bugzilla.redhat.com/show_bug.cgi?id=636937 */
24 /* See if this region of memory lies inside a known file on disk.
25 If so, we can avoid copying its contents by clearing SEC_LOAD. */
26 struct objfile *objfile;
27 @@ -433,6 +434,7 @@ gcore_create_callback (CORE_ADDR vaddr,
28 }
29
30 keep:
31 +#endif
32 flags |= SEC_READONLY;
33 }
34
35 --- /dev/null
36 +++ b/gdb/testsuite/gdb.base/gcore-relro-lib.c
37 @@ -0,0 +1,21 @@
38 +/* Copyright 2010 Free Software Foundation, Inc.
39 +
40 + This file is part of GDB.
41 +
42 + This program is free software; you can redistribute it and/or modify
43 + it under the terms of the GNU General Public License as published by
44 + the Free Software Foundation; either version 3 of the License, or
45 + (at your option) any later version.
46 +
47 + This program is distributed in the hope that it will be useful,
48 + but WITHOUT ANY WARRANTY; without even the implied warranty of
49 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50 + GNU General Public License for more details.
51 +
52 + You should have received a copy of the GNU General Public License
53 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
54 +
55 +void
56 +lib (void)
57 +{
58 +}
59 --- /dev/null
60 +++ b/gdb/testsuite/gdb.base/gcore-relro-main.c
61 @@ -0,0 +1,25 @@
62 +/* Copyright 2010 Free Software Foundation, Inc.
63 +
64 + This file is part of GDB.
65 +
66 + This program is free software; you can redistribute it and/or modify
67 + it under the terms of the GNU General Public License as published by
68 + the Free Software Foundation; either version 3 of the License, or
69 + (at your option) any later version.
70 +
71 + This program is distributed in the hope that it will be useful,
72 + but WITHOUT ANY WARRANTY; without even the implied warranty of
73 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74 + GNU General Public License for more details.
75 +
76 + You should have received a copy of the GNU General Public License
77 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
78 +
79 +extern void lib (void);
80 +
81 +int
82 +main (void)
83 +{
84 + lib ();
85 + return 0;
86 +}
87 --- /dev/null
88 +++ b/gdb/testsuite/gdb.base/gcore-relro.exp
89 @@ -0,0 +1,80 @@
90 +# Copyright 2010 Free Software Foundation, Inc.
91 +
92 +# This program is free software; you can redistribute it and/or modify
93 +# it under the terms of the GNU General Public License as published by
94 +# the Free Software Foundation; either version 3 of the License, or
95 +# (at your option) any later version.
96 +#
97 +# This program is distributed in the hope that it will be useful,
98 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
99 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
100 +# GNU General Public License for more details.
101 +#
102 +# You should have received a copy of the GNU General Public License
103 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
104 +
105 +if {[skip_shlib_tests]} {
106 + return 0
107 +}
108 +
109 +set testfile "gcore-relro"
110 +set srcmainfile ${testfile}-main.c
111 +set srclibfile ${testfile}-lib.c
112 +set libfile ${objdir}/${subdir}/${testfile}-lib.so
113 +set objfile ${objdir}/${subdir}/${testfile}-main.o
114 +set executable ${testfile}-main
115 +set binfile ${objdir}/${subdir}/${executable}
116 +set gcorefile ${objdir}/${subdir}/${executable}.gcore
117 +
118 +if { [gdb_compile_shlib ${srcdir}/${subdir}/${srclibfile} ${libfile} {debug}] != ""
119 + || [gdb_compile ${srcdir}/${subdir}/${srcmainfile} ${objfile} object {debug}] != "" } {
120 + untested ${testfile}.exp
121 + return -1
122 +}
123 +set opts [list debug shlib=${libfile} additional_flags=-Wl,-z,relro]
124 +if { [gdb_compile ${objfile} ${binfile} executable $opts] != "" } {
125 + unsupported "-Wl,-z,relro compilation failed"
126 + return -1
127 +}
128 +
129 +clean_restart $executable
130 +gdb_load_shlibs $libfile
131 +
132 +# Does this gdb support gcore?
133 +set test "help gcore"
134 +gdb_test_multiple $test $test {
135 + -re "Undefined command: .gcore.*\r\n$gdb_prompt $" {
136 + # gcore command not supported -- nothing to test here.
137 + unsupported "gdb does not support gcore on this target"
138 + return -1;
139 + }
140 + -re "Save a core file .*\r\n$gdb_prompt $" {
141 + pass $test
142 + }
143 +}
144 +
145 +if { ![runto lib] } then {
146 + return -1
147 +}
148 +
149 +set escapedfilename [string_to_regexp ${gcorefile}]
150 +
151 +set test "save a corefile"
152 +gdb_test_multiple "gcore ${gcorefile}" $test {
153 + -re "Saved corefile ${escapedfilename}\r\n$gdb_prompt $" {
154 + pass $test
155 + }
156 + -re "Can't create a corefile\r\n$gdb_prompt $" {
157 + unsupported $test
158 + return -1
159 + }
160 +}
161 +
162 +# Now restart gdb and load the corefile.
163 +
164 +clean_restart $executable
165 +gdb_load_shlibs $libfile
166 +
167 +gdb_test "core ${gcorefile}" "Core was generated by .*" "re-load generated corefile"
168 +
169 +gdb_test "frame" "#0 \[^\r\n\]* lib .*" "library got loaded"