+ fprintf(stderr, "%s: %s: no string table section\n", argv0, filename);
+ exit(1);
+ }
+ Location strtab_location(elf_file.section_contents(strtab_shndx));
+ View strtab_view(inc->view(strtab_location));
+ elfcpp::Elf_strtab strtab(strtab_view.data(), strtab_location.data_size);
+
+ // The .gnu_incremental_symtab section contains entries that parallel
+ // the global symbols of the main symbol table. The sh_info field
+ // of the main symbol table's section header tells us how many global
+ // symbols there are, but that count does not include any global
+ // symbols that were forced local during the link. Therefore, we
+ // use the size of the .gnu_incremental_symtab section to deduce
+ // the number of global symbols + forced-local symbols there are
+ // in the symbol table.
+ Incremental_symtab_reader<big_endian> isymtab(inc->symtab_reader());
+ Incremental_relocs_reader<size, big_endian> irelocs(inc->relocs_reader());
+ unsigned int sym_size = elfcpp::Elf_sizes<size>::sym_size;
+ unsigned int nsyms = symtab_location.data_size / sym_size;
+ unsigned int nglobals = isymtab.symbol_count();
+ unsigned int first_global = nsyms - nglobals;
+ unsigned const char* sym_p;
+
+ printf("\nGlobal symbols per input file:\n");
+ for (unsigned int i = 0; i < incremental_inputs.input_file_count(); ++i)
+ {
+ Entry_reader input_file(incremental_inputs.input_file(i));
+
+ if (input_file.type() != INCREMENTAL_INPUT_OBJECT
+ && input_file.type() != INCREMENTAL_INPUT_ARCHIVE_MEMBER
+ && input_file.type() != INCREMENTAL_INPUT_SHARED_LIBRARY)
+ continue;
+
+ const char* objname = input_file.filename();
+ if (objname == NULL)
+ {
+ fprintf(stderr,"%s: %s: failed to get file name for object %u\n",
+ argv0, filename, i);
+ exit(1);
+ }
+
+ printf("[%d] %s\n", i, objname);
+
+ unsigned int nsyms = input_file.get_global_symbol_count();
+ if (nsyms > 0)
+ printf(" %6s %6s %8s %8s %8s %8s\n",
+ "outndx", "shndx", "offset", "chain", "#relocs", "rbase");
+ if (input_file.type() == INCREMENTAL_INPUT_SHARED_LIBRARY)
+ {
+ for (unsigned int symndx = 0; symndx < nsyms; ++symndx)
+ {
+ bool is_def;
+ bool is_copy;
+ unsigned int output_symndx =
+ input_file.get_output_symbol_index(symndx, &is_def, &is_copy);
+ sym_p = symtab_view.data() + output_symndx * sym_size;
+ elfcpp::Sym<size, big_endian> sym(sym_p);
+ const char* symname;
+ if (!strtab.get_c_string(sym.get_st_name(), &symname))
+ symname = "<unknown>";
+ printf(" %6d %6s %8s %8s %8s %8s %-5s %s\n",
+ output_symndx,
+ "", "", "", "", "",
+ is_copy ? "COPY" : (is_def ? "DEF" : "UNDEF"),
+ symname);
+ }
+ }
+ else
+ {
+ for (unsigned int symndx = 0; symndx < nsyms; ++symndx)
+ {
+ Incremental_global_symbol_reader<big_endian> info(
+ input_file.get_global_symbol_reader(symndx));
+ unsigned int output_symndx = info.output_symndx();
+ sym_p = symtab_view.data() + output_symndx * sym_size;
+ elfcpp::Sym<size, big_endian> sym(sym_p);
+ const char* symname;
+ if (!strtab.get_c_string(sym.get_st_name(), &symname))
+ symname = "<unknown>";
+ printf(" %6d %6d %8d %8d %8d %8d %-5s %s\n",
+ output_symndx,
+ info.shndx() == -1U ? -1 : info.shndx(),
+ input_file.get_symbol_offset(symndx),
+ info.next_offset(),
+ info.reloc_count(),
+ info.reloc_offset(),
+ (info.shndx() == -1U
+ ? "BASE"
+ : info.shndx() == 0 ? "UNDEF" : "DEF"),
+ symname);
+ }
+ }