This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB 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]

Problem determining section size


I have the following code


      int              l_ret          = 0;
      bfd              *l_exe         = NULL;
      asection         *l_dynsec      = NULL;
      unsigned long    l_dynsize      = 0;
      unsigned long    l_dynaddr      = 0;
      Elf32_Dyn        *l_dynentry    = NULL;
      Elf32_Dyn        *l_dtemp       = NULL;
      char             **l_match      = NULL;
      const char       *l_err         = NULL;
      
      /***********************/
      /* open the executable */
      /***********************/
      
      l_exe = bfd_openr(p_prinfo->p_exe,NULL);
      if (!l_exe)
      { /* failed to open executable */
         l_err = bfd_errmsg(bfd_get_error( )); /* read BFD error */
         printf("ERROR %s OPENING EXECUTABLE %s
!!!\n",l_err,p_prinfo->p_exe); 
         return(-EBADF); /* set bad file error indicator */
      }
      
      /************************/
      /* find matching format */
      /************************/
      
      if (!bfd_check_format_matches(l_exe,bfd_object,&l_match))
      { /* unable to find matching format */
         l_err = bfd_errmsg(bfd_get_error( )); /* read BFD error */
         bfd_close(l_exe); /* close executable file */
         printf("ERROR %s FINDING MATCHING FORMAT ON %s
!!!\n",l_err,l_exe->filename);
         return(-EBADF); /* set bad file error indicator */
      }
      
      /***********************************/
      /* read the dynamic section header */
      /***********************************/
      
      l_dynsec = bfd_get_section_by_name(l_exe,".dynamic");
      if (!l_dynsec)
      { /* failed to read dynamic section */
         l_err = bfd_errmsg(bfd_get_error( )); /* read BFD error */
         bfd_close(l_exe); /* close executable file */
         printf("ERROR %s READING DYNAMIC SECTION FROM %s
!!!\n",l_err,p_prinfo->p_exe);
         return(-EFAULT); /* set fault indicator */
      }
      
      /********************************/
      /* extract dynamic info address */
      /********************************/
     
      l_dynaddr = bfd_section_vma(l_exe,l_dynsec);
      
      /*************************************/
      /* determine size of dynamic section */
      /*************************************/
      
      l_dynsize = bfd_section_size(l_exe,l_dynsec);
      return(l_ret); /* set response */


l_dynsize always returns 0!!!!!!!

Any ideas why?


Thanks in advance


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