This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: arm-wince-pe support resurrection
- From: Dmitry Semyonov <Dmitry dot Semyonov at oktet dot ru>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: <binutils at sources dot redhat dot com>
- Date: Fri, 5 Dec 2003 15:48:03 +0300 (MSK)
- Subject: Re: arm-wince-pe support resurrection
- Reply-to: <Dmitry dot Semyonov at oktet dot ru>
Nick,
On Thu, 4 Dec 2003, Nick Clifton wrote:
> With regards to this patch:
> -------------------------------------------------------------------------------
> 2003-11-18 Dmitry Semyonov <Dmitry.Semyonov@oktet.ru>
>
> * bfd/peXXigen.c (_bfd_XXi_swap_scnhdr_out): Set flags for some special
> sections (.text, .rdata, .data, .bss) as described in
> "MS PE & COFF Specification".
>
> diff -rNc3p binutils-031114/bfd/peXXigen.c /home/sdv/cross/binutils-031114/bfd/peXXigen.c
> *** binutils-031114/bfd/peXXigen.c Fri Nov 14 21:46:53 2003
> --- /home/sdv/cross/binutils-031114/bfd/peXXigen.c Fri Nov 14 22:11:43 2003
> *************** _bfd_XXi_swap_scnhdr_out (abfd, in, out)
> *** 959,964 ****
> --- 959,993 ----
>
> {
> int flags = scnhdr_int->s_flags;
[...]
> H_PUT_32 (abfd, flags, scnhdr_ext->s_flags);
> }
> -------------------------------------------------------------------------------
>
> I am not sure that this is the right place to be doing this.
May be, but I'm not familiar enough with binutils to quickly find the
right place. I was hoping that somebody (you?) could point to the good
place for the fix.
> So you have an example of how, without this patch applied, the linker is
> producing section with incorrect flag bits set ?
Refer to the beginning of section 6 (Special sections) of MS PE COFF
specification.
Warnings produced by MS linker are:
a.obj : warning LNK4078: multiple '.text' sections found with different attributes (E0000020)
a.obj : warning LNK4078: multiple '.rdata' sections found with different attributes (C0000040)
I don't know whether different flags affect the final result, but I'm
feeling more comfortable without any warnings.
The source file file I'm compiling with arm-wince-pe is:
--- begin ---
void show(const char *s);
static const char *str = "xxx";
static char arr[3] = { 1, 2 ,3 };
void
test(void)
{
show(str);
}
--- end ---
It was compiled with the command:
$ arm-wince-pe-gcc -c -fno-leading-underscore test.c
Section flags are:
$ arm-wince-pe-objdump -h test.o
test.o: file format pe-arm-little
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000020 00000000 00000000 000000b4 2**2
CONTENTS, ALLOC, LOAD, RELOC, CODE
1 .data 00000008 00000000 00000000 000000d4 2**2
CONTENTS, RELOC
2 .bss 00000000 00000000 00000000 00000000 2**2
ALLOC
3 .rdata 00000004 00000000 00000000 000000dc 2**2
CONTENTS, ALLOC, LOAD, DATA
Below is the file I'm compiling with WinCE compiler, and linking
with the mentioned above object:
-- begin --
extern void test(void);
static wchar_t *b = L"Error\r\n";
void show(const char *s)
{
if (s[0] != 'x' || s[1] != 'x' || s[2] != 'x')
NKDbgPrintfW (b);
}
int main(void)
{
b[0] = L'e';
test();
return 0;
}
--- end ---
Below are some extras from MS's 'dumpbin /headers' command output
(dumpbin is - Microsoft (R) COFF/PE Dumper Version 6.24.3064):
GNU arm-wince-pe created object
-------------------------------
FILE HEADER VALUES
1C0 machine (ARM)
4 number of sections
0 time date stamp Thu Jan 01 03:00:00 1970
FE file pointer to symbol table
F number of symbols
0 size of optional header
4D04 characteristics
Line numbers stripped
32 bit word machine
CD - run from swapfile
Net - run from swapfile
Uniprocessor Only
SECTION HEADER #1
.text name
[...]
E0000020 flags
Code
(no align specified)
Execute Read Write
SECTION HEADER #2
.data name
[...]
C0000000 flags
(no align specified)
Read Write
SECTION HEADER #3
.bss name
[...]
C0000080 flags
Uninitialized Data
(no align specified)
Read Write
SECTION HEADER #4
.rdata name
[...]
C0000040 flags
Initialized Data
(no align specified)
Read Write
MS's compiler (clarm) created object
------------------------------------
FILE HEADER VALUES
1C0 machine (ARM)
6 number of sections
3FCF98AF time date stamp Thu Dec 04 23:27:27 2003
770 file pointer to symbol table
2B number of symbols
0 size of optional header
100 characteristics
32 bit word machine
[...]
SECTION HEADER #3
.data name
[...]
C0300040 flags
Initialized Data
4 byte align
Read Write
SECTION HEADER #4
.text name
[...]
60300020 flags
Code
4 byte align
Execute Read
SECTION HEADER #5
.pdata name
[...]
40300040 flags
Initialized Data
4 byte align
Read Only
With my patch applied the warnings are gone away. Although there could
be still a source of possible problem -- alignment is not set inside the
section flags by bfd.
...Bye..Dmitry.