Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/bfd/elf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 20 by monabuilder, Sun Dec 28 03:31:28 2008 UTC revision 21 by monamour, Mon Jul 27 20:34:36 2009 UTC
# Line 1  Line 1 
1  /* ELF executable support for BFD.  /* ELF executable support for BFD.
2    
3     Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,     Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
4     2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.     2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
5       Free Software Foundation, Inc.
6    
7     This file is part of BFD, the Binary File Descriptor library.     This file is part of BFD, the Binary File Descriptor library.
8    
# Line 258  bfd_elf_mkcorefile (bfd *abfd) Line 259  bfd_elf_mkcorefile (bfd *abfd)
259    return bfd_elf_make_generic_object (abfd);    return bfd_elf_make_generic_object (abfd);
260  }  }
261    
262  char *  static char *
263  bfd_elf_get_str_section (bfd *abfd, unsigned int shindex)  bfd_elf_get_str_section (bfd *abfd, unsigned int shindex)
264  {  {
265    Elf_Internal_Shdr **i_shdrp;    Elf_Internal_Shdr **i_shdrp;
# Line 1019  _bfd_elf_make_section_from_shdr (bfd *ab Line 1020  _bfd_elf_make_section_from_shdr (bfd *ab
1020    return TRUE;    return TRUE;
1021  }  }
1022    
 /*  
 INTERNAL_FUNCTION  
         bfd_elf_find_section  
   
 SYNOPSIS  
         struct elf_internal_shdr *bfd_elf_find_section (bfd *abfd, char *name);  
   
 DESCRIPTION  
         Helper functions for GDB to locate the string tables.  
         Since BFD hides string tables from callers, GDB needs to use an  
         internal hook to find them.  Sun's .stabstr, in particular,  
         isn't even pointed to by the .stab section, so ordinary  
         mechanisms wouldn't work to find it, even if we had some.  
 */  
   
 struct elf_internal_shdr *  
 bfd_elf_find_section (bfd *abfd, char *name)  
 {  
   Elf_Internal_Shdr **i_shdrp;  
   char *shstrtab;  
   unsigned int max;  
   unsigned int i;  
   
   i_shdrp = elf_elfsections (abfd);  
   if (i_shdrp != NULL)  
     {  
       shstrtab = bfd_elf_get_str_section (abfd,  
                                           elf_elfheader (abfd)->e_shstrndx);  
       if (shstrtab != NULL)  
         {  
           max = elf_numsections (abfd);  
           for (i = 1; i < max; i++)  
             if (!strcmp (&shstrtab[i_shdrp[i]->sh_name], name))  
               return i_shdrp[i];  
         }  
     }  
   return 0;  
 }  
   
