This is the mail archive of the binutils@sourceware.cygnus.com 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]

Re: patch to nm allows nm to differentiate between weak functions and weak objects


Nick Clifton wrote:
[snip]
> Great, unfortunately I have noticed another problem.  There are
> several places (in bfd/sym.c and binutils/nm.c) where the return value
> of bfd_decode_symclass() is checked to see if the symbol is
> unresolved.  These tests look for a return value of 'U' or 'w', but
> not your new value 'v'....

Hi Nick!

How about tekhex.c (in tekhex_write_object_contents)?

There also seems to be a case here, that checks for 'U' but did not
check for 'w'... I did not take action on adding 'w' & 'v' there in
this (attempted) patch, not knowing anything about tekhex format.

tom

> 
> One other point - please can you send patches and patch revisions to
> the binutils list, rather than just me.  I do read that list, and this
> way other people also get a chance to examine and comment on your
> patches.
> 
> Cheers
>         Nick
We needed to distiguish in an nm dump listing between symbols
that are weak functions and symbols that are weak objects. nm
only dumped weak syms without making the distinction. A new "letter"
was added "V/v" to show weak objects...

Sigh - hope I got everything this time. 3rd time's a charm hopefully?
Sorry, still new to GNU here ;-)
======================================================================
2000-01-27  Thomas de Lellis  <tdel@windriver.com>

        * syms.c (bfd_decode_symclass)
        Two new class characters were added - 'V' and 'v'.  The
        meaning of 'W' is now restricted to just weak non-object
        symbols.  This allows differentiation between, for example,
        weak functions vs weak objects.  nm for example now dumps:
        'W' = weak global
        'w' = weak unresolved
        'V' = weak global object
        'v' = weak unresolved object

        syms.c (bfd_symbol_info): Added 'v' to the list of
        undefined classes being checked.

======================================================================
*** syms.c@@/main/3	Mon Oct  4 13:46:29 1999
--- syms.c	Thu Jan 27 11:42:45 2000
*************** bfd_decode_symclass (symbol)
*** 579,592 ****
    if (bfd_is_und_section (symbol->section))
      {
        if (symbol->flags & BSF_WEAK)
! 	return 'w';
        else
  	return 'U';
      }
    if (bfd_is_ind_section (symbol->section))
      return 'I';
!   if (symbol->flags & BSF_WEAK)
!     return 'W';
    if (!(symbol->flags & (BSF_GLOBAL | BSF_LOCAL)))
      return '?';
  
--- 579,606 ----
    if (bfd_is_und_section (symbol->section))
      {
        if (symbol->flags & BSF_WEAK)
! 	{
! 	  /* If weak, determine if it's specifically an object
! 	     or non-object weak.  */
! 	  if (symbol->flags & BSF_OBJECT)
! 	    return 'v';
! 	  else
! 	    return 'w';
! 	}
        else
  	return 'U';
      }
    if (bfd_is_ind_section (symbol->section))
      return 'I';
!   if (symbol->flags & BSF_WEAK) 
!     {
!       /* If weak, determine if it's specifically an object
! 	 or non-object weak.  */
!       if (symbol->flags & BSF_OBJECT)
! 	return 'V';
!       else
! 	return 'W';
!     }
    if (!(symbol->flags & (BSF_GLOBAL | BSF_LOCAL)))
      return '?';
  
