bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/21564] binary output should scale address by octets per by


From: joe.zbiciak at leftturnonly dot info
Subject: [Bug binutils/21564] binary output should scale address by octets per byte
Date: Sun, 11 Jun 2017 05:53:35 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=21564

--- Comment #2 from Joe Zbiciak <joe.zbiciak at leftturnonly dot info> ---
Good point.  While my executables may have a small number of sections, this is
common code that all architectures will hit when writing a binary output.

I suppose something like this will do the trick, hoisting that call out of the
loop.  I believe 'opb' is the variable name bfd uses elsewhere for this
purpose.

Index: bfd/binary.c
===================================================================
--- bfd/binary.c        (revision 3151)
+++ bfd/binary.c        (working copy)
@@ -233,6 +233,7 @@
       bfd_boolean found_low;
       bfd_vma low;
       asection *s;
+      unsigned int opb = bfd_octets_per_byte(abfd);

       /* The lowest section LMA sets the virtual address of the start
          of the file.  We use this to set the file position of all the
@@ -252,7 +253,7 @@

       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.  */

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]