From 828cfa8d0b07fdae7502ee975092a46db4436f5b Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Mon, 19 Dec 2011 04:36:29 +0000 Subject: [PATCH] try ignoring bad PLT entries in ELF symbol tables Comment says it all: /* On ia64-hpux, we have discovered that the system linker adds undefined symbols with nonzero addresses that cannot be right (their address points inside the code of another function in the .text section). This creates problems when trying to determine which symbol corresponds to a given address. We try to detect those buggy symbols by checking which section we think they correspond to. Normally, PLT symbols are stored inside their own section, and the typical name for that section is ".plt". So, if there is a ".plt" section, and yet the section name of our symbol does not start with ".plt", we ignore that symbol. */ gdb/ChangeLog: * elfread.c (elf_symtab_read): Ignore undefined symbols with nonzero addresses if they do not correspond to a .plt section when one is available in the objfile. --- gdb/ChangeLog | 6 ++++++ gdb/elfread.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5a8eb1c..68267a3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2011-12-19 Joel Brobecker + + * elfread.c (elf_symtab_read): Ignore undefined symbols with + nonzero addresses if they do not correspond to a .plt section + when one is available in the objfile. + 2011-12-17 Andreas Schwab * cp-name-parser.y (cp_merge_demangle_parse_infos): Don't use diff --git a/gdb/elfread.c b/gdb/elfread.c index 067c77f..fd65ecf 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -303,6 +303,23 @@ elf_symtab_read (struct objfile *objfile, int type, if (!sect) continue; + /* On ia64-hpux, we have discovered that the system linker + adds undefined symbols with nonzero addresses that cannot + be right (their address points inside the code of another + function in the .text section). This creates problems + when trying to determine which symbol corresponds to + a given address. + + We try to detect those buggy symbols by checking which + section we think they correspond to. Normally, PLT symbols + are stored inside their own section, and the typical name + for that section is ".plt". So, if there is a ".plt" + section, and yet the section name of our symbol does not + start with ".plt", we ignore that symbol. */ + if (strncmp (sect->name, ".plt", 4) != 0 + && bfd_get_section_by_name (abfd, ".plt") != NULL) + continue; + symaddr += ANOFFSET (objfile->section_offsets, sect->index); msym = record_minimal_symbol -- 2.7.4