Skip to contentSkip to conversation

objtool: Build with disassembly can fail when including bdf.h

PATCH Applied Alexandre Chartre 2 participants 2 messages Nov 26, 2025 – Nov 27, 2025 objtool

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 objtool: Build with disassembly can fail when including bdf.h

Building objtool with disassembly support can fail when including the bdf.h file:

In file included from tools/objtool/include/objtool/arch.h:108,

                   from check.c:14:

/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
| ^~~~~

This check is present in the bfd.h file generated from the binutils source code, but it is not necessarily present in the bfd.h file provided in a binutil package (for example, it is not present in the binutil RPM).

The solution to this issue is to define the PACKAGE macro before including bfd.h. This is the solution suggested by the binutil developer in bug 14243, and it is used by other kernel tools which also use bfd.h (perf and bpf).

---
 tools/objtool/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/objtool/Makefile +1 -1
index 66397d755fe4b..ad6e1ec706ce0 100644
@@ -87,7 +87,7 @@ BUILD_DISAS := n
 
 ifeq ($(feature-libbfd),1)
 	BUILD_DISAS := y
-	OBJTOOL_CFLAGS += -DDISAS
+	OBJTOOL_CFLAGS += -DDISAS -DPACKAGE="objtool"
 	OBJTOOL_LDFLAGS += -lopcodes
 endif
 
Signature · 1 line
2.43.5
#1 lore raw
The following commit has been merged into the objtool/core branch of tip:

The following commit has been merged into the objtool/core branch of tip:

Commit-ID:     59bfa6408214b6533d8691715cf5459e89b45b89
Gitweb:        https://git.kernel.org/tip/59bfa6408214b6533d8691715cf5459e89b45b89
Author:        Alexandre Chartre <[email protected]>
AuthorDate:    Wed, 26 Nov 2025 14:45:19 +01:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Thu, 27 Nov 2025 09:32:46 +01:00

objtool: Build with disassembly can fail when including bdf.h

Building objtool with disassembly support can fail when including the bdf.h file:

In file included from tools/objtool/include/objtool/arch.h:108,

                   from check.c:14:

/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
| ^~~~~

This check is present in the bfd.h file generated from the binutils source code, but it is not necessarily present in the bfd.h file provided in a binutil package (for example, it is not present in the binutil RPM).

The solution to this issue is to define the PACKAGE macro before including bfd.h. This is the solution suggested by the binutil developer in bug 14243, and it is used by other kernel tools which also use bfd.h (perf and bpf).

---
 tools/objtool/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/objtool/Makefile +1 -1
index 66397d7..ad6e1ec 100644
@@ -87,7 +87,7 @@ BUILD_DISAS := n
 
 ifeq ($(feature-libbfd),1)
 	BUILD_DISAS := y
-	OBJTOOL_CFLAGS += -DDISAS
+	OBJTOOL_CFLAGS += -DDISAS -DPACKAGE="objtool"
 	OBJTOOL_LDFLAGS += -lopcodes
 endif