This is the mail archive of the
sid@sources.redhat.com
mailing list for the SID project.
[patch] Check Section Table in Loader component
- From: Dave Brolley <brolley at redhat dot com>
- To: sid at sources dot redhat dot com
- Date: Tue, 27 Apr 2004 16:48:47 -0400
- Subject: [patch] Check Section Table in Loader component
- Organization: Red Hat Canada, Ltd
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
2004-04-27 Dave Brolley <brolley@redhat.com>
* elfload.c (textSectionAddress): Check section table before accessing.
* compLoader.cxx (loader_probe_bus): Initialize section_table.
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;