FreeCalypso > hg > freecalypso-reveng
comparison objgrep/dumpmatch.c @ 173:77cd647375e5
objgrep -r: dump symbols in other sections recovered through relocs
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Fri, 04 Jul 2014 06:34:33 +0000 |
parents | 452baa748747 |
children |
comparison
equal
deleted
inserted
replaced
172:452baa748747 | 173:77cd647375e5 |
---|---|
67 dest |= 0xFF800000; | 67 dest |= 0xFF800000; |
68 dest += location + 4; | 68 dest += location + 4; |
69 return(dest); | 69 return(dest); |
70 } | 70 } |
71 | 71 |
72 dump_relocs_on_match() | 72 process_relocs_on_match() |
73 { | 73 { |
74 unsigned n, value; | 74 unsigned n, value; |
75 struct internal_reloc *rel; | 75 struct internal_reloc *rel; |
76 | 76 |
77 printf("\nDeduced from relocs:\n\n"); | |
78 for (n = 0, rel = relocs; n < grep_section->nreloc; n++, rel++) { | 77 for (n = 0, rel = relocs; n < grep_section->nreloc; n++, rel++) { |
79 switch (rel->type) { | 78 switch (rel->type) { |
80 case RTYPE_LONG: | 79 case RTYPE_LONG: |
81 value = get_u32(binfilemap + match_offset + | 80 value = get_u32(binfilemap + match_offset + |
82 rel->location); | 81 rel->location); |
91 fprintf(stderr, | 90 fprintf(stderr, |
92 "BUG in dump_relocs_on_match(): bad reloc type\n"); | 91 "BUG in dump_relocs_on_match(): bad reloc type\n"); |
93 abort(); | 92 abort(); |
94 } | 93 } |
95 value -= rel->addend; | 94 value -= rel->addend; |
96 if (rel->secbase) | 95 rel->symvalue = value; |
97 printf("%s:%s = %08X\n", objfilename, | 96 if (rel->secbase) { |
98 rel->secbase->name, value); | 97 if (!rel->secbase->recov_flag) { |
99 else if (rel->extsym) | 98 rel->secbase->recov_flag = 1; |
100 printf("%s = %08X\n", rel->extsym->name, value); | 99 rel->secbase->recov_addr = value; |
101 else { | 100 } else if (rel->secbase->recov_addr != value) |
102 fprintf(stderr, | 101 printf("Multiple addresses for %s:%s: %08X, %08X\n", |
103 "BUG in dump_relocs_on_match(): no base for reloc\n"); | 102 objfilename, rel->secbase->name, |
104 abort(); | 103 rel->secbase->recov_addr, value); |
105 } | 104 } |
106 } | 105 } |
107 } | 106 } |
107 | |
108 dump_ext_relocs_on_match() | |
109 { | |
110 unsigned n; | |
111 struct internal_reloc *rel; | |
112 | |
113 printf("\nExternals deduced from relocs:\n\n"); | |
114 for (n = 0, rel = relocs; n < grep_section->nreloc; n++, rel++) | |
115 if (rel->extsym) | |
116 printf("%s = %08X\n", rel->extsym->name, rel->symvalue); | |
117 } | |
118 | |
119 dump_reloc_symtab_on_match() | |
120 { | |
121 unsigned n; | |
122 struct internal_syment *sym; | |
123 | |
124 printf("\nThis module's symbols deduced from section relocs:\n\n"); | |
125 for (n = 0; n < nsymtab; n++) { | |
126 sym = symtab[n]; | |
127 if (!sym || !sym->section) | |
128 continue; | |
129 if (!sym->section->recov_flag) | |
130 continue; | |
131 switch (sym->class) { | |
132 case C_EXT: | |
133 printf("%s = %08X\n", sym->name, | |
134 sym->value + sym->section->recov_addr); | |
135 continue; | |
136 case C_STAT: | |
137 printf("%s:%s = %08X\n", objfilename, sym->name, | |
138 sym->value + sym->section->recov_addr); | |
139 continue; | |
140 } | |
141 } | |
142 } |