~ubuntu-branches/ubuntu/vivid/gcl/vivid

« back to all changes in this revision

Viewing changes to o/rel_coff.c

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2002-03-04 14:29:59 UTC
  • Revision ID: james.westby@ubuntu.com-20020304142959-dey14w08kr7lldu3
Tags: upstream-2.5.0.cvs20020219
ImportĀ upstreamĀ versionĀ 2.5.0.cvs20020219

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/* Copyright William Schelter. All rights reserved.  This file does
 
3
the low level relocation which tends to be very system dependent.
 
4
It is included by the file sfasl.c
 
5
*/
 
6
 
 
7
 
 
8
relocate()
 
9
{
 
10
  char *where;
 
11
  describe_sym(relocation_info.r_symndx);
 
12
  where = the_start + relocation_info.r_vaddr;
 
13
  dprintf (where has %x , *where);
 
14
  dprintf(   at %x -->, where );
 
15
 
 
16
  if (relocation_info.r_type == R_ABS)
 
17
    { dprintf( r_abs ,0)  return; }
 
18
  switch(relocation_info.r_type)
 
19
    { int *q;
 
20
    case R_DIR32:
 
21
      dprintf(new val r_dir32 %x ,  *((int *)where) + 
 
22
              symbol_table[relocation_info.r_symndx].n_value);
 
23
      *(int *)where= *((int *)where) + 
 
24
        symbol_table[relocation_info.r_symndx].n_value;
 
25
      break;
 
26
    case R_PCRLONG:
 
27
 
 
28
      dprintf( r_pcrlong new value = %x ,
 
29
              *((int *)where)  - (int)start_address
 
30
              + symbol_table[relocation_info.r_symndx].n_value );
 
31
#ifdef WINDOWSNT
 
32
      /* the following is logical, except the address offset is
 
33
         not where the 'where' is but where the 'call' is just
 
34
         AFTER the 'where'.
 
35
      */
 
36
      *(int *)where=   symbol_table[relocation_info.r_symndx].n_value
 
37
        - (int) where - sizeof(int *);
 
38
#else      
 
39
            *(int *)where=  *((int *)where)  - (int)start_address
 
40
        + symbol_table[relocation_info.r_symndx].n_value;
 
41
#endif  
 
42
 
 
43
      break;
 
44
    default:
 
45
      fprintf(stdout, "%d: unsupported relocation type.",
 
46
              relocation_info.r_type);
 
47
      FEerror("The relocation type was unknown",0,0);
 
48
    }
 
49
 
 
50
}
 
51
 
 
52
 
 
53
 
 
54
 
 
55
#ifdef DEBUG
 
56
 
 
57
#define describe_sym describe_sym1
 
58
describe_sym1(n)
 
59
int n;
 
60
{char *str;
 
61
 char tem[9];
 
62
 struct syment *sym;
 
63
 sym= &symbol_table[n];
 
64
 str= sym->n_zeroes == 0 ?
 
65
   &my_string_table[sym->n_offset] :
 
66
 (sym->n_name[SYMNMLEN -1] ?
 
67
  /* MAKE IT NULL TERMINATED */
 
68
  (strncpy(tem,sym->n_name,
 
69
           SYMNMLEN),tem):
 
70
  sym->n_name );
 
71
 printf ("sym-index = %d table entry at %x",n,&symbol_table[n]);
 
72
 printf("symbol is (%s):\nsymbol_table[n]._n._n_name %s\nsymbol_table[n]._n._n_n._n_zeroes %d\nsymbol_table[n]._n._n_n._n_offset %d\nsymbol_table[n]._n._n_nptr[0] %d\nsymbol_table[n]._n._n_nptr[n] %d\nsymbol_table[n].n_value %d\nsymbol_table[n].n_scnum %d
 
73
\nsymbol_table[n].n_type %d\nsymbol_table[n].n_sclass %d\nsymbol_table[n].n_numaux %d", str,
 
74
        symbol_table[n]._n._n_name,
 
75
        symbol_table[n]._n._n_n._n_zeroes ,
 
76
        symbol_table[n]._n._n_n._n_offset ,
 
77
        symbol_table[n]._n._n_nptr[0] ,
 
78
        symbol_table[n]._n._n_nptr[1] ,
 
79
        symbol_table[n].n_value ,
 
80
        symbol_table[n].n_scnum ,
 
81
        symbol_table[n].n_type ,
 
82
        symbol_table[n].n_sclass ,
 
83
        symbol_table[n].n_numaux );
 
84
}
 
85
 
 
86
#endif