🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.epoch.misc
Article #179

Patch for "unexmips.c" (SGI & MIPS)

#179
From: Shankar Unni
Date: Fri, 28 Aug 1992 02:25
82 lines
3176 bytes
Here is a patch for "unexmips.c" to make it work with the latest
release of SGI compilers (the 3.10 compilers) on the Irix 4.0.5
platform. This should continue to work with the old 2.* compilers as
well as the MIPS compilers.

The reasons for this patch:

 (a) The order of sections seems to have been changed in the latest
     release. Since we can't rely on the order, we need to linearly scan
     the section list in the header for each section we are interested
     in. Thus, we need to adjust the s_[vp]addr for rdata_section.

 (b) The symbol-table is no longer at the end of the file - it now seems
     to be between the text and data sections.  Thus, we need to adjust
     the scnptr for rdata_section, too.

============================== snip snip ==============================
*** unexmips.c.orig	Fri Aug  7 14:36:00 1992
--- unexmips.c	Thu Aug 27 19:10:46 1992
***************
*** 152,158 ****
--- 152,164 ----
        exit(1);
      }
  
+ /*
+  * The headers are no longer in text-init-rdata-data order. Therefore we 
+  * have to do a linear search for each section in the section list.
+  */
  #define CHECK_SCNHDR(ptr, name, flags) \
+   i = 0; ptr = NULL; \
+   while(i < hdr.fhdr.f_nscns && !ptr) { \
    if (strcmp(hdr.section[i].s_name, name) == 0) { \
      if (hdr.section[i].s_flags != flags) { \
        fprintf(stderr, "unexec: %x flags where %x expected in %s section.\n", \
***************
*** 159,171 ****
  	      hdr.section[i].s_flags, flags, name); \
      } \
      ptr = hdr.section + i; \
-     i += 1; \
    } \
!   else { \
!     ptr = NULL; \
!     }
  
-   i = 0;
    CHECK_SCNHDR(text_section,  _TEXT,  STYP_TEXT);
    CHECK_SCNHDR(init_section,  _INIT,  STYP_INIT);
    CHECK_SCNHDR(rdata_section, _RDATA, STYP_RDATA);
--- 165,174 ----
  	      hdr.section[i].s_flags, flags, name); \
      } \
      ptr = hdr.section + i; \
    } \
!   i += 1; \
!   }
  
    CHECK_SCNHDR(text_section,  _TEXT,  STYP_TEXT);
    CHECK_SCNHDR(init_section,  _INIT,  STYP_INIT);
    CHECK_SCNHDR(rdata_section, _RDATA, STYP_RDATA);
***************
*** 198,203 ****
--- 201,212 ----
  
    hdr.aout.bss_start = hdr.aout.data_start + hdr.aout.dsize;
    rdata_section->s_size = data_start - DATA_START;
+ 
+   /* adjust start and virtual addresses of rdata_section, too */
+   rdata_section->s_vaddr = DATA_START;
+   rdata_section->s_paddr = DATA_START;
+   rdata_section->s_scnptr = text_section->s_scnptr + hdr.aout.tsize;
+ 
    data_section->s_vaddr = data_start;
    data_section->s_paddr = data_start;
    data_section->s_size = brk - data_start;
============================== snip snip ==============================

--
Shankar Unni				E-Mail:	shankar@sgi.com
Silicon Graphics Inc.			Phone:	+1-415-390-2072
Technical Details
Message-ID: <p4akar8@fido.asd.sgi.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!dtix!darwin.sura.net!mips!odin!fido!shankar

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!dtix!darwin.sura.net!mips!odin!fido!shankar
From: shankar@sgi.com (Shankar Unni)
Newsgroups: gnu.epoch.misc
Subject: Patch for "unexmips.c" (SGI & MIPS)
Message-ID: <p4akar8@fido.asd.sgi.com>
Date: 28 Aug 92 02:25:24 GMT
Sender: news@fido.asd.sgi.com (Usenet News Admin)
Organization: Silicon Graphics, Inc.
Lines: 82