Skip to content

Commit

Permalink
Merge pull request #909 from sm00th/symtab_read-fixes
Browse files Browse the repository at this point in the history
Symtab read fixes
  • Loading branch information
joe-lawrence authored Sep 21, 2018
2 parents ded02df + f5679c9 commit b2f5bc5
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions kpatch-build/lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand All @@ -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;
Expand Down

0 comments on commit b2f5bc5

Please sign in to comment.