Skip to content

Commit ce6ecb6

Browse files
corubbafxlb
authored andcommitted
instrument functions: Work around bfd inclusion guard
In 2012 [0] [1] binutils added an inclusion guard to bfd.h, requiring to include the autoconf config.h beforehand. This guard is triggered when enabling instrumentation and development mode: % git clone https://github.com/the-tcpdump-group/tcpdump.git % cd tcpdump % touch .devel % ./autogen.sh % ./configure --enable-instrument-functions --enable-smb --quiet ./mkdep -c gcc -m -M -s . -DHAVE_CONFIG_H -I. fptype.c tcpdump.c \ print-smb.c smbutil.c instrument-functions.c <libnetdissect src list> In file included from ./instrument-functions.c:18: /usr/include/bfd.h:35:2: error: #error config.h must be included before this header 35 | #error config.h must be included before this header | ^~~~~ Note than this does *not* happen on Debian-based systems, because they remove [2] that guard since 2012 [3]. That's also why the Ubuntu-based Linux CI is not affected. [0] https://sourceware.org/bugzilla/show_bug.cgi?id=14072 [1] https://sourceware.org/git/?p=binutils-gdb.git;a=blobdiff;f=bfd/bfd-in.h;h=ae8149a2;hp=d88bcb6c;hb=df7b86aa;hpb=134fa82e [2] https://salsa.debian.org/toolchain-team/binutils/-/blob/38415eb8/debian/rules#L1045-1048 [3] https://code.launchpad.net/~doko/binutils/pkg-2.23-debian [skip ci]
1 parent 62aa26a commit ce6ecb6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

instrument-functions.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@
1515
#include <string.h>
1616
#include <stdlib.h>
1717
#include <unistd.h>
18+
19+
/*
20+
* The binutils bfd header has a weird inclusion guard, requiring this
21+
* macro to be defined. Some distributions patch the guard out, others
22+
* don't.
23+
*/
24+
#define PACKAGE "binutils-bfd.h-guard-workaround"
1825
#include <bfd.h>
26+
#undef PACKAGE
1927

2028
/*
2129
* Generate instrumentation calls for entry and exit to functions.

0 commit comments

Comments
 (0)