displays dynamic segment even if no .dynamic section

Tristan Gingold gingold@adacore.com
Thu Jul 12 10:30:00 GMT 2007

On Jul 12, 2007, at 1:34 AM, Jim Wilson wrote:

> On Mon, 2007-06-25 at 14:42 +0200, Tristan Gingold wrote:
> I lack info and access to an Itanium VMS system.  Also, there is no
> Itanium VMS support in FSF binutils.
Right.  We have a very preliminary port here but far from being  
complete (ld need much work).

>   Anyways, this means I can only go
> by the info you have given me.
> I'm puzzled about what exactly the failure case is here.  If there are
> no section headers, then the existing code will already do what you
> want.

> If there are section headers, but no .dynamic section in the
> headers (or a zero size .dynamic section), then the existing code will
> give an error.

>   This is true even with your patch, so your patch does
> not seem to fix the problem you have described.
Here I am puzzled about your reply!
If there is no .dynamic section, an error is printed but dynamic_addr  
and dynamic_size are set from segment and .dynamic is
eventually displayed.  Am I missing something else ? (I have tested  
this patch on the odd VMS executable).

For reference, here is an excerpt of the modified code:

	  if (dynamic_addr)
	    error (_("more than one dynamic segment\n"));

	  /* By default, we can only assume that the .dynamic
	     section is the first section in the DYNAMIC segment.  */
	  dynamic_addr = segment->p_offset;
	  dynamic_size = segment->p_filesz;

	  /* Try to locate the .dynamic section. If there is
	     a section header table, we can easily locate it.  */
	  if (section_headers != NULL)
	      Elf_Internal_Shdr *sec;

	      sec = find_section (".dynamic");
	      if (sec == NULL || sec->sh_size == 0)
		  error (_("no .dynamic section in the dynamic segment\n"));

	      if (sec->sh_type == SHT_NOBITS)

> Looking at the code,
> the only case where the patch seems to do anything different is if  
> there
> are section headers, there is a .dynamic section in the headers,  
> but the
> dynamic section has SHT_NOBITS.  In this case, dynamic_addr is not set
> without your patch, and is set with your patch.  However, it isn't  
> clear
> to me why you want to do this.  Why use the section if it is  
> empty?  I'm
> also not sure how a section can have non-zero size and SHT_NOBITS set,
> but I'm not a linker expert.
In fact error() doesn't exit.


More information about the Binutils mailing list