This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: displays dynamic segment even if no .dynamic section
- From: Tristan Gingold <gingold at adacore dot com>
- To: Jim Wilson <wilson at specifix dot com>
- Cc: binutils at sourceware dot org
- Date: Thu, 12 Jul 2007 12:32:23 +0200
- Subject: Re: displays dynamic segment even if no .dynamic section
- References: <3443EAAB-0056-4693-B554-2E4D4C96BDF5@adacore.com> <1184196861.2749.73.camel@localhost.localdomain>
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.
Correct.
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.
Correct.
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:
case PT_DYNAMIC:
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"));
break;
}
if (sec->sh_type == SHT_NOBITS)
break;
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.
Tristan.