OSDN Git Service

(LibGoblin)
[drdeamon64/drdeamon64.git] / libgoblin / drd64_libgoblin_type.h
index 945ee3b..99cbe01 100644 (file)
@@ -37,91 +37,304 @@ Comment:
 #ifndef DRD64_HEADER_LIBGOBLIN_TYPE
 #define DRD64_HEADER_LIBGOBLIN_TYPE
 
-#define        LIBGOBLIN_PROGINFO_MAX_BINFO    128
 
-#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        isElf64(n) \
-       ((LIBGOBLIN_BINFO_TYPE_ELF64==((n)->b_type)) ? 0x01 : 0x00)
-#define        isElf32(n) \
-       ((LIBGOBLIN_BINFO_TYPE_ELF32==((n)->b_type)) ? 0x01 : 0x00)
-#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
-
-
-#define        LIBGOBLIN_BINFO_FILE_MMAP               (DWord)0x01
-#define        LIBGOBLIN_BINFO_FILE_EXTALLOC   (DWord)0x02
-#define        LIBGOBLIN_BINFO_FILE_INTALLOC   (DWord)0x04
+/*=====================================================================*/
+/*
+typedef union  {
+       int             i_obj_id;
+       Byte    *pb_info;
+} LibGoblin_ObjInfo_Link;
+*/
 
+/*=====================================================================*/
+typedef        struct  {
+       Byte    *pb_dwinfo;
+       int             i_obj_id;
+} LibGoblin_Index_DWARFInfo;
 
 
 /*=====================================================================*/
 typedef struct {
        Byte    *pb_sechdr;
-       Byte    *pb_data;
-       char    *pstr_secname;
+       Byte    *pb_data;               // FileLocation (Offset)
+       Word    w_index;
+       Ptr             ptr_addr;
        QWord   qw_size;
-       int             i_fid;
+       QWord   qw_flag;
+       QWord   qw_entsize;
+       char    *pstr_secname;
+       int             i_binfile;
+
+       int             i_objid;
 } LibGoblin_SectionInfo;
 
 
 /*=====================================================================*/
