public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* puzzled - old release works, newer doesn't
@ 2006-04-11 23:06 Danny Backx
  2006-04-25 17:39 ` Nick Clifton
  0 siblings, 1 reply; 5+ messages in thread
From: Danny Backx @ 2006-04-11 23:06 UTC (permalink / raw)
  To: binutils


[-- Attachment #1.1: Type: text/plain, Size: 1279 bytes --]

Hi,

I'm trying to build a toolchain to compile apps for Windows CE (I have a
Mio PDA) from my Linux PC.

I am able to do so with some software based on old versions of gcc,
binutils, and newlib; but I'd like to upgrade to newer versions and then
start extending the development environment.

The trouble is that my upgrade doesn't work.

The old environment is based on gcc 3.4.2, gas 2.13.2, binutils 2.15.
(Yes there's a mixup there.) The new environment is using gcc 4.1 and
binutils 2.16. In all versions, the target platform is "arm-wince-pe".

The person who created this distribution explains the mixup by saying
that the GAS from 2.13 works, whereas the one in newer binutils doesn't.

My personal experience with the 2.16 release appears to confirm that.

Attached are a small test program, a script to manipulate it with, and
some of the results. The branch instructions appear different, but I
have to admit I know too little about how gas and ld cooperate so I may
be missing the point there.

Can anyone help in sorting out what the problem is?

To state the obvious : hello1.exe as created by the script works,
hello2.exe crashes my PDA.

Thanks,

	Danny
-- 
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info

[-- Attachment #1.2: hello.c --]
[-- Type: text/x-csrc, Size: 436 bytes --]

#include <windows/windows.h>
#include <stdio.h>
#include <stdlib.h>

HINSTANCE	hinstance;

int WINAPI WinMain
(
	HINSTANCE hInstance,
	HINSTANCE	hPrevInstance,
	LPWSTR		lpCmdLine,
	int		nCmdShow
)
{
	FILE	*f;

	f = fopen("/storage card/devel/log.txt", "w");
	fprintf(f, "Hello\r\n");
	fclose(f);
	exit(0);
}

/* workaround */
int main() {
	WinMain(0, 0, 0, 0);
}

#if 1
char __EH_FRAME_BEGIN__[10];
#endif

[-- Attachment #1.3: hello.s --]
[-- Type: text/plain, Size: 1067 bytes --]

	.file	"hello.c"
	.section .rdata
	.align	0
LC0:
	.ascii	"/storage card/devel/log.txt\000"
	.align	0
LC1:
	.ascii	"w\000"
	.align	0
LC2:
	.ascii	"Hello\r\n\000"
	.text
	.align	0
	.global	_WinMain
_WinMain:
	@ args = 0, pretend = 0, frame = 20
	@ frame_needed = 1, uses_anonymous_args = 0
	mov	ip, sp
	stmfd	sp!, {fp, ip, lr, pc}
	sub	fp, ip, #4
	sub	sp, sp, #20
	str	r0, [fp, #-16]
	str	r1, [fp, #-20]
	str	r2, [fp, #-24]
	str	r3, [fp, #-28]
	ldr	r0, L2
	ldr	r1, L2+4
	bl	_fopen
	mov	r3, r0
	str	r3, [fp, #-32]
	ldr	r0, [fp, #-32]
	ldr	r1, L2+8
	bl	_fprintf
	ldr	r0, [fp, #-32]
	bl	_fclose
	mov	r0, #0
	bl	_exit
L3:
	.align	0
L2:
	.word	LC0
	.word	LC1
	.word	LC2
	.align	0
	.global	_main
_main:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 1, uses_anonymous_args = 0
	mov	ip, sp
	stmfd	sp!, {fp, ip, lr, pc}
	sub	fp, ip, #4
	bl	___gccmain
	mov	r0, #0
	mov	r1, #0
	mov	r2, #0
	mov	r3, #0
	bl	_WinMain
	mov	r0, r3
	ldmfd	sp, {fp, sp, pc}
	.comm	_hinstance, 4	@ 4
	.comm	___EH_FRAME_BEGIN__, 12	@ 10

[-- Attachment #1.4: hello1.objdump --]
[-- Type: text/plain, Size: 6724 bytes --]


hello1.o:     file format pe-arm-little
hello1.o
architecture: xscale, flags 0x00000039:
HAS_RELOC, HAS_DEBUG, HAS_SYMS, HAS_LOCALS
start address 0x00000000

Characteristics 0x4c04
	line numbers stripped

Time/Date		Thu Jan  1 01:00:00 1970

ImageBase		00000000
SectionAlignment	00000000
FileAlignment		00000000
MajorOSystemVersion	0
MinorOSystemVersion	0
MajorImageVersion	0
MinorImageVersion	0
MajorSubsystemVersion	0
MinorSubsystemVersion	0
Win32Version		00000000
SizeOfImage		00000000
SizeOfHeaders		00000000
CheckSum		00000000
Subsystem		00000000	(unspecified)
DllCharacteristics	00000000
SizeOfStackReserve	00000000
SizeOfStackCommit	00000000
SizeOfHeapReserve	00000000
SizeOfHeapCommit	00000000
LoaderFlags		00000000
NumberOfRvaAndSizes	00000000

The Data Directory
Entry 0 00000000 00000000 Export Directory [.edata (or where ever we found it)]
Entry 1 00000000 00000000 Import Directory [parts of .idata]
Entry 2 00000000 00000000 Resource Directory [.rsrc]
Entry 3 00000000 00000000 Exception Directory [.pdata]
Entry 4 00000000 00000000 Security Directory
Entry 5 00000000 00000000 Base Relocation Directory [.reloc]
Entry 6 00000000 00000000 Debug Directory
Entry 7 00000000 00000000 Description Directory
Entry 8 00000000 00000000 Special Directory
Entry 9 00000000 00000000 Thread Storage Directory [.tls]
Entry a 00000000 00000000 Load Configuration Directory
Entry b 00000000 00000000 Bound Import Directory
Entry c 00000000 00000000 Import Address Table Directory
Entry d 00000000 00000000 Delay Import Directory
Entry e 00000000 00000000 Reserved
Entry f 00000000 00000000 Reserved

private flags = 820: [APCS-32] [floats passed in integer registers] [absolute position] [interworking not supported]

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000088  00000000  00000000  000000b4  2**2
                  CONTENTS, RELOC
  1 .data         00000000  00000000  00000000  00000000  2**2
                  
  2 .bss          00000000  00000000  00000000  00000000  2**2
                  ALLOC
  3 .rdata        00000028  00000000  00000000  0000013c  2**2
                  CONTENTS, ALLOC, LOAD, DATA
SYMBOL TABLE:
[  0](sec -2)(fl 0x00)(ty   0)(scl 103) (nx 1) 0x00000000 hello.c
File 
[  2](sec  4)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000000 LC0
[  3](sec  4)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x0000001c LC1
[  4](sec  4)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000020 LC2
[  5](sec  1)(fl 0x00)(ty   0)(scl   6) (nx 0) 0x00000050 L2
[  6](sec  1)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .text
AUX scnlen 0x88 nreloc 8 nlnno 0
[  8](sec  2)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .data
AUX scnlen 0x0 nreloc 0 nlnno 0
[ 10](sec  3)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .bss
AUX scnlen 0x0 nreloc 0 nlnno 0
[ 12](sec  4)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .rdata
AUX scnlen 0x28 nreloc 0 nlnno 0
[ 14](sec  1)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 _WinMain
[ 15](sec  1)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0000005c _main
[ 16](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000004 _hinstance
[ 17](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0000000c ___EH_FRAME_BEGIN__
[ 18](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 _fopen
[ 19](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 _fprintf
[ 20](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 _fclose
[ 21](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 _exit
[ 22](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 ___gccmain


Contents of section .text:
 0000 0dc0a0e1 00d82de9 04b04ce2 14d04de2  ......-...L...M.
 0010 10000be5 14100be5 18200be5 1c300be5  ......... ...0..
 0020 28009fe5 28109fe5 feffffeb 0030a0e1  (...(........0..
 0030 20300be5 20001be5 18109fe5 feffffeb   0.. ...........
 0040 20001be5 feffffeb 0000a0e3 feffffeb   ...............
 0050 00000000 1c000000 20000000 0dc0a0e1  ........ .......
 0060 00d82de9 04b04ce2 feffffeb 0000a0e3  ..-...L.........
 0070 0010a0e3 0020a0e3 0030a0e3 dfffffeb  ..... ...0......
 0080 0300a0e1 00a89de8                    ........        
Contents of section .rdata:
 0000 2f73746f 72616765 20636172 642f6465  /storage card/de
 0010 76656c2f 6c6f672e 74787400 77000000  vel/log.txt.w...
 0020 48656c6c 6f0d0a00                    Hello...        
Disassembly of section .text:

00000000 <_WinMain>:
   0:	e1a0c00d 	mov	ip, sp
   4:	e92dd800 	stmdb	sp!, {fp, ip, lr, pc}
   8:	e24cb004 	sub	fp, ip, #4	; 0x4
   c:	e24dd014 	sub	sp, sp, #20	; 0x14
  10:	e50b0010 	str	r0, [fp, #-16]
  14:	e50b1014 	str	r1, [fp, #-20]
  18:	e50b2018 	str	r2, [fp, #-24]
  1c:	e50b301c 	str	r3, [fp, #-28]
  20:	e59f0028 	ldr	r0, [pc, #40]	; 50 <L2>
  24:	e59f1028 	ldr	r1, [pc, #40]	; 54 <L2+0x4>
  28:	ebfffffe 	bl	28 <_WinMain+0x28>
			28: ARM_26	_fopen
  2c:	e1a03000 	mov	r3, r0
  30:	e50b3020 	str	r3, [fp, #-32]
  34:	e51b0020 	ldr	r0, [fp, #-32]
  38:	e59f1018 	ldr	r1, [pc, #24]	; 58 <L2+0x8>
  3c:	ebfffffe 	bl	3c <_WinMain+0x3c>
			3c: ARM_26	_fprintf
  40:	e51b0020 	ldr	r0, [fp, #-32]
  44:	ebfffffe 	bl	44 <_WinMain+0x44>
			44: ARM_26	_fclose
  48:	e3a00000 	mov	r0, #0	; 0x0
  4c:	ebfffffe 	bl	4c <_WinMain+0x4c>
			4c: ARM_26	_exit

00000050 <L2>:
  50:	00000000 	andeq	r0, r0, r0
			50: ARM_32	LC0
  54:	0000001c 	andeq	r0, r0, ip, lsl r0
			54: ARM_32	LC1+0xffffffe4
  58:	00000020 	andeq	r0, r0, r0, lsr #32
			58: ARM_32	LC2+0xffffffe0

0000005c <_main>:
  5c:	e1a0c00d 	mov	ip, sp
  60:	e92dd800 	stmdb	sp!, {fp, ip, lr, pc}
  64:	e24cb004 	sub	fp, ip, #4	; 0x4
  68:	ebfffffe 	bl	68 <_main+0xc>
			68: ARM_26	___gccmain
  6c:	e3a00000 	mov	r0, #0	; 0x0
  70:	e3a01000 	mov	r1, #0	; 0x0
  74:	e3a02000 	mov	r2, #0	; 0x0
  78:	e3a03000 	mov	r3, #0	; 0x0
  7c:	ebffffdf 	bl	0 <_WinMain>
  80:	e1a00003 	mov	r0, r3
  84:	e89da800 	ldmia	sp, {fp, sp, pc}
Disassembly of section .rdata:

00000000 <LC0>:
   0:	6f74732f 	swivs	0x0074732f
   4:	65676172 	strvsb	r6, [r7, #-370]!
   8:	72616320 	rsbvc	r6, r1, #-2147483648	; 0x80000000
   c:	65642f64 	strvsb	r2, [r4, #-3940]!
  10:	2f6c6576 	swics	0x006c6576
  14:	2e676f6c 	cdpcs	15, 6, cr6, cr7, cr12, {3}
  18:	00747874 	rsbeqs	r7, r4, r4, ror r8

0000001c <LC1>:
  1c:	00000077 	andeq	r0, r0, r7, ror r0

00000020 <LC2>:
  20:	6c6c6548 	cfstr64vs	mvdx6, [ip], #-288
  24:	000a0d6f 	andeq	r0, sl, pc, ror #26
hello.c:
typedef void void;
void _WinMain /* 0x0 */;
void _main /* 0x5c */;
void _hinstance /* 0x4 */;
void ___EH_FRAME_BEGIN__ /* 0xc */;
void _fopen /* 0x0 */;
void _fprintf /* 0x0 */;
void _fclose /* 0x0 */;
void _exit /* 0x0 */;
void ___gccmain /* 0x0 */;

[-- Attachment #1.5: hello2.objdump --]
[-- Type: text/plain, Size: 6643 bytes --]


hello2.o:     file format pe-arm-little
hello2.o
architecture: xscale, flags 0x00000039:
HAS_RELOC, HAS_DEBUG, HAS_SYMS, HAS_LOCALS
start address 0x00000000

Characteristics 0x4d04
	line numbers stripped
	32 bit words

Time/Date		Thu Jan  1 01:00:00 1970

ImageBase		00000000
SectionAlignment	00000000
FileAlignment		00000000
MajorOSystemVersion	0
MinorOSystemVersion	0
MajorImageVersion	0
MinorImageVersion	0
MajorSubsystemVersion	0
MinorSubsystemVersion	0
Win32Version		00000000
SizeOfImage		00000000
SizeOfHeaders		00000000
CheckSum		00000000
Subsystem		00000000	(unspecified)
DllCharacteristics	00000000
SizeOfStackReserve	00000000
SizeOfStackCommit	00000000
SizeOfHeapReserve	00000000
SizeOfHeapCommit	00000000
LoaderFlags		00000000
NumberOfRvaAndSizes	00000000

The Data Directory
Entry 0 00000000 00000000 Export Directory [.edata (or where ever we found it)]
Entry 1 00000000 00000000 Import Directory [parts of .idata]
Entry 2 00000000 00000000 Resource Directory [.rsrc]
Entry 3 00000000 00000000 Exception Directory [.pdata]
Entry 4 00000000 00000000 Security Directory
Entry 5 00000000 00000000 Base Relocation Directory [.reloc]
Entry 6 00000000 00000000 Debug Directory
Entry 7 00000000 00000000 Description Directory
Entry 8 00000000 00000000 Special Directory
Entry 9 00000000 00000000 Thread Storage Directory [.tls]
Entry a 00000000 00000000 Load Configuration Directory
Entry b 00000000 00000000 Bound Import Directory
Entry c 00000000 00000000 Import Address Table Directory
Entry d 00000000 00000000 Delay Import Directory
Entry e 00000000 00000000 Reserved
Entry f 00000000 00000000 Reserved

private flags = 820: [APCS-32] [floats passed in integer registers] [absolute position] [interworking not supported]

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000088  00000000  00000000  000000b4  2**2
                  CONTENTS, ALLOC, LOAD, RELOC, CODE
  1 .data         00000000  00000000  00000000  00000000  2**2
                  ALLOC, LOAD, DATA
  2 .bss          00000000  00000000  00000000  00000000  2**2
                  ALLOC
  3 .rdata        00000028  00000000  00000000  0000013c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
SYMBOL TABLE:
[  0](sec -2)(fl 0x00)(ty   0)(scl 103) (nx 1) 0x00000000 hello.c
File 
[  2](sec  4)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000000 LC0
[  3](sec  4)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x0000001c LC1
[  4](sec  4)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000020 LC2
[  5](sec  1)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .text
AUX scnlen 0x88 nreloc 9 nlnno 0
[  7](sec  2)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .data
AUX scnlen 0x0 nreloc 0 nlnno 0
[  9](sec  3)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .bss
AUX scnlen 0x0 nreloc 0 nlnno 0
[ 11](sec  4)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .rdata
AUX scnlen 0x28 nreloc 0 nlnno 0
[ 13](sec  1)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 _WinMain
[ 14](sec  1)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0000005c _main
[ 15](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000004 _hinstance
[ 16](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x0000000c ___EH_FRAME_BEGIN__
[ 17](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 _fopen
[ 18](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 _fprintf
[ 19](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 _fclose
[ 20](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 _exit
[ 21](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 ___gccmain


Contents of section .text:
 0000 0dc0a0e1 00d82de9 04b04ce2 14d04de2  ......-...L...M.
 0010 10000be5 14100be5 18200be5 1c300be5  ......... ...0..
 0020 28009fe5 28109fe5 000000eb 0030a0e1  (...(........0..
 0030 20300be5 20001be5 18109fe5 000000eb   0.. ...........
 0040 20001be5 000000eb 0000a0e3 000000eb   ...............
 0050 00000000 00000000 00000000 0dc0a0e1  ................
 0060 00d82de9 04b04ce2 000000eb 0000a0e3  ..-...L.........
 0070 0010a0e3 0020a0e3 0030a0e3 dfffffeb  ..... ...0......
 0080 0300a0e1 00a89de8                    ........        
Contents of section .rdata:
 0000 2f73746f 72616765 20636172 642f6465  /storage card/de
 0010 76656c2f 6c6f672e 74787400 77000000  vel/log.txt.w...
 0020 48656c6c 6f0d0a00                    Hello...        
Disassembly of section .text:

00000000 <_WinMain>:
   0:	e1a0c00d 	mov	ip, sp
   4:	e92dd800 	stmdb	sp!, {fp, ip, lr, pc}
   8:	e24cb004 	sub	fp, ip, #4	; 0x4
   c:	e24dd014 	sub	sp, sp, #20	; 0x14
  10:	e50b0010 	str	r0, [fp, #-16]
  14:	e50b1014 	str	r1, [fp, #-20]
  18:	e50b2018 	str	r2, [fp, #-24]
  1c:	e50b301c 	str	r3, [fp, #-28]
  20:	e59f0028 	ldr	r0, [pc, #40]	; 50 <_WinMain+0x50>
  24:	e59f1028 	ldr	r1, [pc, #40]	; 54 <_WinMain+0x54>
  28:	eb000000 	bl	30 <_WinMain+0x30>
			28: ARM_26	_fopen
  2c:	e1a03000 	mov	r3, r0
  30:	e50b3020 	str	r3, [fp, #-32]
  34:	e51b0020 	ldr	r0, [fp, #-32]
  38:	e59f1018 	ldr	r1, [pc, #24]	; 58 <_WinMain+0x58>
  3c:	eb000000 	bl	44 <_WinMain+0x44>
			3c: ARM_26	_fprintf
  40:	e51b0020 	ldr	r0, [fp, #-32]
  44:	eb000000 	bl	4c <_WinMain+0x4c>
			44: ARM_26	_fclose
  48:	e3a00000 	mov	r0, #0	; 0x0
  4c:	eb000000 	bl	54 <_WinMain+0x54>
			4c: ARM_26	_exit
	...
			50: ARM_32	LC0
			54: ARM_32	LC1+0xffffffe4
			58: ARM_32	LC2+0xffffffe0

0000005c <_main>:
  5c:	e1a0c00d 	mov	ip, sp
  60:	e92dd800 	stmdb	sp!, {fp, ip, lr, pc}
  64:	e24cb004 	sub	fp, ip, #4	; 0x4
  68:	eb000000 	bl	70 <_main+0x14>
			68: ARM_26	___gccmain
  6c:	e3a00000 	mov	r0, #0	; 0x0
  70:	e3a01000 	mov	r1, #0	; 0x0
  74:	e3a02000 	mov	r2, #0	; 0x0
  78:	e3a03000 	mov	r3, #0	; 0x0
  7c:	ebffffdf 	bl	0 <_WinMain>
			7c: ARM_26D	_WinMain
  80:	e1a00003 	mov	r0, r3
  84:	e89da800 	ldmia	sp, {fp, sp, pc}
Disassembly of section .rdata:

00000000 <LC0>:
   0:	6f74732f 	swivs	0x0074732f
   4:	65676172 	strvsb	r6, [r7, #-370]!
   8:	72616320 	rsbvc	r6, r1, #-2147483648	; 0x80000000
   c:	65642f64 	strvsb	r2, [r4, #-3940]!
  10:	2f6c6576 	swics	0x006c6576
  14:	2e676f6c 	cdpcs	15, 6, cr6, cr7, cr12, {3}
  18:	00747874 	rsbeqs	r7, r4, r4, ror r8

0000001c <LC1>:
  1c:	00000077 	andeq	r0, r0, r7, ror r0

00000020 <LC2>:
  20:	6c6c6548 	cfstr64vs	mvdx6, [ip], #-288
  24:	000a0d6f 	andeq	r0, sl, pc, ror #26
hello.c:
typedef void void;
void _WinMain /* 0x0 */;
void _main /* 0x5c */;
void _hinstance /* 0x4 */;
void ___EH_FRAME_BEGIN__ /* 0xc */;
void _fopen /* 0x0 */;
void _fprintf /* 0x0 */;
void _fclose /* 0x0 */;
void _exit /* 0x0 */;
void ___gccmain /* 0x0 */;

[-- Attachment #1.6: t2 --]
[-- Type: application/x-shellscript, Size: 4851 bytes --]

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 191 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: puzzled - old release works, newer doesn't
  2006-04-11 23:06 puzzled - old release works, newer doesn't Danny Backx
@ 2006-04-25 17:39 ` Nick Clifton
  2006-04-25 21:15   ` Pedro Alves
  2006-04-27  1:32   ` Danny Backx
  0 siblings, 2 replies; 5+ messages in thread
