[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnet/ildasm ildasm_data.c,NONE,1.1 Makefile.
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnet/ildasm ildasm_data.c,NONE,1.1 Makefile.am,1.5,1.6 ildasm_class.c,1.11,1.12 ildasm_global.c,1.3,1.4ildasm_internal.h,1.5,1.6 |
Date: |
Thu, 30 Jan 2003 05:57:49 -0500 |
Update of /cvsroot/dotgnu-pnet/pnet/ildasm
In directory subversions:/tmp/cvs-serv32389/ildasm
Modified Files:
Makefile.am ildasm_class.c ildasm_global.c ildasm_internal.h
Added Files:
ildasm_data.c
Log Message:
Dump the contents of the ".data" and ".tls" sections.
--- NEW FILE ---
/*
* ildasm_data.c - Dump ".data" blocks.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "ildasm_internal.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Dump the contents of a data section, with labels inserted
* wherever fields reference the data.
*/
static void DumpData(FILE *outstream, ILImage *image, const char *heading,
unsigned long rva, void *addr,
unsigned long len,
unsigned long *fieldRVAs, unsigned
long numFieldRVAs)
{
while(len > 0)
{
/* Scan for the next field >= the current address */
while(numFieldRVAs > 0 && *fieldRVAs < rva)
{
++fieldRVAs;
--numFieldRVAs;
}
if(*fieldRVAs >= (rva + len))
{
numFieldRVAs = 0;
}
/* Dump data before the next field */
if(numFieldRVAs > 0 && *fieldRVAs != rva)
{
fprintf(outstream, "%s D_0x%08lX = bytearray", heading,
rva);
ILDAsmDumpBinaryBlob(outstream, image, addr,
(ILUInt32)(*fieldRVAs - rva));
putc('\n', outstream);
addr = (void *)(((unsigned char *)addr) + (*fieldRVAs -
rva));
len -= (*fieldRVAs - rva);
rva = *fieldRVAs;
}
/* Dump the field or the remaining data */
fprintf(outstream, "%s D_0x%08lX = bytearray", heading, rva);
if(numFieldRVAs > 1)
{
ILDAsmDumpBinaryBlob(outstream, image, addr,
(ILUInt32)(fieldRVAs[1] - rva));
addr = (void *)(((unsigned char *)addr) + (fieldRVAs[1]
- rva));
len -= (fieldRVAs[1] - rva);
rva = fieldRVAs[1];
}
else
{
ILDAsmDumpBinaryBlob(outstream, image, addr, len);
len = 0;
}
putc('\n', outstream);
}
}
void ILDAsmDumpDataSections(FILE *outstream, ILImage *image)
{
unsigned long *fieldRVAs;
unsigned long numFieldRVAs;
unsigned long posn;
unsigned long posn2;
unsigned long temp;
ILFieldRVA *rva;
void *dataAddr;
unsigned long dataRVA;
unsigned long dataLen;
void *tlsAddr;
unsigned long tlsRVA;
unsigned long tlsLen;
/* Collect all field RVA values so that we know where to
insert the data labels */
numFieldRVAs = ILImageNumTokens(image, IL_META_TOKEN_FIELD_RVA);
if(numFieldRVAs > 0)
{
fieldRVAs = (unsigned long *)ILMalloc
(sizeof(unsigned long) * numFieldRVAs);
if(!fieldRVAs)
{
numFieldRVAs = 0;
}
else
{
rva = 0;
posn = 0;
while((rva = (ILFieldRVA *)ILImageNextToken
(image,
IL_META_TOKEN_FIELD_RVA, rva)) != 0)
{
fieldRVAs[posn++] = ILFieldRVA_RVA(rva);
}
}
}
else
{
fieldRVAs = 0;
}
/* Sort the RVA list into ascending order */
for(posn = 0; posn < (numFieldRVAs - 1); ++posn)
{
for(posn2 = posn + 1; posn2 < numFieldRVAs; ++posn2)
{
if(fieldRVAs[posn] > fieldRVAs[posn2])
{
temp = fieldRVAs[posn];
fieldRVAs[posn] = fieldRVAs[posn2];
fieldRVAs[posn2] = temp;
}
}
}
/* Find the extents of the ".data" and ".tls" sections */
if(ILImageGetSection(image, IL_SECTION_DATA, &dataAddr, &dataLen))
{
dataRVA = ILImageGetSectionAddr(image, IL_SECTION_DATA);
}
else
{
dataAddr = 0;
dataLen = 0;
dataRVA = 0;
}
if(ILImageGetSection(image, IL_SECTION_TLS, &tlsAddr, &tlsLen))
{
tlsRVA = ILImageGetSectionAddr(image, IL_SECTION_TLS);
}
else
{
tlsAddr = 0;
tlsLen = 0;
tlsRVA = 0;
}
/* Dump the ".data" section */
if(dataLen > 0)
{
DumpData(outstream, image, ".data", dataRVA, dataAddr, dataLen,
fieldRVAs, numFieldRVAs);
}
/* Dump the ".tls" section */
if(tlsLen > 0)
{
DumpData(outstream, image, ".data tls", tlsRVA, tlsAddr, tlsLen,
fieldRVAs, numFieldRVAs);
}
/* Free the "fieldRVAs" array and exit */
if(fieldRVAs)
{
ILFree(fieldRVAs);
}
}
#ifdef __cplusplus
};
#endif
Index: Makefile.am
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ildasm/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** Makefile.am 4 Jul 2002 04:59:12 -0000 1.5
--- Makefile.am 30 Jan 2003 10:57:46 -0000 1.6
***************
*** 4,7 ****
--- 4,8 ----
ildasm_SOURCES = ildasm_attrs.c \
ildasm_class.c \
+ ildasm_data.c \
ildasm_global.c \
ildasm_java.c \
Index: ildasm_class.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ildasm/ildasm_class.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** ildasm_class.c 9 Jan 2003 12:06:59 -0000 1.11
--- ildasm_class.c 30 Jan 2003 10:57:46 -0000 1.12
***************
*** 178,182 ****
if(rva)
{
! fprintf(outstream, " at 0x%08lX",
(unsigned long)(ILFieldRVA_RVA(rva)));
}
--- 178,182 ----
if(rva)
{
! fprintf(outstream, " at D_0x%08lX",
(unsigned long)(ILFieldRVA_RVA(rva)));
}
Index: ildasm_global.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ildasm/ildasm_global.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** ildasm_global.c 30 Jan 2003 10:16:45 -0000 1.3
--- ildasm_global.c 30 Jan 2003 10:57:46 -0000 1.4
***************
*** 391,394 ****
--- 391,397 ----
IL_META_TOKEN_EXPORTED_TYPE,
(ILDAsmWalkFunc)Dump_ExportedType, 0);
+
+ /* Dump the ".data" and ".tls" sections */
+ ILDAsmDumpDataSections(outstream, image);
}
Index: ildasm_internal.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ildasm/ildasm_internal.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** ildasm_internal.h 13 Dec 2002 06:48:00 -0000 1.5
--- ildasm_internal.h 30 Jan 2003 10:57:46 -0000 1.6
***************
*** 93,96 ****
--- 93,101 ----
ILProgramItem *item, int flags);
+ /*
+ * Dump the ".data" and ".tls" sections.
+ */
+ void ILDAsmDumpDataSections(FILE *outstream, ILImage *image);
+
#ifdef __cplusplus
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnet/ildasm ildasm_data.c,NONE,1.1 Makefile.am,1.5,1.6 ildasm_class.c,1.11,1.12 ildasm_global.c,1.3,1.4ildasm_internal.h,1.5,1.6,
Rhys Weatherley <address@hidden> <=