-typedef        struct  {
-       Ptr             ptr_address;
-       char    *pstr_name;
-       DWord   dw_size;
-       DWord   dw_srcid;
+/*typedef      struct  {
+       Ptr             ptr_address;    // Object Address
+       DWord   dw_size;                // Object Size (Address Range)
+       char    *pstr_name;             // Object Name (Param./Func./etc...)
+       //DWord dw_srcid;               // SourceInfo struct ID
        DWord   dw_next;
        Byte    b_elf_flags;
-       Word    w_secid;
-} LibGoblin_AddressInfo;
+       Word    w_secid;                // SectionInfo ItemIndex belong with this object.
+} LibGoblin_AddressInfo ****OLD****   ;*/
 
 
 /*=====================================================================*/
-/*
-typedef struct  {
+#define        OBJINFO_STATUS_INVALID  0x00000000
+#define        OBJINFO_STATUS_VALID    0x00000001      // bit 0
+#define        OBJINFO_STATUS_DYNAMIC  0x00000002      // bit 1
+#define        OBJINFO_STATUS_RESOLV1  0x00000004      // bit 2 (Specified BinaryInfo & Index)
+//#define      OBJINFO_STATUS_RESOLV2  0x00000008      // bit 3 (Loaded .so)
+#define        OBJINFO_STATUS_REL              0x00000100
+#define        OBJINFO_STATUS_SOLVED   0x00001000
+
+#define        OBJINFO_TYPE_NULL                       0x00
+#define        OBJINFO_TYPE_MASTER                     0x01
+#define        OBJINFO_TYPE_PROGRAM            0x02
+#define        OBJINFO_TYPE_PROGHDR            0x03
+#define        OBJINFO_TYPE_SECTION            0x04
+#define        OBJINFO_TYPE_OBJFILE            0x05
+#define        OBJINFO_TYPE_TYPE_MULTI         0x06
+#define        OBJINFO_TYPE_TYPE_SINGLE        0x07
+#define        OBJINFO_TYPE_TYPEDEF            0x08
+#define        OBJINFO_TYPE_FUNCTION           0x09
+#define        OBJINFO_TYPE_OBJECT                     0x0a
+#define        OBJINFO_TYPE_COMMON                     0x0b
+#define        OBJINFO_TYPE_TLS                        0x0c
+#define        OBJINFO_TYPE_REL                        0x0d
+#define        OBJINFO_TYPE_NONE                       0x7f
+
+typedef        struct  {
        int             i_id;
-       char    str_libfilepath[DRD64_MAX_PATH];
-       char    str_librealpath[DRD64_MAX_PATH];
-       char    str_rpath[DRD64_MAX_PATH];
-       void    *p_nextlib;
-} LibGoblin_LibraryInfo;
-*/
+       Byte    b_type;
+       DWord   dw_status;
+
+       // Address & Memory-Range Info ----
+       struct  {
+               Ptr             ptr_addr;               // Object Address
+               //   [Section] sh_addr - Address in memory image.
+               //   [Symbol ] st_value - Symbol value.
+               QWord   qw_size;                // Object Size (Address Range)
+               //   [Symbol ] st_size - Size of associated object.
+       } addr;
+
+       // Address Order Link ---
+       struct  {
+               int             i_next_id;              // Next Address ObjectInfo
+               int             i_prev_id;              // Prev Address ObjectInfo
+       } addrlink;
+
+       // Group(Parent-Child) Order Link ---
+       struct  {
+               int             i_parent_id;    // Parent ObjectInfo
+               int             i_child_topid;  // Child Top ObjectInfo
+               int             i_prev_id;
+               int             i_next_id;              // Next 
+       } grplink;
+
+       // Type Link ---
+       struct  {
+               int             i_prev_id;
+               int             i_next_id;
+       } typelink;
+
+       // File Info ---
+       struct  {
+               int             i_binfile;
+               void    *pv_offset;
+               //   [Section] sh_offset - Offset in file.
+               QWord   qw_size;
+       } file;
+
+       // ObjectInfo (DATA) ---
+       char    *pstr_name;             // Object Name (Param./Func./etc...)
+       //   [Section] = sh_name - Section name (index into the section header string table).
+       //   [Symbol ] = st_name - String table index of name.
+       DWord   dw_hash;
+       
+       union   {
+               Byte            b_data[128];
+
+               // for OBJINFO_TYPE_PROGRAM
+               struct  {
+                       int             i_binfo_id;
+               } program;
+
+               // for OBJINFO_TYPE_PROGHDR
+               struct  {
+                       DWord   dw_type;                // Entry type.
+                       DWord   dw_flags;               // Access permission flags.
+                       QWord   qw_align;               // Alignment in memory and file.
+                       void    *pv_proghdr;    // Program Header Pointer
+               } proghdr;
+
+               // for OBJINFO_TYPE_SECTION
+               struct  {
+                       QWord   qw_flag;                // sh_flags - Section flags.
+                       QWord   qw_align;               // sh_addralign - Alignment in bytes.
+                       QWord   qw_entsize;             // sh_entsize - Size of each entry in section.
+                       DWord   dw_type;                // sh_type - Section type.
+                       DWord   dw_link;                // sh_link - Index of a related section.
+                       DWord   dw_info;                // sh_info - Depends on section type.
+                       void    *pv_sechdr;
+               } section;
+
+               // for OBJINFO_TYPE_OBJFILE
+               struct  {
+                       int             i_objid_parent;
+                       int             i_abbrevs;
+                       DWARF_AbbrevEntry                               *p_abbrev;
+                       LibGoblin_DWARF_Info_CUHeader   t_cuheader;
+               } objfile;
+
+               struct  {
+                       DWord   dw_size;
+                       Byte    b_encoding;
+                       Byte    b_bit_offset;
+                       Byte    b_bit_size;
+                       Byte    b_endianity;
+                       Byte    b_addr_class;
+                       Byte    b_prototyped;
+               } type;
+
+               struct  {
+                       int             i_objid_parent;
+                       Byte    b_prototyped;
+                       Byte    b_external;
+                       Byte    b_inline;
+
+               } function;
+       } info;
+
+       struct  {
+               Byte    b_type;                 // st_info - Type and binding information.
+               Byte    b_binding;              // st_info - Type and binding information.
+               Byte    b_visibility;   // st_other - Reserved (not used).
+               Word    w_secindex;             // st_shndx - Section index of symbol.
+       } elfsym;
+
+       struct  {
+               int             i_binfo_origin;
+               int             i_dynsym_index;
+
+               int             i_objid_rel;
+       } dynamic;
+
+       struct  {
+               int             i_objid_origin;
+       } rel;
+
+       struct  {
+               Byte    *pb_info;
+
+               int             i_objid_type;
+               Byte    *pb_dwinfo_type;
+       } dwarf;
+
+       int             i_secid;
+       int             i_srcid;                // SourceInfo struct ID
+       DWord   dw_srcline;
+
+       Byte    b_elf_flags;
+       Word    w_secid;                // ==OLD== SectionInfo ItemIndex belong with this object.
+
+} LibGoblin_ObjectInfo;
+
+
+/*=====================================================================*/
+typedef struct {
+       Ptr             ptr_addr;
+       int             i_objid;
+} LibGoblin_AddressInfo;
 
 /*=====================================================================*/
 typedef struct {
+       int             i_id;
+       DWord   dw_hash_filename;
+       DWord   dw_hash_localpath;
+       char    str_filename[DRD64_MAX_PATH];
+       char    str_localpath[DRD64_MAX_PATH];
+       char    str_srcpath[DRD64_MAX_PATH];    // for DW_AT_name
+       //char  str_buildpath[DRD64_MAX_PATH];  // for DW_AT_comp_dir (Optional)
+
+       int             i_bfile_id;
+       struct  {
+               int                                     i_abbrevs;
+               DWARF_AbbrevEntry       *p_abbrev;
+       } dwarf;
+
+} LibGoblin_SrcFile;
+
+
+/*=====================================================================*/
+#define        BINFILE_FLAGMASK_FILE                   (DWord)0x00000007
+#define        BINFILE_FLAG_FILE_MMAP                  (DWord)0x00000001
+#define        BINFILE_FLAG_FILE_EXTALLOC              (DWord)0x00000002
+#define        BINFILE_FLAG_FILE_INTALLOC              (DWord)0x00000004
+
+#define        BINFILE_FLAGMASK_RELTYPE                (DWord)0x00000010
+#define        BINFILE_FLAG_RELTYPE_REL                (DWord)0x00000000
+#define        BINFILE_FLAG_RELTYPE_RELA               (DWord)0x00000010
+
+#define        BINFILE_STATUS_NOUSE                    0x00
+#define        BINFILE_STATUS_CREATE                   0x01
+#define        BINFILE_STATUS_FILEOPEN                 0x02
+#define        BINFILE_STATUS_READSECTION              0x03
+
+typedef struct {
        int                     i_id;
        int                     i_refcount;
 
        /* Binary-File Info. */
        int                     i_fd;
        DWord           dw_flag;
+       Byte            b_status;
+
+       // EXEC-program / shared lib. filename (without directry)
        char            str_filename[DRD64_MAX_PATH];
-       char            str_path[DRD64_MAX_PATH];
-       char            str_rpath[DRD64_MAX_PATH];              // .dyn Section rpath
+       char            str_localpath[DRD64_MAX_PATH];  // filepath in local machine path.(transported)
+       char            str_remotepath[DRD64_MAX_PATH]; // filepath in remote machine path.(local machine is NULL)
+
+       // .dynamic Section - rpath (.so location path - converted real-path) 
+       char            str_rpath[DRD64_MAX_PATH];
+       // .dynamic Section - runpath (.so location path - converted real-path) 
+       char            str_runpath[DRD64_MAX_PATH];
+
        LibFileType_FileType    t_ftype;
 
        /* Binary-File Memory Image Access Info. */
        DWord           dw_size;
        Byte            *pb_binary;
 
+       struct  {
+               LibGoblin_SrcFile       *p_srcfile;
+               int                                     i_alloc;
+               int                                     i_max;
+               int                                     i_now;
+       } srcfile;
+
+       struct  {
+               int                                     i_abbrevs_max;
+               int                                     i_abbrevs_alloc;
+               DWARF_AbbrevEntry       *p_abbrev;
+               QWord                           qw_abbrev_unreadsz;
+
+               LibGoblin_Index_DWARFInfo       *p_offset;
+               int                                     i_alloced_offset;
+               int                                     i_max_offset;
+
+               int                                     i_objfiles;
+
+               int                                     i_maxvals;
+       } dwarf;
+
        /* Binary-Format Depending Info. (ELF)*/
        void            *p_elf;
 
        LibGoblin_SectionInfo   t_section[LIBGOBLIN_SECTION_ID_MAX];
+       int                                             i_secindex[LIBGOBLIN_SECTION_ID_MAX];
 } LibGoblin_BinaryFile;
 
 
