Skip to content

Commit 01a5f11

Browse files
committed
edc_ethercat_drivers: account for new API in binutils 2.34
This does not change anything. It just adds #ifdefs to support the new API as required.
1 parent 351199b commit 01a5f11

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

sr_edc_ethercat_drivers/src/sr_edc.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,18 +845,34 @@ void SrEdc::find_address_range(bfd *fd, unsigned int *smallest_start_address, un
845845
for (s = fd->sections; s; s = s->next)
846846
{
847847
// Only the sections with the LOAD flag on will be considered
848+
#ifdef bfd_get_section_flags
848849
if (bfd_get_section_flags(fd, s) & (SEC_LOAD))
850+
#else
851+
if (bfd_section_flags(s) & (SEC_LOAD))
852+
#endif
849853
{
850854
// Only the sections with the same VMA (virtual memory address) and LMA (load MA) will be considered
851855
// http://www.delorie.com/gnu/docs/binutils/ld_7.html
856+
#ifdef bfd_section_lma
852857
if (bfd_section_lma(fd, s) == bfd_section_vma(fd, s))
858+
#else
859+
if (bfd_section_lma(s) == bfd_section_vma(s))
860+
#endif
853861
{
862+
#ifdef bfd_section_lma
854863
section_addr = (unsigned int) bfd_section_lma(fd, s);
864+
#else
865+
section_addr = (unsigned int) bfd_section_lma(s);
866+
#endif
855867
if (section_addr >= 0x7fff)
856868
{
857869
continue;
858870
}
871+
#ifdef bfd_section_size
859872
section_size = (unsigned int) bfd_section_size(fd, s);
873+
#else
874+
section_size = (unsigned int) bfd_section_size(s);
875+
#endif
860876
*smallest_start_address = std::min(section_addr, *smallest_start_address);
861877
*biggest_end_address = std::max(*biggest_end_address, section_addr + section_size);
862878
}
@@ -873,21 +889,37 @@ bool SrEdc::read_content_from_object_file(bfd *fd, bfd_byte *content, unsigned i
873889
for (s = fd->sections; s; s = s->next)
874890
{
875891
// Only the sections with the LOAD flag on will be considered
892+
#ifdef bfd_get_section_flags
876893
if (bfd_get_section_flags(fd, s) & (SEC_LOAD))
894+
#else
895+
if (bfd_section_flags(s) & (SEC_LOAD))
896+
#endif
877897
{
878898
// Only the sections with the same VMA (virtual memory address) and LMA (load MA) will be considered
879899
// http://www.delorie.com/gnu/docs/binutils/ld_7.html
900+
#ifdef bfd_section_lma
880901
if (bfd_section_lma(fd, s) == bfd_section_vma(fd, s))
902+
#else
903+
if (bfd_section_lma(s) == bfd_section_vma(s))
904+
#endif
881905
{
906+
#ifdef bfd_section_lma
882907
section_addr = (unsigned int) bfd_section_lma(fd, s);
908+
#else
909+
section_addr = (unsigned int) bfd_section_lma(s);
910+
#endif
883911
// The sections starting at an address higher than 0x7fff will be ignored as they are
884912
// not proper "code memory" firmware
885913
// (they can contain the CONFIG bits of the microcontroller, which we don't want to write here)
886914
if (section_addr >= 0x7fff)
887915
{
888916
continue;
889917
}
918+
#ifdef bfd_section_size
890919
section_size = (unsigned int) bfd_section_size(fd, s);
920+
#else
921+
section_size = (unsigned int) bfd_section_size(s);
922+
#endif
891923
bfd_get_section_contents(fd, s, content + (section_addr - base_addr), 0, section_size);
892924
}
893925
else

0 commit comments

Comments
 (0)