From: Nick Clifton @ 2006-04-25 17:39 UTC (permalink / raw)
  To: Danny Backx; +Cc: binutils

Hi Danny,

> The old environment is based on gcc 3.4.2, gas 2.13.2, binutils 2.15.
> (Yes there's a mixup there.) The new environment is using gcc 4.1 and
> binutils 2.16. In all versions, the target platform is "arm-wince-pe".
> 
> The person who created this distribution explains the mixup by saying
> that the GAS from 2.13 works, whereas the one in newer binutils doesn't.
> 
> My personal experience with the 2.16 release appears to confirm that.

Are you upgrading to the new GCC new GAS and new LD all at the same time 
?  If not then that might be the cause.

Are you aware of the --support-old-code linker switch which is specific 
to the arm-wince-pe target ?  Using this might help you.

Using the latest binutils sources from CVS repository might also help. 
If not then I would recommend comparing a disassembly of a working 
binary and broken binary to see where there are changes.  (Do not 
compare the object files, but linked binaries.  This should allow you to 
find out how relocs may have been processed differently).

Cheers
   Nick

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: puzzled - old release works, newer doesn't
  2006-04-25 17:39 ` Nick Clifton
@ 2006-04-25 21:15   ` Pedro Alves
  2006-04-27  2:23     ` Pedro Alves
  2006-04-27  1:32   ` Danny Backx
  1 sibling, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2006-04-25 21:15 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 5071 bytes --]

