summaryrefslogtreecommitdiff
path: root/dev-util/debugedit/files/debugedit-5.0-readelf.patch
blob: 547b6871032416df5cc42950455c46c1a03446c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
From 56e41d7c716a3657bdcce05146f7509d8a4e4a74 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <slyfox@gentoo.org>
Date: Sun, 1 Aug 2021 21:15:35 +0100
Subject: [PATCH] use $READELF, not readelf

Allow user to specify own readelf. Use detected readelf,
not 'readelf'.

Noticed as a set of test failures on system with only
$host-prefixed tools:

  debugedit/tests/testsuite.dir/at-groups/4/test-source:
    line 40: readelf: command not found

	* configure.ac: Add READELF user override.
	* scripts/find-debuginfo.in: Use @READELF@ instead of 'readelf'.
	* tests/atlocal.in: Populate READELF variable detected by configure.
	* tests/debugedit.at: Use $READELF instad of 'readelf' in tests.
	* Makefile.am (do_subst): Add READELF substitution.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
---
 Makefile.am               |  3 ++-
 configure.ac              |  1 +
 scripts/find-debuginfo.in |  2 +-
 tests/atlocal.in          |  1 +
 tests/debugedit.at        | 54 +++++++++++++++++++--------------------
 5 files changed, 32 insertions(+), 29 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 98b2f20..2060b96 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -32,7 +32,8 @@ CLEANFILES = $(bin_SCRIPTS)
 
 # Some standard substitutions for scripts
 do_subst = ($(SED) -e 's,[@]PACKAGE[@],$(PACKAGE),g' \
-		   -e 's,[@]VERSION[@],$(VERSION),g')
+		   -e 's,[@]VERSION[@],$(VERSION),g' \
+		   -e 's,[@]READELF[@],$(READELF),g')
 
 find-debuginfo: $(top_srcdir)/scripts/find-debuginfo.in Makefile
 	$(do_subst) < "$(top_srcdir)/scripts/$@.in" > "$@"
diff --git a/configure.ac b/configure.ac
index 85f2c4f..e5c9230 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,6 +44,7 @@ AC_PROG_SED
 AC_PROG_CC_C99
 AC_PROG_LN_S
 AC_CHECK_TOOL([LD], [ld])
+AC_CHECK_TOOL([READELF], [readelf])
 AM_MISSING_PROG(HELP2MAN, help2man)
 
 # Only really an issue on 32bit platforms. Makes sure we'll get large off_t.
diff --git a/scripts/find-debuginfo.in b/scripts/find-debuginfo.in
index 8b9ce77..9c0a735 100755
--- a/scripts/find-debuginfo.in
+++ b/scripts/find-debuginfo.in
@@ -338,7 +338,7 @@ add_minidebug()
   # symbol and NOBITS sections so cannot use --keep-only because that is
   # too aggressive. Field $2 is the section name, $3 is the section type
   # and $8 are the section flags.
-  local remove_sections=`readelf -W -S "$debuginfo" \
+  local remove_sections=`@READELF@ -W -S "$debuginfo" \
 	| awk '{ if (index($2,".debug_") != 1 \
 		     && ($3 == "PROGBITS" || $3 == "NOTE" || $3 == "NOBITS") \
 		     && index($8,"A") == 0) \
diff --git a/tests/atlocal.in b/tests/atlocal.in
index 0eec351..8399f8d 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -9,6 +9,7 @@ CC="@CC@"
 CFLAGS=""
 LD="@LD@"
 LDFLAGS=""
+READELF="@READELF@"
 
 GDWARF_5_FLAG=@GDWARF_5_FLAG@
 GZ_NONE_FLAG=@GZ_NONE_FLAG@
diff --git a/tests/debugedit.at b/tests/debugedit.at
index 608b1d0..0311d26 100644
--- a/tests/debugedit.at
+++ b/tests/debugedit.at
@@ -93,7 +93,7 @@ DEBUGEDIT_SETUP([-gdwarf-4])
 
 # Capture strings that start with the testdir (pwd) directory path
 # (and replace that textually with /foo/bar/baz)
-readelf -p.debug_str foo.o subdir_bar/bar.o baz.o | cut -c13- \
+$READELF -p.debug_str foo.o subdir_bar/bar.o baz.o | cut -c13- \
         | grep ^$(pwd) | sort \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
 
@@ -108,7 +108,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
 AT_CHECK([[
-readelf -p.debug_str foo.o subdir_bar/bar.o baz.o | cut -c13- \
+$READELF -p.debug_str foo.o subdir_bar/bar.o baz.o | cut -c13- \
         | grep ^/foo/bar/baz | sort
 ]],[0],[expout])
 
@@ -125,7 +125,7 @@ DEBUGEDIT_SETUP([-gdwarf-5])
 
 # Capture strings that start with the testdir (pwd) directory path
 # (and replace that textually with /foo/bar/baz)
-readelf -p.debug_str -p.debug_line_str foo.o subdir_bar/bar.o baz.o \
+$READELF -p.debug_str -p.debug_line_str foo.o subdir_bar/bar.o baz.o \
         | cut -c13- \
         | grep ^$(pwd) | sort | uniq \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
