From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21205 invoked by alias); 11 May 2006 15:12:21 -0000 Received: (qmail 21027 invoked by uid 22791); 11 May 2006 15:12:20 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 11 May 2006 15:12:17 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k4BFCFws031468 for ; Thu, 11 May 2006 11:12:15 -0400 Received: from pobox.toronto.redhat.com (pobox.toronto.redhat.com [172.16.14.4]) by int-mx1.corp.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k4BFCFUJ024867 for ; Thu, 11 May 2006 11:12:15 -0400 Received: from [172.16.14.227] (IDENT:Sx+0eHjeZ3Ws1NvPhu8ZUM97rlef7KS1@topaz.toronto.redhat.com [172.16.14.227]) by pobox.toronto.redhat.com (8.12.8/8.12.8) with ESMTP id k4BFCFAc016840 for ; Thu, 11 May 2006 11:12:15 -0400 Message-ID: <4463544F.5010008@redhat.com> Date: Thu, 11 May 2006 15:12:00 -0000 From: Dave Brolley User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) MIME-Version: 1.0 To: sid@sources.redhat.com Subject: [patch][commit] 64 Bit Support for elf Symbol Table and String Table Content-Type: multipart/mixed; boundary="------------020002030601020700060802" X-IsSubscribed: yes Mailing-List: contact sid-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: sid-owner@sourceware.org X-SW-Source: 2006-q2/txt/msg00026.txt.bz2 This is a multi-part message in MIME format. --------------020002030601020700060802 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 186 Hi, I've committed the attached patch which adds 64 bit support for the symbol table and string table in the elf loader. Tested on an internal port which required the support. Dave --------------020002030601020700060802 Content-Type: text/plain; name="sid-elfload.ChangeLog" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sid-elfload.ChangeLog" Content-length: 217 2006-05-11 Dave Brolley * elfload.c (readElfFile): symTabEntry is now 24 bytes in length. Add 64 bit support for SHT_STRTAB and SHT_SYMTAB. Add 64 bit support for reading the symbol table. --------------020002030601020700060802 Content-Type: text/plain; name="sid-elfload.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sid-elfload.patch.txt" Content-length: 4223 Index: sid/component/loader/elfload.c =================================================================== RCS file: /cvs/src/src/sid/component/loader/elfload.c,v retrieving revision 1.12 diff -c -p -r1.12 elfload.c *** sid/component/loader/elfload.c 19 Aug 2005 19:45:22 -0000 1.12 --- sid/component/loader/elfload.c 11 May 2006 15:03:36 -0000 *************** *** 1,6 **** /* Simple ELF loader * ! * Copyright (c) 1998, 2002, 2004, 2005 Red Hat * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided --- 1,6 ---- /* Simple ELF loader * ! * Copyright (c) 1998, 2002, 2004, 2005, 2006 Red Hat * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided *************** readElfFile (PFLOAD func, unsigned* entr *** 119,125 **** unsigned char fileHeader [64]; unsigned char psymHdr [56]; unsigned char secHdr [64]; ! unsigned char symTabEntry [16]; unsigned long long psymOffset; int psymSize; int psymNum; --- 119,125 ---- unsigned char fileHeader [64]; unsigned char psymHdr [56]; unsigned char secHdr [64]; ! unsigned char symTabEntry [24]; unsigned long long psymOffset; int psymSize; int psymNum; *************** readElfFile (PFLOAD func, unsigned* entr *** 284,289 **** --- 284,307 ---- textSectionCount++; newTextSection (textSectionCount); } + else if (fetchWord(secHdr+4, littleEndian) == SHT_STRTAB) + { + unsigned offset = fetchQuad(secHdr+24, littleEndian); + unsigned size = fetchQuad(secHdr+32, littleEndian); + char *strings = xmalloc (size); + newStringTable (stringTableCount); + stringTables[stringTableCount].ix = x; + stringTables[stringTableCount].strings = strings; + if (func (0, strings, offset, size, 0) != size) + return 0; + ++stringTableCount; + } + else if (fetchWord(secHdr+4, littleEndian) == SHT_SYMTAB) + { + symbolTableOffset = fetchQuad(secHdr+24, littleEndian); + symbolTableSize = fetchQuad(secHdr+32, littleEndian); + symbolTableStringTableIx = fetchWord(secHdr+40, littleEndian); + } } else { *************** readElfFile (PFLOAD func, unsigned* entr *** 341,355 **** newSymbol (symbolCount); if (strings) { ! for (x = 0; x < symbolTableSize; x += sizeof (symTabEntry)) { ! if (func (0, symTabEntry, symbolTableOffset + x, sizeof (symTabEntry), 0) != sizeof (symTabEntry)) return 0; // TODO: Save only symbols representing functions // PROBLEM: Some don't have the STT_FUNC flag set ! symbolTable[symbolCount].name = strings + fetchWord(symTabEntry+0, littleEndian); ! symbolTable[symbolCount].addr = fetchWord(symTabEntry+4, littleEndian); ! symbolTable[symbolCount].size = fetchWord(symTabEntry+8, littleEndian); #if 0 printf ("found symbol %s at 0x%Lx for 0x%Lx\n", symbolTable[symbolCount].name, --- 359,383 ---- newSymbol (symbolCount); if (strings) { ! const unsigned symTabEntrySize = sixtyfourbit ? 24 : 16; ! for (x = 0; x < symbolTableSize; x += symTabEntrySize) { ! if (func (0, symTabEntry, symbolTableOffset + x, symTabEntrySize, 0) != symTabEntrySize) return 0; // TODO: Save only symbols representing functions // PROBLEM: Some don't have the STT_FUNC flag set ! if (sixtyfourbit) ! { ! symbolTable[symbolCount].name = strings + fetchWord(symTabEntry+0, littleEndian); ! symbolTable[symbolCount].addr = fetchQuad(symTabEntry+8, littleEndian); ! symbolTable[symbolCount].size = fetchQuad(symTabEntry+16, littleEndian); ! } ! else ! { ! symbolTable[symbolCount].name = strings + fetchWord(symTabEntry+0, littleEndian); ! symbolTable[symbolCount].addr = fetchWord(symTabEntry+4, littleEndian); ! symbolTable[symbolCount].size = fetchWord(symTabEntry+8, littleEndian); ! } #if 0 printf ("found symbol %s at 0x%Lx for 0x%Lx\n", symbolTable[symbolCount].name, --------------020002030601020700060802--