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: Re: Objcopy problem


Daniel Jacobowitz wrote:
> On Tue, Oct 30, 2007 at 02:48:11PM +0000, Andrew STUBBS wrote:
>   
>> The linker will not allow us to create a loadable section for which we do not 
>> yet know the contents.
>>     
>
> Sure it will.  Just zero-fill it, and then set its contents later -
> you know the size of the signature, right?  You can just use .space.
>   
Hi Daniel,

I'm the culprit who was using this feature of objcopy.  Let me elaborate...

We don't know the size required for the reserve section at compile
time.  In addition we do not know the number of reserve sections
required - the test case provided only had one for the .text section,
but our default linker script supports two, and our users may decide to
create more using an additional linker script.

In our tools the 0x160 in the link.ld script is actually a symbol
defined using the --defsym option to ld, and is changed depending on the
hardware security on the silicon being targeted.

As you say, there is the solution of using a specially created assembler
file with .section and .space directives in it, but this would make
creation of an ELF file that can have the signature(s) added more
involved - rather than defining a symbol (or multiple symbols if there
are multiple reserve sections) at link time, the end user would have to
potentially create these assembler files, assemble them and link them,
to get the same effect.

Looking at the binutils documentation, I believe the old behaviour is
documented where the objcopy option '--set-section-flags' is documented:
"You can set the âcontentsâ flag for a section which does not have
contents..."

Ideally there would be a way to tell ld to make the reserve sections
have the CONTENTS flag in the linker script, but I could not find a way
of doing that without putting something in there (which I don't want to
do in the case where the size of the reserve section should be 0 as no
signature is required).  I had thought that an '=FILLEXP' at the end of
an output section description in the linker script might force the
CONTENTS flag to be set if the section is not 0 size, but it does not.

Regards,
Dave.


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