summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Golubev <fatzer2@gmail.com>2025-08-09 08:49:12 +0300
committerFat-Zer <fatzer2@gmail.com>2025-08-10 07:09:52 +0000
commit0a9401e9c5afd3504162aab918ad84fa279a140b (patch)
tree185c5aa4d561a3f977d760491bb24e7a3c9572a3
parent1256297108752093c40ddd3fe025c0d98ff03a6a (diff)
downloadtdelibs-0a9401e9c5afd3504162aab918ad84fa279a140b.tar.gz
tdelibs-0a9401e9c5afd3504162aab918ad84fa279a140b.zip
Fix build WITH_LIBBFD and libbfd 2.34+
Closes: https://mirror.git.trinitydesktop.org/gitea/TDE/tdelibs/issues/368 Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
-rw-r--r--CMakeLists.txt10
-rw-r--r--config.h.cmake4
-rw-r--r--tdecore/kdebug.cpp7
3 files changed, 20 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 505977a9c..baecceb88 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1102,6 +1102,16 @@ if( WITH_LIBBFD )
endif( NOT HAVE_LIBBFD )
set( LIBBFD_LIBRARIES bfd )
check_include_file( "demangle.h" HAVE_DEMANGLE_H )
+
+ tde_save_and_set( CMAKE_REQUIRED_LIBRARIES "${LIBBFD_LIBRARIES}" )
+ check_c_source_compiles("
+ #define PACKAGE tdelibs
+ #define PACKAGE_VERSION \"${TDE_VERSION}\"
+ #include <bfd.h>
+ int main() {bfd_section_flags((asection *)0); return 0;} "
+ HAVE_LIBBFD_2_34_API
+ )
+ tde_restore( CMAKE_REQUIRED_LIBRARIES )
endif( WITH_LIBBFD )
diff --git a/config.h.cmake b/config.h.cmake
index cd2ec1c96..7aaf0a23f 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -108,6 +108,10 @@
/* Define to 1 if libbfd provides demangle.h header */
#cmakedefine HAVE_DEMANGLE_H 1
+/* Define to 1 if libbfd have API of version 2.34+ (i.e.
+ * bfd_section_flags() has only one paremater) */
+#cmakedefine HAVE_LIBBFD_2_34_API 1
+
/* Define if getaddrinfo is broken and should be replaced */
#cmakedefine HAVE_BROKEN_GETADDRINFO 1
diff --git a/tdecore/kdebug.cpp b/tdecore/kdebug.cpp
index 43b50880d..e30ebeae0 100644
--- a/tdecore/kdebug.cpp
+++ b/tdecore/kdebug.cpp
@@ -693,10 +693,15 @@ void bfdFillAdditionalFunctionsInfo(BacktraceFunctionInfo &func) {
// found source file and line for given address
for (asection *sect = abfd->sections; sect != NULL; sect = sect->next) {
-
+#ifdef HAVE_LIBBFD_2_34_API
+ if (bfd_section_flags(sect) & SEC_ALLOC) {
+ bfd_vma sectStart = bfd_section_vma(sect);
+ bfd_vma sectEnd = sectStart + bfd_section_size(sect);
+#else // HAVE_LIBBFD_2_34_API
if (bfd_get_section_flags(abfd, sect) & SEC_ALLOC) {
bfd_vma sectStart = bfd_get_section_vma(abfd, sect);
bfd_vma sectEnd = sectStart + bfd_section_size(abfd, sect);
+#endif // HAVE_LIBBFD_2_34_API
if (sectStart <= func.offset && func.offset < sectEnd) {
bfd_vma sectOffset = func.offset - sectStart;
const char* functionName;