From mboxrd@z Thu Jan 1 00:00:00 1970 Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 22 Feb 2008 12:29:30 +0000 (GMT) Received: from localhost.localdomain ([127.0.0.1]:18877 "EHLO dl5rb.ham-radio-op.net") by ftp.linux-mips.org with ESMTP id S28577432AbYBVM32 (ORCPT ); Fri, 22 Feb 2008 12:29:28 +0000 Received: from denk.linux-mips.net (denk.linux-mips.net [127.0.0.1]) by dl5rb.ham-radio-op.net (8.14.1/8.13.8) with ESMTP id m1MCTRnO018083; Fri, 22 Feb 2008 12:29:27 GMT Received: (from ralf@localhost) by denk.linux-mips.net (8.14.1/8.14.1/Submit) id m1MCTQXB018082; Fri, 22 Feb 2008 12:29:26 GMT Date: Fri, 22 Feb 2008 12:29:26 +0000 From: Ralf Baechle To: robert song Cc: linux-mips@linux-mips.org Subject: Re: MIPS section alignment of object file Message-ID: <20080222122926.GB17312@linux-mips.org> References: <3e004f8e0802210812k723a11f5ve9fa816d83bb082b@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3e004f8e0802210812k723a11f5ve9fa816d83bb082b@mail.gmail.com> User-Agent: Mutt/1.5.17 (2007-11-01) Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 18288 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: ralf@linux-mips.org Precedence: bulk X-list: 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