This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Objcopy problem
- From: Andrew STUBBS <andrew dot stubbs at st dot com>
- To: binutils at sourceware dot org
- Date: Mon, 29 Oct 2007 19:41:11 +0000
- Subject: Objcopy problem
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
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
BFD: a2.out: section `.text' can't be allocated in segment 0
/group/mdt/products/st40/st40r2-bsf-linux/bin/sh4objcopy: a2.out: Bad value
BFD: a2.out: section `.text' can't be allocated in segment 0
/group/mdt/products/st40/st40r2-bsf-linux/bin/sh4objcopy: a2.out: Bad value
I've tracked this error message to bfd/elf.c . It appears to have been
introduced last February/March as a fix for a linker issue:
http://sourceware.org/ml/binutils/2007-02/msg00375.html . Of course, it
might be that the problem is due to another change somewhere else, and
this check is just catching it.
Am I really trying to do something illegal, or is there likely some
problem with BFD? I can't easily debug this without really understanding
what the right behaviour is. It doesn't seem right that it reports an
error against .text, when it's the .post_text_reserve that's been altered.
My target is SH, if that makes any difference.
Thanks in advance
Andrew