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.