annotate leo-obj/tool/reloc.c @ 206:11761eaf712c

old Calypso F741979B boot ROM analyzed
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Wed, 30 Dec 2015 08:27:46 +0000
parents 87b82398a08b
children
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);
121
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 115
diff changeset
72 if (symidx == 0xFFFFFFFF)
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 115
diff changeset
73 intrel->sym = 0;
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 115
diff changeset
74 else if (symidx >= nsymtab || !symtab[symidx]) {
110
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
75 fprintf(stderr,
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
76 "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
77 symidx, sec->name);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
78 exit(1);
121
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 115
diff changeset
79 } else
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 115
diff changeset
80 intrel->sym = symtab[symidx];
110
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
81 intrel->type = get_u16(extrel->r_type);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
82 switch (intrel->type) {
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
83 case RTYPE_LONG:
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
84 intrel->typestr = "Word32";
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
85 break;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
86 case RTYPE_THUMB_BL:
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
87 intrel->typestr = "Thumb_BL";
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
88 break;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
89 case RTYPE_ARM_B:
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
90 intrel->typestr = "ARM_B";
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
91 break;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
92 default:
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
93 fprintf(stderr,
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
94 "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
95 sec->name, intrel->type);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
96 exit(1);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
97 }
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
98 if (get_u16(extrel->r_reserved))
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
99 fprintf(stderr,
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
100 "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
101 sec->name);
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 }
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 cmd_reloc()
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
106 {
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
107 unsigned n, m;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
108 struct internal_scnhdr *sec;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
109 struct internal_reloc *rel;
121
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 115
diff changeset
110 char *symname;
110
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
111
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
112 get_int_section_table();
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
113 get_int_symbol_table();
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
114 for (n = 0; n < nsections; n++) {
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
115 sec = sections + n;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
116 if (!sec->nreloc)
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
117 continue;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
118 printf("%s:\n\n", sec->name);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
119 get_relocs_of_sec(sec);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
120 rel = sec->int_relocs;
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
121 printf("Location Type Symbol relative to\n");
121
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 115
diff changeset
122 for (m = 0; m < sec->nreloc; m++, rel++) {
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 115
diff changeset
123 if (rel->sym)
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 115
diff changeset
124 symname = rel->sym->name;
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 115
diff changeset
125 else
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 115
diff changeset
126 symname = "<none>";
110
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
127 printf("%08X %-8s %s\n", rel->location, rel->typestr,
121
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 115
diff changeset
128 symname);
d88f2f40e3ae tiobjd: handling of symbol-less relocs
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 115
diff changeset
129 }
110
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
130 putchar('\n');
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
131 }
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
132 exit(0);
e650fdc743fe tiobjd: higher-level reloc handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 82
diff changeset
133 }
113
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 struct internal_reloc *
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
136 find_reloc(sec, loc)
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
137 struct internal_scnhdr *sec;
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
138 unsigned loc;
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
139 {
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
140 struct internal_reloc *rel;
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
141 unsigned m;
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
142
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
143 rel = sec->int_relocs;
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
144 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
145 if (rel->location == loc)
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
146 return(rel);
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
147 if (rel->location > loc)
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
148 return(0);
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
149 }
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
150 return(0);
d97fbe98600b tiobjd: recognizing relocs in ldr literals
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 110
diff changeset
151 }
115
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
152
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
153 struct internal_reloc *
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
154 find_word32_reloc(sec, loc)
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
155 struct internal_scnhdr *sec;
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
156 unsigned loc;
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
157 {
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
158 struct internal_reloc *rel;
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
159
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
160 rel = find_reloc(sec, loc);
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
161 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
162 rel = 0;
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
163 return(rel);
2f23301d2f86 tiobjd: literal reloc recognition restricted to RTYPE_LONG
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 113
diff changeset
164 }