Nick Clifton wrote:
> Hi Danny,
>
>> The old environment is based on gcc 3.4.2, gas 2.13.2, binutils 2.15.
>> (Yes there's a mixup there.) The new environment is using gcc 4.1 and
>> binutils 2.16. In all versions, the target platform is "arm-wince-pe".
>>
>> The person who created this distribution explains the mixup by saying
>> that the GAS from 2.13 works, whereas the one in newer binutils doesn't.
>>
>> My personal experience with the 2.16 release appears to confirm that.
>
> Are you upgrading to the new GCC new GAS and new LD all at the same 
> time ?  If not then that might be the cause.
>
> Are you aware of the --support-old-code linker switch which is 
> specific to the arm-wince-pe target ?  Using this might help you.
>
> Using the latest binutils sources from CVS repository might also help. 
> If not then I would recommend comparing a disassembly of a working 
> binary and broken binary to see where there are changes.  (Do not 
> compare the object files, but linked binaries.  This should allow you 
> to find out how relocs may have been processed differently).
>
> Cheers
>   Nick
>
Here is a patch that "fixes" the differences between  binutils cvs 
20050202 and  cvs head. Probably I got it all wrong, but at least it
shows where the differences are. It fix most of the differences, but 
here is still something in the dll generation that produces quite
some differences. I am still looking into it.

That TE_WINCE addition is there because I didn't take the time yet to 
find the correct place. Any hints where that should be?

Mind you, the both the 20050202 and the head versions I tested with, 
have quite a few more patches applied.
This is just the portion that tries to fix the differences. It should 
also fix them for a pristine cvs version.
Attached is the tar.gz with the tests I used, inspired on Danny's tests.

Particularly, compiling this file (in the tar.gz) shows all the 
differences I could find.

    .global    _ctype_
    .text
    .global    global_sym
    .def    global_sym;    .scl    2;    .type    32;    .endef

_ctype_:
    .word    _ctype_+7

global_sym:
def_sym:
undef_sym:
    nop
    nop
    nop
    b    global_sym
    bl    global_sym
    beq    global_sym
    b    def_sym
    bl    def_sym
    beq    def_sym
    b    undef_sym
    bl    undef_sym
    ldr    r0, global_sym
    ldr    r0, def_sym
    ldr    r0, undef_sym

Cheers,
Pedro Alves

Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.256
diff -u -r1.256 tc-arm.c
--- gas/config/tc-arm.c    7 Apr 2006 15:11:19 -0000    1.256
+++ gas/config/tc-arm.c    25 Apr 2006 15:52:17 -0000
@@ -11182,8 +11182,12 @@
      then we just want to put out any pipeline compensation that the linker
      will need.  Otherwise we want to use the calculated base.  */
   if (fixP->fx_pcrel
-      && ((fixP->fx_addsy && S_GET_SEGMENT (fixP->fx_addsy) != seg)
-      || arm_force_relocation (fixP)))
+    && ((fixP->fx_addsy && S_GET_SEGMENT (fixP->fx_addsy) != seg)
+#ifdef TE_WINCE
+    || (!S_IS_EXTERNAL (fixP->fx_addsy) && arm_force_relocation (fixP))))
+#else
+    || arm_force_relocation (fixP)))
+#endif
     base = 0;
 
   switch (fixP->fx_r_type)
