public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* binutils on arm - research on Pedro's stuff
@ 2006-04-29  2:08 Danny Backx
  2006-05-02 22:23 ` Sorted out (Pedro's stuff does fix binutils on arm-wince-pe) Danny Backx
  0 siblings, 1 reply; 2+ messages in thread
From: Danny Backx @ 2006-04-29  2:08 UTC (permalink / raw)
  To: binutils


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

Guys,

I can confirm that Pedro's work (the binutils-head-wince_edited.diff
file that he posted) does provide a solution for my problems.

The solution is only partial, but that may not be a binutils problem.

Here's the detail :
- I created a Makefile (attached) to call gcc, gas, and ld in the same
way as demonstrated by an example from Pedro
- Pedro's example that just calls MessageBoxW() works with that.
- My example that calls fopen/fprintf/fclose doesn't do anything.
- In file2.c I made a mixture between both to call MessageBoxW before
and after the fopen call. Only the MessageBoxW call before fopen
happens, the one after is never reached. This is on a PDA, no other
feedback comes, the process is just gone. This may not be a binutils
issue at all.

So I would encourage you to look into Pedro's patch because it
transforms a clearly broken binutils (on ARM) into one that appears to
work.

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

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

typedef unsigned short wchar_t;
typedef wchar_t WCHAR;
typedef const WCHAR* LPCWSTR;
typedef void* HWND;
typedef unsigned int UINT;

int MessageBoxW ( HWND hWnd , LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);

int WinMainCRTStartup()
{
	  MessageBoxW(0, L"HELLO!", L"H3LLO!", 0);
}

[-- Attachment #1.3: file1.c --]
[-- Type: text/x-csrc, Size: 2030 bytes --]

struct FILE_;
typedef struct FILE_ FILE;
typedef unsigned short wchar_t;

FILE* fopen (const char *, const char *);
int fprintf (FILE *, const char *, ...);
int fclose (FILE *);

#define _C ' '
#define _S 'a'
#define _P 'a'
#define _N 'a'
#define _L 'a'
#define _X 'a'
#define _B 'c'
#define _U 'a'

#define _CTYPE_DATA_0_127 \
  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,	0

const char _ctype_[1 + 256] = {
  0,
  _CTYPE_DATA_0_127,
  _CTYPE_DATA_128_256
};

const char* __ctype_ptr = _ctype_ + 1;

int local_fun(void)
{
  FILE	*f;

  f = fopen("/log.txt", "w");
  fprintf(f, "Hello\r\n");
  fprintf(f, "Hello %p\r\n", *__ctype_ptr);
  fclose(f);
  //	exit(0);
  return 0;
}

int WinMainCRTStartup(void)
{
#define TRIGGER

#ifndef TRIGGER
  FILE	*f;

  f = fopen("/log.txt", "w");
  fprintf(f, "Hello\r\n");
  fclose(f);
  //	exit(0);
  return 0;
#else
  return local_fun();
#endif
}

[-- Attachment #1.4: file2.c --]
[-- Type: text/x-csrc, Size: 1990 bytes --]

struct FILE_;
typedef struct FILE_ FILE;
typedef unsigned short wchar_t;

FILE* fopen (const char *, const char *);
int fprintf (FILE *, const char *, ...);
int fclose (FILE *);

#define _C ' '
#define _S 'a'
#define _P 'a'
#define _N 'a'
#define _L 'a'
#define _X 'a'
#define _B 'c'
#define _U 'a'

#define _CTYPE_DATA_0_127 \
  _C,	_C,	_C,	_C,	_C,	_C,	_C,	_C, \
  _C,	_C|_S,	_C|_S,	_C|_S,	_C|_S,	_C|_S,	_C,	_C, \
  _C,	_C,	_C,	_C,	_C,	_C,	_C,	_C, \
  _C,	_C,	_C,	_C,	_C,	_C,	_C,	_C, \
  _S|_B,	_P,	_P,	_P,	_P,	_P,	_P,	_P, \
  _P,	_P,	_P,	_P,	_P,	_P,	_P,	_P, \
  _N,	_N,	_N,	_N,	_N,	_N,	_N,	_N, \
  _N,	_N,	_P,	_P,	_P,	_P,	_P,	_P, \
  _P,	_U|_X,	_U|_X,	_U|_X,	_U|_X,	_U|_X,	_U|_X,	_U, \
  _U,	_U,	_U,	_U,	_U,	_U,	_U,	_U, \
  _U,	_U,	_U,	_U,	_U,	_U,	_U,	_U, \
  _U,	_U,	_U,	_P,	_P,	_P,	_P,	_P, \
  _P,	_L|_X,	_L|_X,	_L|_X,	_L|_X,	_L|_X,	_L|_X,	_L, \
  _L,	_L,	_L,	_L,	_L,	_L,	_L,	_L, \
  _L,	_L,	_L,	_L,	_L,	_L,	_L,	_L, \
  _L,	_L,	_L,	_P,	_P,	_P,	_P,	_C

#define _CTYPE_DATA_128_256 \
  0,	0,	0,	0,	0,	0,	0,	0, \
  0,	0,	0,	0,	0,	0,	0,	0, \
  0,	0,	0,	0,	0,	0,	0,	0, \
  0,	0,	0,	0,	0,	0,	0,	0, \
  0,	0,	0,	0,	0,	0,	0,	0, \
  0,	0,	0,	0,	0,	0,	0,	0, \
  0,	0,	0,	0,	0,	0,	0,	0, \
  0,	0,	0,	0,	0,	0,	0,	0, \
  0,	0,	0,	0,	0,	0,	0,	0, \
  0,	0,	0,	0,	0,	0,	0,	0, \
  0,	0,	0,	0,	0,	0,	0,	0, \
  0,	0,	0,	0,	0,	0,	0,	0, \
  0,	0,	0,	0,	0,	0,	0,	0, \
  0,	0,	0,	0,	0,	0,	0,	0, \
  0,	0,	0,	0,	0,	0,	0,	0, \
  0,	0,	0,	0,	0,	0,	0,	0

const char _ctype_[1 + 256] = {
  0,
  _CTYPE_DATA_0_127,
  _CTYPE_DATA_128_256
};

const char* __ctype_ptr = _ctype_ + 1;

int local_fun(void)
{
  FILE	*f;

  MessageBoxW(0, L"before file open", L"H3LLO!", 0);
  f = fopen("/storage card/devel/log.txt", "w");
  MessageBoxW(0, L"after file open", L"H3LLO!", 0);
  fprintf(f, "Hello\r\n");
  fprintf(f, "Hello %p\r\n", *__ctype_ptr);
  fclose(f);
  //	exit(0);
  return 0;
}

int WinMainCRTStartup(void)
{
  return local_fun();
}

[-- Attachment #1.5: Makefile --]
[-- Type: text/x-makefile, Size: 1729 bytes --]

.SUFFIXES:
.SUFFIXES:	.c .o .s .exe .dist .exedump .objdump

P=              /usr/ppc/bin/arm-wince-pe
STARTUP=	-e_WinMainCRTStartup		# -e_WinMain causes crash
PCC=            ${P}-gcc ${CFLAGS} ${STARTUP}
PAS=            ${P}-as
PLD=            ${P}-ld ${STARTUP}
WINDRES=        ${P}-windres

CFLAGS=         -DUNICODE -D_UNICODE -DWINE_UNICODE_NATIVE -DWINCE \
		${VERBOSE} ${INCLUDE}
#LDFLAGS=        -Wl,--major-subsystem-version=4,--minor-subsystem-version=20
CCLDFLAGS=        -Wl,--major-subsystem-version=3,--minor-subsystem-version=0
LDFLAGS=        --major-subsystem-version=3 --minor-subsystem-version=0
#INCLUDE=       -I/usr/include/wine/windows -I/usr/include/wine
INCLUDE=        -I/usr/ppc/arm-wince-pe/include \
		-I/usr/ppc/arm-wince-pe/sys-include/windows
VERBOSE=        # -v
PDADIR=         ":/storage card/devel"

LDPATH=		-L/usr/ppc/lib/gcc/arm-wince-pe/4.1.0
#LIBS=		-lcoredll
LIBS=		${LDPATH} -lcoredll -lwinsock -lgcc -lc -lcoredll -lwinsock -lgcc -lc

all::	dialog.exe dialog.exedump dialog.dist

.exe.dist:
	pcp $*.exe ${PDADIR}/$*.exe

.c.o:
	${PCC} -S -o $*.s $?
	${PAS} -o $@ $*.s

.c.s:
	${PCC} -S -o $@ $?

.s.o:
	${PAS} -o $@ $?

.o.exe:
	${PLD} -o $@ $? ${LDFLAGS} ${LIBS}

.exe.exedump:
	${P}-objdump -x -s -g -D $*.exe > $*.exedump

.o.objdump:
	${P}-objdump -x -s -g -D $*.o > $*.objdump

clean::
	-rm -f dialog.exe dialog.s dialog.o dialog.objdump dialog.exedump
	-rm -f hello.exe hello.s hello.o hello.objdump hello.exedump
	-rm -f file1.exe file1.s file1.o file1.objdump file1.exedump
	-rm -f file2.exe file2.s file2.o file2.objdump file2.exedump

all::	file1.exe file1.dist file1.exedump
all::	file2.exe file2.dist file2.exedump

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

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

* Sorted out (Pedro's stuff does fix binutils on arm-wince-pe)
  2006-04-29  2:08 binutils on arm - research on Pedro's stuff Danny Backx
@ 2006-05-02 22:23 ` Danny Backx
  0 siblings, 0 replies; 2+ messages in thread
