~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to unixport/rsym_nt.c

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* defining IN_SFASL gets us fopen_binary  */
 
2
#define IN_RSYM
 
3
 
 
4
#include "config.h"
 
5
#include <stdio.h>
 
6
#include "ext_sym.h"
 
7
 
 
8
 
 
9
 
 
10
 
 
11
struct lsymbol_table tab;
 
12
 
 
13
int main(int argc,char *argv[],char **envp)
 
14
{
 
15
    char buf[1000];
 
16
    char *in = argv[1];
 
17
    char *out = argv[2];
 
18
    if ( argc != 3 ) {
 
19
        perror("bad arg count");
 
20
        fflush(stdout);
 
21
        exit(1);
 
22
    }
 
23
 
 
24
    fprintf ( stderr, "rsym_nt: %s %s\n", in, out );
 
25
    sprintf ( buf, "nm -g %s > _rsym1", argv[1] );
 
26
    if ( system ( buf ) ) {
 
27
        printf("failed: %s", buf);
 
28
        exit(1);
 
29
    }
 
30
    {
 
31
        FILE *fp = fopen("_rsym1","rb");
 
32
        FILE *symout;
 
33
        char buf1[1000];
 
34
        symout = fopen ( out, "wb" );
 
35
        if ( !symout ) {
 
36
            perror ( out );
 
37
            exit ( 1 );
 
38
        };
 
39
        tab.n_symbols=0;
 
40
        tab.tot_leng=0;
 
41
        fseek( symout, sizeof ( struct lsymbol_table ), 0 );
 
42
        {
 
43
            int addr;
 
44
            char ch;
 
45
            char *name;
 
46
            char name1[1000];
 
47
 
 
48
            while (1) {
 
49
                name = name1;
 
50
                fgets(buf1,sizeof(buf1),fp);
 
51
                if ( 3 == sscanf ( buf1, "%x %c %s", &addr, &ch, name )
 
52
                     && ch != '?' ) {
 
53
                    tab.n_symbols++;
 
54
                    fwrite ( (char *)&addr, sizeof ( int ), 1, symout );
 
55
                    while ( tab.tot_leng++, *name )
 
56
                        putc ( *name++, symout );
 
57
                    putc ( 0, symout );
 
58
                }
 
59
                if ( feof ( fp ) ) break;
 
60
            }
 
61
            fseek ( symout, 0, 0 );
 
62
            fwrite ( &tab, sizeof ( tab ), 1, symout );
 
63
            
 
64
            fclose ( symout );
 
65
        }
 
66
    }
 
67
    exit ( 0 );
 
68
}