Merge pull request #909 from sm00th/symtab_read-fixes

Symtab read fixes
This commit is contained in:
Joe Lawrence 2018-09-21 10:09:25 -04:00 committed by GitHub
commit b2f5bc577c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -197,16 +197,24 @@ static void symtab_read(struct lookup_table *table, char *path)
FILE *file;
long unsigned int value, size;
unsigned int i = 0;
int matched;
char line[256], name[256], type[16], bind[16], ndx[16];
if ((file = fopen(path, "r")) == NULL)
ERROR("fopen");
while (fgets(line, 256, file)) {
if (sscanf(line, "%*s %lx %lu %s %s %*s %s %s\n",
&value, &size, type, bind, ndx, name) != 6 ||
matched = sscanf(line, "%*s %lx %lu %s %s %*s %s %s\n",
&value, &size, type, bind, ndx, name);
if (matched == 5) {
name[0] = '\0';
matched++;
}
if (matched != 6 ||
!strcmp(ndx, "UNDEF") ||
!strcmp(bind, "SECTION"))
!strcmp(type, "SECTION"))
continue;
table->obj_nr++;
@ -220,10 +228,17 @@ static void symtab_read(struct lookup_table *table, char *path)
rewind(file);
while (fgets(line, 256, file)) {
if (sscanf(line, "%*s %lx %lu %s %s %*s %s %s\n",
&value, &size, type, bind, ndx, name) != 6 ||
matched = sscanf(line, "%*s %lx %lu %s %s %*s %s %s\n",
&value, &size, type, bind, ndx, name);
if (matched == 5) {
name[0] = '\0';
matched++;
}
if (matched != 6 ||
!strcmp(ndx, "UNDEF") ||
!strcmp(bind, "SECTION"))
!strcmp(type, "SECTION"))
continue;
table->obj_syms[i].value = value;