• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修訂0860f6373e0df2b8dcece04dd874f95c3f09e3df (tree)
時間2017-11-27 02:38:09
作者H.J. Lu <hjl.tools@gmai...>
CommiterH.J. Lu

Log Message

Check corrupted symbol table

bfd/

PR binutils/12639
* elfcode.h (elf_slurp_symbol_table): Check corrupted global
symbols.

binutils/

PR binutils/12639
* readelf.c (process_symbol_table): Detect corrupted symbol
table.

Change Summary

差異

--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -1173,6 +1173,9 @@ elf_slurp_symbol_table (bfd *abfd, asymbol **symptrs, bfd_boolean dynamic)
11731173 sym = symbase = NULL;
11741174 else
11751175 {
1176+ /* Start of global symbols */
1177+ Elf_Internal_Sym *start_global;
1178+
11761179 isymbuf = bfd_elf_get_elf_syms (abfd, hdr, symcount, 0,
11771180 NULL, NULL, NULL);
11781181 if (isymbuf == NULL)
@@ -1218,6 +1221,9 @@ elf_slurp_symbol_table (bfd *abfd, asymbol **symptrs, bfd_boolean dynamic)
12181221 if (xver != NULL)
12191222 ++xver;
12201223 isymend = isymbuf + symcount;
1224+ start_global = isymbuf;
1225+ if (!elf_bad_symtab (abfd))
1226+ start_global += hdr->sh_info;
12211227 for (isym = isymbuf + 1, sym = symbase; isym < isymend; isym++, sym++)
12221228 {
12231229 memcpy (&sym->internal_elf_sym, isym, sizeof (Elf_Internal_Sym));
@@ -1275,6 +1281,12 @@ elf_slurp_symbol_table (bfd *abfd, asymbol **symptrs, bfd_boolean dynamic)
12751281 if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
12761282 sym->symbol.value -= sym->symbol.section->vma;
12771283
1284+ if (isym < start_global
1285+ && ELF_ST_BIND (isym->st_info) != STB_LOCAL)
1286+ (*_bfd_error_handler)
1287+ (_("%s: corrupted global symbol `%s' treated as local"),
1288+ abfd->filename, sym->symbol.name);
1289+
12781290 switch (ELF_ST_BIND (isym->st_info))
12791291 {
12801292 case STB_LOCAL:
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -11571,6 +11571,12 @@ process_symbol_table (Filedata * filedata)
1157111571 && filedata->section_headers != NULL)
1157211572 {
1157311573 unsigned int i;
11574+ /* Irix 5 and 6 are broken. Object file symbol tables are not
11575+ always sorted correctly such that local symbols precede global
11576+ symbols, and the sh_info field in the symbol table is not
11577+ always right. */
11578+ bfd_boolean check_corrupt_symtab
11579+ = filedata->file_header.e_ident[EI_OSABI] != ELFOSABI_IRIX;
1157411580
1157511581 for (i = 0, section = filedata->section_headers;
1157611582 i < filedata->file_header.e_shnum;
@@ -11640,7 +11646,12 @@ process_symbol_table (Filedata * filedata)
1164011646 putchar (' ');
1164111647 print_vma (psym->st_size, DEC_5);
1164211648 printf (" %-7s", get_symbol_type (filedata, ELF_ST_TYPE (psym->st_info)));
11643- printf (" %-6s", get_symbol_binding (filedata, ELF_ST_BIND (psym->st_info)));
11649+ if (check_corrupt_symtab
11650+ && si < section->sh_info
11651+ && ELF_ST_BIND (psym->st_info) != STB_LOCAL)
11652+ printf (" %-6s", "<corrupt>");
11653+ else
11654+ printf (" %-6s", get_symbol_binding (filedata, ELF_ST_BIND (psym->st_info)));
1164411655 if (filedata->file_header.e_ident[EI_OSABI] == ELFOSABI_SOLARIS)
1164511656 printf (" %-7s", get_solaris_symbol_visibility (psym->st_other));
1164611657 else