[patch] Elf Loader Section Table
Dave Brolley <[email protected]>
| Newsgroups | gmane.comp.emulators.sid.devel |
|---|---|
| Organization | Red Hat Canada, Ltd |
| Message-ID | <[email protected]> |
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
elfload-2.ChangeLog
(text/plain, 252 B)
2004-02-26 Dave Brolley <[email protected]> * 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.
elfload-2.patch.txt
(text/plain, 2.4 KB)
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;
}