@@ -11220,7 +11224,19 @@
     case BFD_RELOC_ARM_PCREL_BLX:
     case BFD_RELOC_ARM_PLT32:
 #ifdef TE_WINCE
-      return base;
+      /*
+       * When handling fixups immediately, because we have already
+       * discovered the value of a symbol, or the address of the frag 
involved
+       * we must account for the offset by +8, as the OS loader will 
never see the reloc.
+       * see fixup_segment() in write.c
+       * The S_IS_EXTERNAL test handles the case of global symbols.
+       * Those need the calculated base, not just the pipe compensation 
the linker will need.
+      */
+      if (fixP->fx_pcrel && fixP->fx_addsy && (S_GET_SEGMENT 
(fixP->fx_addsy) == seg)
+        && (S_IS_EXTERNAL (fixP->fx_addsy) || !arm_force_relocation 
(fixP)))
+        return base + 8;
+      else
+        return base;
 #else
       return base + 8;
 #endif
@@ -12107,10 +12123,16 @@
     case BFD_RELOC_ARM_ROSEGREL32:
     case BFD_RELOC_ARM_SBREL32:
     case BFD_RELOC_32_PCREL:
+#ifdef TE_WINCE
+      if (seg->use_rela_p && !fixP->fx_done)
+        break;
+      if (fixP->fx_done || fixP->fx_pcrel)
+        md_number_to_chars (buf, value, 4);
+#else
       if (fixP->fx_done || !seg->use_rela_p)
     md_number_to_chars (buf, value, 4);
+#endif
       break;
-
 #ifdef OBJ_ELF
     case BFD_RELOC_ARM_PREL31:
       if (fixP->fx_done || !seg->use_rela_p)
