This is the mail archive of the gdb-patches@sourceware.org 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]

Re: [PING] [rfc]: Framework for looking up multiply defined global symbols in shared libraries


Markus Deuling wrote:

> +/* Handler for library-specific lookup of global symbol
> +   NAME in BLOCK.  Detect objfile corresponding to BLOCK
> +   and call the library-specific handler if it is installed
> +   for the current target.  */

Comment no longer matches the prototype ...

> +struct symbol *
> +solib_global_lookup (const struct objfile *objfile,
> +		     const char *name,
> +		     const char *linkage_name,
> +		     const domain_enum domain,
> +		     struct symtab **symtab)


> +has_SYMBOLIC (bfd *obfd)
> +{
> +  CORE_ADDR dyn_ptr = 0;
> +  int sect_size, arch_size;
> +  gdb_byte *buf, *bufstart, *bufend, *p;
> +  asection *sect;
> +
> +  if (obfd == NULL)
> +    return -1;
> +  arch_size = bfd_get_arch_size (obfd);
> +  if (arch_size == -1)
> +    return -1;
> +
> +  /* Retrieve information about .dynamic section.  */
> +  sect = bfd_get_section_by_name (obfd, ".dynamic");
> +  if (!sect)
> +    return -1;
> +
> +  /* Read the .dynamic section.  */
> +  sect_size = bfd_section_size (obfd, sect);
> +  buf = alloca (sect_size);
> +  if (!bfd_get_section_contents (obfd, sect,
> +				 buf, 0, sect_size))
> +    return -1;
> +
> +  if (arch_size == 32)
> +    { /* 32-bit elf */
> +      for (bufend = buf + sect_size;
> +	   buf < bufend;
> +	   buf += sizeof (Elf32_External_Dyn))
> +	{
> +	  Elf32_External_Dyn *x_dynp = (Elf32_External_Dyn *) buf;
> +	  long dyn_tag;
> +	  dyn_tag = extract_unsigned_integer ((gdb_byte *) x_dynp->d_tag, 4);
> +	  if (dyn_tag == DT_NULL)
> +	    break;
> +	  else if (dyn_tag == DT_SYMBOLIC)
> +	    return 1;
> +	}
> +    }
> +  else
> +    { /* 64-bit elf */
> +      for (bufend = buf + sect_size;
> +	   buf < bufend;
> +	   buf += sizeof (Elf64_External_Dyn))
> +	{
> +	  Elf64_External_Dyn *x_dynp = (Elf64_External_Dyn *) buf;
> +	  long dyn_tag;
> +
> +	  dyn_tag = extract_unsigned_integer ((gdb_byte *) x_dynp->d_tag, 8);
> +	  if (dyn_tag == DT_NULL)
> +	    break;
> +	  else if (dyn_tag == DT_SYMBOLIC)
> +	    return 1;
> +	}
> +    }

It looks like this duplicates a whole bunch of code from elf_locate_base.
Maybe we should extract a helper routine that retrieves a given DT_ tag
from the .dynamic section?


> +/* Look up OBJFILE to BLOCK.  */
> +
> +struct objfile *
> +lookup_objfile_from_block (const struct block *block)

I guess this could be static now.

> +/* Lookup objfile to a block.  */
> +extern struct objfile *
> +lookup_objfile_from_block (const struct block *block);

If we make it static, this should go away.  Otherwise, the function name
should again not start in the first column for the prototype.


Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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