public inbox for sid@sourceware.org
 help / color / mirror / Atom feed
From: Dave Brolley <brolley@redhat.com>
To: sid@sources.redhat.com
Subject: [patch][commit] 64 Bit Support for elf Symbol Table and String Table
Date: Thu, 11 May 2006 15:12:00 -0000	[thread overview]
Message-ID: <4463544F.5010008@redhat.com> (raw)

[-- 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,

                 reply	other threads:[~2006-05-11 15:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4463544F.5010008@redhat.com \
    --to=brolley@redhat.com \
    --cc=sid@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).