@@ -141,7 +141,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
 AT_CHECK([[
-readelf -p.debug_str -p.debug_line_str foo.o subdir_bar/bar.o baz.o \
+$READELF -p.debug_str -p.debug_line_str foo.o subdir_bar/bar.o baz.o \
         | cut -c13- \
         | grep ^/foo/bar/baz | sort | uniq
 ]],[0],[expout],[ignore])
@@ -160,7 +160,7 @@ DEBUGEDIT_SETUP([-gdwarf-4])
 # (and replace that textually with /foo/bar/baz)
 # Note that partially linked files, might have multiple duplicate
 # strings, but debugedit will merge them. So use sort -u.
-readelf -p.debug_str ./foobarbaz.part.o | cut -c13- \
+$READELF -p.debug_str ./foobarbaz.part.o | cut -c13- \
         | grep ^$(pwd) | sort -u \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
 
@@ -173,7 +173,7 @@ fi
 # Check the replaced strings are all there.
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
 AT_CHECK([[
-readelf -p.debug_str ./foobarbaz.part.o | cut -c13- \
+$READELF -p.debug_str ./foobarbaz.part.o | cut -c13- \
         | grep ^/foo/bar/baz | sort
 ]],[0],[expout])
 
@@ -192,7 +192,7 @@ DEBUGEDIT_SETUP([-gdwarf-5])
 # (and replace that textually with /foo/bar/baz)
 # Note that partially linked files, might have multiple duplicate
 # strings, but debugedit will merge them. So use sort -u.
-readelf -p.debug_str -p.debug_line_str ./foobarbaz.part.o | cut -c13- \
+$READELF -p.debug_str -p.debug_line_str ./foobarbaz.part.o | cut -c13- \
         | grep ^$(pwd) | sort -u | uniq \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
 
@@ -205,7 +205,7 @@ fi
 # Check the replaced strings are all there.
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
 AT_CHECK([[
-readelf -p.debug_str -p.debug_line_str ./foobarbaz.part.o | cut -c13- \
+$READELF -p.debug_str -p.debug_line_str ./foobarbaz.part.o | cut -c13- \
         | grep ^/foo/bar/baz | sort | uniq
 ]],[0],[expout],[ignore])
 
@@ -221,7 +221,7 @@ DEBUGEDIT_SETUP([-gdwarf-4])
 
 # Capture strings that start with the testdir (pwd) directory path
 # (and replace that textually with /foo/bar/baz)
-readelf -p.debug_str foobarbaz.exe | cut -c13- \
+$READELF -p.debug_str foobarbaz.exe | cut -c13- \
         | grep ^$(pwd) | sort \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
 
@@ -235,7 +235,7 @@ fi
 # Check the replaced strings are all there.
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
 AT_CHECK([[
-readelf -p.debug_str foobarbaz.exe | cut -c13- \
+$READELF -p.debug_str foobarbaz.exe | cut -c13- \
         | grep ^/foo/bar/baz | sort
 ]],[0],[expout])
 
@@ -252,7 +252,7 @@ DEBUGEDIT_SETUP([-gdwarf-5])
 
 # Capture strings that start with the testdir (pwd) directory path
 # (and replace that textually with /foo/bar/baz)
-readelf -p.debug_str -p.debug_line_str foobarbaz.exe | cut -c13- \
+$READELF -p.debug_str -p.debug_line_str foobarbaz.exe | cut -c13- \
         | grep ^$(pwd) | sort | uniq \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
 
@@ -266,7 +266,7 @@ fi
 # Check the replaced strings are all there.
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
 AT_CHECK([[
-readelf -p.debug_str -p.debug_line_str foobarbaz.exe | cut -c13- \
+$READELF -p.debug_str -p.debug_line_str foobarbaz.exe | cut -c13- \
         | grep ^/foo/bar/baz | sort | uniq
 ]],[0],[expout],[ignore])
 
@@ -305,7 +305,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
 AT_CHECK([[
-readelf --debug-dump=info foo.o subdir_bar/bar.o baz.o \
+$READELF --debug-dump=info foo.o subdir_bar/bar.o baz.o \
         | grep -E 'DW_AT_(name|comp_dir)' \
         | rev | cut -d: -f1 | rev | cut -c2- | grep ^/foo/bar/baz | sort -u
 ]],[0],[expout])
