This is the mail archive of the binutils@sources.redhat.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]
Other format: [Raw text]

Broken symbol version number check.


The check in elf_link_add_object_symbols assumes they are consecutive and 
zero-based. This is happens to be true for DSOs produced by GNU ld, but 
AFAICS is not a requirement. Comments (and code) in 
_bfd_elf_slurp_version_tables also indicate that defined symbol version 
numbers need not be consecutive.

The patch below fixes the test to accept non-consecutive symbol versions. It 
takes advantage of the fact that verdef array is allocated with bfd_zalloc, 
so unused version indices will have a NULL name.

Build --enable-targets=all and tested on i686-linux.
Ok?

Paul

2004-11-04  Paul Brook  <paul@codesourcery.com>

 * elflink.c (elf_link_add_object_symbols): Don't assume version
 indices are consecutive.

Index: elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.116
diff -c -p -r1.116 elflink.c
*** elflink.c 2 Nov 2004 05:44:34 -0000 1.116
--- elflink.c 4 Nov 2004 15:23:47 -0000
*************** elf_link_add_object_symbols (bfd *abfd, 
*** 3518,3537 ****
  
      if (isym->st_shndx != SHN_UNDEF)
        {
!         if (vernum > elf_tdata (abfd)->dynverdef_hdr.sh_info)
     {
       (*_bfd_error_handler)
         (_("%B: %s: invalid version %u (max %d)"),
          abfd, name, vernum,
!         elf_tdata (abfd)->dynverdef_hdr.sh_info);
       bfd_set_error (bfd_error_bad_value);
       goto error_free_vers;
     }
-         else if (vernum > 1)
-    verstr =
-      elf_tdata (abfd)->verdef[vernum - 1].vd_nodename;
-         else
-    verstr = "";
        }
      else
        {
--- 3518,3540 ----
  
      if (isym->st_shndx != SHN_UNDEF)
        {
!         if (vernum > elf_tdata (abfd)->cverdefs)
!    verstr = NULL;
!         else if (vernum > 1)
!    verstr =
!      elf_tdata (abfd)->verdef[vernum - 1].vd_nodename;
!         else
!    verstr = "";
! 
!         if (verstr == NULL)
     {
       (*_bfd_error_handler)
         (_("%B: %s: invalid version %u (max %d)"),
          abfd, name, vernum,
!         elf_tdata (abfd)->cverdefs);
       bfd_set_error (bfd_error_bad_value);
       goto error_free_vers;
     }
        }
      else
        {


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