Another development environment option!
Moderators: chiark

Jump to page : 1
Now viewing page 1 [15 messages per page]

Forums · General Discussion · Developers Arena

smb_gaiden
Posted 2018-04-01 2:57 AM
#
Factorite (Elite)

100


Posts:
120
Member Nº:
6987
Status:
Well, came across another compiler and observed they added ARM support about 4-5 years ago. Then there was an update in December 2017 fixing some stuff and adding ARM64 support. The former was intriguing and the latter was not applicable.

Introducing Tiny C compiler for Windows CE HPC development! The author is here: https://bellard.org/tcc/ . The download is here: http://download.savannah.gnu.org/releases/tinycc/ . It needs the .tar.bz2 package, so it includes sources.

tldr; used tcc to compile an executable that ran successfully on the jornada 820.

My adventure follows:

1. Downloaded the .tar.bz2
2. unpacked it on linux (chromeos using crouton to a trusty chroot)
3. Compiled it to test the general native compiler
4. built a helloworld native app to test, and observed success
5. built the compiler again for all cross platforms
6. wrote a simple Windows CE app to show a MessageBoxW
MessageBoxW(0, "T\0e\0s\0t\0\0", "T\0e\0s\0t\0\0", 0);
7. needed to make a COREDLL.def to link with for the MessageBoxW symbol
8. compiled with the arm-wince-tcc
9. Ran it on Jornada 820 and it failed with some unloaded dependencies
10. Used embedded visual tools 3.0 to compile a similar app without any external dependencies such as wWinMainCRT or whatever it is called.
11. Observed the binary generated by EVT3 ran on the jornada 820.
12. Did some work to extract the raw code from the .text section of the PE files of each respectively.
13. Used objdump to show the associated assembler code and read through it.
14. Determined both generated valid code, but differently.
15. Used a PE inspector to look at the differences between the TCC generated binary and the EVT3 generated binary.
16. Observed some differences within some of the optional headers fields
17. hex edited the TCC generated binary to match the EVT3 generated binary
18. Loaded the hex edited binary to the jornada 820 and ran it.


success!

I left out a bunch of steps of failure trying to use the wce211 sdk include files, fixing case sensitive header file names, and circular dependencies. That's for later.

What does it mean?
1. There's a possibility that the tcc project itself could be ported onto arm architecture in order to use jornada as a development machine in order to write software that runs on itself. First thing is first, which will be to edit tcc in order to accept command line options to control the areas I had to manually hex edit.
2. I don't have to boot into a virtual machine in order to write software targeting a Jornada 820 (and likely other ARM based CE devices).
3. Sanitizing the wce header files may make compile time checking easier to develop in this environment, blindly linking against dynamic dlls won't guarantee the caller is using the appropriate parameter count and types.

Addendum:

Here's what the compile command looked like:
./arm-wince-tcc -o MsgBawx.exe -nostdlib -DUNICODE -D_UNICODE -D_ARM_ -L . -lcoredll MsgBawx.c

Here's what the .def file looked like:
LIBRARY coredll.dll

EXPORTS
MessageBoxW

Here's the project source code:

void _start(void)
{
MessageBoxW(0, "T\0e\0s\0t\0\0", "T\0e\0s\0t\0\0", 0);
}

The MSVC project to compare against was whittled down to resemble the tcc project and removed or altered:
- cpp, and flattened to c
- resource files
- stdafx
- *.rc
- resource headers
- wWinMainCRT or whatever, just did the int SYMBOL(){} as an entry point (SYMBOL was some name that I used in the project settings as entry point)
- did not use command line arguments or hwnd arguments, just an empty paramter function returning int.
- generated own library, so they wouldnt link the dynamically linked library by ordinal
--- this involved making a def file as above
--- using lib.exe such as:
----- lib.exe /def:coredll.def /machine:arm /out:coredll.lib
---------- the above may have had ARM instead of lowercase arm


As a result the file sizes were:
TCC MsgBawx: 1,536
EVT3 MsgBawx: 3,072

The PE file comparison:
TCC MsgBawx has two sections (.data and .text)
EVT3 MsgBawx has four sections (.data, .text, .rdata, .pdata)

TCC MsgBawx has a smaller MS-DOS stub than the EVT3 MsgBawx.
 Top of the page
smb_gaiden
Posted 2018-04-04 8:49 PM
#
Factorite (Elite)

100


Posts:
120
Member Nº:
6987
Status:
Copy stingraze and add a screenshot!





(msgbawx.png)



Attachments
----------------
Attachments msgbawx.png (11KB - 0 downloads)
 Top of the page
stingraze
Posted 2018-04-05 2:30 AM
#


Writing Team
H/PC Elder

10005001001001002525


Posts:
1874
Member Nº:
35
Location:
Kanagawa, Japan
Status:
This is very cool.

Do you mean the TCC can compile on Jornada itself to create binaries for itself?

-stingraze
 Top of the page
smb_gaiden
Posted 2018-04-05 4:32 AM
#
Factorite (Elite)

100


Posts:
120
Member Nº:
6987
Status:
Ohaiyou!

Theoretically still - haven't heard of any projects which ported tcc to the wince device itself yet. Making it reality is my future goal actually!

Thoughts:
tcc compiles itself. For example, I compiled tcc and the tcc cross compilers (including arm-wince-tcc from source on ubuntu).
Then arm-wince-tcc compiles an arm binary that needs 3 bytes hex edited to successfully execute on the jornada. (May only need two, didn't test after success with three altered bytes), as long as in the hex editor 3 vs. 2 is insignificant. Next goal is to alter tcc src in order to add linker options to alter those bytes directly.
Therefore, if i use arm-wince-tcc to compile arm-wince-tcc and resolve std c library deficiencies it should run on the Jornada. Then it will be an exercise of debugging in case some RAM/HDD assumptions are too limiting.

I guess my hobby is weird, I bought that Jornada 820 in 1998 in order to listen to mp3s relocating from east coast to west coast and also use offline mapquest maps. Nostalgia! Also fired up the embedded visual tools in order to add a feature to my scrngrab tool. If I do a capture with the old way then the main app loses focus and the title bar becomes grey. Added an option for delayed capture to afford a bit of time to refocus the app. Took five lines of code to implement . #define NEWVAL 0x0102, case NEWVAL: Sleep(4000); DoCapture(); break;

Regretfully, I saw a message about failure to communicate with main battery last week and continuing into this week. Have seen threads here about re-celling batteries, but that's still scary to me.
 Top of the page
stingraze
Posted 2018-04-05 5:03 AM
#


Writing Team
H/PC Elder

10005001001001002525


Posts:
1874
Member Nº:
35
Location:
Kanagawa, Japan
Status:
Thank you for your detailed explanation.

The goal will be really awesome, good luck with it!

I think I first bought my Sigmarion (1) around 2002 or 3.
I bought it after I got into Windows CE by Cassiopeia E-700WE.
Since then, I've been on and off in this amazing form factor, but recently been interested in it a lot again.

Yes, recelling cells for me is scary too!
 Top of the page
hpc:factor« View previous thread · Developers Arena · View next thread »

Jump to page : 1
Now viewing page 1 [15 messages per page]

Jump to forum :
Search this forum
Printer friendly version
E-mail a link to this thread
Seconds to generate: 0.367 - Cached queries : 60 - Executed queries : 9
Server Time now is: Friday, 20 April 2018 - 19:7