1023  const char *const bfd_elf_section_type_names[] = {  const char *const bfd_elf_section_type_names[] = {
1024    "SHT_NULL", "SHT_PROGBITS", "SHT_SYMTAB", "SHT_STRTAB",    "SHT_NULL", "SHT_PROGBITS", "SHT_SYMTAB", "SHT_STRTAB",
1025    "SHT_RELA", "SHT_HASH", "SHT_DYNAMIC", "SHT_NOTE",    "SHT_RELA", "SHT_HASH", "SHT_DYNAMIC", "SHT_NOTE",
# Line 1766  bfd_section_from_shdr (bfd *abfd, unsign Line 1728  bfd_section_from_shdr (bfd *abfd, unsign
1728             reject them, but, unfortunately, some people need to use             reject them, but, unfortunately, some people need to use
1729             them.  We scan through the section headers; if we find only             them.  We scan through the section headers; if we find only
1730             one suitable symbol table, we clobber the sh_link to point             one suitable symbol table, we clobber the sh_link to point
1731             to it.  I hope this doesn't break anything.  */             to it.  I hope this doesn't break anything.
1732          if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_SYMTAB  
1733               Don't do it on executable nor shared library.  */
1734            if ((abfd->flags & (DYNAMIC | EXEC_P)) == 0
1735                && elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_SYMTAB
1736              && elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_DYNSYM)              && elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_DYNSYM)
1737            {            {
1738              unsigned int scan;              unsigned int scan;
# Line 1802  bfd_section_from_shdr (bfd *abfd, unsign Line 1767  bfd_section_from_shdr (bfd *abfd, unsign
1767             represent such a section, so at least for now, we don't             represent such a section, so at least for now, we don't
1768             try.  We just present it as a normal section.  We also             try.  We just present it as a normal section.  We also
1769             can't use it as a reloc section if it points to the null             can't use it as a reloc section if it points to the null
1770             section, an invalid section, or another reloc section.  */             section, an invalid section, another reloc section, or its
1771               sh_link points to the null section.  */
1772          if (hdr->sh_link != elf_onesymtab (abfd)          if (hdr->sh_link != elf_onesymtab (abfd)
1773                || hdr->sh_link == SHN_UNDEF
1774              || hdr->sh_info == SHN_UNDEF              || hdr->sh_info == SHN_UNDEF
1775              || hdr->sh_info >= num_sec              || hdr->sh_info >= num_sec
1776              || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_REL              || elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_REL
# Line 1959  bfd_section_from_shdr (bfd *abfd, unsign Line 1926  bfd_section_from_shdr (bfd *abfd, unsign
1926    return TRUE;    return TRUE;
1927  }  }
1928    
1929  /* Return the section for the local symbol specified by ABFD, R_SYMNDX.  /* Return the local symbol specified by ABFD, R_SYMNDX.  */
    Return SEC for sections that have no elf section, and NULL on error.  */  
1930    
1931  asection *  Elf_Internal_Sym *
1932  bfd_section_from_r_symndx (bfd *abfd,  bfd_sym_from_r_symndx (struct sym_cache *cache,
1933                             struct sym_sec_cache *cache,                         bfd *abfd,
1934                             asection *sec,                         unsigned long r_symndx)
                            unsigned long r_symndx)  
1935  {  {
1936    unsigned int ent = r_symndx % LOCAL_SYM_CACHE_SIZE;    unsigned int ent = r_symndx % LOCAL_SYM_CACHE_SIZE;
   asection *s;  
1937    
1938    if (cache->abfd != abfd || cache->indx[ent] != r_symndx)    if (cache->abfd != abfd || cache->indx[ent] != r_symndx)
1939      {      {
1940        Elf_Internal_Shdr *symtab_hdr;        Elf_Internal_Shdr *symtab_hdr;
1941        unsigned char esym[sizeof (Elf64_External_Sym)];        unsigned char esym[sizeof (Elf64_External_Sym)];
1942        Elf_External_Sym_Shndx eshndx;        Elf_External_Sym_Shndx eshndx;
       Elf_Internal_Sym isym;  
1943    
1944        symtab_hdr = &elf_tdata (abfd)->symtab_hdr;        symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
1945        if (bfd_elf_get_elf_syms (abfd, symtab_hdr, 1, r_symndx,        if (bfd_elf_get_elf_syms (abfd, symtab_hdr, 1, r_symndx,
1946                                  &isym, esym, &eshndx) == NULL)                                  &cache->sym[ent], esym, &eshndx) == NULL)
1947          return NULL;          return NULL;
1948    
1949        if (cache->abfd != abfd)        if (cache->abfd != abfd)
# Line 1989  bfd_section_from_r_symndx (bfd *abfd, Line 1952  bfd_section_from_r_symndx (bfd *abfd,
1952            cache->abfd = abfd;            cache->abfd = abfd;
1953          }          }
1954        cache->indx[ent] = r_symndx;        cache->indx[ent] = r_symndx;
       cache->shndx[ent] = isym.st_shndx;  
1955      }      }
1956    
1957    s = bfd_section_from_elf_index (abfd, cache->shndx[ent]);    return &cache->sym[ent];
   if (s != NULL)  
     return s;  
   
   return sec;  
1958  }  }
1959    
1960  /* Given an ELF section number, retrieve the corresponding BFD  /* Given an ELF section number, retrieve the corresponding BFD
# Line 2778  bfd_elf_set_group_contents (bfd *abfd, a Line 2736  bfd_elf_set_group_contents (bfd *abfd, a
2736        asection *s;        asection *s;
2737        unsigned int idx;        unsigned int idx;
2738    
       loc -= 4;  
2739        s = elt;        s = elt;
2740        if (!gas)        if (! elf_discarded_section (s))
2741          s = s->output_section;          {
2742        idx = 0;            loc -= 4;
2743        if (s != NULL)            if (!gas)
2744          idx = elf_section_data (s)->this_idx;              s = s->output_section;
2745        H_PUT_32 (abfd, idx, loc);            idx = 0;
2746              if (s != NULL)
2747                idx = elf_section_data (s)->this_idx;
2748              H_PUT_32 (abfd, idx, loc);
2749            }
2750        elt = elf_next_in_group (elt);        elt = elf_next_in_group (elt);
2751        if (elt == first)        if (elt == first)
2752          break;          break;
# Line 2809  assign_section_numbers (bfd *abfd, struc Line 2770  assign_section_numbers (bfd *abfd, struc
2770    unsigned int section_number, secn;    unsigned int section_number, secn;
2771    Elf_Internal_Shdr **i_shdrp;    Elf_Internal_Shdr **i_shdrp;
2772    struct bfd_elf_section_data *d;    struct bfd_elf_section_data *d;
2773      bfd_boolean need_symtab;
2774    
2775    section_number = 1;    section_number = 1;
2776    
# Line 2864  assign_section_numbers (bfd *abfd, struc Line 2826  assign_section_numbers (bfd *abfd, struc
2826    _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->shstrtab_hdr.sh_name);    _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->shstrtab_hdr.sh_name);
2827    elf_elfheader (abfd)->e_shstrndx = t->shstrtab_section;    elf_elfheader (abfd)->e_shstrndx = t->shstrtab_section;
2828    
2829    if (bfd_get_symcount (abfd) > 0)    need_symtab = (bfd_get_symcount (abfd) > 0
2830                    || (link_info == NULL
2831                        && ((abfd->flags & (EXEC_P | DYNAMIC | HAS_RELOC))
2832                            == HAS_RELOC)));
2833      if (need_symtab)
2834      {      {
2835        t->symtab_section = section_number++;        t->symtab_section = section_number++;
2836        _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->symtab_hdr.sh_name);        _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->symtab_hdr.sh_name);
# Line 2903  assign_section_numbers (bfd *abfd, struc Line 2869  assign_section_numbers (bfd *abfd, struc
2869    elf_elfsections (abfd) = i_shdrp;    elf_elfsections (abfd) = i_shdrp;
2870    
2871    i_shdrp[t->shstrtab_section] = &t->shstrtab_hdr;    i_shdrp[t->shstrtab_section] = &t->shstrtab_hdr;
2872    if (bfd_get_symcount (abfd) > 0)    if (need_symtab)
2873      {      {
2874        i_shdrp[t->symtab_section] = &t->symtab_hdr;        i_shdrp[t->symtab_section] = &t->symtab_hdr;
2875        if (elf_numsections (abfd) > (SHN_LORESERVE & 0xFFFF))        if (elf_numsections (abfd) > (SHN_LORESERVE & 0xFFFF))
# Line 3296  _bfd_elf_compute_section_file_positions Line 3262  _bfd_elf_compute_section_file_positions
3262    bfd_boolean failed;    bfd_boolean failed;
3263    struct bfd_strtab_hash *strtab = NULL;    struct bfd_strtab_hash *strtab = NULL;
3264    Elf_Internal_Shdr *shstrtab_hdr;    Elf_Internal_Shdr *shstrtab_hdr;
3265      bfd_boolean need_symtab;
3266    
3267    if (abfd->output_has_begun)    if (abfd->output_has_begun)
3268      return TRUE;      return TRUE;
# Line 3320  _bfd_elf_compute_section_file_positions Line 3287  _bfd_elf_compute_section_file_positions
3287      return FALSE;      return FALSE;
3288    
3289    /* The backend linker builds symbol table information itself.  */    /* The backend linker builds symbol table information itself.  */
3290    if (link_info == NULL && bfd_get_symcount (abfd) > 0)    need_symtab = (link_info == NULL
3291                     && (bfd_get_symcount (abfd) > 0
3292                         || ((abfd->flags & (EXEC_P | DYNAMIC | HAS_RELOC))
3293                             == HAS_RELOC)));
3294      if (need_symtab)
3295      {      {
3296        /* Non-zero if doing a relocatable link.  */        /* Non-zero if doing a relocatable link.  */
3297        int relocatable_p = ! (abfd->flags & (EXEC_P | DYNAMIC));        int relocatable_p = ! (abfd->flags & (EXEC_P | DYNAMIC));
# Line 3351  _bfd_elf_compute_section_file_positions Line 3322  _bfd_elf_compute_section_file_positions
3322    if (!assign_file_positions_except_relocs (abfd, link_info))    if (!assign_file_positions_except_relocs (abfd, link_info))
3323      return FALSE;      return FALSE;
3324    
3325    if (link_info == NULL && bfd_get_symcount (abfd) > 0)    if (need_symtab)
3326      {      {
3327        file_ptr off;        file_ptr off;
3328        Elf_Internal_Shdr *hdr;        Elf_Internal_Shdr *hdr;
# Line 4708  assign_file_positions_for_non_load_secti Line 4679  assign_file_positions_for_non_load_secti
4679                p->p_align = 1;                p->p_align = 1;
4680                p->p_flags = (lp->p_flags & ~PF_W);                p->p_flags = (lp->p_flags & ~PF_W);
4681              }              }
4682            else if (link_info != NULL)            else
4683              {              {
4684                memset (p, 0, sizeof *p);                memset (p, 0, sizeof *p);
4685                p->p_type = PT_NULL;                p->p_type = PT_NULL;
4686              }              }
           else  
             abort ();  
4687          }          }
4688        else if (m->count != 0)        else if (m->count != 0)
4689          {          {
# Line 5863  copy_elf_program_header (bfd *ibfd, bfd Line 5832  copy_elf_program_header (bfd *ibfd, bfd
5832        map->p_align_valid = 1;        map->p_align_valid = 1;
5833        map->p_vaddr_offset = 0;        map->p_vaddr_offset = 0;
5834    
5835        if (map->p_type == PT_GNU_RELRO        if (map->p_type == PT_GNU_RELRO)
           && segment->p_filesz == segment->p_memsz)  
5836          {          {
5837            /* The PT_GNU_RELRO segment may contain the first a few            /* The PT_GNU_RELRO segment may contain the first a few
5838               bytes in the .got.plt section even if the whole .got.plt               bytes in the .got.plt section even if the whole .got.plt
5839               section isn't in the PT_GNU_RELRO segment.  We won't               section isn't in the PT_GNU_RELRO segment.  We won't
5840               change the size of the PT_GNU_RELRO segment.  */               change the size of the PT_GNU_RELRO segment.  */
5841            map->p_size = segment->p_filesz;            map->p_size = segment->p_memsz;
5842            map->p_size_valid = 1;            map->p_size_valid = 1;
5843          }          }
5844    
# Line 6427  Unable to find equivalent output section Line 6395  Unable to find equivalent output section
6395    
6396        if ((flags & BSF_THREAD_LOCAL) != 0)        if ((flags & BSF_THREAD_LOCAL) != 0)
6397          type = STT_TLS;          type = STT_TLS;
6398          else if ((flags & BSF_GNU_INDIRECT_FUNCTION) != 0)
6399            type = STT_GNU_IFUNC;
6400        else if ((flags & BSF_FUNCTION) != 0)        else if ((flags & BSF_FUNCTION) != 0)
6401          type = STT_FUNC;          type = STT_FUNC;
6402        else if ((flags & BSF_OBJECT) != 0)        else if ((flags & BSF_OBJECT) != 0)
# Line 6476  Unable to find equivalent output section Line 6446  Unable to find equivalent output section
6446    
6447            if (flags & BSF_LOCAL)            if (flags & BSF_LOCAL)
6448              bind = STB_LOCAL;              bind = STB_LOCAL;
6449              else if (flags & BSF_GNU_UNIQUE)
6450                bind = STB_GNU_UNIQUE;
6451            else if (flags & BSF_WEAK)            else if (flags & BSF_WEAK)
6452              bind = STB_WEAK;              bind = STB_WEAK;
6453            else if (flags & BSF_GLOBAL)            else if (flags & BSF_GLOBAL)
# Line 7076  _bfd_elf_set_arch_mach (bfd *abfd, Line 7048  _bfd_elf_set_arch_mach (bfd *abfd,
7048     for error reporting.  */     for error reporting.  */
7049    
7050  static bfd_boolean  static bfd_boolean
7051  elf_find_function (bfd *abfd ATTRIBUTE_UNUSED,  elf_find_function (bfd *abfd,
7052                     asection *section,                     asection *section,
7053                     asymbol **symbols,                     asymbol **symbols,
7054                     bfd_vma offset,                     bfd_vma offset,
# Line 7096  elf_find_function (bfd *abfd ATTRIBUTE_U Line 7068  elf_find_function (bfd *abfd ATTRIBUTE_U
7068       make a better choice of file name for local symbols by ignoring       make a better choice of file name for local symbols by ignoring
7069       file symbols appearing after a given local symbol.  */       file symbols appearing after a given local symbol.  */
7070    enum { nothing_seen, symbol_seen, file_after_symbol_seen } state;    enum { nothing_seen, symbol_seen, file_after_symbol_seen } state;
7071      const struct elf_backend_data *bed = get_elf_backend_data (abfd);
7072    
7073    filename = NULL;    filename = NULL;
7074    func = NULL;    func = NULL;
# Line 7106  elf_find_function (bfd *abfd ATTRIBUTE_U Line 7079  elf_find_function (bfd *abfd ATTRIBUTE_U
7079    for (p = symbols; *p != NULL; p++)    for (p = symbols; *p != NULL; p++)
7080      {      {
7081        elf_symbol_type *q;        elf_symbol_type *q;
7082          unsigned int type;
7083    
7084        q = (elf_symbol_type *) *p;        q = (elf_symbol_type *) *p;
7085    
7086        switch (ELF_ST_TYPE (q->internal_elf_sym.st_info))        type = ELF_ST_TYPE (q->internal_elf_sym.st_info);
7087          switch (type)
7088          {          {
         default:  
           break;  
7089          case STT_FILE:          case STT_FILE:
7090            file = &q->symbol;            file = &q->symbol;
7091            if (state == symbol_seen)            if (state == symbol_seen)
7092              state = file_after_symbol_seen;              state = file_after_symbol_seen;
7093            continue;            continue;
7094            default:
7095              if (!bed->is_function_type (type))
7096                break;
7097          case STT_NOTYPE:          case STT_NOTYPE:
         case STT_FUNC:  
7098            if (bfd_get_section (&q->symbol) == section            if (bfd_get_section (&q->symbol) == section
7099                && q->symbol.value >= low_func                && q->symbol.value >= low_func
7100                && q->symbol.value <= offset)                && q->symbol.value <= offset)
# Line 8133  elfcore_grok_netbsd_note (bfd *abfd, Elf Line 8108  elfcore_grok_netbsd_note (bfd *abfd, Elf
8108  }  }
8109    
8110  static bfd_boolean  static bfd_boolean
8111    elfcore_grok_openbsd_procinfo (bfd *abfd, Elf_Internal_Note *note)
8112    {
8113      /* Signal number at offset 0x08. */
8114      elf_tdata (abfd)->core_signal
8115        = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x08);
8116    
8117      /* Process ID at offset 0x20. */
8118      elf_tdata (abfd)->core_pid
8119        = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x20);
8120    
8121      /* Command name at 0x48 (max 32 bytes, including nul). */
8122      elf_tdata (abfd)->core_command
8123        = _bfd_elfcore_strndup (abfd, note->descdata + 0x48, 31);
8124    
8125      return TRUE;
8126    }
8127    
8128    static bfd_boolean
8129    elfcore_grok_openbsd_note (bfd *abfd, Elf_Internal_Note *note)
8130    {
8131      if (note->type == NT_OPENBSD_PROCINFO)
8132        return elfcore_grok_openbsd_procinfo (abfd, note);
8133    
8134      if (note->type == NT_OPENBSD_REGS)
8135        return elfcore_make_note_pseudosection (abfd, ".reg", note);
8136    
8137      if (note->type == NT_OPENBSD_FPREGS)
8138        return elfcore_make_note_pseudosection (abfd, ".reg2", note);
8139    
8140      if (note->type == NT_OPENBSD_XFPREGS)
8141        return elfcore_make_note_pseudosection (abfd, ".reg-xfp", note);
8142    
8143      if (note->type == NT_OPENBSD_AUXV)
8144        {
8145          asection *sect = bfd_make_section_anyway_with_flags (abfd, ".auxv",
8146                                                               SEC_HAS_CONTENTS);
8147    
8148          if (sect == NULL)
8149            return FALSE;
8150          sect->size = note->descsz;
8151          sect->filepos = note->descpos;
8152          sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32;
8153    
8154          return TRUE;
8155        }
8156    
8157      if (note->type == NT_OPENBSD_WCOOKIE)
8158        {
8159          asection *sect = bfd_make_section_anyway_with_flags (abfd, ".wcookie",
8160                                                               SEC_HAS_CONTENTS);
8161    
8162          if (sect == NULL)
8163            return FALSE;
8164          sect->size = note->descsz;
8165          sect->filepos = note->descpos;
8166          sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32;
8167    
8168          return TRUE;
8169        }
8170    
8171      return TRUE;
8172    }
8173    
8174    static bfd_boolean
8175  elfcore_grok_nto_status (bfd *abfd, Elf_Internal_Note *note, long *tid)  elfcore_grok_nto_status (bfd *abfd, Elf_Internal_Note *note, long *tid)
8176  {  {
8177    void *ddata = note->descdata;    void *ddata = note->descdata;
# Line 8619  elf_parse_notes (bfd *abfd, char *buf, s Line 8658  elf_parse_notes (bfd *abfd, char *buf, s
8658                if (! elfcore_grok_netbsd_note (abfd, &in))                if (! elfcore_grok_netbsd_note (abfd, &in))
8659                  return FALSE;                  return FALSE;
8660              }              }
8661              else if (CONST_STRNEQ (in.namedata, "OpenBSD"))
8662                {
8663                  if (! elfcore_grok_openbsd_note (abfd, &in))
8664                    return FALSE;
8665                }
8666            else if (CONST_STRNEQ (in.namedata, "QNX"))            else if (CONST_STRNEQ (in.namedata, "QNX"))
8667              {              {
8668                if (! elfcore_grok_nto_note (abfd, &in))                if (! elfcore_grok_nto_note (abfd, &in))
# Line 8880  _bfd_elf_get_synthetic_symtab (bfd *abfd Line 8924  _bfd_elf_get_synthetic_symtab (bfd *abfd
8924    size = count * sizeof (asymbol);    size = count * sizeof (asymbol);
8925    p = relplt->relocation;    p = relplt->relocation;
8926    for (i = 0; i < count; i++, p += bed->s->int_rels_per_ext_rel)    for (i = 0; i < count; i++, p += bed->s->int_rels_per_ext_rel)
8927      size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");      {
8928          size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt");
8929          if (p->addend != 0)
8930            {
8931    #ifdef BFD64
8932              size += sizeof ("+0x") - 1 + 8 + 8 * (bed->s->elfclass == ELFCLASS64);
8933    #else
8934              size += sizeof ("+0x") - 1 + 8;
8935    #endif
8936            }
8937        }
8938    
8939    s = *ret = bfd_malloc (size);    s = *ret = bfd_malloc (size);
8940    if (s == NULL)    if (s == NULL)
# Line 8911  _bfd_elf_get_synthetic_symtab (bfd *abfd Line 8965  _bfd_elf_get_synthetic_symtab (bfd *abfd
8965        len = strlen ((*p->sym_ptr_ptr)->name);        len = strlen ((*p->sym_ptr_ptr)->name);
8966        memcpy (names, (*p->sym_ptr_ptr)->name, len);        memcpy (names, (*p->sym_ptr_ptr)->name, len);
8967        names += len;        names += len;
8968          if (p->addend != 0)
8969            {
8970              char buf[30], *a;
8971              int len;
8972              memcpy (names, "+0x", sizeof ("+0x") - 1);
8973              names += sizeof ("+0x") - 1;
8974              bfd_sprintf_vma (abfd, buf, p->addend);
8975              for (a = buf; *a == '0'; ++a)
8976                ;
8977              len = strlen (a);
8978              memcpy (names, a, len);
8979              names += len;
8980            }
8981        memcpy (names, "@plt", sizeof ("@plt"));        memcpy (names, "@plt", sizeof ("@plt"));
8982        names += sizeof ("@plt");        names += sizeof ("@plt");
8983        ++s, ++n;        ++s, ++n;
# Line 8933  _bfd_elf_set_osabi (bfd * abfd, Line 9000  _bfd_elf_set_osabi (bfd * abfd,
9000    i_ehdrp = elf_elfheader (abfd);    i_ehdrp = elf_elfheader (abfd);
9001    
9002    i_ehdrp->e_ident[EI_OSABI] = get_elf_backend_data (abfd)->elf_osabi;    i_ehdrp->e_ident[EI_OSABI] = get_elf_backend_data (abfd)->elf_osabi;
9003    
9004      /* To make things simpler for the loader on Linux systems we set the
9005         osabi field to ELFOSABI_LINUX if the binary contains symbols of
9006         the STT_GNU_IFUNC type.  */
9007      if (i_ehdrp->e_ident[EI_OSABI] == ELFOSABI_NONE
9008          && elf_tdata (abfd)->has_ifunc_symbols)
9009        i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_LINUX;
9010  }  }
9011    
9012    
9013  /* Return TRUE for ELF symbol types that represent functions.  /* Return TRUE for ELF symbol types that represent functions.
9014     This is the default version of this function, which is sufficient for     This is the default version of this function, which is sufficient for
9015     most targets.  It returns true if TYPE is STT_FUNC.  */     most targets.  It returns true if TYPE is STT_FUNC or STT_GNU_IFUNC.  */
9016    
9017  bfd_boolean  bfd_boolean
9018  _bfd_elf_is_function_type (unsigned int type)  _bfd_elf_is_function_type (unsigned int type)
9019  {  {
9020    return (type == STT_FUNC);    return (type == STT_FUNC
9021              || type == STT_GNU_IFUNC);
9022  }  }

Legend:
Removed from v.20  
changed lines
  Added in v.21

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26