@@ -131,12 +344,41 @@ typedef struct    {
 #define        LIBGOBLIN_BINFO_PHASE_SETNAME   0x20
 #define        LIBGOBLIN_BINFO_PHASE_SETPROG   0x30
 #define        LIBGOBLIN_BINFO_PHASE_BINREAD   0x40
+#define        LIBGOBLIN_BINFO_PHASE_ELF1READ  0x51
+#define        LIBGOBLIN_BINFO_PHASE_ELF2READ  0x52
 #define        LIBGOBLIN_BINFO_PHASE_ANALYZED  0x50
 
-#define        LIBGOBLIN_BINFO_MAXFILES                3
+#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        isElf64(n) \
+       ((LIBGOBLIN_BINFO_TYPE_ELF64==((n)->b_type)) ? 0x01 : 0x00)
+#define        isElf32(n) \
+       ((LIBGOBLIN_BINFO_TYPE_ELF32==((n)->b_type)) ? 0x01 : 0x00)
+#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
+
+#define        LIBGOBLIN_BINFO_MAXFILES                3       // Except FILE_LIBRARY
 #define        LIBGOBLIN_BINFO_FILE_EXEC               0
 #define        LIBGOBLIN_BINFO_FILE_CORE               1
 #define        LIBGOBLIN_BINFO_FILE_DEBUG              2
+#define        LIBGOBLIN_BINFO_FILE_LIBRARY    -1
+
+#define        LIBGOBLIN_DWARF_ATTR_DEF_MAX    0x6f
+#define        LIBGOBLIN_DWARF_ATTR_EXT_MAX    53
+#define        LIBGOBLIN_DWARF_ATTR_MAX                (LIBGOBLIN_DWARF_ATTR_DEF_MAX + LIBGOBLIN_DWARF_ATTR_EXT_MAX)
 
 typedef struct {
        /* BinaryInfo Struct ID */
@@ -152,25 +394,42 @@ typedef struct    {
        void            *p_debug;
 
        /* Address Table Info. */
+/*
        LibGoblin_AddressInfo   *p_addrinfo;
        DWord           dw_alloc_addrinfo;
        DWord           dw_max_addrinfo;
+*/
 
        /* Exec. File Info. */
        char            str_filename[DRD64_MAX_PATH];
-       char            str_path[DRD64_MAX_PATH];
-       char            str_rpath[DRD64_MAX_PATH];              // .dynamic Section - rpath (.so location path)
-       int                     i_req_bid;
+       DWord           dw_hash;
        
-       LibGoblin_BinaryFile    *p_binfile;
+       int                     i_binfile;              // binaryFile ID
+       int                     i_binfile_debug;
+
+       int                     i_pginfo;
+       int                     i_binfo_parent;
+       int                     i_binfo_next;
+
+       PtrValue        ptr_loadbase;
+
+       LibGoblin_SectionInfo   t_section[LIBGOBLIN_SECTION_ID_MAX];
 
        /* Binary-Format Depending Info. (ELF)*/
        //void          *p_format;
 
-       LibGoblin_SectionInfo   t_section[LIBGOBLIN_SECTION_ID_MAX];
-       
-       void            *pv_pginfo;
-       void            *pv_lib_binfile_next;   // NEW
+       struct  {
+               int                                                     i_maxvals;
+               LibGoblin_DWARF_DIEValue        *p_infoval;
+
+               int                                                     i_extattrs;
+               LibGoblin_DWARF_Attribute       t_attr[LIBGOBLIN_DWARF_ATTR_MAX+1];
+
+               int                                                     i_alloc_srctbl;
+               int                                                     i_max_srctbl;
+               int                                                     *pi_srctbl; 
+       } dwarf;
+
 
 }      LibGoblin_BinaryInfo;
 
@@ -180,17 +439,27 @@ typedef   struct  {
 
        int                                             i_id;
 
-       int                                             i_num_binfo;
-       LibGoblin_BinaryInfo    *p_binfo[LIBGOBLIN_PROGINFO_MAX_BINFO];
-       LibGoblin_BinaryInfo    *p_binfo_core;          // NEW
-       LibGoblin_BinaryInfo    *p_binfo_debug;         // NEW
-
-       int                                             i_opened_bid;
+       // Object Table & Address Table ---
+       struct  {
+               LibGoblin_ObjectInfo    *p_objinfo;
+               int                                             i_empty;        // Empty ObjectInfo Chain Top-ID.
+               int                                             i_alloced;      // Alloced ObjectInfo
+               int                                             i_used;         // ObjectInfo Items
+               int                                             i_topid;        // Top-Ptr ObjectInfo
 
+       } objinfo;
+       LibGoblin_AddressInfo   *p_addrinfo;
+       
+       Word                                    dw_flag;
+       int             i_binfo_id;
+       int             i_binfo_id_core;
 
-       // Working Area
-       LibGoblin_LibraryFileList       t_libflist;
+       /* Address Table Info. */
+       //LibGoblin_AddressInfo *p_addrinfo;
+       //DWord         dw_alloc_addrinfo;
+       //DWord         dw_max_addrinfo;
 
+       
 }      LibGoblin_ProgramInfo;