public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* displays dynamic segment even if no .dynamic section
@ 2007-06-25 12:40 Tristan Gingold
  2007-06-25 12:57 ` Changing mips-elf-as behavior on delayed branches nkavv
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Tristan Gingold @ 2007-06-25 12:40 UTC (permalink / raw)
  To: binutils

Hi,

currently dynamic segment of VMS itanium (ELF format) cannot be  
displayed because there is no .dynamic section in the section table.
This patch fixes the issue by always using dynamic segment unless  
there is a .dynamic section.

binutils:
2007-06-25  Tristan Gingold  <gingold@adacore.com>

	* readelf.c (process_program_headers): use DYNAMIC segment unless
	.dynamic section is found.

*** readelf.c   30 May 2007 14:29:27 -0000      1.365
--- readelf.c   25 Jun 2007 12:30:55 -0000
*************** process_program_headers (FILE *file)
*** 3503,3508 ****
--- 3503,3513 ----
           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)
*************** process_program_headers (FILE *file)
*** 3528,3540 ****
               else if (dynamic_addr > segment->p_offset)
                 warn (_("the .dynamic section is not the first  
section in the dynamic segment.\n"));
             }
-         else
-           {
-             /* Otherwise, 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;
-           }
           break;

         case PT_INTERP:
--- 3533,3538 ----

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Changing mips-elf-as behavior on delayed branches
  2007-06-25 12:40 displays dynamic segment even if no .dynamic section Tristan Gingold
@ 2007-06-25 12:57 ` nkavv
  2007-06-25 13:19   ` Thiemo Seufer
  2007-07-12  1:39 ` displays dynamic segment even if no .dynamic section Jim Wilson
  2007-10-24  3:55 ` Alan Modra
  2 siblings, 1 reply; 6+ messages in thread
From: nkavv @ 2007-06-25 12:57 UTC (permalink / raw)
  To: binutils

Hi fellow binutilers

i have to comment on something that caught me by surprise. The binutils MIPS
target (actually for binutils-2.15.94 of a build for a no-cost development
environment) does not provide any options on delayed branching.

The "mips-elf-as" assembler supposes that what is ALWAYS targeted is a MIPS
microarchitecture with delayed branches (this applies for example for -mips1
and -mips32). It does not even provide the option to switch this assumption
off. At first i expected that there would exist something close to the gcc
option (-fno-delayed-branch) that is resolved by gcc RTL emission. But is seems
impossible to the assembler making the decision.

I work on embedded systems (embedded processor architecture) since 2000 and i
always thought that delayed branching is a bad-to-the-bone design practice.

Is it possible to disable assembly-code restructuring by "mips-elf-as" as it
could be for a clean microarchitecture with no delayed branching.

Thank you in advance
Nikolaos Kavvadias

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Changing mips-elf-as behavior on delayed branches
  2007-06-25 12:57 ` Changing mips-elf-as behavior on delayed branches nkavv
@ 2007-06-25 13:19   ` Thiemo Seufer
  0 siblings, 0 replies; 6+ messages in thread
From: Thiemo Seufer @ 2007-06-25 13:19 UTC (permalink / raw)
  To: nkavv; +Cc: binutils

nkavv@physics.auth.gr wrote:
> Hi fellow binutilers
> 
> i have to comment on something that caught me by surprise. The binutils MIPS
> target (actually for binutils-2.15.94 of a build for a no-cost development
> environment) does not provide any options on delayed branching.
>
> The "mips-elf-as" assembler supposes that what is ALWAYS targeted is a MIPS
> microarchitecture with delayed branches (this applies for example for -mips1
> and -mips32). It does not even provide the option to switch this assumption
> off. At first i expected that there would exist something close to the gcc
> option (-fno-delayed-branch) that is resolved by gcc RTL emission. But is seems
> impossible to the assembler making the decision.

ISTR that version had already -O0 (and -g) implying no swapped branches.

> I work on embedded systems (embedded processor architecture) since 2000 and i
> always thought that delayed branching is a bad-to-the-bone design practice.

It also makes a CPU a lot faster without having to pay the cost of a branch
predictor. :-)


Thiemo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: displays dynamic segment even if no .dynamic section
  2007-06-25 12:40 displays dynamic segment even if no .dynamic section Tristan Gingold
  2007-06-25 12:57 ` Changing mips-elf-as behavior on delayed branches nkavv
