annotate ticoff/reloc.c @ 118:193926ccd1ec

tiobjd: better handling of section-relative relocs
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Thu, 03 Apr 2014 07:47:03 +0000
parents 2f23301d2f86
children d88f2f40e3ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
82
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * Handling of relocation records
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdlib.h>
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include "filestruct.h"
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include "intstruct.h"
110
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
10 #include "coffconst.h"
82
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "globals.h"
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 extern unsigned get_u16(), get_u32();
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 cmd_rawrel()
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 {
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 unsigned n, m;
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 struct internal_scnhdr *sec;
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 struct external_reloc *rel;
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 get_int_section_table();
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 for (n = 0; n < nsections; n++) {
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 sec = sections + n;
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 if (!sec->nreloc)
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 continue;
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 printf("%s:\n\n", sec->name);
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 rel = (struct external_reloc *)(filemap + sec->reloc_offset);
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 printf("Location SymIndex Rsvd Type\n");
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 for (m = 0; m < sec->nreloc; m++, rel++)
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 printf("%08X %08X %04X %04X\n",
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 get_u32(rel->r_vaddr), get_u32(rel->r_symndx),
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 get_u16(rel->r_reserved), get_u16(rel->r_type));
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 putchar('\n');
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 }
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 exit(0);
c20dc315a9d4 tiobjd: beginning of reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 }
110
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
37
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
38 void
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
39 get_relocs_of_sec(sec)
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
40 struct internal_scnhdr *sec;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
41 {
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
42 unsigned n;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
43 struct external_reloc *extrel;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
44 struct internal_reloc *intrel;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
45 unsigned lastloc, symidx;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
46
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
47 if (sec->int_relocs)
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
48 return;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
49 if (!sec->nreloc) {
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
50 fprintf(stderr,
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
51 "BUG: get_relocs_of_sec() called for section \"%s\" w/o relocs\n",
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
52 sec->name);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
53 exit(1);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
54 }
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
55 intrel = malloc(sizeof(struct internal_reloc) * sec->nreloc);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
56 if (!intrel) {
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
57 perror("malloc");
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
58 exit(1);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
59 }
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
60 sec->int_relocs = intrel;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
61 extrel = (struct external_reloc *)(filemap + sec->reloc_offset);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
62 for (n = 0; n < sec->nreloc; n++, extrel++, intrel++) {
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
63 intrel->location = get_u32(extrel->r_vaddr);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
64 if (n && intrel->location <= lastloc) {
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
65 fprintf(stderr,
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
66 "error: non-increasing reloc order in section \"%s\"\n",
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
67 sec->name);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
68 exit(1);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
69 }
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
70 lastloc = intrel->location;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
71 symidx = get_u32(extrel->r_symndx);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
72 if (symidx >= nsymtab || !symtab[symidx]) {
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
73 fprintf(stderr,
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
74 "error: reloc references invalid symbol #%u in section \"%s\"\n",
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
75 symidx, sec->name);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
76 exit(1);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
77 }
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
78 intrel->sym = symtab[symidx];
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
79 intrel->type = get_u16(extrel->r_type);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
80 switch (intrel->type) {
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
81 case RTYPE_LONG:
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
82 intrel->typestr = "Word32";
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
83 break;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
84 case RTYPE_THUMB_BL:
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
85 intrel->typestr = "Thumb_BL";
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
86 break;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
87 case RTYPE_ARM_B:
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
88 intrel->typestr = "ARM_B";
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
89 break;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
90 default:
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
91 fprintf(stderr,
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
92 "error: reloc in section \"%s\" of unexpected type 0x%x\n",
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
93 sec->name, intrel->type);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
94 exit(1);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
95 }
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
96 if (get_u16(extrel->r_reserved))
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
97 fprintf(stderr,
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
98 "warning: reloc in section \"%s\" has non-zero reserved field\n",
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
99 sec->name);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
100 }
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
101 }
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
102
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
103 cmd_reloc()
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
104 {
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
105 unsigned n, m;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
106 struct internal_scnhdr *sec;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
107 struct internal_reloc *rel;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
108
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
109 get_int_section_table();
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
110 get_int_symbol_table();
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
111 for (n = 0; n < nsections; n++) {
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
112 sec = sections + n;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
113 if (!sec->nreloc)
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
114 continue;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
115 printf("%s:\n\n", sec->name);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
116 get_relocs_of_sec(sec);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
117 rel = sec->int_relocs;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
118 printf("Location Type Symbol relative to\n");
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
119 for (m = 0; m < sec->nreloc; m++, rel++)
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
120 printf("%08X %-8s %s\n", rel->location, rel->typestr,
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
121 rel->sym->name);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
122 putchar('\n');
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
123 }
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
124 exit(0);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
125 }
113
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
126
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
127 struct internal_reloc *
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
128 find_reloc(sec, loc)
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
129 struct internal_scnhdr *sec;
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
130 unsigned loc;
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
131 {
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
132 struct internal_reloc *rel;
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
133 unsigned m;
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
134
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
135 rel = sec->int_relocs;
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
136 for (m = 0; m < sec->nreloc; m++, rel++) {
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
137 if (rel->location == loc)
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
138 return(rel);
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
139 if (rel->location > loc)
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
140 return(0);
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
141 }
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
142 return(0);
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
143 }
115
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
144
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
145 struct internal_reloc *
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
146 find_word32_reloc(sec, loc)
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
147 struct internal_scnhdr *sec;
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
148 unsigned loc;
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
149 {
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
150 struct internal_reloc *rel;
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
151
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
152 rel = find_reloc(sec, loc);
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
153 if (rel && rel->type != RTYPE_LONG)
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
154 rel = 0;
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
155 return(rel);
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
156 }