1 /*
2 * Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5
6 #include "runtime_loader_private.h"
7
8 #include <runtime_loader.h>
9
10 #include <string.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13
14
15 //#define TRACE_RLD
16 #ifdef TRACE_RLD
17 # define TRACE(x) dprintf x
18 #else
19 # define TRACE(x) ;
20 #endif
21
22
23 static int
relocate_rel(image_t * rootImage,image_t * image,Elf32_Rel * rel,int rel_len,SymbolLookupCache * cache)24 relocate_rel(image_t *rootImage, image_t *image, Elf32_Rel *rel, int rel_len,
25 SymbolLookupCache* cache)
26 {
27 // ToDo: implement me!
28
29 return B_NO_ERROR;
30 }
31
32
33 status_t
arch_relocate_image(image_t * rootImage,image_t * image,SymbolLookupCache * cache)34 arch_relocate_image(image_t *rootImage, image_t *image,
35 SymbolLookupCache* cache)
36 {
37 status_t status = B_NO_ERROR;
38
39 // deal with the rels first
40 if (image->rel) {
41 status = relocate_rel(rootImage, image, image->rel, image->rel_len,
42 cache);
43 if (status < B_OK)
44 return status;
45 }
46
47 if (image->pltrel) {
48 status = relocate_rel(rootImage, image, image->pltrel,
49 image->pltrel_len, cache);
50 if (status < B_OK)
51 return status;
52 }
53
54 if (image->rela) {
55 //int i;
56 printf("RELA relocations not supported\n");
57 return EOPNOTSUPP;
58
59 //for (i = 1; i * (int)sizeof(Elf32_Rela) < image->rela_len; i++) {
60 // printf("rela: type %d\n", ELF32_R_TYPE(image->rela[i].r_info));
61 //}
62 }
63
64 return B_OK;
65 }
66