#include<fcntl.h>
#include<unistd.h>
#include<assert.h>
+
+#ifdef __FreeBSD__
#include<elf.h>
#include<dwarf.h>
#include<sys/stat.h>
#include<sys/mman.h>
+#endif /* __FREEBSD__ */
+
+#ifdef __linux__
+#include<elf.h>
+#include<dwarf.h>
+#include<sys/stat.h>
+#include<sys/mman.h>
+#endif /* __FREEBSD__ */
+
#include"../include/drd64_types.h"
#include"../include/drd64_defines.h"
#include"../include/drd64_error.h"
#include"../include/drd64_conf.h"
#include"../include/libgoblin.h"
+#include"drd64_libgoblin_sectbl.h"
#include"drd64_libgoblin_binfo.h"
#include"drd64_libgoblin_checkbin.h"
#include"drd64_libgoblin_analyze.h"
char *pstr_filepath )
{
int i_bid;
- int i_bintype;
int i_err;
int i_fd;
struct stat t_sb;
DWord dw_size )
{
int i_bid;
- int i_bintype;
int i_result;
LibGoblin_BinaryInfo *p_bin;
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_IsElf(
Byte *p_data )
{
- Elf_Ehdr *p_elfhdr;
+ //Elf_Ehdr *p_elfhdr;
assert( NULL != p_data );
- p_elfhdr = (Elf_Ehdr *)p_data;
+ //p_elfhdr = (Elf_Ehdr *)p_data;
+ if( ( ELFMAG0 == *(p_data + EI_MAG0) )
+ && ( ELFMAG1 == *(p_data + EI_MAG1) )
+ && ( ELFMAG2 == *(p_data + EI_MAG2) )
+ && ( ELFMAG3 == *(p_data + EI_MAG3) ) )
+ { return 0x01; }
+ return 0x00;
- return IS_ELF( *p_elfhdr );
+ //return IS_ELF( *p_elfhdr );
}
LibGoblin_AnalyzeElf(
LibGoblin_BinaryInfo *p_bin )
{
- int i_err;
+ //int i_err;
Byte *pb_data;
assert( NULL != p_bin );