symtab_read: support entries with blank names

symtab_read() would previously skip entries with blank names resulting
in some of important entries being skipped. For instance vmlinux file
has an STT_FILE entry at the end with a blank name that contains global
offset table. Because it was skipped all of the global entries from this
table were considered a part of previous processed file resulting in
create-diff-object failing in find_local_syms().

Signed-off-by: Artem Savkov <asavkov@redhat.com>
This commit is contained in:
Artem Savkov 2018-09-12 16:23:17 +02:00
parent f7cfe25e8a
commit f5679c9780

View File

@ -197,14 +197,22 @@ 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(type, "SECTION"))
continue;
@ -220,8 +228,15 @@ 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(type, "SECTION"))
continue;