This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[REINSTATED] Re: [PATCH,trunk+2.20.1] Extend COFF .section directive syntax to specify alignment.
- From: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- To: Dave Korn <dave dot korn dot cygwin at googlemail dot com>, "binutils at sourceware dot org" <binutils at sourceware dot org>, Tristan Gingold <gingold at adacore dot com>
- Date: Thu, 21 Jan 2010 16:08:21 +0000
- Subject: [REINSTATED] Re: [PATCH,trunk+2.20.1] Extend COFF .section directive syntax to specify alignment.
- References: <4B535907.2010904@gmail.com> <20100117234125.GG8112@bubble.grove.modra.org>
On 17/01/2010 23:41, Alan Modra wrote:
> On Sun, Jan 17, 2010 at 06:37:59PM +0000, Dave Korn wrote:
>> There's currently no way to specify the alignment of a section in the
>> assembler;
>
> Huh?
>
> .text
> nop
>
> .data
> .p2align 7
> .long 123
>
> $ gas/as-new /src/tmp/align.s
> $ binutils/objdump -h a.out
>
> a.out: file format pe-i386
>
> Sections:
> Idx Name Size VMA LMA File off Algn
> 0 .text 00000004 00000000 00000000 0000008c 2**2
> CONTENTS, ALLOC, LOAD, READONLY, CODE
> 1 .data 00000080 00000000 00000000 00000090 2**7
> CONTENTS, ALLOC, LOAD, DATA
> 2 .bss 00000000 00000000 00000000 00000000 2**2
> ALLOC
Ah, hang on.
What I should have said was: There is currently no way to specify an
alignment *less than the default section alignment* for a section:
> $ for x in 12 11 10 9 8 7 6 5 4 3 2 1 0 ; do echo " .text ; nop ; .data ; .p2al
> ign $x; .long 123; .end " | as -o test.o - ; objdump -h test.o | grep '\.data'
> ; done
> 1 .data 00001000 00000000 00000000 00000090 2**12
> 1 .data 00000800 00000000 00000000 00000090 2**11
> 1 .data 00000400 00000000 00000000 00000090 2**10
> 1 .data 00000200 00000000 00000000 00000090 2**9
> 1 .data 00000100 00000000 00000000 00000090 2**8
> 1 .data 00000080 00000000 00000000 00000090 2**7
> 1 .data 00000040 00000000 00000000 00000090 2**6
> 1 .data 00000020 00000000 00000000 00000090 2**5
> 1 .data 00000010 00000000 00000000 00000090 2**4
> 1 .data 00000008 00000000 00000000 00000090 2**3
> 1 .data 00000004 00000000 00000000 00000090 2**2
> 1 .data 00000004 00000000 00000000 00000090 2**2
> 1 .data 00000004 00000000 00000000 00000090 2**2
>
> $
LTO requires sections to be 2**0 aligned, because they have to be exactly
sized to their contents: any trailing padding fatally confuses the zlib stream
decompressor. See also gas/config/obj-coff.c!coff_frob_section(), where it
forcibly pads out section sizes to the default alignment:
> /* The COFF back end in BFD requires that all section sizes be
> rounded up to multiples of the corresponding section alignments,
> supposedly because standard COFF has no other way of encoding alignment
> for sections. If your COFF flavor has a different way of encoding
> section alignment, then skip this step, as TICOFF does. */
So I don't think I can leave it 4-aligned but have the size 1-byte granular,
if that warning is anything to go by. Therefore I think I need a way to
under-ride the default section size. Is there anything else you can think of
that already exists and will do what I want, or should I revive this patch?
cheers,
DaveK