diff src/unexaix.c @ 294:4b85ae5eabfb r21-0b45

Import from CVS: tag r21-0b45
author cvs
date Mon, 13 Aug 2007 10:38:01 +0200
parents 57709be46d1b
children 70ad99077275
line wrap: on
line diff
--- a/src/unexaix.c	Mon Aug 13 10:37:16 2007 +0200
+++ b/src/unexaix.c	Mon Aug 13 10:38:01 2007 +0200
@@ -154,7 +154,7 @@
 {
   int new = -1, a_out = -1;
 
-  if (a_name && (a_out = open (a_name, 0)) < 0)
+  if (a_name && (a_out = open (a_name, O_RDONLY)) < 0)
     {
       PERROR (a_name);
     }
@@ -326,6 +326,7 @@
   {
     ulong ptr = section[0].s_scnptr;
 
+    bias = -1;
     for (scns = 0; scns < f_hdr.f_nscns; scns++)
       {
 	struct scnhdr *s = &section[scns];
@@ -344,12 +345,17 @@
 	      }
 	    s->s_scnptr = ptr;
 	  }
-	else
+	else if (s->s_flags & STYP_DATA)
+	  s->s_scnptr = ptr;
+	else if (!(s->s_flags & (STYP_TEXT | STYP_BSS)))
 	  {
+	    if (bias == -1)                /* if first section after bss */
 	      bias = ptr - s->s_scnptr;
-	      s->s_scnptr = ptr;
+
+	    s->s_scnptr += bias;
+	    ptr = s->s_scnptr;
 	  }
-
+  
 	ptr = ptr + s->s_size;
       }
   }
@@ -535,7 +541,7 @@
   if (!lnnoptr || !f_hdr.f_symptr)
     return 0;
 
-  if ((new = open (new_name, 2)) < 0)
+  if ((new = open (new_name, O_RDWR)) < 0)
     {
       PERROR (new_name);
       return -1;
@@ -552,7 +558,7 @@
 	  write (new, &symentry, SYMESZ);
 	}
 
-      for (naux = symentry.n_numaux; naux-- != 0; )
+      for (naux = symentry.n_numaux; naux != 0; --naux)
 	{
 	  read (new, &auxentry, AUXESZ);
 	  nsyms++;