Subject: Changes to elf2aout and elf2ecoff...
To: None <jonathan@dsg.stanford.edu>
From: Ted Lemon <mellon@fugue.com>
List: port-pmax
Date: 11/24/1995 23:11:06
Jonathan, the problem you've been having with elf2aout is that due to
some bogus heuristics, it's guessing that the text section starts at
zero and has a length of 0x80030000.   The patches below fix this
problem and the same problem in elf2ecoff.   This obviates the need
for Arne's patch to binutils, which is probably a good thing - it's
less effort for us to change our code than to get a change into the
FSF's code.

			       _MelloN_

diff -c2 elf2aout.c~ elf2aout.c
*** elf2aout.c~	Sun Mar  5 16:05:21 1995
--- elf2aout.c	Fri Nov 24 23:05:41 1995
***************
*** 197,200 ****
--- 197,211 ----
      }
  
+   /* If there's a data section but no text section, then the loader
+      combined everything into one section.   That needs to be the
+      text section, so just make the data section zero length following
+      text. */
+   if (data.len && !text.len)
+     {
+       text = data;
+       data.vaddr = text.vaddr + text.len;
+       data.len = 0;
+     }
+ 
    /* If there is a gap between text and data, we'll fill it when we copy
       the data, so update the length of the text segment as represented in
diff -c2 elf2ecoff.c~ elf2ecoff.c
*** elf2ecoff.c~	Wed Aug 30 11:36:44 1995
--- elf2ecoff.c	Fri Nov 24 23:02:22 1995
***************
*** 176,179 ****
--- 176,190 ----
      }
  
+   /* If there's a data section but no text section, then the loader
+      combined everything into one section.   That needs to be the
+      text section, so just make the data section zero length following
+      text. */
+   if (data.len && !text.len)
+     {
+       text = data;
+       data.vaddr = text.vaddr + text.len;
+       data.len = 0;
+     }
+ 
    /* If there is a gap between text and data, we'll fill it when we copy
       the data, so update the length of the text segment as represented in
***************
*** 241,244 ****
--- 252,262 ----
    esecs [5].es_flags = 0x80;
    esecs [6].es_flags = 0x2100000;
+ 
+   for (i = 0; i < 6; i++)
+     {
+       printf ("Section %d: %s phys %x  size %x  file offset %x\n",
+ 	      i, esecs [i].es_name, esecs [i].es_physaddr,
+ 	      esecs [i].es_size, esecs [i].es_raw_offset);
+     }
  
    /* Make the output file... */