@ 2007-07-12  1:39 ` Jim Wilson
  2007-07-12 10:30   ` Tristan Gingold
  2007-10-24  3:55 ` Alan Modra
  2 siblings, 1 reply; 6+ messages in thread
From: Jim Wilson @ 2007-07-12  1:39 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: binutils

On Mon, 2007-06-25 at 14:42 +0200, Tristan Gingold wrote:
> currently dynamic segment of VMS itanium (ELF format) cannot be  
> displayed because there is no .dynamic section in the section table.
> This patch fixes the issue by always using dynamic segment unless  
> there is a .dynamic section.

I lack info and access to an Itanium VMS system.  Also, there is no
Itanium VMS support in FSF binutils.  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.  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.
-- 
Jim Wilson, GNU Tools Support, http://www.specifix.com


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: displays dynamic segment even if no .dynamic section
  2007-07-12  1:39 ` displays dynamic segment even if no .dynamic section Jim Wilson
@ 2007-07-12 10:30   ` Tristan Gingold
  0 siblings, 0 replies; 6+ messages in thread
From: Tristan Gingold @ 2007-07-12 10:30 UTC (permalink / raw)
  To: Jim Wilson; +Cc: binutils


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.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: displays dynamic segment even if no .dynamic section
  2007-06-25 12:40 displays dynamic segment even if no .dynamic section Tristan Gingold
  2007-06-25 12:57 ` Changing mips-elf-as behavior on delayed branches nkavv
  2007-07-12  1:39 ` displays dynamic segment even if no .dynamic section Jim Wilson
@ 2007-10-24  3:55 ` Alan Modra
  2 siblings, 0 replies; 6+ messages in thread
From: Alan Modra @ 2007-10-24  3:55 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: binutils

On Mon, Jun 25, 2007 at 02:42:32PM +0200, Tristan Gingold wrote:
> 	* readelf.c (process_program_headers): use DYNAMIC segment unless
> 	.dynamic section is found.

I'm about to apply this variation of your patch.

Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.381
diff -u -p -r1.381 readelf.c
--- binutils/readelf.c	9 Oct 2007 13:32:50 -0000	1.381
+++ binutils/readelf.c	17 Oct 2007 05:06:45 -0000
@@ -3530,6 +3530,11 @@ process_program_headers (FILE *file)
 	  if (dynamic_addr)
 	    error (_("more than one dynamic segment\n"));
 
+	  /* By default, 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)
@@ -3544,23 +3549,21 @@ process_program_headers (FILE *file)
 		}
 
 	      if (sec->sh_type == SHT_NOBITS)
-		break;
+		{
+		  dynamic_size = 0;
+		  break;
+		}
 
 	      dynamic_addr = sec->sh_offset;
 	      dynamic_size = sec->sh_size;
 
 	      if (dynamic_addr < segment->p_offset
 		  || dynamic_addr > segment->p_offset + segment->p_filesz)
-		warn (_("the .dynamic section is not contained within the dynamic segment\n"));
+		warn (_("the .dynamic section is not contained"
+			" within the dynamic segment\n"));
 	      else if (dynamic_addr > segment->p_offset)
-		warn (_("the .dynamic section is not the first section in the dynamic segment.\n"));
-	    }
-	  else
-	    {
-	      /* Otherwise, 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;
+		warn (_("the .dynamic section is not the first section"
+			" in the dynamic segment.\n"));
 	    }
 	  break;
 

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-10-24  2:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-25 12:40 displays dynamic segment even if no .dynamic section Tristan Gingold
2007-06-25 12:57 ` Changing mips-elf-as behavior on delayed branches nkavv
2007-06-25 13:19   ` Thiemo Seufer
2007-07-12  1:39 ` displays dynamic segment even if no .dynamic section Jim Wilson
2007-07-12 10:30   ` Tristan Gingold
2007-10-24  3:55 ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).