/[gcl]/gcl/o/sfasli.c
ViewVC logotype

Diff of /gcl/o/sfasli.c

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

revision 1.2 by camm, Sun Feb 3 18:44:08 2002 UTC revision 1.3 by camm, Wed Jun 12 23:56:59 2002 UTC
# Line 2  Line 2 
2  /*  /*
3  Copyright William Schelter. All rights reserved. */  Copyright William Schelter. All rights reserved. */
4    
5    #if !defined(HAVE_LIBBFD) && !defined(SPECIAL_RSYM)
6    #error Need either BFD or SPECIAL_RSYM
7    #endif
8    
9    #ifdef SPECIAL_RSYM
10    
11  int node_compare();  int node_compare();
12    
# Line 20  find_sym_ptable(name) Line 24  find_sym_ptable(name)
24   }   }
25                
26    
27  build_symbol_table()  #else
28  { char tmpfile1[50];  
29    /* Replace this with gcl's own hash structure at some point */
30    int
31    build_symbol_table_bfd(void) {
32    
33      int u,v;
34      asymbol **q;
35    
36      bfd_init();
37      if (!(bself=bfd_openr(kcl_self,0)))
38        FEerror("Cannot open self\n");
39      if (!bfd_check_format(bself,bfd_object))
40        FEerror("I'm not an object");
41    /*    if (link_info.hash) */
42    /*      bfd_link_hash_table_free(bself,link_info.hash); */
43      if (!(link_info.hash = bfd_link_hash_table_create (bself)))
44        FEerror("Cannot make hash table");
45      if (!bfd_link_add_symbols(bself,&link_info))
46        FEerror("Cannot add self symbols\n");
47      if ((u=bfd_get_symtab_upper_bound(bself))<0)
48        FEerror("Cannot get self's symtab upper bound");
49    #ifdef HAVE_ALLOC
50      q=(asymbol **)alloca(u);
51    #else
52      q=(asymbol **)malloc(u);
53    #endif
54      if ((v=bfd_canonicalize_symtab(bself,q))<0)
55        FEerror("Cannot canonicalize self's symtab");
56      for (u=0;u<v;u++) {
57        char *c;
58        if ((c=(char *)strstr(q[u]->name,"@@GLIBC"))) {
59          struct bfd_link_hash_entry *h;
60          *c=0;
61          if (!(h=bfd_link_hash_lookup(link_info.hash,q[u]->name,true,true,true)))
62            FEerror("Cannot make new hash entry");
63          h->type=bfd_link_hash_defined;
64          if (!q[u]->section)
65            FEerror("Symbol is missing section");
66          h->u.def.value=q[u]->value+q[u]->section->vma;
67          h->u.def.section=q[u]->section;
68          *c='@';
69        }
70      }
71    #ifndef HAVE_ALLOCA
72      free(q);
73    #endif
74    
75      return 0;
76      
77    }
78    
79    #endif /* special_rsym */
80    
81    int
82    build_symbol_table(void) {
83    
84      char tmpfile1[50];
85    char command [250];    char command [250];
86    
87    printf("Building symbol table for %s ..\n",kcl_self);fflush(stdout);    printf("Building symbol table for %s ..\n",kcl_self);fflush(stdout);
88    
89    #ifdef SPECIAL_RSYM
90    
91    sprintf(tmpfile1,"rsym%d",getpid());    sprintf(tmpfile1,"rsym%d",getpid());
92  #ifndef STAND  #ifndef STAND
93    coerce_to_filename(symbol_value(sSAsystem_directoryA),    coerce_to_filename(symbol_value(sSAsystem_directoryA),
# Line 44  build_symbol_table() Line 108  build_symbol_table()
108    read_special_symbols(tmpfile1);    read_special_symbols(tmpfile1);
109    unlink(tmpfile1);    unlink(tmpfile1);
110    qsort((char*)(c_table.ptable),(int)(c_table.length),sizeof(struct node),node_compare);    qsort((char*)(c_table.ptable),(int)(c_table.length),sizeof(struct node),node_compare);
111    
112    #else /* special_rsym */
113    
114      build_symbol_table_bfd();
115    
116    #endif
117    
118  }  }
119    

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