This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] PR 21564, Section start in binary output file incorrect


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9b97dfbf8049bed3b2f79c6c785afaf18206dad3

commit 9b97dfbf8049bed3b2f79c6c785afaf18206dad3
Author: Alan Modra <amodra@gmail.com>
Date:   Sun Jun 11 13:34:13 2017 +0930

    PR 21564, Section start in binary output file incorrect
    
    	PR 21564
    	* binary.c (binary_set_section_contents): Scale lma by octets
    	per byte to set filepos.

Diff:
---
 bfd/ChangeLog | 6 ++++++
 bfd/binary.c  | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index d899df6..a0c2681 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2017-06-11  Joe Zbiciak  <joe.zbiciak@leftturnonly.info>
+
+	PR 21564
+	* binary.c (binary_set_section_contents): Scale lma by octets
+	per byte to set filepos.
+
 2017-06-08  Cupertino Miranda  <cmiranda@synopsys.com>
 
 	* elf32-arc.c (elf_arc_check_relocs): Fixed conditions to generate
diff --git a/bfd/binary.c b/bfd/binary.c
index ff52f14..0a811cf 100644
--- a/bfd/binary.c
+++ b/bfd/binary.c
@@ -230,6 +230,7 @@ binary_set_section_contents (bfd *abfd,
 
   if (! abfd->output_has_begun)
     {
+      unsigned int opb;
       bfd_boolean found_low;
       bfd_vma low;
       asection *s;
@@ -250,9 +251,10 @@ binary_set_section_contents (bfd *abfd,
 	    found_low = TRUE;
 	  }
 
+      opb = bfd_octets_per_byte (abfd);
       for (s = abfd->sections; s != NULL; s = s->next)
 	{
-	  s->filepos = s->lma - low;
+	  s->filepos = (s->lma - low) * opb;
 
 	  /* Skip following warning check for sections that will not
 	     occupy file space.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]