Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions sr_edc_ethercat_drivers/src/sr_edc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,18 +845,34 @@ void SrEdc::find_address_range(bfd *fd, unsigned int *smallest_start_address, un
for (s = fd->sections; s; s = s->next)
{
// Only the sections with the LOAD flag on will be considered
#ifdef bfd_get_section_flags
if (bfd_get_section_flags(fd, s) & (SEC_LOAD))
#else
if (bfd_section_flags(s) & (SEC_LOAD))
#endif
{
// Only the sections with the same VMA (virtual memory address) and LMA (load MA) will be considered
// http://www.delorie.com/gnu/docs/binutils/ld_7.html
#ifdef bfd_section_lma
if (bfd_section_lma(fd, s) == bfd_section_vma(fd, s))
#else
if (bfd_section_lma(s) == bfd_section_vma(s))
#endif
{
#ifdef bfd_section_lma
section_addr = (unsigned int) bfd_section_lma(fd, s);
#else
section_addr = (unsigned int) bfd_section_lma(s);
#endif
if (section_addr >= 0x7fff)
{
continue;
}
#ifdef bfd_section_size
section_size = (unsigned int) bfd_section_size(fd, s);
#else
section_size = (unsigned int) bfd_section_size(s);
#endif
*smallest_start_address = std::min(section_addr, *smallest_start_address);
*biggest_end_address = std::max(*biggest_end_address, section_addr + section_size);
}
Expand All @@ -873,21 +889,37 @@ bool SrEdc::read_content_from_object_file(bfd *fd, bfd_byte *content, unsigned i
for (s = fd->sections; s; s = s->next)
{
// Only the sections with the LOAD flag on will be considered
#ifdef bfd_get_section_flags
if (bfd_get_section_flags(fd, s) & (SEC_LOAD))
#else
if (bfd_section_flags(s) & (SEC_LOAD))
#endif
{
// Only the sections with the same VMA (virtual memory address) and LMA (load MA) will be considered
// http://www.delorie.com/gnu/docs/binutils/ld_7.html
#ifdef bfd_section_lma
if (bfd_section_lma(fd, s) == bfd_section_vma(fd, s))
#else
if (bfd_section_lma(s) == bfd_section_vma(s))
#endif
{
#ifdef bfd_section_lma
section_addr = (unsigned int) bfd_section_lma(fd, s);
#else
section_addr = (unsigned int) bfd_section_lma(s);
#endif
// The sections starting at an address higher than 0x7fff will be ignored as they are
// not proper "code memory" firmware
// (they can contain the CONFIG bits of the microcontroller, which we don't want to write here)
if (section_addr >= 0x7fff)
{
continue;
}
#ifdef bfd_section_size
section_size = (unsigned int) bfd_section_size(fd, s);
#else
section_size = (unsigned int) bfd_section_size(s);
#endif
bfd_get_section_contents(fd, s, content + (section_addr - base_addr), 0, section_size);
}
else
Expand Down