The "stack" binary built by elfutils has the same name
as the standard C++ header <stack>.

If that header were to be in the list of includes
while building the C++ elfutils program "srcfiles",
then there is a chance that the "stack" binary
is included instead and treated as text,
leading to a decode error
if "stack" happens to be built first
and "." is in the include paths.

Adding the result of C++ compilation srcfiles.o
to the dependencies of "stack" ensures that
the C++ compilation will happen first,
before the stack binary is present.

While this doesn't guarantee an error will not occur
in all cases, it does guarantee that it will not occur
from a clean build state.

      * src/Makefile.am: Add compilation dependency between
      the stack and srcfiles binaries.

Signed-off-by: Michael Pratt <mcpr...@pm.me>
---
 src/Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/Makefile.am b/src/Makefile.am
index e0267d96..c5474c68 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -94,6 +94,7 @@ strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
 ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS)
 unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
 stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) 
$(demanglelib)
+EXTRA_stack_DEPENDENCIES = $(if $(findstring 
srcfiles,$(bin_PROGRAMS)),$(srcfiles_OBJECTS))
 elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD)
 elfclassify_LDADD = $(libelf) $(libdw) $(libeu) $(argp_LDADD)
 srcfiles_SOURCES = srcfiles.cxx
-- 
2.30.2


Reply via email to