OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [ldso/] [ldso/] [arm/] [ld_sysdep.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/*
2
 * Various assmbly language/system dependent  hacks that are required
3
 * so that we can minimize the amount of platform specific code.
4
 */
5
 
6
/*
7
 * Define this if the system uses RELOCA.
8
 */
9
#undef ELF_USES_RELOCA
10
 
11
/*
12
 * Get a pointer to the argv array.  On many platforms this can be just
13
 * the address if the first argument, on other platforms we need to
14
 * do something a little more subtle here.
15
 */
16
#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long*)   ARGS)
17
 
18
/*
19
 * Initialization sequence for a GOT.
20
 */
21
#define INIT_GOT(GOT_BASE,MODULE) \
22
{                               \
23
  GOT_BASE[2] = (unsigned long) _dl_linux_resolve; \
24
  GOT_BASE[1] = (unsigned long) MODULE; \
25
}
26
 
27
/*
28
 * Here is a macro to perform a relocation.  This is only used when
29
 * bootstrapping the dynamic loader.  RELP is the relocation that we
30
 * are performing, REL is the pointer to the address we are relocating.
31
 * SYMBOL is the symbol involved in the relocation, and LOAD is the
32
 * load address.
33
 */
34
#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB)    \
35
        switch(ELF32_R_TYPE((RELP)->r_info)){                   \
36
        case R_ARM_ABS32:                                       \
37
          *REL += SYMBOL;                                       \
38
          break;                                                \
39
        case R_ARM_PC24:                                        \
40
            { long newvalue, topbits;                           \
41
            unsigned long addend = *REL & 0x00ffffff;           \
42
            if (addend & 0x00800000) addend |= 0xff000000;      \
43
            newvalue=SYMBOL-(unsigned long)REL+(addend<<2);     \
44
            topbits = newvalue & 0xfe000000;                    \
45
            if (topbits!=0xfe000000&&topbits!=0x00000000){      \
46
            newvalue = fix_bad_pc24(REL, SYMBOL)                \
47
                -(unsigned long)REL+(addend<<2);                \
48
            topbits = newvalue & 0xfe000000;                    \
49
            if (topbits!=0xfe000000&&topbits!=0x00000000){      \
50
            SEND_STDERR("R_ARM_PC24 relocation out of range\n");\
51
            _dl_exit(1); } }                                    \
52
            newvalue>>=2;                                       \
53
            SYMBOL=(*REL&0xff000000)|(newvalue & 0x00ffffff);   \
54
            *REL=SYMBOL;                                        \
55
            }                                                   \
56
          break;                                                \
57
        case R_ARM_GLOB_DAT:                                    \
58
        case R_ARM_JUMP_SLOT:                                   \
59
          *REL = SYMBOL;                                        \
60
          break;                                                \
61
        case R_ARM_RELATIVE:                                    \
62
          *REL += (unsigned long) LOAD;                         \
63
          break;                                                \
64
        case R_ARM_NONE:                                        \
65
          break;                                                \
66
        default:                                                \
67
          SEND_STDERR("Aiieeee!");                              \
68
          _dl_exit(1);                                          \
69
        }
70
 
71
 
72
/*
73
 * Transfer control to the user's application, once the dynamic loader
74
 * is done.  This routine has to exit the current function, then
75
 * call the _dl_elf_main function.
76
 */
77
 
78
#define START()   return _dl_elf_main;      
79
 
80
 
81
 
82
/* Here we define the magic numbers that this dynamic loader should accept */
83
 
84
#define MAGIC1 EM_ARM
85
#undef  MAGIC2
86
/* Used for error messages */
87
#define ELF_TARGET "ARM"
88
 
89
struct elf_resolve;
90
unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
91
 
92
static inline unsigned long arm_modulus(unsigned long m, unsigned long p) {
93
        unsigned long i,t,inc;
94
        i=p; t=0;
95
        while(!(i&(1<<31))) {
96
                i<<=1;
97
                t++;
98
        }
99
        t--;
100
        for(inc=t;inc>2;inc--) {
101
                i=p<<inc;
102
                if(i&(1<<31))
103
                        break;
104
                while(m>=i) {
105
                        m-=i;
106
                        i<<=1;
107
                        if(i&(1<<31))
108
                                break;
109
                        if(i<p)
110
                                break;
111
                }
112
        }
113
        while(m>=p) {
114
                m-=p;
115
        }
116
        return m;
117
}
118
 
119
#define do_rem(result, n, base)  result=arm_modulus(n,base);
120
 
121
/* 4096 bytes alignment */
122
#define PAGE_ALIGN 0xfffff000
123
#define ADDR_ALIGN 0xfff
124
#define OFFS_ALIGN 0x7ffff000

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.