summaryrefslogtreecommitdiffstats
path: root/dev-libs/libr/files/libr-14.1.5-Update-for-API-change-in-binutils-2.46.patch
blob: ec44486eb4cb2a90d933082e1623535a0e963fca (plain)
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
From 6ac41e2f0ba06d6ba49326b5b7460c0e4bc1d7ff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= <slavek.banko@axis.cz>
Date: Sun, 25 Jan 2026 18:29:16 +0100
Subject: [PATCH] Update for API change in binutils 2.46.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

According to the commit message in binutils, it was a simple renaming
of `*_set_reloc` to `*_finalize_section_relocs` without changing the
functionality.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit b471c5f6213db85a3ac35e98a0a1054dc9eb9ad3)
---
 CMakeLists.txt     |  1 +
 src/config.h.cmake |  3 +++
 src/libr-bfd.c     | 10 ++++++++++
 3 files changed, 14 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f7f489d..3eb7384 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -73,6 +73,7 @@ if( WITH_BACKEND_LIBBFD )
            bfd_copy_private_section_data(ihandle, iscn, ohandle, oscn, NULL);
          }"
         HAVE_BFD_2_45)
+    check_symbol_exists( bfd_finalize_section_relocs bfd.h HAVE_BFD_2_46 )
     tde_restore( CMAKE_REQUIRED_LIBRARIES )
     tde_restore( CMAKE_REQUIRED_DEFINITIONS )
     set( BACKEND_LIBRARIES "-lbfd" )
diff --git a/src/config.h.cmake b/src/config.h.cmake
index e2673d2..bf6d3e7 100644
--- a/src/config.h.cmake
+++ b/src/config.h.cmake
@@ -13,3 +13,6 @@
 
 /* Define to 1 if you have Binutils >= 2.45 */
 #cmakedefine HAVE_BFD_2_45 1
+
+/* Define to 1 if you have Binutils >= 2.46 */
+#cmakedefine HAVE_BFD_2_46 1
diff --git a/src/libr-bfd.c b/src/libr-bfd.c
index 9d72cce..b472543 100644
--- a/src/libr-bfd.c
+++ b/src/libr-bfd.c
@@ -320,12 +320,22 @@ int build_output(libr_file *file_handle)
 		oscn = iscn->output_section;
 		reloc_size = bfd_get_reloc_upper_bound(ihandle, iscn);
 		if(reloc_size == 0)
+		{
+			#ifdef HAVE_BFD_2_46
+			bfd_finalize_section_relocs(ohandle, oscn, NULL, 0);
+			#else
 			bfd_set_reloc(ohandle, oscn, NULL, 0);
+			#endif
+		}
 		else
 		{
 			reloc_buffer = malloc(reloc_size);
 			reloc_count = bfd_canonicalize_reloc(ihandle, iscn, reloc_buffer, symtab_buffer);
+			#ifdef HAVE_BFD_2_46
+			bfd_finalize_section_relocs(ohandle, oscn, reloc_buffer, reloc_count);
+			#else
 			bfd_set_reloc(ohandle, oscn, reloc_buffer, reloc_count);
+			#endif
 		}
 
 		if(
-- 
2.52.0