Index: gas/config/te-pe.h
===================================================================
RCS file: /cvs/src/src/gas/config/te-pe.h,v
retrieving revision 1.2
diff -u -r1.2 te-pe.h
--- gas/config/te-pe.h    6 Nov 2002 19:36:19 -0000    1.2
+++ gas/config/te-pe.h    25 Apr 2006 15:52:24 -0000
@@ -1,3 +1,4 @@
+#define TE_WINCE
 #define TE_PE
 #define LEX_AT (LEX_BEGIN_NAME | LEX_NAME) /* Can have @'s inside 
labels.  */
 


[-- Attachment #2: binutils-hunt.tar.gz --]
[-- Type: application/gzip, Size: 18872 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: puzzled - old release works, newer doesn't
  2006-04-25 17:39 ` Nick Clifton
  2006-04-25 21:15   ` Pedro Alves
@ 2006-04-27  1:32   ` Danny Backx
  1 sibling, 0 replies; 5+ messages in thread
From: Danny Backx @ 2006-04-27  1:32 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

[-- Attachment #1: Type: text/plain, Size: 5686 bytes --]

Nick & others,

Thanks for the input, but the --support-old-code flag doesn't appear to
be the answer. And yes I am trying to replace GCC, GAS, and LD at the
same time, I'm currently playing with binutils from CVS. No improvement
from that either.

I did some more digging since my last message, below I'll indicate what
I see. The hello.s I use is still the same. As you said, the output
pasted in below is from the fully linked exe file, not the .obj file.

The executables I create from hello.s lack at least in two areas :
- branches are off
- references to literal strings are off

In the piece below, you'll see that the statement at 11044 branches to
an address 8 bytes too far to reach _fopen, also at 1106c and further
you'll see three pointers all pointing to the same address. This is
wrong too.

The piece produced by the new compiler+binutils :

0001101c <_WinMain>:
   1101c:       e1a0c00d        mov     ip, sp
   11020:       e92dd800        stmdb   sp!, {fp, ip, lr, pc}
   11024:       e24cb004        sub     fp, ip, #4      ; 0x4
   11028:       e24dd014        sub     sp, sp, #20     ; 0x14
   1102c:       e50b0010        str     r0, [fp, #-16]
   11030:       e50b1014        str     r1, [fp, #-20]
   11034:       e50b2018        str     r2, [fp, #-24]
   11038:       e50b301c        str     r3, [fp, #-28]
   1103c:       e59f0028        ldr     r0, [pc, #40]   ; 1106c
<_WinMain+0x50>
   11040:       e59f1028        ldr     r1, [pc, #40]   ; 11070
<_WinMain+0x54>
   11044:       eb0005da        bl      127b4 <_fopen+0x8>
   11048:       e1a03000        mov     r3, r0
   1104c:       e50b3020        str     r3, [fp, #-32]
   11050:       e51b0020        ldr     r0, [fp, #-32]
   11054:       e59f1018        ldr     r1, [pc, #24]   ; 11074
<_WinMain+0x58>
   11058:       eb0005de        bl      127d8 <_fprintf+0x8>
   1105c:       e51b0020        ldr     r0, [fp, #-32]
   11060:       eb0005e4        bl      127f8 <_fclose+0x8>
   11064:       e3a00000        mov     r0, #0  ; 0x0
   11068:       eb00061b        bl      128dc <_exit+0x8>
   1106c:       00023000        andeq   r3, r2, r0
   11070:       00023000        andeq   r3, r2, r0
   11074:       00023000        andeq   r3, r2, r0

For reference, here is a similar piece produced with old compiler
+binutils :
0001101c <_WinMain>:
   1101c:       e1a0c00d        mov     ip, sp
   11020:       e92dd800        stmdb   sp!, {fp, ip, lr, pc}
   11024:       e24cb004        sub     fp, ip, #4      ; 0x4
   11028:       e24dd014        sub     sp, sp, #20     ; 0x14
   1102c:       e50b0010        str     r0, [fp, #-16]
   11030:       e50b1014        str     r1, [fp, #-20]
   11034:       e50b2018        str     r2, [fp, #-24]  
   11038:       e50b301c        str     r3, [fp, #-28]
   1103c:       e59f0028        ldr     r0, [pc, #40]   ; 1106c
<_WinMain+0x50>
   11040:       e59f1028        ldr     r1, [pc, #40]   ; 11070
<_WinMain+0x54>
   11044:       eb0005d8        bl      127ac <_fopen>
   11048:       e1a03000        mov     r3, r0  
   1104c:       e50b3020        str     r3, [fp, #-32]
   11050:       e51b0020        ldr     r0, [fp, #-32]
   11054:       e59f1018        ldr     r1, [pc, #24]   ; 11074
<_WinMain+0x58>
   11058:       eb0005dc        bl      127d0 <_fprintf>
   1105c:       e51b0020        ldr     r0, [fp, #-32]
   11060:       eb0005e2        bl      127f0 <_fclose>
   11064:       e3a00000        mov     r0, #0  ; 0x0   
   11068:       eb000619        bl      128d4 <_exit>
   1106c:       00023000        andeq   r3, r2, r0
   11070:       0002301c        andeq   r3, r2, ip, lsl r0
   11074:       00023020        andeq   r3, r2, r0, lsr #32

In both cases, the pointers should refer to this :
Contents of section .rdata:
 23000 2f73746f 72616765 20636172 642f6465  /storage card/de
 23010 76656c2f 6c6f672e 74787400 77000000  vel/log.txt.w...
 23020 48656c6c 6f0d0a00 57434554 52414345  Hello...WCETRACE

There might be other problems with the file produced, these are the ones
I discovered. Unfortunately they appear more than enough reason for the
executable not to do anything sensible :-(

Quite frankly I have just started looking into binutils so its source is
still a mystery so all clues are appreciated.

I haven't bothered testing the recent pre-release.

	Danny

On Tue, 2006-04-25 at 18:22 +0100, Nick Clifton wrote:
> Hi Danny,
> 
> > The old environment is based on gcc 3.4.2, gas 2.13.2, binutils 2.15.
> > (Yes there's a mixup there.) The new environment is using gcc 4.1 and
> > binutils 2.16. In all versions, the target platform is "arm-wince-pe".
> > 
> > The person who created this distribution explains the mixup by saying
> > that the GAS from 2.13 works, whereas the one in newer binutils doesn't.
> > 
> > My personal experience with the 2.16 release appears to confirm that.
> 
> Are you upgrading to the new GCC new GAS and new LD all at the same time 
> ?  If not then that might be the cause.
> 
> Are you aware of the --support-old-code linker switch which is specific 
> to the arm-wince-pe target ?  Using this might help you.
> 
> Using the latest binutils sources from CVS repository might also help. 
> If not then I would recommend comparing a disassembly of a working 
> binary and broken binary to see where there are changes.  (Do not 
> compare the object files, but linked binaries.  This should allow you to 
> find out how relocs may have been processed differently).
> 
> Cheers
>    Nick
> 
-- 
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 191 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: puzzled - old release works, newer doesn't
  2006-04-25 21:15   ` Pedro Alves
@ 2006-04-27  2:23     ` Pedro Alves
  0 siblings, 0 replies; 5+ messages in thread
From: Pedro Alves @ 2006-04-27  2:23 UTC (permalink / raw)
  To: binutils; +Cc: danny.backx

[-- Attachment #1: Type: text/plain, Size: 1528 bytes --]

Hi all,

Pedro Alves wrote:
> Here is a patch that "fixes" the differences between  binutils cvs 
> 20050202 and  cvs head. Probably I got it all wrong, but at least it
> shows where the differences are. It fix most of the differences, but 
> here is still something in the dll generation that produces quite
> some differences. I am still looking into it.
>
> That TE_WINCE addition is there because I didn't take the time yet to 
> find the correct place. Any hints where that should be?
>
Ignore me here. Obviously in gas/config/te-wince-pe.h. Missed that 
before. Humm, this file isn't included anywhere.
> Mind you, the both the 20050202 and the head versions I tested with, 
> have quite a few more patches applied.
> This is just the portion that tries to fix the differences. It should 
> also fix them for a pristine cvs version.
>

I have reduced my patches against both cvs20050202, which is the version 
I am using to work on the cegcc toolchain (http://cegcc.berlios.de), and
cvs head. If you tried my previous patch and saw no differences, it was 
because you need this full patch.

I am suffering from weird network problems, so I can't do a cvs diff 
now. Because of that I hand edited the patches to remove some messing 
I've done regarding target underscoring. That part of my original 
patches should not make any difference to the problem at hand now.

Some of the code in the patches is found in several places in the web, 
and I don't know who is the original author. Sorry for that.

Cheers,
Pedro Alves


[-- Attachment #2: binutils-head-wince_edited.diff --]
[-- Type: text/plain, Size: 7347 bytes --]

Index: bfd/coff-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-arm.c,v
retrieving revision 1.63
diff -u -r1.63 coff-arm.c
--- bfd/coff-arm.c	16 Mar 2006 12:20:15 -0000	1.63
+++ bfd/coff-arm.c	26 Apr 2006 22:29:05 -0000
@@ -220,7 +220,7 @@
 	   complain_overflow_dont,
 	   aoutarm_fix_pcrel_26_done,
 	   "ARM_26D",
-	   FALSE,
+	   TRUE,
 	   0x00ffffff,
 	   0x0,
 	   PCRELOFFSET),
@@ -233,7 +233,7 @@
 	   complain_overflow_bitfield,
 	   coff_arm_reloc,
 	   "ARM_32",
-	   FALSE,
+	   TRUE,
 	   0xffffffff,
 	   0xffffffff,
 	   PCRELOFFSET),
@@ -246,7 +246,7 @@
 	   complain_overflow_bitfield,
 	   coff_arm_reloc,
 	   "ARM_RVA32",
-	   FALSE,
+	   TRUE,
 	   0xffffffff,
 	   0xffffffff,
 	   PCRELOFFSET),
@@ -294,7 +294,7 @@
 	   complain_overflow_bitfield,
 	   coff_arm_reloc,
 	   "ARM_SECTION",
-	   FALSE,
+	   TRUE,
 	   0x0000ffff,
 	   0x0000ffff,
 	   PCRELOFFSET),
@@ -307,7 +307,7 @@
 	   complain_overflow_bitfield,
 	   coff_arm_reloc,
 	   "ARM_SECREL",
-	   FALSE,
+	   TRUE,
 	   0xffffffff,
 	   0xffffffff,
 	   PCRELOFFSET),
@@ -1215,6 +1215,9 @@
 #ifdef ARM_WINCE
       /* MS ARM-CE makes the reloc relative to the opcode's pc, not
 	 the next opcode's pc, so is off by one.  */
+
+      if (howto->pc_relative && !info->relocatable)
+        addend -= 8;
 #endif
 
       /* If we are doing a relocatable link, then we can just ignore
Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.256
diff -u -r1.256 tc-arm.c
--- gas/config/tc-arm.c	7 Apr 2006 15:11:19 -0000	1.256
+++ gas/config/tc-arm.c	26 Apr 2006 22:30:19 -0000
@@ -11182,8 +11182,12 @@
      then we just want to put out any pipeline compensation that the linker
      will need.  Otherwise we want to use the calculated base.  */
   if (fixP->fx_pcrel 
-      && ((fixP->fx_addsy && S_GET_SEGMENT (fixP->fx_addsy) != seg)
-	  || arm_force_relocation (fixP)))
+    && ((fixP->fx_addsy && S_GET_SEGMENT (fixP->fx_addsy) != seg)
+#ifdef TE_WINCE
+    || (!S_IS_EXTERNAL (fixP->fx_addsy) && arm_force_relocation (fixP))))
+#else
+    || arm_force_relocation (fixP)))
+#endif
     base = 0;
 
   switch (fixP->fx_r_type)
@@ -11220,7 +11224,19 @@
     case BFD_RELOC_ARM_PCREL_BLX:
     case BFD_RELOC_ARM_PLT32:
 #ifdef TE_WINCE
-      return base;
+      /*
+       * When handling fixups immediately, because we have already 
+       * discovered the value of a symbol, or the address of the frag involved
+       * we must account for the offset by +8, as the OS loader will never see the reloc.
+       * see fixup_segment() in write.c
+       * The S_IS_EXTERNAL test handles the case of global symbols.
+       * Those need the calculated base, not just the pipe compensation the linker will need.
+      */
+      if (fixP->fx_pcrel && fixP->fx_addsy && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
+        && (S_IS_EXTERNAL (fixP->fx_addsy) || !arm_force_relocation (fixP)))
+        return base + 8;
+      else
+        return base;
 #else
       return base + 8;
 #endif
@@ -12107,10 +12123,16 @@
     case BFD_RELOC_ARM_ROSEGREL32:
     case BFD_RELOC_ARM_SBREL32:
     case BFD_RELOC_32_PCREL:
+#ifdef TE_WINCE
+      if (seg->use_rela_p && !fixP->fx_done)
+        break;
+      if (fixP->fx_done || fixP->fx_pcrel)
+        md_number_to_chars (buf, value, 4);
+#else
       if (fixP->fx_done || !seg->use_rela_p)
 	md_number_to_chars (buf, value, 4);
+#endif
       break;
-
 #ifdef OBJ_ELF
     case BFD_RELOC_ARM_PREL31:
       if (fixP->fx_done || !seg->use_rela_p)
Index: gas/config/te-pe.h
===================================================================
RCS file: /cvs/src/src/gas/config/te-pe.h,v
retrieving revision 1.2
diff -u -r1.2 te-pe.h
--- gas/config/te-pe.h	6 Nov 2002 19:36:19 -0000	1.2
+++ gas/config/te-pe.h	26 Apr 2006 22:30:19 -0000
@@ -1,3 +1,4 @@
+#define TE_WINCE
 #define TE_PE
 #define LEX_AT (LEX_BEGIN_NAME | LEX_NAME) /* Can have @'s inside labels.  */
 
Index: ld/pe-dll.c
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.c,v
retrieving revision 1.83
diff -u -r1.83 pe-dll.c
--- ld/pe-dll.c	31 Jan 2006 22:08:14 -0000	1.83
+++ ld/pe-dll.c	26 Apr 2006 22:31:22 -0000
@@ -216,6 +216,9 @@
 
 static autofilter_entry_type autofilter_symbollist[] =
 {
+  { "DllMain", 7 },
+  { "DllMainCRTStartup", 17 },
+  { "_DllMainCRTStartup", 18 },
   { "DllMain@12", 10 },
   { "DllEntryPoint@0", 15 },
   { "DllMainCRTStartup@12", 20 },
@@ -226,12 +229,14 @@
   { "_pei386_runtime_relocator", 25 },
   { "do_pseudo_reloc", 15 },
   { "cygwin_crt0", 11 },
+  { ".text", 5 },
   { NULL, 0 }
 };
 
 /* Do not specify library suffix explicitly, to allow for dllized versions.  */
 static autofilter_entry_type autofilter_liblist[] =
 {
+  { "libcegcc", 8 },
   { "libcygwin", 9 },
   { "libgcc", 6 },
   { "libstdc++", 9 },
@@ -261,9 +266,10 @@
 
 static autofilter_entry_type autofilter_symbolprefixlist[] =
 {
-  /*  { "__imp_", 6 }, */
+  { "__imp_", 6 },
   /* Do __imp_ explicitly to save time.  */
   { "__rtti_", 7 },
+  { ".idata$", 7 },
   /* Don't re-export auto-imported symbols.  */
   { "_nm_", 4 },
   { "__builtin_", 10 },
@@ -1130,9 +1167,14 @@
 	  asymbol **symbols;
 	  int nsyms, symsize;
 
+#if 0
 	  /* If it's not loaded, we don't need to relocate it this way.  */
+	  /* sometimes .data section gets no SEC_LOAD flag, but contains relocs */
 	  if (!(s->output_section->flags & SEC_LOAD))
 	    continue;
+#endif
+	  if (strncmp (bfd_get_section_name (abfd, s), ".idata",6) == 0)
+	    continue;
 
 	  /* I don't know why there would be a reloc for these, but I've
 	     seen it happen - DJ  */
@@ -1780,6 +1824,14 @@
   0x08, 0x00, 0x00, 0x01,  0x00, 0x00, 0x00, 0x00
 };
 
+static unsigned char arm_jtab[] =
+{
+  0x00, 0xc0, 0x9f, 0xe5,	/* ldr  ip, [pc] */
+  0x00, 0xf0, 0x9c, 0xe5,	/* ldr  pc, [ip] */
+  0,    0,    0,    0
+};
+
+
 static bfd *
 make_one (def_file_export *exp, bfd *parent)
 {
@@ -1801,6 +1853,10 @@
       jmp_bytes = jmp_sh_bytes;
       jmp_byte_count = sizeof (jmp_sh_bytes);
       break;
+    case PE_ARCH_arm:
+      jmp_bytes = arm_jtab;
+      jmp_byte_count = sizeof (arm_jtab);
+      break;
     case PE_ARCH_mips:
       jmp_bytes = jmp_mips_bytes;
       jmp_byte_count = sizeof (jmp_mips_bytes);
@@ -1873,6 +1933,9 @@
 	case PE_ARCH_sh:
 	  quick_reloc (abfd, 8, BFD_RELOC_32, 2);
 	  break;
+	case PE_ARCH_arm:
+	  quick_reloc (abfd, 8, BFD_RELOC_32, 2);
+	  break;
 	case PE_ARCH_mips:
 	  quick_reloc (abfd, 0, BFD_RELOC_HI16_S, 2);
 	  quick_reloc (abfd, 0, BFD_RELOC_LO16, 0); /* MIPS_R_PAIR */
Index: ld/emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.113
diff -u -r1.113 pe.em
--- ld/emultempl/pe.em	24 Nov 2005 06:02:08 -0000	1.113
+++ ld/emultempl/pe.em	26 Apr 2006 22:31:27 -0000
@@ -283,7 +283,7 @@
   D(MajorImageVersion,"__major_image_version__", 1),
   D(MinorImageVersion,"__minor_image_version__", 0),
 #ifdef TARGET_IS_armpe
-  D(MajorSubsystemVersion,"__major_subsystem_version__", 2),
+  D(MajorSubsystemVersion,"__major_subsystem_version__", 3),
 #else
   D(MajorSubsystemVersion,"__major_subsystem_version__", 4),
 #endif

[-- Attachment #3: binutils-cvs20050202_wince_edited.diff --]
[-- Type: text/plain, Size: 6364 bytes --]

diff -Nur binutils-cvs20050202_2/bfd/coff-arm.c binutils-cvs20050202/bfd/coff-arm.c
--- binutils-cvs20050202_2/bfd/coff-arm.c	2005-01-31 23:13:16.000000000 +0000
+++ binutils-cvs20050202/bfd/coff-arm.c	2005-12-11 10:46:00.000000000 +0000
@@ -273,7 +273,7 @@
 	   complain_overflow_dont,
 	   aoutarm_fix_pcrel_26_done,
 	   "ARM_26D",
-	   FALSE,
+	   TRUE,
 	   0x00ffffff,
 	   0x0,
 	   PCRELOFFSET),
@@ -286,7 +286,7 @@
 	   complain_overflow_bitfield,
 	   coff_arm_reloc,
 	   "ARM_32",
-	   FALSE,
+	   TRUE,
 	   0xffffffff,
 	   0xffffffff,
 	   PCRELOFFSET),
@@ -299,7 +299,7 @@
 	   complain_overflow_bitfield,
 	   coff_arm_reloc,
 	   "ARM_RVA32",
-	   FALSE,
+	   TRUE,
 	   0xffffffff,
 	   0xffffffff,
 	   PCRELOFFSET),
@@ -347,7 +347,7 @@
 	   complain_overflow_bitfield,
 	   coff_arm_reloc,
 	   "ARM_SECTION",
-	   FALSE,
+	   TRUE,
 	   0x0000ffff,
 	   0x0000ffff,
 	   PCRELOFFSET),
@@ -360,7 +360,7 @@
 	   complain_overflow_bitfield,
 	   coff_arm_reloc,
 	   "ARM_SECREL",
-	   FALSE,
+	   TRUE,
 	   0xffffffff,
 	   0xffffffff,
 	   PCRELOFFSET),
@@ -1288,6 +1295,8 @@
 #ifdef ARM_WINCE
       /* MS ARM-CE makes the reloc relative to the opcode's pc, not
 	 the next opcode's pc, so is off by one.  */
+      if (howto->pc_relative && !info->relocatable)
+	addend -= 8;
 #endif
 
       /* If we are doing a relocatable link, then we can just ignore
@@ -1303,7 +1312,7 @@
 	     VxWorks and EPOC-PE targets, but it is also known that it
 	     was suppressed for other ARM targets.  This ought to be
 	     sorted out one day.  */
-#ifdef ARM_COFF_BUGFIX
+#if 1//def ARM_COFF_BUGFIX
 	  /* We must not ignore the symbol value.  If the symbol is
 	     within the same section, the relocation should have already
 	     been fixed, but if it is not, we'll be handed a reloc into
diff -Nur binutils-cvs20050202_2/gas/config/tc-arm.c binutils-cvs20050202/gas/config/tc-arm.c
--- binutils-cvs20050202_2/gas/config/tc-arm.c	2005-01-31 23:18:26.000000000 +0000
+++ binutils-cvs20050202/gas/config/tc-arm.c	2005-12-08 21:59:08.000000000 +0000
@@ -1106,7 +1106,10 @@
     }
 
   inst.reloc.exp.X_op         = O_symbol;
-  inst.reloc.exp.X_add_number = ((int) entry) * 4 - 8;
+  inst.reloc.exp.X_add_number = ((int) entry) * 4;
+#ifndef TE_WINCE
+  inst.reloc.exp.X_add_number -= 8; /* PC relative adjust.  */
+#endif
   inst.reloc.exp.X_add_symbol = pool->symbol;
 
   return SUCCESS;
@@ -2404,7 +2407,9 @@
 	return FAIL;
 
       inst.reloc.type = BFD_RELOC_ARM_CP_OFF_IMM;
+#ifndef TE_WINCE
       inst.reloc.exp.X_add_number -= 8;  /* PC rel adjust.  */
+#endif
       inst.reloc.pc_rel = 1;
       inst.instruction |= (REG_PC << 16);
       pre_inc = PRE_INDEX;
@@ -2540,7 +2545,9 @@
         return FAIL;
 
       inst.reloc.type = BFD_RELOC_ARM_CP_OFF_IMM_S2;
-      inst.reloc.exp.X_add_number -= 8;  /* PC rel adjust.  */
+#ifndef TE_WINCE
+      inst.reloc.exp.X_add_number -= 8; /* PC relative adjust.  */
+#endif
       inst.reloc.pc_rel = 1;
       inst.instruction |= (REG_PC << 16);
       pre_inc = PRE_INDEX;
@@ -3054,7 +3061,9 @@
 
       inst.instruction            |= HWOFFSET_IMM;	/* The I bit.  */
       inst.reloc.type              = BFD_RELOC_ARM_OFFSET_IMM8;
+#ifndef TE_WINCE
       inst.reloc.exp.X_add_number -= 8;  		/* PC rel adjust.  */
+#endif
       inst.reloc.pc_rel            = 1;
       inst.instruction            |= (REG_PC << 16);
 
diff -Nur binutils-cvs20050202_2/gas/config/te-pe.h binutils-cvs20050202/gas/config/te-pe.h
--- binutils-cvs20050202_2/gas/config/te-pe.h	2002-11-06 19:36:20.000000000 +0000
+++ binutils-cvs20050202/gas/config/te-pe.h	2005-12-04 19:26:56.000000000 +0000
@@ -1,3 +1,4 @@
+#define TE_WINCE
 #define TE_PE
 #define LEX_AT (LEX_BEGIN_NAME | LEX_NAME) /* Can have @'s inside labels.  */
 
diff -Nur binutils-cvs20050202_2/ld/pe-dll.c binutils-cvs20050202/ld/pe-dll.c
--- binutils-cvs20050202_2/ld/pe-dll.c	2005-01-21 04:16:00.000000000 +0000
+++ binutils-cvs20050202/ld/pe-dll.c	2005-12-05 00:45:10.000000000 +0000
@@ -199,7 +199,7 @@
     11 /* ARM_RVA32 */,
     PE_ARCH_arm,
     bfd_arch_arm,
-    1
+    0
   },
   {
     "epoc-pei-arm-little",
@@ -226,6 +226,7 @@
   { "_pei386_runtime_relocator", 25 },
   { "do_pseudo_reloc", 15 },
   { "cygwin_crt0", 11 },
+  { ".text", 5 },
   { NULL, 0 }
 };
 
@@ -261,9 +262,10 @@
 
 static autofilter_entry_type autofilter_symbolprefixlist[] =
 {
-  /*  { "__imp_", 6 }, */
+  { "__imp_", 6 },
   /* Do __imp_ explicitly to save time.  */
   { "__rtti_", 7 },
+  { ".idata$", 7 },
   /* Don't re-export auto-imported symbols.  */
   { "_nm_", 4 },
   { "__builtin_", 10 },
@@ -735,8 +768,8 @@
       else
 	{
 	  /* xgettext:c-format */
-	  einfo (_("%XCannot export %s: symbol not found\n"),
-		 pe_def_file->exports[i].internal_name);
+	  einfo (_("%XCannot export %s (%s): symbol not found\n"),
+		 pe_def_file->exports[i].internal_name,pe_def_file->exports[i].name);
 	}
       free (name);
     }
@@ -1083,9 +1116,14 @@
 	  asymbol **symbols;
 	  int nsyms, symsize;
 
+#if 0
 	  /* If it's not loaded, we don't need to relocate it this way.  */
+	  /* sometimes .data section gets no SEC_LOAD flag, but contains relocs */
 	  if (!(s->output_section->flags & SEC_LOAD))
 	    continue;
+#endif
+	  if (strncmp (bfd_get_section_name (abfd, s), ".idata",6) == 0)
+	    continue;
 
 	  /* I don't know why there would be a reloc for these, but I've
 	     seen it happen - DJ  */
@@ -1733,6 +1773,14 @@
   0x08, 0x00, 0x00, 0x01,  0x00, 0x00, 0x00, 0x00
 };
 
+static unsigned char arm_jtab[] =
+{
+  0x00, 0xc0, 0x9f, 0xe5,	/* ldr  ip, [pc] */
+  0x00, 0xf0, 0x9c, 0xe5,	/* ldr  pc, [ip] */
+  0,    0,    0,    0
+};
+
+
 static bfd *
 make_one (def_file_export *exp, bfd *parent)
 {
@@ -1754,6 +1802,10 @@
       jmp_bytes = jmp_sh_bytes;
       jmp_byte_count = sizeof (jmp_sh_bytes);
       break;
+    case PE_ARCH_arm:
+      jmp_bytes = arm_jtab;
+      jmp_byte_count = sizeof (arm_jtab);
+      break;
     case PE_ARCH_mips:
       jmp_bytes = jmp_mips_bytes;
       jmp_byte_count = sizeof (jmp_mips_bytes);
@@ -1826,6 +1882,9 @@
 	case PE_ARCH_sh:
 	  quick_reloc (abfd, 8, BFD_RELOC_32, 2);
 	  break;
+	case PE_ARCH_arm:
+	  quick_reloc (abfd, 8, BFD_RELOC_32, 2);
+	  break;
 	case PE_ARCH_mips:
 	  quick_reloc (abfd, 0, BFD_RELOC_HI16_S, 2);
 	  quick_reloc (abfd, 0, BFD_RELOC_LO16, 0); /* MIPS_R_PAIR */

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-04-27  0:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-11 23:06 puzzled - old release works, newer doesn't Danny Backx
2006-04-25 17:39 ` Nick Clifton
2006-04-25 21:15   ` Pedro Alves
2006-04-27  2:23     ` Pedro Alves
2006-04-27  1:32   ` Danny Backx

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).