/* drd64_libgoblin_?????.c Functions =====================*/
LIBGOBLIN_FUNC
int
- LibGoblin_Init(
- void );
-
-LIBGOBLIN_FUNC
-int
- LibGoblin_Term(
- void );
-
-LIBGOBLIN_FUNC
-int
LibGoblin_ReadBinary_Memory(
Byte *p_data,
DWord dw_size );
LibGoblin_ReadBinary_File(
char *pstr_filepath );
+#ifdef DRD64_SRC_LIBGOBLIN_SYSTEM
+ #define LIBGOBLIN_API_SYSTEM
+#else
+ #define LIBGOBLIN_API_SYSTEM extern
+#endif
+LIBGOBLIN_API_SYSTEM
+ int LibGoblin_Init( void );
+LIBGOBLIN_API_SYSTEM
+ int LibGoblin_Term( void );
+
#endif /* DRD64_HEADER_LIBGOBLIN */
drd64_libgoblin_dwarf_line.o \
drd64_libgoblin_dwarf_common.o
HEADER = drd64_libgoblin.h \
+ drd64_libgoblin_type.h \
drd64_libgoblin_binfo.h \
drd64_libgoblin_checkbin.h \
drd64_libgoblin_analyze.h \
TEST_FLAGS_LINKER = -L/usr/local/lib -lcunit
TEST_TARGET = test_libgoblin
TEST_HEADER = test_libgoblin.h
-TEST_OBJS = test_libgoblin.o
+TEST_OBJS = test_libgoblin.o \
+ test_libgoblin_system.o \
+ test_libgoblin_binfo.o
TESTPROG = ../dwarftest
$(CC) -c -o test_libgoblin.o \
$(FLAGS_DEBUG) $(FLAGS_COMPILE) $(TEST_FLAGS_COMPILE) \
test_libgoblin.c
+test_libgoblin_system.o: test_libgoblin_system.c $(HEADER) $(TEST_HEADER)
+ $(CC) -c -o test_libgoblin_system.o \
+ $(FLAGS_DEBUG) $(FLAGS_COMPILE) $(TEST_FLAGS_COMPILE) \
+ test_libgoblin_system.c
+test_libgoblin_binfo.o: test_libgoblin_binfo.c $(HEADER) $(TEST_HEADER)
+ $(CC) -c -o test_libgoblin_binfo.o \
+ $(FLAGS_DEBUG) $(FLAGS_COMPILE) $(TEST_FLAGS_COMPILE) \
+ test_libgoblin_binfo.c
$(TEST_TARGET): $(TEST_OBJS) $(TARGET)
$(CC) -o $(TEST_TARGET) $(FLAGS_DEBUG) $(TEST_OBJS) $(TARGET) $(TEST_FLAGS_LINKER)
#include"../include/drd64_conf.h"
#include"../include/libgoblin.h"
// #include"drd64_libgoblin_sectbl.h"
+#include"drd64_libgoblin_type.h"
#include"drd64_libgoblin_binfo.h"
#include"drd64_libgoblin_checkbin.h"
#include"drd64_libgoblin_analyze.h"
----------------------------------------------------------------------*/
LIBGOBLIN_BINFO_EXTERN
LibGoblin_BinaryInfo *
+ LibGoblin_BInfo_GetBinaryInfo(
+ int i_bid )
+{
+ if(( gi_now_binary_info <= i_bid ) && ( 0 > i_bid ))
+ { return NULL; }
+
+ return (gp_binary_info + i_bid);
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+LIBGOBLIN_BINFO_EXTERN
+LibGoblin_BinaryInfo *
LibDrd64_BinInfo_AllocBinInfo(
void)
{
----------------------------------------------------------------------*/
LIBGOBLIN_BINFO_EXTERN
int
- LibGoblin_InitBinaryInfo(
+ LibGoblin_BinInfo_Init(
void)
{
gp_binary_info = malloc( sizeof( LibGoblin_BinaryInfo )
----------------------------------------------------------------------*/
LIBGOBLIN_BINFO_EXTERN
int
- LibGoblin_TermBinaryInfo(
+ LibGoblin_BinInfo_Term(
void )
{
LibGoblin_BinaryInfo *p_bin;
}
-/*----------------------------------------------------------------------
-----------------------------------------------------------------------*/
-LIBGOBLIN_BINFO_EXTERN
-LibGoblin_BinaryInfo *
- LibGoblin_BInfo_GetBinaryInfo(
- int i_bid )
-{
- if(( gi_now_binary_info <= i_bid ) && ( 0 > i_bid ))
- { return NULL; }
-
- return (gp_binary_info + i_bid);
-}
-
-
/* EOF of drd64_.c ----------------------------------- */
#define LIBGOBLIN_BINFO_UNITS 8
-#define LIBGOBLIN_BINFO_TYPE_NONE 0x00
-#define LIBGOBLIN_BINFO_TYPE_ELF 0x01
-#define LIBGOBLIN_BINFO_TYPE_ELF64 0x64
-#define LIBGOBLIN_BINFO_TYPE_ELF32 0x32
-
-#define IsBinfoType_Elf64(n) \
- ((LIBGOBLIN_BINFO_TYPE_ELF64==((n)->b_type)) ? 0x01 : 0x00)
-#define IsBinfoType_Elf32(n) \
- ((LIBGOBLIN_BINFO_TYPE_ELF32==((n)->b_type)) ? 0x01 : 0x00)
-
-#define LIBGOBLIN_BINFO_ENDIAN_NONE 0x00
-#define LIBGOBLIN_BINFO_ENDIAN_LITTLE 0x01
-#define LIBGOBLIN_BINFO_ENDIAN_BIG 0x02
-
-#define LIBGOBLIN_BINFO_SECTION_TEXT 0x00
-#define LIBGOBLIN_BINFO_SECTION_DATA 0x01
-#define LIBGOBLIN_BINFO_SECTION_BSS 0x02
-
-
-typedef struct {
- /* BinaryInfo Struct ID */
- int i_id;
-
- /* Binary-File Info. */
- int i_fd;
- char str_filepath[DRD64_MAX_PATH];
-
- /* Binary-File Memory Image Access Info. */
- DWord dw_size;
- Byte *p_binary;
-
- /* BinaryInfo Common Info. */
- Byte b_type;
- Byte b_endian;
- Byte b_bits;
-
- /* Binary-Format Depending Info. (ELF)*/
- void *p_format;
- /* Debug-Format Depending Info. (DWarf) */
- void *p_debug;
-
- /* Section Table */
- int i_num_sectbl;
- //LibGoblin_SectionTable *p_sectbl;
-
-} LibGoblin_BinaryInfo;
-
-
-
-
LIBGOBLIN_BINFO_EXTERN LibGoblin_BinaryInfo *gp_binary_info;
LIBGOBLIN_BINFO_EXTERN int gi_max_binary_info;
LIBGOBLIN_BINFO_EXTERN int gi_now_binary_info;
LIBGOBLIN_BINFO_EXTERN
LibGoblin_BinaryInfo *
+ LibGoblin_BInfo_GetBinaryInfo(
+ int i_bid );
+LIBGOBLIN_BINFO_EXTERN
+ LibGoblin_BinaryInfo *
LibDrd64_BinInfo_AllocBinInfo(
void );
LIBGOBLIN_BINFO_EXTERN
int
- LibGoblin_InitBinaryInfo(
- void );
-
+ LibGoblin_BinInfo_Init( void );
LIBGOBLIN_BINFO_EXTERN
int
- LibGoblin_TermBinaryInfo(
- void );
-
-LIBGOBLIN_BINFO_EXTERN
- LibGoblin_BinaryInfo *
- LibGoblin_BInfo_GetBinaryInfo(
- int i_bid );
+ LibGoblin_BinInfo_Term( void );
#ifdef LIBGOBLIN_BINFO_INTERNALFUNC
/*----------------------------------------------------------------------
----------------------------------------------------------------------*/
-LIBGOBLIN_FUNC
+LIBGOBLIN_API_SYSTEM
int
LibGoblin_Init(
void )
{
int i_err;
- i_err = LibGoblin_InitBinaryInfo();
+ i_err = LibGoblin_BinInfo_Init();
if( 0x00 != i_err ) { return i_err; }
return 0x00;
/*----------------------------------------------------------------------
----------------------------------------------------------------------*/
-LIBGOBLIN_FUNC
+LIBGOBLIN_API_SYSTEM
int
LibGoblin_Term(
void )
{
int i_err;
- i_err = LibGoblin_TermBinaryInfo();
+ i_err = LibGoblin_BinInfo_Term();
if( 0x00 != i_err ) { return i_err; }
return 0x00;
--- /dev/null
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+ D r . D e a m o n 6 4
+ for INTEL64(R), AMD64(R)
+
+ Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.h
+Function: Header
+Comment:
+----------------------------------------------------------------------*/
+
+#ifndef DRD64_HEADER_LIBGOBLIN_TYPE
+#define DRD64_HEADER_LIBGOBLIN_TYPE
+
+#include"drd64_libgoblin.h"
+
+
+#define LIBGOBLIN_BINFO_TYPE_NONE 0x00
+#define LIBGOBLIN_BINFO_TYPE_ELF 0x01
+#define LIBGOBLIN_BINFO_TYPE_ELF64 0x64
+#define LIBGOBLIN_BINFO_TYPE_ELF32 0x32
+
+#define IsBinfoType_Elf64(n) \
+ ((LIBGOBLIN_BINFO_TYPE_ELF64==((n)->b_type)) ? 0x01 : 0x00)
+#define IsBinfoType_Elf32(n) \
+ ((LIBGOBLIN_BINFO_TYPE_ELF32==((n)->b_type)) ? 0x01 : 0x00)
+
+#define LIBGOBLIN_BINFO_ENDIAN_NONE 0x00
+#define LIBGOBLIN_BINFO_ENDIAN_LITTLE 0x01
+#define LIBGOBLIN_BINFO_ENDIAN_BIG 0x02
+
+#define LIBGOBLIN_BINFO_SECTION_TEXT 0x00
+#define LIBGOBLIN_BINFO_SECTION_DATA 0x01
+#define LIBGOBLIN_BINFO_SECTION_BSS 0x02
+
+
+typedef struct {
+ /* BinaryInfo Struct ID */
+ int i_id;
+
+ /* Binary-File Info. */
+ int i_fd;
+ char str_filepath[DRD64_MAX_PATH];
+
+ /* Binary-File Memory Image Access Info. */
+ DWord dw_size;
+ Byte *p_binary;
+
+ /* BinaryInfo Common Info. */
+ Byte b_type;
+ Byte b_endian;
+ Byte b_bits;
+
+ /* Binary-Format Depending Info. (ELF)*/
+ void *p_format;
+ /* Debug-Format Depending Info. (DWarf) */
+ void *p_debug;
+
+ /* Section Table */
+ int i_num_sectbl;
+ //LibGoblin_SectionTable *p_sectbl;
+
+} LibGoblin_BinaryInfo;
+
+
+
+typedef struct {
+ Word dw_id;
+ Word w_flag;
+ Ptr *p_address;
+ DWord dw_size;
+ DWord dw_srcid;
+ DWord dw_name;
+ DWord dw_next;
+ Word w_secid;
+} LibGoblin_SymbolInfo;
+
+
+#endif /* DRD64_HEADER_LIBGOBLIN_SYMINFO*/
+
+/* EOF of drd64_.h ----------------------------------- */
{
CU_initialize_registry();
-
+ Test_LibGoblin_System();
+ Test_LibGoblin_BinInfo();
CU_basic_run_tests();
CU_cleanup_registry();
#include"CUnit/Basic.h"
-#ifdef DRD64_SRC_TEST_LIBGOBLIN_XXX
- #define DRD64_TEST_LIBGOBLIN_XXX_EXTERN
+#ifdef DRD64_SRC_TEST_LIBGOBLIN_SYSTEM
+ #define DRD64_TEST_LIBGOBLIN_SYSTEM_EXTERN
#else
- #define DRD64_TEST_LIBGOBLIN_XXX_EXTERN extern
+ #define DRD64_TEST_LIBGOBLIN_SYSTEM_EXTERN extern
#endif
+DRD64_TEST_LIBGOBLIN_SYSTEM_EXTERN int Test_LibGoblin_System( void );
+
+
+#ifdef DRD64_SRC_TEST_LIBGOBLIN_BINFO
+ #define DRD64_TEST_LIBGOBLIN_BINFO_EXTERN
+#else
+ #define DRD64_TEST_LIBGOBLIN_BINFO_EXTERN extern
+#endif
+DRD64_TEST_LIBGOBLIN_BINFO_EXTERN int Test_LibGoblin_BinInfo( void );
+
#endif /* DRD64_HEADER_XXX */
--- /dev/null
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+ D r . D e a m o n 6 4
+ for INTEL64(R), AMD64(R)
+
+ Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.c
+Function:
+Comment:
+----------------------------------------------------------------------*/
+
+#define DRD64_SRC_TEST_LIBGOBLIN_BINFO
+#include"drd64_libgoblin.h"
+#include"test_libgoblin.h"
+
+
+/* LibGoblin_BinInfo_Init() & Term() **********************************/
+/*--------------------------------------------------------------------*/
+void Test_LibGoblin_BinInfo_InitTerm_test00_001( void )
+{
+ int i_result;
+
+ i_result = LibGoblin_BinInfo_Init();
+ CU_ASSERT( 0x00 == i_result );
+
+ i_result = LibGoblin_BinInfo_Term();
+ CU_ASSERT( 0x00 == i_result );
+
+ return;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+DRD64_TEST_LIBGOBLIN_BINFO_EXTERN
+int
+ Test_LibGoblin_BinInfo(
+ void )
+{
+ CU_pSuite pt_goblin;
+
+ pt_goblin = CU_add_suite( "LibGoblin_BinInfo", NULL, NULL );
+
+ CU_add_test( pt_goblin, "LibGoblin_BinInfo_InitTerm_test00_001",
+ Test_LibGoblin_BinInfo_InitTerm_test00_001 );
+
+
+ return 0x00;
+}
+
+
+/* EOF of drd64_.c ----------------------------------- */
--- /dev/null
+/*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
+
+ D r . D e a m o n 6 4
+ for INTEL64(R), AMD64(R)
+
+ Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+OF THE POSSIBILITY OF SUCH DAMAGE.
+
+DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
+
+/* File Info -----------------------------------------------------------
+File: drd64_.c
+Function:
+Comment:
+----------------------------------------------------------------------*/
+
+#define DRD64_SRC_TEST_LIBGOBLIN_SYSTEM
+#include"drd64_libgoblin.h"
+#include"test_libgoblin.h"
+
+
+/* (API) LibGoblin_Init() & Term() ************************************/
+/*--------------------------------------------------------------------*/
+void Test_LibGoblin_System_InitTerm_test00_001( void )
+{
+ int i_result;
+
+ i_result = LibGoblin_Init();
+ CU_ASSERT( 0x00 == i_result );
+
+ i_result = LibGoblin_Term();
+ CU_ASSERT( 0x00 == i_result );
+
+ return;
+}
+
+
+/*----------------------------------------------------------------------
+----------------------------------------------------------------------*/
+DRD64_TEST_LIBGOBLIN_SYSTEM_EXTERN
+int
+ Test_LibGoblin_System(
+ void )
+{
+ CU_pSuite pt_goblin;
+
+ pt_goblin = CU_add_suite( "LibGoblin_System", NULL, NULL );
+
+ CU_add_test( pt_goblin, "LibGoblin_System_InitTerm_test00_001",
+ Test_LibGoblin_System_InitTerm_test00_001 );
+
+
+ return 0x00;
+}
+
+
+/* EOF of drd64_.c ----------------------------------- */