OSDN Git Service

11557f41df92433548d0a9b4ebbd151c7fef743d
[drdeamon64/drdeamon64.git] / libgoblin / drd64_libgoblin_objinfo_postproc.c
1 /*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
2
3                          D r . D e a m o n  6 4
4                         for INTEL64(R), AMD64(R)
5         
6    Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10
11  1. Redistributions of source code must retain the above copyright notice,
12     this list of conditions and the following disclaimer.
13  2. Redistributions in binary form must reproduce the above copyright
14     notice, this list of conditions and the following disclaimer in the
15     documentation and/or other materials provided with the distribution.
16
17 THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27 OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
30
31 /* File Info -----------------------------------------------------------
32 File: drd64_.c
33 Function: 
34 Comment: 
35 ----------------------------------------------------------------------*/
36
37 #define DRD64_SRC_LIBGOBLIN_OBJINFO_POSTPROC
38 #include"drd64_libgoblin.h"
39
40 /*----------------------------------------------------------------------
41 ----------------------------------------------------------------------*/
42 int
43         ObjectInfo_PostProc_ResolvTypeLink(
44                 LibGoblin_ProgramInfo   *p_pginfo,
45                 LibGoblin_BinaryInfo    *p_binfo,
46                 LibGoblin_ObjectInfo    *pobj_now )
47 {
48         int                                             i_result;
49         int                                             i_objid_parent;
50         Byte                                    *pb_dwinfo;
51         LibGoblin_ObjectInfo    *pobj_parent;
52
53         if(( OBJINFO_TYPE_TYPE_SINGLE != pobj_now->b_type )
54                                 && ( OBJINFO_TYPE_TYPE_MULTI != pobj_now->b_type ))
55                 { goto  goto_ObjectInfo_PostProc_ResolvTypeLink_post; }
56
57         if( NULL == pobj_now->info.type.p_dwtype )
58                 { goto  goto_ObjectInfo_PostProc_ResolvTypeLink_post; }
59
60         pb_dwinfo               = pobj_now->info.type.p_dwtype;
61         i_objid_parent  = Index_DWARFInfo_SearchObjectInfo( p_binfo, pb_dwinfo );
62
63 /*
64         printf("  Link: ObjID=%d dwinfo=%8ph -> LinkAddr=%8p  => parent: %d (old: %d)\n",
65                                 pobj_now->i_id, pobj_now->dwarf.pb_info, pobj_now->info.type.p_dwtype,
66                                 i_objid_parent, pobj_now->grplink.i_parent_id );
67 */
68
69         if( NO_OBJ != i_objid_parent )  {
70                 pobj_parent     = OBJINFO( p_pginfo, i_objid_parent );
71                 i_result        = ObjectInfo_AdoptObjectInfo( p_pginfo, pobj_parent, pobj_now );
72                 
73                 pobj_now->info.type.i_objid_type        = i_objid_parent;
74         }
75
76 goto_ObjectInfo_PostProc_ResolvTypeLink_post:
77         return 0x00;
78 }
79                 
80
81 /*----------------------------------------------------------------------
82 ----------------------------------------------------------------------*/
83 LIBGOBLIN_OBJINFO_POSTPROC_EXTERN
84 int
85         ObjectInfo_PostProc(
86                 LibGoblin_ProgramInfo   *p_pginfo,
87                 LibGoblin_BinaryInfo    *p_binfo )
88 {
89         int             i_result;
90         LibGoblin_ObjectInfo    *pobj_now;
91
92         pobj_now        = p_pginfo->objinfo.p_objinfo;
93
94         if( NULL == pobj_now )
95                 { goto goto_ObjectInfo_PostProc_post; }
96
97         do      {
98                 // Resolv from address link in .debug_info to ObjectInfo IDs.---
99                 i_result        = ObjectInfo_PostProc_ResolvTypeLink(
100                                                                                 p_pginfo, p_binfo, pobj_now );
101         
102                 // Regist Address INDEX table ---
103
104                 // Regist Name INDEX table ---
105
106
107                 pobj_now        = ((NO_OBJ == pobj_now->addrlink.i_next_id) ? NULL
108                                                 : OBJINFO( p_pginfo, pobj_now->addrlink.i_next_id ));
109         }while( NULL != pobj_now );
110
111         // Sort Address INDEX table ---
112
113         // Sort Name INDEX table ---
114
115 goto_ObjectInfo_PostProc_post:
116
117         return 0x00;
118 }
119
120 /*----------------------------------------------------------------------
121 ----------------------------------------------------------------------*/
122
123
124
125 /* EOF of drd64_.c ----------------------------------- */