This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[darwin/committed]: Add a few comments to bfd_mach_o_get_synthetic_symtab


Hi,

this patch just adds a few comments I added while reviewing.

Committed on trunk.

Tristan.

bfd/
2012-01-04  Tristan Gingold  <gingold@adacore.com>

	* mach-o.c (bfd_mach_o_get_synthetic_symtab): Add comments.

RCS file: /cvs/src/src/bfd/mach-o.c,v
retrieving revision 1.86
diff -c -r1.86 mach-o.c
*** bfd/mach-o.c	4 Jan 2012 09:58:54 -0000	1.86
--- bfd/mach-o.c	4 Jan 2012 10:12:41 -0000
***************
*** 651,656 ****
--- 651,658 ----
    return nsyms;
  }
  
+ /* Create synthetic symbols for indirect symbols.  */
+ 
  long
  bfd_mach_o_get_synthetic_symtab (bfd *abfd,
                                   long symcount ATTRIBUTE_UNUSED,
***************
*** 670,688 ****
  
    *ret = NULL;
  
    if (dysymtab == NULL || symtab == NULL || symtab->symbols == NULL)
      return 0;
  
    if (dysymtab->nindirectsyms == 0)
      return 0;
  
    count = dysymtab->nindirectsyms;
    size = count * sizeof (asymbol) + 1;
  
    for (j = 0; j < count; j++)
      {
        unsigned int isym = dysymtab->indirect_syms[j];
!               
        if (isym < symtab->nsyms && symtab->symbols[isym].symbol.name)
          size += strlen (symtab->symbols[isym].symbol.name) + sizeof ("$stub");
      }
--- 672,694 ----
  
    *ret = NULL;
  
+   /* Stop now if no symbols or no indirect symbols.  */
    if (dysymtab == NULL || symtab == NULL || symtab->symbols == NULL)
      return 0;
  
    if (dysymtab->nindirectsyms == 0)
      return 0;
  
+   /* We need to allocate a bfd symbol for every indirect symbol and to
+      allocate the memory for its name.  */
    count = dysymtab->nindirectsyms;
    size = count * sizeof (asymbol) + 1;
  
    for (j = 0; j < count; j++)
      {
        unsigned int isym = dysymtab->indirect_syms[j];
! 
!       /* Some indirect symbols are anonymous.  */
        if (isym < symtab->nsyms && symtab->symbols[isym].symbol.name)
          size += strlen (symtab->symbols[isym].symbol.name) + sizeof ("$stub");
      }
***************
*** 707,712 ****
--- 713,719 ----
          case BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS:
          case BFD_MACH_O_S_LAZY_SYMBOL_POINTERS:
          case BFD_MACH_O_S_SYMBOL_STUBS:
+           /* Only these sections have indirect symbols.  */
            first = sec->reserved1;
            last = first + bfd_mach_o_section_get_nbr_indirect (abfd, sec);
            addr = sec->addr;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]