Linux MIPS Architecture development
 help / color / mirror / Atom feed
* MIPS section alignment of object file
@ 2008-02-21 16:12 robert song
  2008-02-22 12:29 ` Ralf Baechle
  0 siblings, 1 reply; 3+ messages in thread
From: robert song @ 2008-02-21 16:12 UTC (permalink / raw)
  To: linux-mips

Hello, everyone.
some sections like  .data are set to 16 bytes alignment  in the
binutils/gas/config/tc-mips.c as bellows.
	  (void) bfd_set_section_alignment (stdoutput, text_section, 4);

But in other architectures like arm, .data section is aligned to 4
bytes alignment,
and  now I test the object file generated by gas, and found that the
size of .data section sometimes is a little bigger than the situation
of 4 bytes alignments because of the amount of padding.

There are some comments in the tc-mips.c as bellows:
         On a native system other than VxWorks, sections must be aligned
	 to 16 byte boundaries.  When configured for an embedded ELF
	 target, we don't bother.

I want to know whether some mips architecture requires that the
sections of elf object file specifies to be aligned to 16 bytes,  or
else 16-bytes alignment will get a good performance than other
alignments just like 4 bytes????

I recompiled  the binutils by changing the alignment to 4 bytes, and
compiled some
test files, and ran on my mips target(TX4937). There is no problem.

I am really puzzled and any help will be appreciated.

robertsong

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

* Re: MIPS section alignment of object file
  2008-02-21 16:12 MIPS section alignment of object file robert song
@ 2008-02-22 12:29 ` Ralf Baechle
  2008-02-22 19:02   ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Ralf Baechle @ 2008-02-22 12:29 UTC (permalink / raw)
  To: robert song; +Cc: linux-mips

On Fri, Feb 22, 2008 at 01:12:01AM +0900, robert song wrote:

> But in other architectures like arm, .data section is aligned to 4
> bytes alignment,
> and  now I test the object file generated by gas, and found that the
> size of .data section sometimes is a little bigger than the situation
> of 4 bytes alignments because of the amount of padding.
> 
> There are some comments in the tc-mips.c as bellows:
>          On a native system other than VxWorks, sections must be aligned
> 	 to 16 byte boundaries.  When configured for an embedded ELF
> 	 target, we don't bother.
> 
> I want to know whether some mips architecture requires that the
> sections of elf object file specifies to be aligned to 16 bytes,  or
> else 16-bytes alignment will get a good performance than other
> alignments just like 4 bytes????
> 
> I recompiled  the binutils by changing the alignment to 4 bytes, and
> compiled some
> test files, and ran on my mips target(TX4937). There is no problem.
> 
> I am really puzzled and any help will be appreciated.

The minimum alignment technically required is the largest alignment of
any type contained in a section.  Due to the possibility of relocatable
links the assembler can't know what the largest aligment is, so it has
to make a reasonable guess which would be 8 bytes, the size of a double
floating point.  For performance reasons an alignment of the size of a
primary cache line (typically 32 byte these days but could be as much as
128 bytes) could make sense.

  Ralf

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

* Re: MIPS section alignment of object file
  2008-02-22 12:29 ` Ralf Baechle
@ 2008-02-22 19:02   ` Daniel Jacobowitz
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2008-02-22 19:02 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: robert song, linux-mips

On Fri, Feb 22, 2008 at 12:29:26PM +0000, Ralf Baechle wrote:
> The minimum alignment technically required is the largest alignment of
> any type contained in a section.  Due to the possibility of relocatable
> links the assembler can't know what the largest aligment is, so it has
> to make a reasonable guess which would be 8 bytes, the size of a double
> floating point.

That's not really true.  The compiler is responsible for emitting
appropriate .align directives to communicate this.  I don't remember
where the hack in gas came from, but I bet it's required for IRIX.

-- 
Daniel Jacobowitz
CodeSourcery

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

end of thread, other threads:[~2008-02-22 19:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-21 16:12 MIPS section alignment of object file robert song
2008-02-22 12:29 ` Ralf Baechle
2008-02-22 19:02   ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox