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
|
From 2ef4ae411f630affb53a709e090d05c43ee7b1c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= <slavek.banko@axis.cz>
Date: Tue, 5 Aug 2025 01:43:24 +0200
Subject: [PATCH 1/2] Update for API change in binutils 2.45. Simplify binutils
version definitions.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit c57eae31615bc70072c7e99d712c2285817bd2e5)
(cherry picked from commit 8380fc26a471d64bcddc38a2bce9442f6386b805)
---
CMakeLists.txt | 9 ++++++++-
src/config.h.cmake | 3 +++
src/libr-bfd.c | 8 +++++++-
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ba522b1..f7f489d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,6 +28,7 @@ set( PACKAGE_VERSION 0.7.0 )
include( FindPkgConfig )
include( FindThreads )
+include( CheckCSourceCompiles )
include( CheckIncludeFile )
include( CheckFunctionExists )
include( CheckLibraryExists )
@@ -66,8 +67,14 @@ if( WITH_BACKEND_LIBBFD )
endif( NOT HAVE_BFD_H )
tde_save_and_set( CMAKE_REQUIRED_LIBRARIES "bfd" )
check_symbol_exists( bfd_asymbol_section bfd.h HAVE_BFD_2_34 )
- tde_restore( CMAKE_REQUIRED_DEFINITIONS )
+ check_c_source_compiles(
+ "#include <bfd.h>
+ int main() { bfd *ihandle, *ohandle; asection *iscn, *oscn;
+ bfd_copy_private_section_data(ihandle, iscn, ohandle, oscn, NULL);
+ }"
+ HAVE_BFD_2_45)
tde_restore( CMAKE_REQUIRED_LIBRARIES )
+ tde_restore( CMAKE_REQUIRED_DEFINITIONS )
set( BACKEND_LIBRARIES "-lbfd" )
set( LIBR_BACKEND "bfd" )
set( BACKEND_NAME "libbfd" )
diff --git a/src/config.h.cmake b/src/config.h.cmake
index 34fe955..e2673d2 100644
--- a/src/config.h.cmake
+++ b/src/config.h.cmake
@@ -10,3 +10,6 @@
/* Define to 1 if you have Binutils >= 2.34 */
#cmakedefine HAVE_BFD_2_34 1
+
+/* Define to 1 if you have Binutils >= 2.45 */
+#cmakedefine HAVE_BFD_2_45 1
diff --git a/src/libr-bfd.c b/src/libr-bfd.c
index 53e8aee..9d72cce 100644
--- a/src/libr-bfd.c
+++ b/src/libr-bfd.c
@@ -240,7 +240,13 @@ int setup_sections(bfd *ihandle, bfd *ohandle)
oscn->entsize = iscn->entsize;
iscn->output_section = oscn;
iscn->output_offset = vma;
- if(!bfd_copy_private_section_data(ihandle, iscn, ohandle, oscn))
+ if(
+ #ifdef HAVE_BFD_2_45
+ !bfd_copy_private_section_data(ihandle, iscn, ohandle, oscn, NULL)
+ #else
+ !bfd_copy_private_section_data(ihandle, iscn, ohandle, oscn)
+ #endif
+ )
{
printf("failed to compute section alignment: %s\n", bfd_errmsg(bfd_get_error()));
return false;
--
2.52.0
|