Line 369... |
Line 369... |
void readsyms_coff(char *filename, unsigned long symptr, long syms)
|
void readsyms_coff(char *filename, unsigned long symptr, long syms)
|
{
|
{
|
FILE *inputfs;
|
FILE *inputfs;
|
struct COFF_syment coffsymhdr;
|
struct COFF_syment coffsymhdr;
|
int breakpoint = 0;
|
int breakpoint = 0;
|
|
int count = 0;
|
|
long nsyms = syms;
|
if (!(inputfs = fopen(filename, "r"))) {
|
if (!(inputfs = fopen(filename, "r"))) {
|
perror("readsyms_coff");
|
perror("readsyms_coff");
|
exit(1);
|
exit(1);
|
}
|
}
|
|
|
Line 382... |
Line 383... |
perror("readsyms_coff");
|
perror("readsyms_coff");
|
exit(1);
|
exit(1);
|
}
|
}
|
|
|
while(syms--) {
|
while(syms--) {
|
|
int i, n;
|
if (fread(&coffsymhdr, COFF_SYMESZ, 1, inputfs) != 1) {
|
if (fread(&coffsymhdr, COFF_SYMESZ, 1, inputfs) != 1) {
|
fclose(inputfs);
|
fclose(inputfs);
|
perror("readsyms_coff");
|
perror("readsyms_coff");
|
exit(1);
|
exit(1);
|
}
|
}
|
debug("Symbol: %s,", coffsymhdr.e.e_name);
|
|
debug(" val: 0x%.8x,", COFF_LONG_H(coffsymhdr.e_value));
|
n = (unsigned char)coffsymhdr.e_numaux[0];
|
debug(" auxs: %c\n", coffsymhdr.e_numaux);
|
/* If not important or not in text, skip. */
|
|
if (COFF_SHORT_H(coffsymhdr.e_type) & COFF_N_TMASK & COFF_STYP_TEXT) {
|
|
|
|
if (*((unsigned long *)coffsymhdr.e.e.e_zeroes)) {
|
if (strlen(coffsymhdr.e.e_name) && strlen(coffsymhdr.e.e_name) < 9)
|
if (strlen(coffsymhdr.e.e_name) && strlen(coffsymhdr.e.e_name) < 9)
|
addlabel(coffsymhdr.e.e_name, COFF_LONG_H(coffsymhdr.e_value),&breakpoint);
|
addlabel(coffsymhdr.e.e_name, COFF_LONG_H(coffsymhdr.e_value),&breakpoint);
|
|
debug("[%i] Symbol: %s,", count++, coffsymhdr.e.e_name);
|
|
} else {
|
|
long fpos = ftell (inputfs);
|
|
|
|
if (fseek(inputfs, symptr + nsyms * COFF_SYMESZ + COFF_LONG_H(coffsymhdr.e.e.e_offset), SEEK_SET) == 0) {
|
|
char tmp[33], *s = &tmp[0];
|
|
while (s != &tmp[32])
|
|
if ((*(s++) = fgetc(inputfs)) == 0) break;
|
|
tmp[32] = 0;
|
|
addlabel(&tmp[0], COFF_LONG_H(coffsymhdr.e_value),&breakpoint);
|
|
debug("[%i] Symbol: %s,", count++, &tmp[0]);
|
|
}
|
|
fseek(inputfs, fpos, SEEK_SET);
|
|
}
|
|
|
|
debug(" val: 0x%.8x,", COFF_LONG_H(coffsymhdr.e_value));
|
|
debug(" type: %x, %x, auxs: %i\n", COFF_SHORT_H(coffsymhdr.e_type), *((unsigned short *)coffsymhdr.e_type), n);
|
|
}
|
|
|
|
for (i = 0; i < n; i++)
|
|
if (fread(&coffsymhdr, COFF_SYMESZ, 1, inputfs) != 1) {
|
|
fclose(inputfs);
|
|
perror("readsyms_coff3");
|
|
exit(1);
|
|
}
|
|
syms -= n;
|
|
count += n;
|
}
|
}
|
|
|
fclose(inputfs);
|
fclose(inputfs);
|
printf("Finished loading symbols.\n");
|
printf("Finished loading symbols.\n");
|
return;
|
return;
|