This is the mail archive of the
sid@sources.redhat.com
mailing list for the SID project.
[patch] Elf Loader Section Table
- From: Dave Brolley <brolley at redhat dot com>
- To: sid at sources dot redhat dot com
- Date: Thu, 26 Feb 2004 11:50:19 -0500
- Subject: [patch] Elf Loader Section Table
- Organization: Red Hat Canada, Ltd
I've committed this patch which corrects a problem with table
reallocation in the new section table implementation. readElfFile was
giving out addresses into textSections which gets realloc'ed when full.
The addresses previously handed out then become invalid.
This patch changes the algorithm to allocate a separate section table
for each load and to give out the address only after the table has been
completed.
Dave
2004-02-26 Dave Brolley <brolley@redhat.com>
* elfload.c (textSectionNum): Now file level static.
(readElfFile): Initialize textSections, textSectionNum and
textSectionCount for each load. Set *section_table after all
sections have been saved.
Index: sid/component/loader/elfload.c
===================================================================
RCS file: /cvs/src/src/sid/component/loader/elfload.c,v
retrieving revision 1.7
diff -c -p -r1.7 elfload.c
*** sid/component/loader/elfload.c 23 Feb 2004 20:08:53 -0000 1.7
--- sid/component/loader/elfload.c 26 Feb 2004 16:10:24 -0000
*************** newLoadArea (int index)
*** 39,53 ****
}
}
! /* The section table is kept for the duration of the simulation.
! It is divided into sub tables, one for each loader in the system. */
! static int textSectionCount = 0;
! static struct TextSection *textSections = 0;
static void
newTextSection (int index)
{
- static textSectionNum = 0;
if (index >= textSectionNum)
{
textSectionNum = index + 10;
--- 39,52 ----
}
}
! /* A new section table is created for each loader in the system. */
! static struct TextSection *textSections;
! static int textSectionCount;
! static int textSectionNum;
static void
newTextSection (int index)
{
if (index >= textSectionNum)
{
textSectionNum = index + 10;
*************** readElfFile (PFLOAD func, unsigned* entr
*** 204,211 ****
/* Look in the section table in order to determine which sections contain
code and which contain data. */
newTextSection (textSectionCount);
- *section_table = textSections + textSectionCount;
if (sixtyfourbit)
{
secOffset = fetchQuad (fileHeader+40, littleEndian);
--- 203,212 ----
/* Look in the section table in order to determine which sections contain
code and which contain data. */
+ textSections = 0;
+ textSectionNum = 0;
+ textSectionCount = 0;
newTextSection (textSectionCount);
if (sixtyfourbit)
{
secOffset = fetchQuad (fileHeader+40, littleEndian);
*************** readElfFile (PFLOAD func, unsigned* entr
*** 256,264 ****
/* Terminate this portion of the section table. */
textSections[textSectionCount].lbound = 0;
textSections[textSectionCount].hbound = 0;
- textSectionCount++;
*entry_point = entryPoint;
*little_endian = littleEndian;
return 1;
}
--- 257,266 ----
/* Terminate this portion of the section table. */
textSections[textSectionCount].lbound = 0;
textSections[textSectionCount].hbound = 0;
*entry_point = entryPoint;
*little_endian = littleEndian;
+ *section_table = textSections;
+
return 1;
}