]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gprofng: Remove check_Relocs() function
authorClaudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
Fri, 28 Mar 2025 11:25:19 +0000 (13:25 +0200)
committerVladimir Mezentsev <vladimir.mezentsev@oracle.com>
Mon, 7 Apr 2025 01:23:54 +0000 (18:23 -0700)
check_Relocs() function is not anylonger required as it can only
handle Studio compiler relocs, now defunct. Remove this function.

Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
gprofng/src/Stabs.cc
gprofng/src/Stabs.h

index 2120319382359fd76148e6fbb7b6d4fc3ef98f19..908dcc4b7b4c718c54635cacc1e5cee9700fd5e5 100644 (file)
@@ -272,7 +272,7 @@ Stabs::Stabs (char *_path, char *_lo_name)
   stabsModules = NULL;
   textsz = 0;
   wsize = Wnone;
-  st_check_symtab = st_check_relocs = false;
+  st_check_symtab = false;
   status = DBGD_ERR_NONE;
 
   if (openElf (false) == NULL)
@@ -412,7 +412,6 @@ Stabs::read_symbols (Vector<Function*> *functions)
   if (openElf (true) == NULL)
     return false;
   check_Symtab ();
-  check_Relocs ();
   if (functions)
     {
       Function *fp;
@@ -1820,142 +1819,6 @@ Stabs::readSymSec (unsigned int sec, Elf *elf)
   dump ();
 }//check_Symtab
 
-void
-Stabs::check_Relocs ()
-{
-  // We may have many relocation tables to process: .rela.text%foo,
-  // rela.text%bar, etc. On Intel, compilers generate .rel.text sections
-  // which have to be processed as well. A lot of rework is needed here.
-  Symbol *sptr = NULL;
-  if (st_check_relocs)
-    return;
-  st_check_relocs = true;
-
-  Elf *elf = openElf (false);
-  if (elf == NULL)
-    return;
-  for (unsigned int sec = 1; sec < elf->elf_getehdr ()->e_shnum; sec++)
-    {
-      bool use_rela, use_PLT;
-      char *name = elf->get_sec_name (sec);
-      if (name == NULL)
-       continue;
-      if (strncmp (name, NTXT (".rela.text"), 10) == 0)
-       {
-         use_rela = true;
-         use_PLT = false;
-       }
-      else if (streq (name, NTXT (".rela.plt")))
-       {
-         use_rela = true;
-         use_PLT = true;
-       }
-      else if (strncmp (name, NTXT (".rel.text"), 9) == 0)
-       {
-         use_rela = false;
-         use_PLT = false;
-       }
-      else if (streq (name, NTXT (".rel.plt")))
-       {
-         use_rela = false;
-         use_PLT = true;
-       }
-      else
-       continue;
-
-      Elf_Internal_Shdr *shdr = elf->get_shdr (sec);
-      if (shdr == NULL)
-       continue;
-
-      // Get ELF data
-      Elf_Data *data = elf->elf_getdata (sec);
-      if (data == NULL)
-       continue;
-      uint64_t ScnSize = data->d_size;
-      uint64_t EntSize = shdr->sh_entsize;
-      if ((ScnSize == 0) || (EntSize == 0))
-       continue;
-      int tot = (int) (ScnSize / EntSize);
-
-      // Get corresponding text section
-      Elf_Internal_Shdr *shdr_txt = elf->get_shdr (shdr->sh_info);
-      if (shdr_txt == NULL)
-       continue;
-      if (!(shdr_txt->sh_flags & SHF_EXECINSTR))
-           continue;
-
-      // Get corresponding symbol table section
-      Elf_Internal_Shdr *shdr_sym = elf->get_shdr (shdr->sh_link);
-      if (shdr_sym == NULL)
-       continue;
-      Elf_Data *data_sym = elf->elf_getdata (shdr->sh_link);
-
-      // Get corresponding string table section
-      Elf_Data *data_str = elf->elf_getdata (shdr_sym->sh_link);
-      if (data_str == NULL)
-       continue;
-      char *Strtab = (char*) data_str->d_buf;
-      for (int n = 0; n < tot; n++)
-       {
-         Elf_Internal_Sym sym;
-         Elf_Internal_Rela rela;
-         char *symName;
-         if (use_rela)
-           elf->elf_getrela (data, n, &rela);
-         else
-           {
-             // GElf_Rela is extended GElf_Rel
-             elf->elf_getrel (data, n, &rela);
-             rela.r_addend = 0;
-           }
-
-         int ndx = (int) GELF_R_SYM (rela.r_info);
-         elf->elf_getsym (data_sym, ndx, &sym);
-         switch (GELF_ST_TYPE (sym.st_info))
-           {
-           case STT_FUNC:
-           case STT_OBJECT:
-           case STT_NOTYPE:
-             if (sym.st_name == 0 || sym.st_name >= data_str->d_size)
-               continue;
-             symName = Strtab + sym.st_name;
-             break;
-           case STT_SECTION:
-             {
-               Elf_Internal_Shdr *secHdr = elf->get_shdr (sym.st_shndx);
-               if (secHdr == NULL)
-                 continue;
-               if (sptr == NULL)
-                 sptr = new Symbol;
-               sptr->value = secHdr->sh_offset + rela.r_addend;
-               long index = SymLst->bisearch (0, -1, &sptr, SymFindCmp);
-               if (index == -1)
-                 continue;
-               Symbol *sp = SymLst->fetch (index);
-               if (sptr->value != sp->value)
-                 continue;
-               symName = sp->name;
-               break;
-             }
-           default:
-             continue;
-           }
-         Reloc *reloc = new Reloc;
-         reloc->name = dbe_strdup (symName);
-         reloc->type = GELF_R_TYPE (rela.r_info);
-         reloc->value = use_PLT ? rela.r_offset
-                 : rela.r_offset + shdr_txt->sh_offset;
-         reloc->addend = rela.r_addend;
-         if (use_PLT)
-           RelPLTLst->append (reloc);
-         else
-           RelLst->append (reloc);
-       }
-    }
-  delete sptr;
-  RelLst->sort (RelValueCmp);
-} //check_Relocs
-
 void
 Stabs::get_save_addr (bool need_swap_endian)
 {
index 42aa6fbc7916f42f96d60d68f7847f393ce19614..88c2b8d64a5fa926f733a26cd39d9bcccbc042cf 100644 (file)
@@ -130,7 +130,6 @@ class Stabs {
     // Interface with Elf Symbol Table
     void                check_Symtab();
     void                readSymSec(unsigned int sec, Elf *elf);
-    void                check_Relocs();
     void                get_save_addr(bool need_swap_endian);
     Symbol              *map_PC_to_sym(uint64_t pc);
     Symbol              *pltSym;
@@ -146,7 +145,7 @@ class Stabs {
     Map<const char*, Symbol*> *get_elf_symbols();
     Dwarf       *dwarf;
 
-    bool        st_check_symtab, st_check_relocs;
+    bool       st_check_symtab;
     Function   *createFunction(LoadObject *lo, Module *module, Symbol *sym);
     void        fixSymtabAlias();