From: Danny Backx @ 2006-05-02 22:23 UTC (permalink / raw)
  To: binutils


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

Following up on my own post.

The uncertainties I had last Friday about Pedro's submission are gone. I
was having library conflicts. Once these were sorted out, the test
programs all worked. I was mixing newlib and coredll stuff in a bad way.

So for me this boils down to :
- Binutils (CVS and 2.17 pre) is badly broken for arm-wince-pe (aka to
  generate code for a standard Windows CE PDA). GAS and LD work (as in
  "they don't crash"), but they generate broken code.
- Pedro's patches fix the problems known to me.

Evidence is attached (including .s files, .exe files, and full objdump
of the .exe files).

You can compare the "exedump" files to what I described in an earlier
post. Both problems are now gone.

	Danny

P.S. The "evidence" was created with these tools :
dannypc: {24} arm-wince-pe-as --version
GNU assembler 2.17.50 20060427
Copyright 2005 Free Software Foundation, Inc. [...]
This assembler was configured for a target of `arm-wince-pe'.
dannypc: {25} arm-wince-pe-ld --version
GNU ld version 2.17.50 20060427
Copyright 2005 Free Software Foundation, Inc. [...]
dannypc: {26} arm-wince-pe-gcc --version
arm-wince-pe-gcc (GCC) 4.1.0
Copyright (C) 2006 Free Software Foundation, Inc. [...]

	Danny

On Fri, 2006-04-28 at 21:02 +0200, Danny Backx wrote:
> Guys,
> 
> I can confirm that Pedro's work (the binutils-head-wince_edited.diff
> file that he posted) does provide a solution for my problems.
> 
> The solution is only partial, but that may not be a binutils problem.
> 
> Here's the detail :
> - I created a Makefile (attached) to call gcc, gas, and ld in the same
> way as demonstrated by an example from Pedro
> - Pedro's example that just calls MessageBoxW() works with that.
> - My example that calls fopen/fprintf/fclose doesn't do anything.
> - In file2.c I made a mixture between both to call MessageBoxW before
> and after the fopen call. Only the MessageBoxW call before fopen
> happens, the one after is never reached. This is on a PDA, no other
> feedback comes, the process is just gone. This may not be a binutils
> issue at all.
> 
> So I would encourage you to look into Pedro's patch because it
> transforms a clearly broken binutils (on ARM) into one that appears to
> work.
> 
> 	Danny
-- 
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info

[-- Attachment #1.2: ship.tar.gz --]
[-- Type: application/x-compressed-tar, Size: 17747 bytes --]

[-- Attachment #1.3: typescript --]
[-- Type: text/plain, Size: 3174 bytes --]

Script started on Wed 03 May 2006 00:09:27 CEST
dannypc: {1} make clean
rm -f   dialog.s file1.s file2.s dialog.o file1.o file2.o dialog.exe file1.exe file2.exe dialog.exedump file1.exedump file2.exedump dialog.objdump file1.objdump file2.objdump
dannypc: {2} make dist
/usr/ppc/bin/arm-wince-pe-gcc -DUNICODE -D_UNICODE -DWINE_UNICODE_NATIVE -DWINCE   -I/usr/ppc/arm-wince-pe/include -I/usr/ppc/arm-wince-pe/sys-include/windows -e_WinMainCRTStartup              -S -o dialog.s dialog.c
/usr/ppc/bin/arm-wince-pe-gcc -DUNICODE -D_UNICODE -DWINE_UNICODE_NATIVE -DWINCE   -I/usr/ppc/arm-wince-pe/include -I/usr/ppc/arm-wince-pe/sys-include/windows -e_WinMainCRTStartup              -S -o file1.s file1.c
/usr/ppc/bin/arm-wince-pe-gcc -DUNICODE -D_UNICODE -DWINE_UNICODE_NATIVE -DWINCE   -I/usr/ppc/arm-wince-pe/include -I/usr/ppc/arm-wince-pe/sys-include/windows -e_WinMainCRTStartup              -S -o file2.s file2.c
/usr/ppc/bin/arm-wince-pe-gcc -DUNICODE -D_UNICODE -DWINE_UNICODE_NATIVE -DWINCE   -I/usr/ppc/arm-wince-pe/include -I/usr/ppc/arm-wince-pe/sys-include/windows -e_WinMainCRTStartup              -S -o dialog.s dialog.c
/usr/ppc/bin/arm-wince-pe-as -o dialog.o dialog.s
/usr/ppc/bin/arm-wince-pe-gcc -DUNICODE -D_UNICODE -DWINE_UNICODE_NATIVE -DWINCE   -I/usr/ppc/arm-wince-pe/include -I/usr/ppc/arm-wince-pe/sys-include/windows -e_WinMainCRTStartup              -S -o file1.s file1.c
/usr/ppc/bin/arm-wince-pe-as -o file1.o file1.s
/usr/ppc/bin/arm-wince-pe-gcc -DUNICODE -D_UNICODE -DWINE_UNICODE_NATIVE -DWINCE   -I/usr/ppc/arm-wince-pe/include -I/usr/ppc/arm-wince-pe/sys-include/windows -e_WinMainCRTStartup              -S -o file2.s file2.c
/usr/ppc/bin/arm-wince-pe-as -o file2.o file2.s
/usr/ppc/bin/arm-wince-pe-ld -e_WinMainCRTStartup                -o dialog.exe dialog.o --major-subsystem-version=4 --minor-subsystem-version=2 -lcoredll -Map dialog.map
/usr/ppc/bin/arm-wince-pe-ld -e_WinMainCRTStartup                -o file1.exe file1.o --major-subsystem-version=4 --minor-subsystem-version=2 -lcoredll -Map file1.map
/usr/ppc/bin/arm-wince-pe-ld -e_WinMainCRTStartup                -o file2.exe file2.o --major-subsystem-version=4 --minor-subsystem-version=2 -lcoredll -Map file2.map
/usr/ppc/bin/arm-wince-pe-objdump -x -s -g -D dialog.exe > dialog.exedump
/usr/ppc/bin/arm-wince-pe-objdump -x -s -g -D file1.exe > file1.exedump
/usr/ppc/bin/arm-wince-pe-objdump -x -s -g -D file2.exe > file2.exedump
/usr/ppc/bin/arm-wince-pe-objdump -x -s -g -D dialog.o > dialog.objdump
/usr/ppc/bin/arm-wince-pe-objdump -x -s -g -D file1.o > file1.objdump
/usr/ppc/bin/arm-wince-pe-objdump -x -s -g -D file2.o > file2.objdump
tar cfvz ship.tar.gz Makefile dialog.c file1.c file2.c dialog.s file1.s file2.s dialog.o file1.o file2.o dialog.exe file1.exe file2.exe dialog.exedump file1.exedump file2.exedump dialog.objdump file1.objdump file2.objdump
Makefile
dialog.c
file1.c
file2.c
dialog.s
file1.s
file2.s
dialog.o
file1.o
file2.o
dialog.exe
file1.exe
file2.exe
dialog.exedump
file1.exedump
file2.exedump
dialog.objdump
file1.objdump
file2.objdump
dannypc: {3} ^D\b\b
Script done on Wed 03 May 2006 00:09:34 CEST

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

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

end of thread, other threads:[~2006-05-02 22:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-29  2:08 binutils on arm - research on Pedro's stuff Danny Backx
2006-05-02 22:23 ` Sorted out (Pedro's stuff does fix binutils on arm-wince-pe) 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).