RIP gzip, we found a nicer playmate.
[dragonfly.git] / gnu / usr.bin / ld / sparc / md-static-funcs.c
1
2 /*
3  * $FreeBSD: src/gnu/usr.bin/ld/sparc/md-static-funcs.c,v 1.5 1999/08/27 23:36:04 peter Exp $
4  * $DragonFly: src/gnu/usr.bin/ld/sparc/Attic/md-static-funcs.c,v 1.2 2003/06/17 04:25:46 dillon Exp $
5  *
6  * Simple SPARC relocations for the benefit of self-relocation of ld.so
7  * avoiding the use of global variables (ie. reloc_bitshift[] et. al.).
8  * Only types supported are RELOC_32 and RELOC_RELATIVE.
9  *
10  * This *must* be a static function, so it is not called through a jmpslot.
11  */
12 static void
13 md_relocate_simple(r, relocation, addr)
14 struct relocation_info  *r;
15 long                    relocation;
16 char                    *addr;
17 {
18         register unsigned long  mask;
19         register unsigned long  shift;
20
21         switch (r->r_type) {
22         case RELOC_32:
23                 mask = 0xffffffff;
24                 shift = 0;
25                 break;
26         case RELOC_RELATIVE:
27                 mask = 0x003fffff;
28                 shift = 10;
29                 break;
30         }
31         relocation += (*(long *)addr & mask) << shift;
32         relocation >>= shift;
33         relocation &= mask;
34
35         *(long *) (addr) &= ~mask;
36         *(long *) (addr) |= relocation;
37 }
38