summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2020-01-27 01:37:31 +0100
committerSlávek Banko <slavek.banko@axis.cz>2020-01-27 01:37:31 +0100
commit0e3a275c7d9b33dd6d98a44c82a8e3ed37ec97f0 (patch)
treecf6ccfe4743510562a7dfe516c4ea1f3691ec68d /src
parente6288da4f98eee77f05358aa95b710d9d5344ed1 (diff)
downloadlibr-0e3a275c7d9b33dd6d98a44c82a8e3ed37ec97f0.tar.gz
libr-0e3a275c7d9b33dd6d98a44c82a8e3ed37ec97f0.zip
Fix FTBFS with binutils 2.34.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/config.h94
-rw-r--r--src/config.h.cmake7
-rw-r--r--src/libr-bfd.c74
4 files changed, 75 insertions, 101 deletions
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;
}