@@ -328,7 +328,7 @@ AT_DATA([expout],
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
 AT_CHECK([[
-readelf --debug-dump=info ./foobarbaz.part.o \
+$READELF --debug-dump=info ./foobarbaz.part.o \
         | grep -E 'DW_AT_(name|comp_dir)' \
         | rev | cut -d: -f1 | rev | cut -c2- | grep ^/foo/bar/baz | sort -u
 ]],[0],[expout])
@@ -351,7 +351,7 @@ AT_DATA([expout],
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
 AT_CHECK([[
-readelf --debug-dump=info ./foobarbaz.exe | grep -E 'DW_AT_(name|comp_dir)' \
+$READELF --debug-dump=info ./foobarbaz.exe | grep -E 'DW_AT_(name|comp_dir)' \
         | rev | cut -d: -f1 | rev | cut -c2- | grep ^/foo/bar/baz | sort -u
 ]],[0],[expout])
 
@@ -385,7 +385,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
 AT_CHECK([[
 for i in ./foo.o ./subdir_bar/bar.o ./baz.o;do \
-  readelf --debug-dump=info $i \
+  $READELF --debug-dump=info $i \
           | awk '/Abbrev Number:.*DW_TAG_type_unit/{p=1}{if(p)print}/^$/{p=0}' \
           | sed -n 's/^.*> *DW_AT_name *:.* \(stringp[^ ]*\|st.\)$/\1/p' \
           | sort;
@@ -415,7 +415,7 @@ stz
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
 AT_CHECK([[
-readelf --debug-dump=info ./foobarbaz.part.o \
+$READELF --debug-dump=info ./foobarbaz.part.o \
         | awk '/Abbrev Number:.*DW_TAG_type_unit/{p=1}{if(p)print}/^$/{p=0}' \
         | sed -n 's/^.*> *DW_AT_name *:.* \(stringp[^ ]*\|st.\)$/\1/p' \
         | sort
@@ -444,7 +444,7 @@ stz
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
 AT_CHECK([[
-readelf --debug-dump=info ./foobarbaz.exe \
+$READELF --debug-dump=info ./foobarbaz.exe \
         | awk '/Abbrev Number:.*DW_TAG_type_unit/{p=1}{if(p)print}/^$/{p=0}' \
         | sed -n 's/^.*> *DW_AT_name *:.* \(stringp[^ ]*\|st.\)$/\1/p' \
         | sort
@@ -474,7 +474,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
 AT_CHECK([[
-readelf --debug-dump=line foo.o subdir_bar/bar.o baz.o \
+$READELF --debug-dump=line foo.o subdir_bar/bar.o baz.o \
         | grep -A3 "The Directory Table" | grep "^  [123]" \
 	| grep /foo/ | cut -c5- | sort
 ]],[0],[expout])
@@ -499,7 +499,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
 AT_CHECK([[
-readelf --debug-dump=line foo.o subdir_bar/bar.o baz.o \
+$READELF --debug-dump=line foo.o subdir_bar/bar.o baz.o \
         | grep -A5 "The Directory Table" | grep "^  [123]" \
 	| cut -f2- -d/ | grep ^foo/ | sort
 ]],[0],[expout])
@@ -521,7 +521,7 @@ AT_DATA([expout],
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
 AT_CHECK([[
-readelf --debug-dump=line ./foobarbaz.part.o \
+$READELF --debug-dump=line ./foobarbaz.part.o \
         | grep -A3 "The Directory Table" | grep "^  [123]" \
 	| grep /foo/ | cut -c5- | sort
 ]],[0],[expout])
@@ -544,7 +544,7 @@ foo/bar/baz/subdir_headers
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
 AT_CHECK([[
-readelf --debug-dump=line ./foobarbaz.part.o \
+$READELF --debug-dump=line ./foobarbaz.part.o \
         | grep -A5 "The Directory Table" | grep "^  [123]" \
 	| cut -f2- -d/ | grep ^foo/ | sort
 ]],[0],[expout])
@@ -566,7 +566,7 @@ AT_DATA([expout],
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
 AT_CHECK([[
-readelf --debug-dump=line ./foobarbaz.exe \
+$READELF --debug-dump=line ./foobarbaz.exe \
         | grep -A3 "The Directory Table" | grep "^  [123]" \
 	| grep /foo/ | cut -c5- | sort
 ]],[0],[expout])
@@ -589,7 +589,7 @@ foo/bar/baz/subdir_headers
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
 AT_CHECK([[
-readelf --debug-dump=line ./foobarbaz.exe \
+$READELF --debug-dump=line ./foobarbaz.exe \
         | grep -A5 "The Directory Table" | grep "^  [123]" \
 	| cut -f2- -d/ | grep ^foo/ | sort
 ]],[0],[expout])
@@ -615,7 +615,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
 AT_CHECK([[
-readelf --debug-dump=macro foo.o subdir_bar/bar.o baz.o \
+$READELF --debug-dump=macro foo.o subdir_bar/bar.o baz.o \
         | grep NUMBER | rev | cut -d: -f1 | rev | cut -c2-
 ]],[0],[expout])
 
@@ -638,7 +638,7 @@ NUMBER 42
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
 AT_CHECK([[
-readelf --debug-dump=macro ./foobarbaz.part.o \
+$READELF --debug-dump=macro ./foobarbaz.part.o \
         | grep NUMBER | rev | cut -d: -f1 | rev | cut -c2-
 ]],[0],[expout])
 
@@ -661,7 +661,7 @@ NUMBER 42
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
 AT_CHECK([[
-readelf --debug-dump=macro ./foobarbaz.exe \
+$READELF --debug-dump=macro ./foobarbaz.exe \
         | grep NUMBER | rev | cut -d: -f1 | rev | cut -c2-
 ]],[0],[expout])
 
-- 
2.27.0