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
| | commit 3f445279b60b16b6cb062921b74ae400344b4a68
Author: Mark Wielaard <mark@klomp.org>
Date: Thu Dec 5 14:22:56 2019 +0100
tests: Run elfcompress under testrun in run-elfclassify.sh
Otherwise elfcompress might run against the system libelf which might
be too old or missing.
Signed-off-by: Mark Wielaard <mark@klomp.org>
diff --git a/tests/run-elfclassify.sh b/tests/run-elfclassify.sh
index 5a849bbd..fb14139d 100755
--- a/tests/run-elfclassify.sh
+++ b/tests/run-elfclassify.sh
@@ -267,7 +267,7 @@ $(echo $kmod_files | sed -e "s/ /\n/g")
EOF
echo "gnu compressed kmods are unstripped"
-${abs_top_builddir}/src/elfcompress -t gnu --force $kmod_files
+testrun ${abs_top_builddir}/src/elfcompress -t gnu --force $kmod_files
testrun ${abs_top_builddir}/src/elfclassify --unstripped $kmod_files
testrun_compare ${abs_top_builddir}/src/elfclassify --unstripped --print $kmod_files <<EOF
$(echo $kmod_files | sed -e "s/ /\n/g")
@@ -312,7 +312,7 @@ $(echo $debug_files | sed -e "s/ /\n/g")
EOF
echo "compress the debug sections and try again"
-${abs_top_builddir}/src/elfcompress -t gnu --force $debug_files
+testrun ${abs_top_builddir}/src/elfcompress -t gnu --force $debug_files
echo "again unstripped"
testrun ${abs_top_builddir}/src/elfclassify --unstripped $debug_files
commit eaffa79d52da7454044be53d28b525cebdb0093b
Author: Mark Wielaard <mark@klomp.org>
Date: Fri Dec 6 15:48:00 2019 +0100
tests: Run strip under testrun in run-debuginfod-find.sh
Otherwise strip might run against the system libelf which might be too
old or missing.
Signed-off-by: Mark Wielaard <mark@klomp.org>
diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh
index 0ade03b7..6f92fbf1 100755
--- a/tests/run-debuginfod-find.sh
+++ b/tests/run-debuginfod-find.sh
@@ -102,7 +102,7 @@ export DEBUGINFOD_TIMEOUT=10
echo "int main() { return 0; }" > ${PWD}/prog.c
tempfiles prog.c
gcc -g -o prog ${PWD}/prog.c
- ${abs_top_builddir}/src/strip -g -f prog.debug ${PWD}/prog
+testrun ${abs_top_builddir}/src/strip -g -f prog.debug ${PWD}/prog
BUILDID=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \
-a prog | grep 'Build ID' | cut -d ' ' -f 7`
commit cf1b5fe170fa24f32871ef284ff2968c73816f98
Author: Mark Wielaard <mark@klomp.org>
Date: Fri Dec 6 17:20:00 2019 +0100
Make sure to always build with build-ids.
We really need build-ids for various things. If the system compiler
doesn't generate build-ids warn and generate them anyway for both the
binaries and the tests.
Signed-off-by: Mark Wielaard <mark@klomp.org>
diff --git a/configure.ac b/configure.ac
index 5a2dc373..36a6b6c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -197,6 +197,15 @@ if test "$ac_cv_zdefs" = "yes"; then
dso_LDFLAGS="$dso_LDFLAGS $ZDEFS_LDFLAGS"
fi
+# We really want build-ids. Warn and force generating them if gcc was
+# configure without --enable-linker-build-id
+AC_CACHE_CHECK([whether the compiler generates build-ids], ac_cv_buildid, [dnl
+AC_LINK_IFELSE([AC_LANG_PROGRAM()],[ac_cv_buildid=yes; readelf -n conftest$EXEEXT | grep -q NT_GNU_BUILD_ID || ac_cv_buildid=no],AC_MSG_FAILURE([unexpected compile failure]))])
+if test "$ac_cv_buildid" = "no"; then
+ AC_MSG_WARN([compiler doesn't generate build-id by default])
+ LDFLAGS="$LDFLAGS -Wl,--build-id"
+fi
+
ZRELRO_LDFLAGS="-Wl,-z,relro"
AC_CACHE_CHECK([whether gcc supports $ZRELRO_LDFLAGS], ac_cv_zrelro, [dnl
save_LDFLAGS="$LDFLAGS"
diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh
index 6f92fbf1..6533996a 100755
--- a/tests/run-debuginfod-find.sh
+++ b/tests/run-debuginfod-find.sh
@@ -101,7 +101,7 @@ export DEBUGINFOD_TIMEOUT=10
# cannot find it without debuginfod.
echo "int main() { return 0; }" > ${PWD}/prog.c
tempfiles prog.c
-gcc -g -o prog ${PWD}/prog.c
+gcc -Wl,--build-id -g -o prog ${PWD}/prog.c
testrun ${abs_top_builddir}/src/strip -g -f prog.debug ${PWD}/prog
BUILDID=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \
-a prog | grep 'Build ID' | cut -d ' ' -f 7`
@@ -138,7 +138,7 @@ cmp $filename ${PWD}/prog.c
# Build another, non-stripped binary
echo "int main() { return 0; }" > ${PWD}/prog2.c
tempfiles prog2.c
-gcc -g -o prog2 ${PWD}/prog2.c
+gcc -Wl,--build-id -g -o prog2 ${PWD}/prog2.c
BUILDID2=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \
-a prog2 | grep 'Build ID' | cut -d ' ' -f 7`
--- a/configure 1970-01-01 01:00:00.000000000 +0100
+++ b/configure 2019-12-11 14:18:11.812008097 +0100
@@ -5325,6 +5325,43 @@
dso_LDFLAGS="$dso_LDFLAGS $ZDEFS_LDFLAGS"
fi
+# We really want build-ids. Warn and force generating them if gcc was
+# configure without --enable-linker-build-id
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler generates build-ids" >&5
+$as_echo_n "checking whether the compiler generates build-ids... " >&6; }
+if ${ac_cv_buildid+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_buildid=yes; readelf -n conftest$EXEEXT | grep -q NT_GNU_BUILD_ID || ac_cv_buildid=no
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "unexpected compile failure
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_buildid" >&5
+$as_echo "$ac_cv_buildid" >&6; }
+if test "$ac_cv_buildid" = "no"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: compiler doesn't generate build-id by default" >&5
+$as_echo "$as_me: WARNING: compiler doesn't generate build-id by default" >&2;}
+ LDFLAGS="$LDFLAGS -Wl,--build-id"
+fi
+
ZRELRO_LDFLAGS="-Wl,-z,relro"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether gcc supports $ZRELRO_LDFLAGS" >&5
$as_echo_n "checking whether gcc supports $ZRELRO_LDFLAGS... " >&6; }
|