From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22831 invoked by alias); 26 Feb 2004 16:50:21 -0000 Mailing-List: contact sid-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: sid-owner@sources.redhat.com Received: (qmail 22823 invoked from network); 26 Feb 2004 16:50:20 -0000 Received: from unknown (HELO touchme.toronto.redhat.com) (216.129.200.20) by sources.redhat.com with SMTP; 26 Feb 2004 16:50:20 -0000 Received: from redhat.com (topaz.toronto.redhat.com [172.16.14.227]) by touchme.toronto.redhat.com (Postfix) with ESMTP id E8DC880001E for ; Thu, 26 Feb 2004 11:50:19 -0500 (EST) Message-ID: <403E23CB.2010700@redhat.com> Date: Thu, 26 Feb 2004 16:50:00 -0000 From: Dave Brolley Organization: Red Hat Canada, Ltd User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225 MIME-Version: 1.0 To: sid@sources.redhat.com Subject: [patch] Elf Loader Section Table Content-Type: multipart/mixed; boundary="------------040705040907030800050205" X-SW-Source: 2004-q1/txt/msg00036.txt.bz2 This is a multi-part message in MIME format. --------------040705040907030800050205 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 427 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 --------------040705040907030800050205 Content-Type: text/plain; name="elfload-2.ChangeLog" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="elfload-2.ChangeLog" Content-length: 252 2004-02-26 Dave Brolley * 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. --------------040705040907030800050205 Content-Type: text/plain; name="elfload-2.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="elfload-2.patch.txt" Content-length: 2474 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; } --------------040705040907030800050205--