This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Objcopy problem
- From: "H.J. Lu" <hjl at lucon dot org>
- To: Andrew STUBBS <andrew dot stubbs at st dot com>
- Cc: binutils at sourceware dot org
- Date: Mon, 29 Oct 2007 13:16:32 -0700
- Subject: Re: Objcopy problem
- References: <47263757.2070908@st.com>
On Mon, Oct 29, 2007 at 07:41:11PM +0000, Andrew STUBBS wrote:
> Hi,
>
> I'm having a bit of trouble adjusting section flags with objcopy.
>
> I can create a test case using the following program and linker script:
>
> FILE: test.c
> int main()
> {
> }
> END-FILE
>
> FILE: link.ld
> SECTIONS
> {
> .text :
> {
> *(.text .stub .text.* .gnu.linkonce.t.*)
> } =0
> .post_text_reserve :
> {
> /* Reserve some space so we can drop something in here later */
> . += 0x160;
> }
> }
> END-FILE
>
> $ gcc test.c -T link.ld -nostdlib
>
> This successfully produces a (rather useless) binary which looks like this:
>
> $ sh4objdump -ph a.out
>
> a.out: file format elf32-shl
>
> Program Header:
> LOAD off 0x00000080 vaddr 0x00000000 paddr 0x00000000 align 2**7
> filesz 0x0000000c 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
> ALLOC
> 2 .comment 00000043 00000000 00000000 0000008c 2**0
> CONTENTS, READONLY
>
.post_text_reserve has file size 0 and memory size 0x160
>
>
>
> All good so far, but now I need to add extra flags to the
> .post_text_reserve section.
>
> I used to be able to do it with objdump (I was using 2.16.91.0.5), but
> now I get an error (using 2.17.50.0.17):
> $ sh4objcopy a.out a2.out --set-section-flags
> .post_text_reserve=contents,alloc,load,readonly,code
How do you load a section with file size 0?
H.J.