/[gcl]/gcl/bfdtest.c
ViewVC logotype

Diff of /gcl/bfdtest.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by mjthomas, Wed Oct 16 03:57:53 2002 UTC revision 1.3 by mjthomas, Tue Jul 29 06:28:31 2003 UTC
# Line 3  Line 3 
3  #include <bfdlink.h>  #include <bfdlink.h>
4  #include <string.h>  #include <string.h>
5  #include <stdio.h>  #include <stdio.h>
6    #define MY_BFD_BOOLEAN bfd_boolean
7    #define MY_BFD_FALSE FALSE
8    #define MY_BFD_TRUE TRUE
9    
10    
11  static bfd *exe_bfd = NULL;  static bfd *exe_bfd = NULL;
12  struct bfd_link_info link_info;  struct bfd_link_info link_info;
# Line 50  int build_symbol_table_bfd ( char *oname Line 54  int build_symbol_table_bfd ( char *oname
54          char *c;          char *c;
55          if ( ( c = (char *) strstr ( q[u]->name, "_" ) ) ) {          if ( ( c = (char *) strstr ( q[u]->name, "_" ) ) ) {
56              struct bfd_link_hash_entry *h;              struct bfd_link_hash_entry *h;
57              if ( ! ( h = bfd_link_hash_lookup ( link_info.hash, q[u]->name, true, true, true ) ) )              if ( ( h = bfd_link_hash_lookup ( link_info.hash,
58                                                    q[u]->name, MY_BFD_TRUE,MY_BFD_TRUE,MY_BFD_TRUE ) ) ) {
59                    h->type=bfd_link_hash_defined;
60                    if ( !q[u]->section )
61                        fprintf ( stderr, "Symbol is missing section.\n" );
62                    h->u.def.value   = q[u]->value + q[u]->section->vma;
63                    h->u.def.section = q[u]->section;
64                    fprintf ( stderr, "Processed %s\n", q[u]->name );
65                } else {
66                  fprintf ( stderr, "Cannot make new hash entry.\n" );                  fprintf ( stderr, "Cannot make new hash entry.\n" );
67              h->type=bfd_link_hash_defined;              }
             if ( !q[u]->section )  
                 fprintf ( stderr, "Symbol is missing section.\n" );  
             h->u.def.value   = q[u]->value + q[u]->section->vma;  
             h->u.def.section = q[u]->section;  
             fprintf ( stderr, "Processed %s\n", q[u]->name );  
68          }          }
69      }      }
70  #else      #else    
# Line 66  int build_symbol_table_bfd ( char *oname Line 73  int build_symbol_table_bfd ( char *oname
73          if ((c=(char *)strstr(q[u]->name,"@@GLIBC\n" ))) {          if ((c=(char *)strstr(q[u]->name,"@@GLIBC\n" ))) {
74              struct bfd_link_hash_entry *h;              struct bfd_link_hash_entry *h;
75              *c=0;              *c=0;
76              if (!(h=bfd_link_hash_lookup(link_info.hash,q[u]->name,true,true,true)))              if (!(h=bfd_link_hash_lookup(link_info.hash,q[u]->name,MY_BFD_TRUE,MY_BFD_TRUE,MY_BFD_TRUE)))
77                  fprintf ( stderr, "Cannot make new hash entry.\n" );                  fprintf ( stderr, "Cannot make new hash entry.\n" );
78              h->type=bfd_link_hash_defined;              h->type=bfd_link_hash_defined;
79              if (!q[u]->section)              if (!q[u]->section)
# Line 96  static void * Line 103  static void *
103  #define ROUND_UP(a,b) round_up(a,b)  #define ROUND_UP(a,b) round_up(a,b)
104    
105    
106  static boolean  static MY_BFD_BOOLEAN
107      madd_archive_element (struct bfd_link_info * link_info,      madd_archive_element (struct bfd_link_info * link_info,
108                             bfd *abfd,                             bfd *abfd,
109                             const char *name) {                             const char *name) {
110          fprintf ( stderr, "madd_archive_element\n");          fprintf ( stderr, "madd_archive_element\n");
111          return false;          return MY_BFD_FALSE;
112    
113      }      }
114    
115  static boolean  static MY_BFD_BOOLEAN
116      mmultiple_definition (struct bfd_link_info * link_info,      mmultiple_definition (struct bfd_link_info * link_info,
117                             const char *name,                             const char *name,
118                             bfd *obfd,                             bfd *obfd,
# Line 116  static boolean Line 123  static boolean
123                             bfd_vma nval) {                             bfd_vma nval) {
124    
125          fprintf ( stderr, "mmultiple_definition\n");          fprintf ( stderr, "mmultiple_definition\n");
126          return false;          return MY_BFD_FALSE;
127    
128      }      }
129    
130  static boolean  static MY_BFD_BOOLEAN
131      mmultiple_common (struct bfd_link_info * link_info,      mmultiple_common (struct bfd_link_info * link_info,
132                         const char *name,                         const char *name,
133                         bfd *obfd,                         bfd *obfd,
# Line 131  static boolean Line 138  static boolean
138                         bfd_vma nsize) {                         bfd_vma nsize) {
139    
140          fprintf ( stderr, " mmultiple_common\n");          fprintf ( stderr, " mmultiple_common\n");
141          return false;          return MY_BFD_FALSE;
142    
143      }      }
144    
145  static boolean  static MY_BFD_BOOLEAN
146      madd_to_set (struct bfd_link_info * link_info,      madd_to_set (struct bfd_link_info * link_info,
147                    struct bfd_link_hash_entry *entry,                    struct bfd_link_hash_entry *entry,
148                    bfd_reloc_code_real_type reloc,                    bfd_reloc_code_real_type reloc,
149                    bfd *abfd, asection *sec, bfd_vma value) {                    bfd *abfd, asection *sec, bfd_vma value) {
150    
151          fprintf ( stderr, "madd_to_set\n");          fprintf ( stderr, "madd_to_set\n");
152          return false;          return MY_BFD_FALSE;
153    
154      }      }
155    
156  static  boolean  static  MY_BFD_BOOLEAN
157      mconstructor (struct bfd_link_info * link_info,boolean constructor,      mconstructor (struct bfd_link_info * link_info,MY_BFD_BOOLEAN constructor,
158                     const char *name, bfd *abfd, asection *sec,                     const char *name, bfd *abfd, asection *sec,
159                     bfd_vma value) {                     bfd_vma value) {
160    
161          fprintf ( stderr, "mconstructor\n");          fprintf ( stderr, "mconstructor\n");
162          return false;          return MY_BFD_FALSE;
163    
164      }      }
165    
166  static boolean  static MY_BFD_BOOLEAN
167      mwarning (struct bfd_link_info * link_info,      mwarning (struct bfd_link_info * link_info,
168                 const char *warning, const char *symbol,                 const char *warning, const char *symbol,
169                 bfd *abfd, asection *section,                 bfd *abfd, asection *section,
170                 bfd_vma address) {                 bfd_vma address) {
171    
172          fprintf ( stderr, "mwarning\n");          fprintf ( stderr, "mwarning\n");
173          return false;          return MY_BFD_FALSE;
174    
175      }      }
176    
177  static boolean  static MY_BFD_BOOLEAN
178      mundefined_symbol (struct bfd_link_info * link_info,      mundefined_symbol (struct bfd_link_info * link_info,
179                          const char *name, bfd *abfd,                          const char *name, bfd *abfd,
180                          asection *section,                          asection *section,
181                          bfd_vma address,                          bfd_vma address,
182                          boolean fatal) {                          MY_BFD_BOOLEAN fatal) {
183    
184          printf("mundefined_symbol %s is undefined\n",name);          printf("mundefined_symbol %s is undefined\n",name);
185          return false;          return MY_BFD_FALSE;
186      }      }
187    
188  static boolean  static MY_BFD_BOOLEAN
189      mreloc_overflow (struct bfd_link_info * link_info,      mreloc_overflow (struct bfd_link_info * link_info,
190                        const char *name,                        const char *name,
191                        const char *reloc_name, bfd_vma addend,                        const char *reloc_name, bfd_vma addend,
# Line 186  static boolean Line 193  static boolean
193                        bfd_vma address) {                        bfd_vma address) {
194    
195          printf("mreloc_overflow reloc for %s is overflowing\n",name);          printf("mreloc_overflow reloc for %s is overflowing\n",name);
196          return false;          return MY_BFD_FALSE;
197    
198      }      }
199    
200  static boolean  static MY_BFD_BOOLEAN
201      mreloc_dangerous (struct bfd_link_info * link_info,      mreloc_dangerous (struct bfd_link_info * link_info,
202                         const char *message,                         const char *message,
203                         bfd *abfd, asection *section,                         bfd *abfd, asection *section,
204                         bfd_vma address) {                         bfd_vma address) {
205    
206          printf("mreloc_dangerous reloc is dangerous %s\n",message);          printf("mreloc_dangerous reloc is dangerous %s\n",message);
207          return false;          return MY_BFD_FALSE;
208    
209      }      }
210    
211  static boolean  static MY_BFD_BOOLEAN
212      munattached_reloc (struct bfd_link_info * link_info,      munattached_reloc (struct bfd_link_info * link_info,
213                          const char *name,                          const char *name,
214                          bfd *abfd, asection *section,                          bfd *abfd, asection *section,
215                          bfd_vma address) {                          bfd_vma address) {
216    
217          fprintf ( stderr, " munattached_reloc\n");          fprintf ( stderr, " munattached_reloc\n");
218          return false;          return MY_BFD_FALSE;
219    
220      }      }
221    
222  static boolean  static MY_BFD_BOOLEAN
223      mnotice (struct bfd_link_info * link_info, const char *name,      mnotice (struct bfd_link_info * link_info, const char *name,
224                bfd *abfd, asection *section, bfd_vma address) {                bfd *abfd, asection *section, bfd_vma address) {
225    
226          fprintf ( stderr, "mnotice\n");          fprintf ( stderr, "mnotice\n");
227          return false;          return MY_BFD_FALSE;
228    
229      }      }
230    
# Line 310  int main ( int argc, char ** argv ) Line 317  int main ( int argc, char ** argv )
317    
318              current+=s->_raw_size;              current+=s->_raw_size;
319    
320              fprintf ( stderr, "Section %s: owner = %x, output_offset = %x, output_section = %x (%s)\n",              fprintf ( stderr,
321                        s->name, s->owner, s->output_offset, s->output_section, s->output_section->name );                        "Section %s: owner = %x, output_offset = %x, "
322                          "output_section = %x (%s)\n",
323                          s->name, s->owner, s->output_offset, s->output_section,
324                          s->output_section->name );
325          }          }
326    
327          fprintf ( stderr, "1\n");          fprintf ( stderr, "1\n");
# Line 353  int main ( int argc, char ** argv ) Line 363  int main ( int argc, char ** argv )
363              fprintf ( stderr, "Section address %x\n", s );              fprintf ( stderr, "Section address %x\n", s );
364              fprintf ( stderr, "m loop Section %s: owner = %x, output_offset = %x, "              fprintf ( stderr, "m loop Section %s: owner = %x, output_offset = %x, "
365                        "output_section = %x (%s), vma = %x, m = %x\n",                        "output_section = %x (%s), vma = %x, m = %x\n",
366                        s->name, s->owner, s->output_offset, s->output_section, s->output_section->name,                        s->name, s->owner, s->output_offset,
367                          s->output_section, s->output_section->name,
368                        s->output_section->vma, m );                        s->output_section->vma, m );
             
369          }          }
370    
371          fprintf ( stderr, "\n\nDOING SOMETHING WITH THE HASHED SYMBOLS\n\n" );          fprintf ( stderr, "\n\nDOING SOMETHING WITH THE HASHED SYMBOLS\n\n" );
# Line 376  int main ( int argc, char ** argv ) Line 386  int main ( int argc, char ** argv )
386                  continue;                  continue;
387              }              }
388    
389              if (!(h=bfd_link_hash_lookup(link_info.hash,q[u]->name, false, false, true)))              if (!(h=bfd_link_hash_lookup(link_info.hash,q[u]->name, MY_BFD_FALSE, MY_BFD_FALSE, MY_BFD_TRUE)))
390                  continue;                  continue;
391    
392              if (h->type!=bfd_link_hash_defined)              if (h->type!=bfd_link_hash_defined)

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26