*************** bfd_symbol_info (symbol, ret)
*** 629,635 ****
       symbol_info *ret;
  {
    ret->type = bfd_decode_symclass (symbol);
!   if (ret->type != 'U' && ret->type != 'w')
      ret->value = symbol->value + symbol->section->vma;
    else
      ret->value = 0;
--- 643,649 ----
       symbol_info *ret;
  {
    ret->type = bfd_decode_symclass (symbol);
!   if (ret->type != 'U' && ret->type != 'w' && ret->type != 'v')
      ret->value = symbol->value + symbol->section->vma;
    else
      ret->value = 0;
======================================================================
2000-27-01  Thomas de Lellis  <tdel@windriver.com>

        * nm.c (print_symbol_info_bsd):  Where 'w' class weaks
        were being check for, we now also check for 'v' weaks.
        (print_symbol_info_sysv):  Ditto.
        (print_symbol_info_posix):  Ditto.

        * binutils.texi: Document new 'V' symclass flag for nm.

======================================================================
*** nm.c@@/main/3	Fri Jul 16 18:36:14 1999
--- nm.c	Thu Jan 27 14:22:41 2000
*************** print_archive_filename_posix (filename)
*** 1326,1332 ****
  
  static void
  print_archive_member_bsd (archive, filename)
!      char *archive;
       CONST char *filename;
  {
    if (!filename_per_symbol)
--- 1326,1332 ----
  
  static void
  print_archive_member_bsd (archive, filename)
!      char *archive ATTRIBUTE_UNUSED;
       CONST char *filename;
  {
    if (!filename_per_symbol)
*************** print_symbol_info_bsd (info, abfd)
*** 1434,1440 ****
       symbol_info *info;
       bfd *abfd;
  {
!   if (info->type == 'U')
      {
        printf ("%*s",
  #ifdef BFD64
--- 1434,1440 ----
       symbol_info *info;
       bfd *abfd;
  {
!   if (info->type == 'U' || info->type == 'w' || info->type == 'v')
      {
        printf ("%*s",
  #ifdef BFD64
*************** print_symbol_info_sysv (info, abfd)
*** 1465,1471 ****
       bfd *abfd;
  {
    print_symname ("%-20s|", info->name, abfd);	/* Name */
!   if (info->type == 'U')
      printf ("        ");	/* Value */
    else
      print_value (info->value);
--- 1465,1471 ----
       bfd *abfd;
  {
    print_symname ("%-20s|", info->name, abfd);	/* Name */
!   if (info->type == 'U' || info->type == 'w' || info->type == 'v')
      printf ("        ");	/* Value */
    else
      print_value (info->value);
*************** print_symbol_info_posix (info, abfd)
*** 1488,1494 ****
  {
    print_symname ("%s ", info->name, abfd);
    printf ("%c ", info->type);
!   if (info->type == 'U')
      printf ("        ");
    else
      print_value (info->value);
--- 1488,1494 ----
  {
    print_symname ("%s ", info->name, abfd);
    printf ("%c ", info->type);
!   if (info->type == 'U' || info->type == 'w' || info->type == 'v')
      printf ("        ");
    else
      print_value (info->value);
======================================================================
*** binutils.texi@@/main/4	Mon Oct  4 13:02:35 1999
--- binutils.texi	Tue Jan 25 15:13:47 2000
*************** The symbol is in the text (code) section
*** 712,722 ****
  @item U
  The symbol is undefined.
  
  @item W
! The symbol is weak.  When a weak defined symbol is linked with a normal
! defined symbol, the normal defined symbol is used with no error.  When a
! weak undefined symbol is linked and the symbol is not defined, the value
! of the weak symbol becomes zero with no error.
  
  @item -
  The symbol is a stabs symbol in an a.out object file.  In this case, the
--- 712,729 ----
  @item U
  The symbol is undefined.
  
+ @item V
+ The symbol is a weak object.  When a weak defined symbol is linked with
+ a normal defined symbol, the normal defined symbol is used with no error.
+ When a weak undefined symbol is linked and the symbol is not defined,
+ the value of the weak symbol becomes zero with no error.
+ 
  @item W
! The symbol is a weak symbol that has not been specifically tagged as a
! weak object symbol.  When a weak defined symbol is linked with a normal
! defined symbol, the normal defined symbol is used with no error.
! When a weak undefined symbol is linked and the symbol is not defined,
! the value of the weak symbol becomes zero with no error.
  
  @item -
  The symbol is a stabs symbol in an a.out object file.  In this case, the

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