* [patch] Elf Loader Section Table
@ 2004-02-26 16:50 Dave Brolley
0 siblings, 0 replies; only message in thread
From: Dave Brolley @ 2004-02-26 16:50 UTC (permalink / raw)
To: sid
[-- Attachment #1: Type: text/plain, Size: 427 bytes --]
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
[-- Attachment #2: elfload-2.ChangeLog --]
[-- Type: text/plain, Size: 252 bytes --]
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.
[-- Attachment #3: elfload-2.patch.txt --]
[-- Type: text/plain, Size: 2474 bytes --]
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;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-02-26 16:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-26 16:50 [patch] Elf Loader Section Table Dave Brolley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).