Usermode/ld-acess - Added two more ARM relocation types
authorJohn Hodge <[email protected]>
Thu, 17 Nov 2011 14:13:17 +0000 (22:13 +0800)
committerJohn Hodge <[email protected]>
Thu, 17 Nov 2011 14:13:17 +0000 (22:13 +0800)
Usermode/Libraries/ld-acess.so_src/elf.c
Usermode/Libraries/ld-acess.so_src/elf32.h

index 3bc159e..5550ba2 100644 (file)
@@ -296,6 +296,11 @@ void *Elf32Relocate(void *Base, char **envp, const char *Filename)
                switch(type)
                {
                // (S + A) | T
+               case R_ARM_ABS32:
+                       DEBUGS(" elf_doRelocate_arm: R_ARM_ABS32 %p (%s + %x)", ptr, Sym, addend);
+                       val = (intptr_t)GetSymbol(Sym, NULL);
+                       *ptr = val + addend;
+                       break;
                case R_ARM_GLOB_DAT:
                        DEBUGS(" elf_doRelocate_arm: R_ARM_GLOB_DAT %p (%s + %x)", ptr, Sym, addend);
                        val = (intptr_t)GetSymbol(Sym, NULL);
@@ -307,12 +312,23 @@ void *Elf32Relocate(void *Base, char **envp, const char *Filename)
                        val = (intptr_t)GetSymbol(Sym, NULL);
                        *ptr = val + addend;
                        break;
+               // Copy
                case R_ARM_COPY: {
                        size_t  size;
                        void    *src = GetSymbol(Sym, &size);
                        DEBUGS(" elf_doRelocate_arm: R_ARM_COPY (%p, %p, %i)", ptr, src, size);
                        memcpy(ptr, src, size);
                        break; }
+               // Delta between link and runtime locations + A
+               case R_ARM_RELATIVE:
+                       if(Sym[0] != '\0') {
+                               // TODO: Get delta for a symbol
+                               SysDebug("elf_doRelocate_arm: TODO - Implment R_ARM_RELATIVE for symbols");
+                       }
+                       else {
+                               *ptr = iBaseDiff + addend;
+                       }
+                       break;
                default:
                        SysDebug("elf_doRelocate_arm: Unknown Relocation, %i", type);
                        break;
index 0808747..3018a89 100644 (file)
@@ -174,30 +174,30 @@ enum {
 //  'T' means the thumb bit
 //  'B(S)' Origin of a symbol
 enum {
-       R_ARM_NONE,     // No action
-       R_ARM_PC24,     // ((S + A) | T) - P
-       R_ARM_ABS32,    // (S + A) | T
-       R_ARM_REL32,    // ((S + A) | T) - P
-       R_ARM_LDR_PC_G0,        // S + A - P
-       R_ARM_ABS16,    // S + A
-       R_ARM_ABS12,    // S + A
-       R_ARM_THM_ABS5, // S + A
-       R_ARM_ABS8,     // S + A
-       R_ARM_SBREL32,  // ((S + A) | T) - B(S)
-       R_ARM_THM_CALL, // ((S + A) | T) - P
-       R_ARM_THM_PC8,  // S + A - Pa,
-       R_ARM_BREL_ADJ, // ΔB(S) + A
-       R_ARM_TLS_DESC, // --
-       R_ARM_THM_SWI8, // (Reserved)
-       R_ARM_XPC25,    // (Reserved)
-       R_ARM_THM_XPC22,        // (Reserved)
-       R_ARM_TLS_DTPMOD32,     // Module[S]
-       R_ARM_TLS_DTPOFF32,     // S + A - TLS
-       R_ARM_TLS_TPOFF32,      // S + A - tp
-       R_ARM_COPY,     // Misc
-       R_ARM_GLOB_DAT, // (S + A) | T
-       R_ARM_JUMP_SLOT,        // (S + A) | T
-       R_ARM_RELATIVE, // B(S) + A (extra?)
+       R_ARM_NONE,     //  0 No action
+       R_ARM_PC24,     //  1 ((S + A) | T) - P
+       R_ARM_ABS32,    //  2 (S + A) | T
+       R_ARM_REL32,    //  3 ((S + A) | T) - P
+       R_ARM_LDR_PC_G0,        //  4 S + A - P
+       R_ARM_ABS16,    //  5 S + A
+       R_ARM_ABS12,    //  6 S + A
+       R_ARM_THM_ABS5, //  7 S + A
+       R_ARM_ABS8,     //  8 S + A
+       R_ARM_SBREL32,  //  9 ((S + A) | T) - B(S)
+       R_ARM_THM_CALL, // 10 ((S + A) | T) - P
+       R_ARM_THM_PC8,  // 11 S + A - Pa,
+       R_ARM_BREL_ADJ, // 12 ΔB(S) + A
+       R_ARM_TLS_DESC, // 13 --
+       R_ARM_THM_SWI8, // 14 (Reserved)
+       R_ARM_XPC25,    // 15 (Reserved)
+       R_ARM_THM_XPC22,        // 16 (Reserved)
+       R_ARM_TLS_DTPMOD32,     // 17 Module[S]
+       R_ARM_TLS_DTPOFF32,     // 18 S + A - TLS
+       R_ARM_TLS_TPOFF32,      // 19 S + A - tp
+       R_ARM_COPY,     // 20 Misc
+       R_ARM_GLOB_DAT, // 21 (S + A) | T
+       R_ARM_JUMP_SLOT,        // 22 (S + A) | T
+       R_ARM_RELATIVE, // 23 B(S) + A (extra?)
        // ... More defined (IHI0044)
 };
 

UCC git Repository :: git.ucc.asn.au