This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: can we pad some section with some value


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]