[patch] Check Section Table in Loader component

Dave Brolley <[email protected]>
Newsgroups gmane.comp.emulators.sid.devel
Organization Red Hat Canada, Ltd
Message-ID <[email protected]>
I've committed the attached patch which checks that the section table 
has been allocated in the loader before attempting to use it. This can 
happen for ports which initialize memory before the program is loaded.

Dave
sid-loader.ChangeLog (text/plain, 186 B)
2004-04-27  Dave Brolley  <[email protected]>

	* elfload.c (textSectionAddress): Check section table before accessing.
	* compLoader.cxx (loader_probe_bus): Initialize section_table.
sid-loader.patch.txt (text/plain, 1.6 KB)
Index: sid/component/loader/compLoader.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/loader/compLoader.cxx,v
retrieving revision 1.7
diff -c -p -r1.7 compLoader.cxx
*** sid/component/loader/compLoader.cxx	12 Feb 2004 20:30:08 -0000	1.7
--- sid/component/loader/compLoader.cxx	27 Apr 2004 20:20:27 -0000
*************** class loader_probe_bus: public sidutil::
*** 68,74 ****
    public:
      loader_probe_bus (sid::bus **t, output_pin *p) :
        sidutil::passthrough_bus (t),
!       write_to_code_address_pin (p)
      {
        assert (t);
      }
--- 68,75 ----
    public:
      loader_probe_bus (sid::bus **t, output_pin *p) :
        sidutil::passthrough_bus (t),
!       write_to_code_address_pin (p),
!       section_table (0)
      {
        assert (t);
      }
Index: sid/component/loader/elfload.c
===================================================================
RCS file: /cvs/src/src/sid/component/loader/elfload.c,v
retrieving revision 1.8
diff -c -p -r1.8 elfload.c
*** sid/component/loader/elfload.c	26 Feb 2004 16:44:40 -0000	1.8
--- sid/component/loader/elfload.c	27 Apr 2004 20:20:27 -0000
*************** newTextSection (int index)
*** 57,62 ****
--- 57,66 ----
  int
  textSectionAddress (unsigned long long address, const struct TextSection *section_table)
  {
+   // Not a text section address if there is no table.
+   if (! section_table)
+     return 0;
+ 
    /* The table begins with the given pointer and is terminated by an entry with
       zeroes for both the high and low bounds.  */
    int i;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.