···
1
-
From: Tristan Ross <tristan.ross@midstall.com>
2
-
Date: Wed, 31 Jul 2024 04:03:03 +0000 (-0700)
3
-
Subject: Prevent binaries in src from colliding with libc++ headers
4
-
X-Git-Url: https://sourceware.org/git/?p=elfutils.git;a=commitdiff_plain;h=232b9ede92cbecabbd61291c2fc9aaf3fc61061f;hp=87a60d22299c4ba7b94cbce04a32c2abf015f98a
6
-
Prevent binaries in src from colliding with libc++ headers
8
-
Discovered with Nix and LLVM 17. Headers inside of libc++ can easily
9
-
collide with binaries being linked in src. This results in clang trying
10
-
to include a binary as a header.
12
-
Fix this by removing '-I.' and '-I$(srcdir)' from AM_CPPFLAGS and
13
-
DEFAULT_INCLUDES in src/Makefile.am.
15
-
To facilitate this config/eu.am has been refactored. New file
16
-
config/eu-common.am contains all of the old eu.am but with the
17
-
AM_CPPFLAGS definition removed. eu.am now includes eu-common.am and
18
-
contains the old AM_CPPFLAGS definition.
20
-
eu.am functionality does not change, but src/Makefile.am can instead
21
-
include eu-common.am and define its own AM_CPPFLAGS without causing a
22
-
"multiply defined" warning during autoreconf.
24
-
Signed-off-by: Tristan Ross <tristan.ross@midstall.com>
27
-
diff --git a/config/eu-common.am b/config/eu-common.am
28
-
new file mode 100644
29
-
index 00000000..9cc7f696
31
-
+++ b/config/eu-common.am
33
-
+## Common automake fragments for elfutils subdirectory makefiles.
35
-
+## Copyright (C) 2010, 2014, 2016 Red Hat, Inc.
36
-
+## Copyright (C) 2023, Mark J. Wielaard <mark@klomp.org>
38
-
+## This file is part of elfutils.
40
-
+## This file is free software; you can redistribute it and/or modify
41
-
+## it under the terms of either
43
-
+## * the GNU Lesser General Public License as published by the Free
44
-
+## Software Foundation; either version 3 of the License, or (at
45
-
+## your option) any later version
49
-
+## * the GNU General Public License as published by the Free
50
-
+## Software Foundation; either version 2 of the License, or (at
51
-
+## your option) any later version
53
-
+## or both in parallel, as here.
55
-
+## elfutils is distributed in the hope that it will be useful, but
56
-
+## WITHOUT ANY WARRANTY; without even the implied warranty of
57
-
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
58
-
+## General Public License for more details.
60
-
+## You should have received copies of the GNU General Public License and
61
-
+## the GNU Lesser General Public License along with this program. If
62
-
+## not, see <http://www.gnu.org/licenses/>.
65
-
+DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"${localedir}"'
67
-
+# Drop the 'u' flag that automake adds by default. It is incompatible
68
-
+# with deterministic archives.
71
-
+# Warn about stack usage of more than 256K = 262144 bytes.
72
-
+if ADD_STACK_USAGE_WARNING
73
-
+STACK_USAGE_WARNING=-Wstack-usage=262144
74
-
+STACK_USAGE_NO_ERROR=-Wno-error=stack-usage=
76
-
+STACK_USAGE_WARNING=
77
-
+STACK_USAGE_NO_ERROR=
80
-
+if SANE_LOGICAL_OP_WARNING
81
-
+LOGICAL_OP_WARNING=-Wlogical-op
83
-
+LOGICAL_OP_WARNING=
86
-
+if HAVE_DUPLICATED_COND_WARNING
87
-
+DUPLICATED_COND_WARNING=-Wduplicated-cond
89
-
+DUPLICATED_COND_WARNING=
92
-
+if HAVE_NULL_DEREFERENCE_WARNING
93
-
+NULL_DEREFERENCE_WARNING=-Wnull-dereference
95
-
+NULL_DEREFERENCE_WARNING=
98
-
+if HAVE_IMPLICIT_FALLTHROUGH_WARNING
99
-
+# Use strict fallthrough. Only __attribute__((fallthrough)) will prevent the
101
-
+if HAVE_IMPLICIT_FALLTHROUGH_5_WARNING
102
-
+IMPLICIT_FALLTHROUGH_WARNING=-Wimplicit-fallthrough=5
104
-
+IMPLICIT_FALLTHROUGH_WARNING=-Wimplicit-fallthrough
107
-
+IMPLICIT_FALLTHROUGH_WARNING=
110
-
+if HAVE_TRAMPOLINES_WARNING
111
-
+TRAMPOLINES_WARNING=-Wtrampolines
113
-
+TRAMPOLINES_WARNING=
116
-
+if HAVE_NO_PACKED_NOT_ALIGNED_WARNING
117
-
+NO_PACKED_NOT_ALIGNED_WARNING=-Wno-packed-not-aligned
119
-
+NO_PACKED_NOT_ALIGNED_WARNING=
122
-
+if HAVE_USE_AFTER_FREE3_WARNING
123
-
+USE_AFTER_FREE3_WARNING=-Wuse-after-free=3
125
-
+USE_AFTER_FREE3_WARNING=
128
-
+AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \
129
-
+ -Wold-style-definition -Wstrict-prototypes $(TRAMPOLINES_WARNING) \
130
-
+ $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \
131
-
+ $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \
132
-
+ $(USE_AFTER_FREE3_WARNING) \
133
-
+ $(if $($(*F)_no_Werror),,-Werror) \
134
-
+ $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
135
-
+ $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \
136
-
+ $(if $($(*F)_no_Wpacked_not_aligned),$(NO_PACKED_NOT_ALIGNED_WARNING),) \
139
-
+AM_CXXFLAGS = -std=c++11 -Wall -Wshadow \
140
-
+ $(TRAMPOLINES_WARNING) \
141
-
+ $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \
142
-
+ $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \
143
-
+ $(if $($(*F)_no_Werror),,-Werror) \
144
-
+ $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
145
-
+ $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \
146
-
+ $(if $($(*F)_no_Wpacked_not_aligned),$(NO_PACKED_NOT_ALIGNED_WARNING),) \
147
-
+ $($(*F)_CXXFLAGS)
149
-
+COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage, $(COMPILE))
151
-
+DEFS.os = -DPIC -DSHARED
152
-
+if SYMBOL_VERSIONING
153
-
+DEFS.os += -DSYMBOL_VERSIONING
159
-
+ $(AM_V_CC)if $(COMPILE.os) -c -o $@ $(fpic_CFLAGS) $(DEFS.os) -MT $@ -MD -MP \
160
-
+ -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
161
-
+ then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
162
-
+ rm -f "$(DEPDIR)/$*.Tpo"; \
163
-
+ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
166
-
+ $(AM_V_CC)$(COMPILE.os) -c -o $@ $(fpic_CFLAGS) $(DEFS.os) $<
169
-
+CLEANFILES = *.gcno *.gcda
171
-
+textrel_msg = echo "WARNING: TEXTREL found in '$@'"
173
-
+textrel_found = $(textrel_msg); exit 1
175
-
+textrel_found = $(textrel_msg)
177
-
+textrel_check = if $(READELF) -d $@ | grep -F -q TEXTREL; then $(textrel_found); fi
181
-
diff --git a/config/eu.am b/config/eu.am
182
-
index 0b7dab5b..3aa6048a 100644
186
-
-## Common automake fragments for elfutils subdirectory makefiles.
187
-
+## Common automake fragments for elfutils subdirectory makefiles
188
-
+## with AM_CPPFLAGS set.
190
-
## Copyright (C) 2010, 2014, 2016 Red Hat, Inc.
191
-
## Copyright (C) 2023, Mark J. Wielaard <mark@klomp.org>
192
-
@@ -30,120 +31,5 @@
193
-
## not, see <http://www.gnu.org/licenses/>.
196
-
-DEFS = -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"${localedir}"'
197
-
-AM_CPPFLAGS = -iquote . -I$(srcdir) -I$(top_srcdir)/lib -I..
199
-
-# Drop the 'u' flag that automake adds by default. It is incompatible
200
-
-# with deterministic archives.
203
-
-# Warn about stack usage of more than 256K = 262144 bytes.
204
-
-if ADD_STACK_USAGE_WARNING
205
-
-STACK_USAGE_WARNING=-Wstack-usage=262144
206
-
-STACK_USAGE_NO_ERROR=-Wno-error=stack-usage=
208
-
-STACK_USAGE_WARNING=
209
-
-STACK_USAGE_NO_ERROR=
212
-
-if SANE_LOGICAL_OP_WARNING
213
-
-LOGICAL_OP_WARNING=-Wlogical-op
215
-
-LOGICAL_OP_WARNING=
218
-
-if HAVE_DUPLICATED_COND_WARNING
219
-
-DUPLICATED_COND_WARNING=-Wduplicated-cond
221
-
-DUPLICATED_COND_WARNING=
224
-
-if HAVE_NULL_DEREFERENCE_WARNING
225
-
-NULL_DEREFERENCE_WARNING=-Wnull-dereference
227
-
-NULL_DEREFERENCE_WARNING=
230
-
-if HAVE_IMPLICIT_FALLTHROUGH_WARNING
231
-
-# Use strict fallthrough. Only __attribute__((fallthrough)) will prevent the
233
-
-if HAVE_IMPLICIT_FALLTHROUGH_5_WARNING
234
-
-IMPLICIT_FALLTHROUGH_WARNING=-Wimplicit-fallthrough=5
236
-
-IMPLICIT_FALLTHROUGH_WARNING=-Wimplicit-fallthrough
239
-
-IMPLICIT_FALLTHROUGH_WARNING=
242
-
-if HAVE_TRAMPOLINES_WARNING
243
-
-TRAMPOLINES_WARNING=-Wtrampolines
245
-
-TRAMPOLINES_WARNING=
248
-
-if HAVE_NO_PACKED_NOT_ALIGNED_WARNING
249
-
-NO_PACKED_NOT_ALIGNED_WARNING=-Wno-packed-not-aligned
251
-
-NO_PACKED_NOT_ALIGNED_WARNING=
254
-
-if HAVE_USE_AFTER_FREE3_WARNING
255
-
-USE_AFTER_FREE3_WARNING=-Wuse-after-free=3
257
-
-USE_AFTER_FREE3_WARNING=
260
-
-AM_CFLAGS = -std=gnu99 -Wall -Wshadow -Wformat=2 \
261
-
- -Wold-style-definition -Wstrict-prototypes $(TRAMPOLINES_WARNING) \
262
-
- $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \
263
-
- $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \
264
-
- $(USE_AFTER_FREE3_WARNING) \
265
-
- $(if $($(*F)_no_Werror),,-Werror) \
266
-
- $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
267
-
- $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \
268
-
- $(if $($(*F)_no_Wpacked_not_aligned),$(NO_PACKED_NOT_ALIGNED_WARNING),) \
271
-
-AM_CXXFLAGS = -std=c++11 -Wall -Wshadow \
272
-
- $(TRAMPOLINES_WARNING) \
273
-
- $(LOGICAL_OP_WARNING) $(DUPLICATED_COND_WARNING) \
274
-
- $(NULL_DEREFERENCE_WARNING) $(IMPLICIT_FALLTHROUGH_WARNING) \
275
-
- $(if $($(*F)_no_Werror),,-Werror) \
276
-
- $(if $($(*F)_no_Wunused),,-Wunused -Wextra) \
277
-
- $(if $($(*F)_no_Wstack_usage),,$(STACK_USAGE_WARNING)) \
278
-
- $(if $($(*F)_no_Wpacked_not_aligned),$(NO_PACKED_NOT_ALIGNED_WARNING),) \
279
-
- $($(*F)_CXXFLAGS)
281
-
-COMPILE.os = $(filter-out -fprofile-arcs -ftest-coverage, $(COMPILE))
283
-
-DEFS.os = -DPIC -DSHARED
284
-
-if SYMBOL_VERSIONING
285
-
-DEFS.os += -DSYMBOL_VERSIONING
291
-
- $(AM_V_CC)if $(COMPILE.os) -c -o $@ $(fpic_CFLAGS) $(DEFS.os) -MT $@ -MD -MP \
292
-
- -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
293
-
- then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
294
-
- rm -f "$(DEPDIR)/$*.Tpo"; \
295
-
- else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
298
-
- $(AM_V_CC)$(COMPILE.os) -c -o $@ $(fpic_CFLAGS) $(DEFS.os) $<
301
-
-CLEANFILES = *.gcno *.gcda
303
-
-textrel_msg = echo "WARNING: TEXTREL found in '$@'"
305
-
-textrel_found = $(textrel_msg); exit 1
307
-
-textrel_found = $(textrel_msg)
309
-
-textrel_check = if $(READELF) -d $@ | grep -F -q TEXTREL; then $(textrel_found); fi
313
-
+AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_srcdir)/lib -I..
314
-
+include $(top_srcdir)/config/eu-common.am
315
-
diff --git a/src/Makefile.am b/src/Makefile.am
316
-
index 97a0c61a..5bb8c078 100644
317
-
--- a/src/Makefile.am
318
-
+++ b/src/Makefile.am
319
-
@@ -16,14 +16,15 @@
320
-
## You should have received a copy of the GNU General Public License
321
-
## along with this program. If not, see <http://www.gnu.org/licenses/>.
323
-
-include $(top_srcdir)/config/eu.am
324
-
+include $(top_srcdir)/config/eu-common.am
325
-
DEFS += $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \
326
-
-DSRCDIR=\"$(shell cd $(srcdir);pwd)\" -DOBJDIR=\"$(shell pwd)\"
328
-
-DEFAULT_INCLUDES =
329
-
-AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
330
-
- -I$(srcdir)/../libdw -I$(srcdir)/../libdwelf \
331
-
- -I$(srcdir)/../libdwfl -I$(srcdir)/../libasm -I../debuginfod
332
-
+DEFAULT_INCLUDES = -I$(top_builddir)
333
-
+AM_CPPFLAGS = -I$(top_srcdir)/lib -I.. \
334
-
+ -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
335
-
+ -I$(srcdir)/../libdw -I$(srcdir)/../libdwelf \
336
-
+ -I$(srcdir)/../libdwfl -I$(srcdir)/../libasm -I../debuginfod
338
-
AM_LDFLAGS = -Wl,-rpath-link,../libelf:../libdw $(STACK_USAGE_NO_ERROR)