This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: can we pad some section with some value
- From: loody <miloody at gmail dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: binutils at sourceware dot org
- Date: Tue, 2 Feb 2010 21:31:51 +0800
- Subject: Re: can we pad some section with some value
- References: <3a665c761001210039h508e2355v9d2f5468f7178272@mail.gmail.com> <4B5D7F23.6090408@redhat.com>
Dear Nick:
2010/1/25 Nick Clifton <nickc@redhat.com>:
> Hi miloody,
>
>> What can I ask linker to help me, if I need the whole binary padding
>> to a fix length?
>> ex:
>> ? ?suppose my binary is 11k. But I want the linker to pad the end of
>> binary and make the whole size of final output file ?to be 16k, like
>> what alignment does.
>> is there any command I can use?
>
> What you need is a dummy section at the end of your linker script which is
> sized so that it will extend the binary to the required length. ?For
> example:
>
> ?SECTIONS
> ?{
> ? ?.text : { *(.text); }
> ? ?.data : { *(.data); }
>
> ? ?here = . ; .fill : { LONG(0xff); . = 0x3ffc - here ; } =0xff
> ?}
>
> Note - you need at least one entry in the .fill section in order to the
> linker to decide that it actually has some contents, and so give it the
> PROGBITS type rather than the NOBITS type.
>
> The value 0x3ffc in the above example is computed as: "16k - 4 bytes", the
> four bytes being for the LONG value.
>
> Cheers
> ?Nick
>
Thanks for your help :)
miloody