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


On Tue, Oct 30, 2007 at 02:48:11PM +0000, Andrew STUBBS wrote:
> H.J. Lu wrote:
> >How do you load a section with file size 0?
> 
> One does not. Here's the effect of this command in the old tools:
> 
>   $ sh4objcopy a.out a2.out --set-section-flags 
> .post_text_reserve=contents,alloc,load,readonly,code
>   $ sh4objdump -ph a2.out
> 
> a2.out:     file format elf32-shl
> 
> Program Header:
>     LOAD off    0x00000080 vaddr 0x00000000 paddr 0x00000000 align 2**7
>          filesz 0x0000016c memsz 0x0000016c flags rwx
> 
> Sections:
> Idx Name          Size      VMA       LMA       File off  Algn
>   0 .text         0000000c  00000000  00000000  00000080  2**1
>                   CONTENTS, ALLOC, LOAD, READONLY, CODE
>   1 .post_text_reserve 00000160  0000000c  0000000c  0000008c  2**0
>                   CONTENTS, ALLOC, LOAD, READONLY, CODE
>   2 .comment      00000043  00000000  00000000  000001ec  2**0
>                   CONTENTS, READONLY
> 
> As you can see, the section now _has_ a file size. This was the point of 
> the exercise - the section contents may now be overwritten with the 
> final data (in this case a digital signature used to verify the other 
> sections).
> 
> The linker will not allow us to create a loadable section for which we 
> do not yet know the contents. Therefore, this trick is used to convert 
> the elf file into the form we need.

Please open a bug report. I will take a look. Thanks.



H.J.


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