]> git.wh0rd.org Git - elf2flt.git/commitdiff
Build elf2flt with headers from binutils 2.15.94+.
authorBernardo Innocenti <bernie@develer.com>
Wed, 23 Feb 2005 01:33:26 +0000 (01:33 +0000)
committerBernardo Innocenti <bernie@develer.com>
Wed, 23 Feb 2005 01:33:26 +0000 (01:33 +0000)
Should still work with older versions of binutils.

Patch submitted by Bernardo Innocenti <bernie@develer.com>.

elf2flt.c

index 19ae196aa847bad09c5784107d26d235e7a54e36..d0b78514e9492720b5e6eb48b5d3f93ae79be2a4 100644 (file)
--- a/elf2flt.c
+++ b/elf2flt.c
@@ -1532,6 +1532,8 @@ int main(int argc, char *argv[])
   /* Group output sections into text, data, and bss, and calc their sizes.  */
   for (s = abs_bfd->sections; s != NULL; s = s->next) {
     unsigned long *vma, *len;
+    bfd_size_type sec_size;
+    bfd_vma sec_vma;
 
     if (s->flags & SEC_CODE) {
       vma = &text_vma;
@@ -1545,14 +1547,17 @@ int main(int argc, char *argv[])
     } else
       continue;
 
-    if (s->vma < *vma) {
+    sec_size = bfd_section_size(abs_bfd, s);
+    sec_vma  = bfd_section_vma(abs_bfd, s);
+
+    if (sec_vma < *vma) {
       if (*len > 0)
-       *len += s->vma - *vma;
+       *len += sec_vma - *vma;
       else
-       *len = s->_raw_size;
-      *vma = s->vma;
-    } else if (s->vma + s->_raw_size > *vma + *len)
-      *len = s->vma + s->_raw_size - *vma;
+       *len = sec_size;
+      *vma = sec_vma;
+    } else if (sec_vma + sec_size > *vma + *len)
+      *len = sec_vma + sec_size - *vma;
   }
 
   if (text_len == 0) {
@@ -1570,7 +1575,7 @@ int main(int argc, char *argv[])
     if (s->flags & SEC_CODE) 
       if (!bfd_get_section_contents(abs_bfd, s,
                                   text + (s->vma - text_vma), 0,
-                                  s->_raw_size))
+                                  bfd_section_size(abs_bfd, s)))
       {
        fprintf(stderr, "read error section %s\n", s->name);
        exit(2);
@@ -1601,7 +1606,7 @@ int main(int argc, char *argv[])
     if (s->flags & SEC_DATA) 
       if (!bfd_get_section_contents(abs_bfd, s,
                                   data + (s->vma - data_vma), 0,
-                                  s->_raw_size))
+                                  bfd_section_size(abs_bfd, s)))
       {
        fprintf(stderr, "read error section %s\n", s->name);
        exit(2);