summaryrefslogtreecommitdiffstats
path: root/src/libr-bfd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libr-bfd.c')
-rw-r--r--src/libr-bfd.c74
1 files changed, 67 insertions, 7 deletions
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;
}