Add a call O to the function exit(). This should return execution to the operating system. Comment out the call to return() Q. A return call in this location causes a stack underflow because there is nowhere within this application to return to!

This fixed the problem—no more killed messages! Look at figure 13.6, where we see that the dynamic version of Hello, Android! now runs just fine.

Figure 13.6 A better-behaving dynamic version of Hello Android

~C:\WIND0WS\fyitem32\tmd.iKe-«lb shell

.^bellodiinsnic Hello, Android! tt


Figure 13.6 A better-behaving dynamic version of Hello Android

Unfortunately we are not finished. It turns out that our application does not properly interact with other libraries, nor does it properly handle the argc and argv[] arguments to the main function. The C library (remember, we are linking against has certain expectations for application structure and stack location. We're closer but still not quite ready for prime time.

What our application requires is a start routine, which is called by the operating system when our application is invoked. This function in turn calls our application's main function. This start routine must set up the necessary structures to allow the application to properly interact with the operating system and the core C libraries.

0 0

Post a comment