diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2020-01-27 01:37:31 +0100 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2020-01-27 01:37:31 +0100 |
commit | 0e3a275c7d9b33dd6d98a44c82a8e3ed37ec97f0 (patch) | |
tree | cf6ccfe4743510562a7dfe516c4ea1f3691ec68d | |
parent | e6288da4f98eee77f05358aa95b710d9d5344ed1 (diff) | |
download | libr-0e3a275c7d9b33dd6d98a44c82a8e3ed37ec97f0.tar.gz libr-0e3a275c7d9b33dd6d98a44c82a8e3ed37ec97f0.zip |
Fix FTBFS with binutils 2.34.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r-- | CMakeLists.txt | 11 | ||||
-rw-r--r-- | libr.pc.in | 4 | ||||
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/config.h | 94 | ||||
-rw-r--r-- | src/config.h.cmake | 7 | ||||
-rw-r--r-- | src/libr-bfd.c | 74 |
6 files changed, 87 insertions, 104 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bb4037a..10f7928 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,8 @@ cmake_minimum_required( VERSION 2.6 ) project( libr ) set( PACKAGE libr ) -set( VERSION 0.6.0 ) +set( VERSION R14.1.0 ) +set( PACKAGE_VERSION 0.6.0 ) ##### include essential cmake modules ########### @@ -25,6 +26,7 @@ include( FindPkgConfig ) include( CheckIncludeFile ) include( CheckFunctionExists ) include( CheckLibraryExists ) +include( CheckSymbolExists ) ##### include our cmake modules ################# @@ -53,6 +55,9 @@ if( WITH_BACKEND_LIBBFD ) if( NOT HAVE_BFD_H ) tde_message_fatal( "Could not find libbfd header file (bfd.h)!\nThis file is usually included in the package binutils-dev." ) 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_LIBRARIES ) set( BACKEND_LIBRARIES "-lbfd" ) set( LIBR_BACKEND "bfd" ) set( BACKEND_NAME "libbfd" ) @@ -124,3 +129,7 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libr.pc tde_auto_add_subdirectories() + +##### write configure files ##################### + +configure_file( src/config.h.cmake config.h @ONLY ) @@ -3,9 +3,9 @@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ -Name: libr +Name: @PACKAGE@ Description: libr ELF resource manager library -Version: 0.6.0 +Version: @PACKAGE_VERSION@ Requires: Libs: -L${libdir} -lr diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 559d8bc..56d1848 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,6 +12,7 @@ include_directories( ${CMAKE_INSTALL_INCLUDEDIR}/libr + ${CMAKE_BINARY_DIR} ${BACKEND_INCLUDE_DIRS} ${LIBGLADE_INCLUDE_DIRS} ) diff --git a/src/config.h b/src/config.h deleted file mode 100644 index a51743e..0000000 --- a/src/config.h +++ /dev/null @@ -1,94 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if translation of program messages to the user's native - language is requested. */ -#define ENABLE_NLS 1 - -/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the - CoreFoundation framework. */ -/* #undef HAVE_CFLOCALECOPYCURRENT */ - -/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in - the CoreFoundation framework. */ -/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */ - -/* Define if the GNU dcgettext() function is already present or preinstalled. - */ -#define HAVE_DCGETTEXT 1 - -/* Define to 1 if you have the <dlfcn.h> header file. */ -#define HAVE_DLFCN_H 1 - -/* Define if the GNU gettext() function is already present or preinstalled. */ -#define HAVE_GETTEXT 1 - -/* Define if you have the iconv() function and it works. */ -/* #undef HAVE_ICONV */ - -/* Define to 1 if you have the <inttypes.h> header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the <math.h> header file. */ -#define HAVE_MATH_H 1 - -/* Define to 1 if you have the <memory.h> header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the <pthread.h> header file. */ -#define HAVE_PTHREAD_H 1 - -/* Define to 1 if you have the <stdint.h> header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the <stdlib.h> header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the <strings.h> header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the <string.h> header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the <sys/stat.h> header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the <sys/types.h> header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the <unistd.h> header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the <zlib.h> header file. */ -#define HAVE_ZLIB_H 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "libr" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "0.4.0" diff --git a/src/config.h.cmake b/src/config.h.cmake new file mode 100644 index 0000000..5b0870f --- /dev/null +++ b/src/config.h.cmake @@ -0,0 +1,7 @@ + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +#define ENABLE_NLS 1 + +/* Define to 1 if you have Binutils >= 2.34 */ +#cmakedefine HAVE_BFD_2_34 1 diff --git a/src/libr-bfd.c b/src/libr-bfd.c index 9d6d263..61e59e4 100644 --- a/src/libr-bfd.c +++ b/src/libr-bfd.c @@ -113,8 +113,16 @@ int keep_symbol(libr_section *sections, libr_section *chkscn) if(scn == chkscn) { /* if it is, and has size zero, then it was marked for deletion */ - if(bfd_get_section_size(chkscn) == 0) + if( + #ifdef HAVE_BFD_2_34 + bfd_section_size(chkscn) == 0 + #else + bfd_get_section_size(chkscn) == 0 + #endif + ) + { return false; + } return true; } } @@ -135,7 +143,13 @@ void remove_sections(libr_section *sections, void *symtab_buffer, long *symtab_c asymbol *symbol = symtab[i]; if(symbol != NULL) + { + #ifdef HAVE_BFD_2_34 + chkscn = bfd_asymbol_section(symbol); + #else chkscn = bfd_get_section(symbol); + #endif + } if(chkscn != NULL && !keep_symbol(sections, chkscn)) { /* remove the symbol from the table */ @@ -156,7 +170,13 @@ int setup_sections(bfd *ihandle, bfd *ohandle) for(iscn = ihandle->sections; iscn != NULL; iscn = iscn->next) { - if(bfd_get_section_size(iscn) == 0) + if( + #ifdef HAVE_BFD_2_34 + bfd_section_size(iscn) == 0 + #else + bfd_get_section_size(iscn) == 0 + #endif + ) { continue; /* Section has been marked for deletion */ } @@ -178,19 +198,41 @@ int setup_sections(bfd *ihandle, bfd *ohandle) printf("failed to create out section: %s\n", bfd_errmsg(bfd_get_error())); return false; } - if(!bfd_set_section_size(ohandle, oscn, iscn->size)) + if( + #ifdef HAVE_BFD_2_34 + !bfd_set_section_size(oscn, iscn->size) + #else + !bfd_set_section_size(ohandle, oscn, iscn->size) + #endif + ) { printf("failed to set data size: %s\n", bfd_errmsg(bfd_get_error())); return false; } + #ifdef HAVE_BFD_2_34 + vma = bfd_section_vma(iscn); + #else vma = bfd_section_vma(ihandle, iscn); - if(!bfd_set_section_vma(ohandle, oscn, vma)) + #endif + if( + #ifdef HAVE_BFD_2_34 + !bfd_set_section_vma(oscn, vma) + #else + !bfd_set_section_vma(ohandle, oscn, vma) + #endif + ) { printf("failed to set virtual memory address: %s\n", bfd_errmsg(bfd_get_error())); return false; } oscn->lma = iscn->lma; - if(!bfd_set_section_alignment(ohandle, oscn, bfd_section_alignment(ihandle, iscn))) + if( + #ifdef HAVE_BFD_2_34 + !bfd_set_section_alignment(oscn, bfd_section_alignment(iscn)) + #else + !bfd_set_section_alignment(ohandle, oscn, bfd_section_alignment(ihandle, iscn)) + #endif + ) { printf("failed to compute section alignment: %s\n", bfd_errmsg(bfd_get_error())); return false; @@ -262,7 +304,11 @@ int build_output(libr_file *file_handle) /* Actually copy section data */ for(iscn = ihandle->sections; iscn != NULL; iscn = iscn->next) { + #ifdef HAVE_BFD_2_34 + size = bfd_section_size(iscn); + #else size = bfd_get_section_size(iscn); + #endif if(size == 0) continue; /* Section has been marked for deletion */ oscn = iscn->output_section; @@ -276,7 +322,13 @@ int build_output(libr_file *file_handle) bfd_set_reloc(ohandle, oscn, reloc_buffer, reloc_count); } - if(bfd_get_section_flags(ihandle, iscn) & SEC_HAS_CONTENTS) + if( + #ifdef HAVE_BFD_2_34 + bfd_section_flags(iscn) & SEC_HAS_CONTENTS + #else + bfd_get_section_flags(ihandle, iscn) & SEC_HAS_CONTENTS + #endif + ) { /* NOTE: if the section is just being copied then do that, otherwise grab * the user data for the section (stored previously by set_data) @@ -500,8 +552,16 @@ libr_intstatus add_section(libr_file *file_handle, char *resource_name, libr_sec scn = bfd_make_section(file_handle->bfd_read, resource_name); if(scn == NULL) RETURN(LIBR_ERROR_NEWSECTION, "Failed to create new section"); - if(!bfd_set_section_flags(file_handle->bfd_read, scn, SEC_HAS_CONTENTS | SEC_DATA | SEC_IN_MEMORY)) + if( + #ifdef HAVE_BFD_2_34 + !bfd_set_section_flags(scn, SEC_HAS_CONTENTS | SEC_DATA | SEC_IN_MEMORY) + #else + !bfd_set_section_flags(file_handle->bfd_read, scn, SEC_HAS_CONTENTS | SEC_DATA | SEC_IN_MEMORY) + #endif + ) + { RETURN(LIBR_ERROR_SETFLAGS, "Failed to set flags for section"); + } *retscn = scn; RETURN_OK; } |