* [patch][commit] 64 Bit Support for elf Symbol Table and String Table
@ 2006-05-11 15:12 Dave Brolley
0 siblings, 0 replies; only message in thread
From: Dave Brolley @ 2006-05-11 15:12 UTC (permalink / raw)
To: sid
[-- Attachment #1: Type: text/plain, Size: 186 bytes --]
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
[-- Attachment #2: sid-elfload.ChangeLog --]
[-- Type: text/plain, Size: 217 bytes --]
2006-05-11 Dave Brolley <brolley@redhat.com>
* 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.
[-- Attachment #3: sid-elfload.patch.txt --]
[-- Type: text/plain, Size: 4223 bytes --]
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,
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-05-11 15:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-11 15:12 [patch][commit] 64 Bit Support for elf Symbol Table and String 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).