diff -urN prc-tools-0.5.0-orig/Makefile prc-tools-0.5.0/Makefile --- prc-tools-0.5.0-orig/Makefile Thu Jul 10 04:14:12 1997 +++ prc-tools-0.5.0/Makefile Mon Oct 5 13:49:31 1998 @@ -2,7 +2,7 @@ CFLAGS = -O2 -g # -g -DDEBUG -PREFIX = /usr/local/gnu +PREFIX = /usr/palm HOST = i386-slackware-linux TARGET-NAME = m68k-palmos-coff @@ -29,7 +29,7 @@ LIBMDIR = libmf.0.1.2 LIBGLIBDIR = libglib.0.1.0 -PILRCDIR = pilrc1.5 +PILRCDIR = pilrc2.0a # export doesn't work on make in gnuwin32 b18... MAKEEXPORTS = PREFIX=$(PREFIX) TOOLDIR=$(TOOLDIR) \ @@ -64,6 +64,7 @@ cd $(LIBCDIR) ; make $(MAKEEXPORTS) install cd $(LIBMDIR) ; make $(MAKEEXPORTS) install cd $(LIBGLIBDIR) ; make $(MAKEEXPORTS) install + cd gdbpanel ; make $(MAKEEXPORTS) install cp -f pilrc$(EXEEXT) $(PREFIX)/$(TARGET-NAME)/bin cp -f txt2bitm$(EXEEXT) $(PREFIX)/$(TARGET-NAME)/bin cp -f obj-res$(EXEEXT) $(PREFIX)/$(TARGET-NAME)/bin @@ -72,7 +73,8 @@ cp -f exportlist $(PREFIX)/$(TARGET-NAME)/bin -cp -raf PalmOS1 $(PREFIX)/$(TARGET-NAME)/include -cp -raf PalmOS2 $(PREFIX)/$(TARGET-NAME)/include - ln -snf $(PREFIX)/$(TARGET-NAME)/include/PalmOS2 $(PREFIX)/$(TARGET-NAME)/include/PalmOS + -cp -raf PalmOS3 $(PREFIX)/$(TARGET-NAME)/include + ln -snf PalmOS3 $(PREFIX)/$(TARGET-NAME)/include/PalmOS ln -sf $(PREFIX)/$(TARGET-NAME)/bin/pilrc$(EXEEXT) $(PREFIX)/bin/pilrc$(EXEEXT) ln -sf $(PREFIX)/$(TARGET-NAME)/bin/txt2bitm$(EXEEXT) $(PREFIX)/bin/txt2bitm$(EXEEXT) ln -sf $(PREFIX)/$(TARGET-NAME)/bin/obj-res$(EXEEXT) $(PREFIX)/bin/$(TARGET-NAME)-obj-res$(EXEEXT) @@ -81,6 +83,7 @@ ln -sf $(PREFIX)/$(TARGET-NAME)/bin/stubgen $(PREFIX)/bin/$(TARGET-NAME)-stubgen install-man: dummy + -mkdir -p $(PREFIX)/man/man1 cp man/* $(PREFIX)/man/man1 send: all @@ -100,10 +103,10 @@ $(CC) $(CFLAGS) txt2bitm.o -o txt2bitm$(EXEEXT) $(PILRCDIR)/pilrc: - cd $(PILRCDIR) ; make + cd $(PILRCDIR) ; make pilrc pilrc$(EXEEXT): $(PILRCDIR)/pilrc - mv $(PILRCDIR)/pilrc pilrc$(EXEEXT) + cp $(PILRCDIR)/pilrc pilrc$(EXEEXT) exportlist: dummy echo \#!/bin/sh > $@ diff -urN prc-tools-0.5.0-orig/Makefile.win32 prc-tools-0.5.0/Makefile.win32 --- prc-tools-0.5.0-orig/Makefile.win32 Thu Jul 10 07:00:13 1997 +++ prc-tools-0.5.0/Makefile.win32 Mon Oct 5 13:48:00 1998 @@ -30,7 +30,7 @@ LIBMDIR = libmf.0.1.2 LIBGLIBDIR = libglib.0.1.0 -PILRCDIR = pilrc1.5 +PILRCDIR = pilrc2.0a # export doesn't work on make in gnuwin32 b18... MAKEEXPORTS = PREFIX=$(PREFIX) TOOLDIR=$(TOOLDIR) \ diff -urN prc-tools-0.5.0-orig/PalmOS1/Common.h prc-tools-0.5.0/PalmOS1/Common.h --- prc-tools-0.5.0-orig/PalmOS1/Common.h Fri Jun 13 14:44:15 1997 +++ prc-tools-0.5.0/PalmOS1/Common.h Mon Oct 5 13:48:00 1998 @@ -209,9 +209,11 @@ #define NULL 0 #endif // NULL +#if !(defined(__GNUC__) && defined(__cplusplus)) #ifndef __TYPES__ // Macintosh Types enum {false, true}; #define __TYPES__ +#endif #endif #endif //__COMMON_H__ diff -urN prc-tools-0.5.0-orig/PalmOS2/Common.h prc-tools-0.5.0/PalmOS2/Common.h --- prc-tools-0.5.0-orig/PalmOS2/Common.h Mon Oct 5 13:45:45 1998 +++ prc-tools-0.5.0/PalmOS2/Common.h Mon Oct 5 13:48:00 1998 @@ -248,7 +248,7 @@ #define false 0 #endif #endif - #else + #elif !(defined(__GNUC__) && defined(__cplusplus)) enum {false, true}; #endif #endif /* __TYPES__ */ diff -urN prc-tools-0.5.0-orig/README.shared prc-tools-0.5.0/README.shared --- prc-tools-0.5.0-orig/README.shared Sun Jun 1 20:22:57 1997 +++ prc-tools-0.5.0/README.shared Mon Oct 5 13:48:00 1998 @@ -1,230 +1,242 @@ -GLib shared libraries for the Pilot - -This document describes how to use gcc to create and use GLib shared -libraries on the Pilot. It is divided into six sections: - - What is a GLib shared library? - Upgrading gcc - Creating GLib shared libraries - Creating applications that use GLib shared libraries - Using applications that use GLib shared libraries - Conclusions - -Comments are welcome; see the Conclusions section. +[The most recent version of this file can be found at +"http://www.isaac.cs.berkeley.edu/pilot/GLib/GLib.html". - Ian] + GLib shared libraries for the Pilot + + This document describes how to use gcc to create and use GLib shared + libraries on the Pilot. It is divided into seven sections: + * What is a GLib shared library? + * Upgrading gcc + * Creating static libraries + * Creating GLib shared libraries + * Creating applications that use GLib shared libraries + * Using applications that use GLib shared libraries + * Conclusions + + Comments are welcome; see the Conclusions section. + What is a GLib shared library? -Shared libraries enable many applications to share common code, without -having to have a copy of the code in each application's code resource. For -example, there can be one copy of encryption routines, or a version of the -standard C library, and many applications can be using it. - -Shared libraries can also help you get around the 32K code size limit; you -can break up your code into a main portion (of at most 32K), and a number -of libraries (each of at most 32K). - -GLib (pronounced ``gee-lib'') shared libraries are a way to implement -shared libraries on the Pilot that differs from the ``standard'' (SysLib) -mechanism for the Palm Pilot. - -Some features of GLib: - - GLib libraries work on the old Pilots as well as the Palm Pilots. - It is extremely easy to convert a static library into a GLib shared - library, as well as to link an application to the GLib library. - GLib libraries can have static and global data (though they cannot, at - this time, export global data to the calling application). - The common case is fast: no systraps are done to call a GLib shared - library function after the library has been loaded, when globals are - available. - The uncommon case is correct: GLib shared libraries work even - when the application globals have not been loaded. - -GLib libraries are implemented as resource databases, with a database type -of GLib, and a library-specific creator ID. The GLib library will usually -contain three resources: GLib 0 (the code), data 0 (the library globals), and -rloc 0 (the data relocation table). By contrast, an application if a resource -database with (usually) five resources: code 0, code 1, data 0, rloc 0, and -pref 0. The GLib 0 resource in a shared library corresponds exactly to the -code 1 resource in an application. - + Shared libraries enable many applications to share common code, + without having to have a copy of the code in each application's code + resource. For example, there can be one copy of encryption routines, + or a version of the standard C library, and many applications can be + using it. + + Shared libraries can also help you get around the 32K code size limit; + you can break up your code into a main portion (of at most 32K), and a + number of libraries (each of at most 32K). + + GLib (pronounced ``gee-lib'') shared libraries are a way to implement + shared libraries on the Pilot that differs from the ``standard'' + (SysLib) mechanism for the Palm Pilot. + + Some features of GLib: + * GLib libraries work on the old Pilots as well as the Palm Pilots. + * It is extremely easy to convert a static library into a GLib + shared library, as well as to link an application to the GLib + library. + * GLib libraries can have static and global data (though they + cannot, at this time, export global data to the calling + application). + * The common case is fast: no systraps are done to call a GLib + shared library function after the library has been loaded, when + globals are available. + * The uncommon case is correct: GLib shared libraries work even when + the application globals have not been loaded. + + GLib libraries are implemented as resource databases, with a database + type of GLib, and a library-specific creator ID. The GLib library will + usually contain three resources: GLib 0 (the code), data 0 (the + library globals), and rloc 0 (the data relocation table). By contrast, + an application if a resource database with (usually) five resources: + code 0, code 1, data 0, rloc 0, and pref 0. The GLib 0 resource in a + shared library corresponds exactly to the code 1 resource in an + application. + Upgrading gcc -Before going any further, you need to make sure that you have a recent -version of gcc. m68k-palmos-coff-gcc -v should report its version number -to be (at time of writing) 2.7.2.2-krab-051897. - -If you have version 2.7.2.2-krab-030597, you can upgrade to -2.7.2.2-krab-051897 by replacing the following five files and recompiling: - - c-common.c (get new version) - config/m68k/m68k.c (get new version) - config/m68k/m68kpalmos.h (get new version) - config/m68k/palmos_crt0.c (get new version) (this is not the - version that comes with 2.7.2.2-krab-051897; it is the same as the - version in the instructions below) - version.c (get new version) - -After you have gcc version 2.7.2.2-krab-051897 successfully installed, -you will need to upgrade some of its support files. (Note to Kresten: it would -be good if these changes were merged into the next release.) This upgrade -adds some new features (such as support for GLib shared libraries) as well -as fixing some bugs. You may want to do this even if you don't plan to use -shared libraries. - -Find the directory that contains the specs file for the compiler (you can find -this by running m68k-palmos-coff-gcc -v). This directory should contain -crt0.o, pilot.ld, specs, and some other files. - -Replace the following two files in that directory: - - specs (get new version) - pilot.ld (get new version) - -You will also need to create a new version of crt0.o, and you will need to -install the new files scrt0.o, libGLib.a, and libgGLib.a. For your -convenience, I have precompiled versions available of all four of these files: -crt0.o, scrt0.o, libGLib.a, libgGLib.a. These should all go in the same -directory as specs. - -If you want to create these files yourself, follow these instructions: - -Download the following files into an empty directory: - GLib.h, GLib.c, palmos_crt0.c, palmos_crt0_shared.c -Create crt0.o: - m68k-palmos-coff-gcc -O5 -c palmos_crt0.c -o crt0.o -Create scrt0.o: - m68k-palmos-coff-gcc -O5 -c palmos_crt0_shared.c -o - scrt0.o -Create libGLib.a: - m68k-palmos-coff-gcc -O5 -c GLib.c -o GLib.o - m68k-palmos-coff-ar rcs libGLib.a GLib.o -Create libgGLib.a: - m68k-palmos-coff-gcc -O5 -g -c GLib.c -o gGLib.o - m68k-palmos-coff-ar rcs libgGLib.a gGLib.o -Install crt0.o, scrt0.o, libGLib.a, and libgGLib.a in the same directory -as specs. - -Your copy of gcc should now be ready to create GLib shared libraries and -apps that link to them. - + Before going any further, you need to make sure that you have a recent + version of gcc. m68k-palmos-coff-gcc -v should report its version + number to be (at time of writing) 2.7.2.2-kgpd-071097. This is the + version also known as 0.5.0. If you are using an earlier version, you + should certainly upgrade; this version fixes quite a few problems, + including handling of certain kinds of global variables. + +Creating static libraries + + The first step in creating a GLib shared library is to create a + ``static'' library (also called an ar archive). This is quite simple. + First, compile (but don't link) each of your .c files, with command + lines like the following: + +m68k-palmos-coff-gcc -g -O2 -c file.c -o file.o + + Actually, the ``-o file.o'' is optional. Also, the ``-O2'' can be left + out if you want to compile without optimization (the program is + usually smaller and faster with -O2, but sometimes it's harder to + debug). + + Once you have all of the .o files that will be part of your library, + group them together into a static library. For example, if your .o + files are file1.o, file2.o, and file3.o, and you want to call your + library ``foo'', you would use the command: + +m68k-palmos-coff-ar rcs libfoo.a file1.o file2.o file3.o + + The prefix ``lib'' and the suffix ``.a'' are mandatory in the name of + the library. + + If you want to create a program that uses this static library, just + write your program normally, including calls to functions that you + defined in your library. When you link this program, just put -lfoo at + the end of the command. For example: + +m68k-palmos-coff-gcc mainprog.o -o mainprog -lfoo + + If you use a static library in this way, each program that uses the + library will have its own copy of the library embedded into it. If you + want to share the code for the library between all the programs that + use it, you need to turn your static library into a shared library. + Creating GLib shared libraries -Turning a static library into a GLib shared library is quite simple. First, make -sure your static library was compiled with the upgraded version of gcc -(above). Let's call this static library libfoo.a. We are going to create -FooLib.prc (the GLib shared library), as well as libfoo_s.a, a ``stub'' -library that will be linked to the application. - -You need to generate a list of the functions exported by your library. One -way to do this is the following: - -m68k-palmos-coff-nm libfoo.a | grep ' T ' | cut -c12- | sort -u - -Save the output of the above command in the file foo.exp. This will contain -the list of exported functions, one per line. Note: the order of the functions -listed in foo.exp is important if you create a new version of the GLib library. -Existing functions should not change their positions in the list, and new -functions should be added to the end. - -Get the stubgen perl script (download), and run the following: - -stubgen "Foo Library" FooL foostub.c FooLib.S < foo.exp - -Here, "Foo Library" is the (human-readable) name for your library. FooL -is the four-character creator ID (you pick this yourself, but it's supposed to -be globally unique). foostub.c and FooLib.S are files that will be generated -by stubgen. - -Now create FooLib.prc as follows: - -m68k-palmos-coff-gcc -shared -o FooLib FooLib.S -lfoo - This creates FooLib by linking FooLib.S to libfoo.a using the - -shared flag. You may need to specify -Ldir before -lfoo if - libfoo.a is not in your library path. -m68k-palmos-coff-obj-res -rloc FooLib - This extracts the code 0, code 1, data 0, rloc 0, and pref 0 resources - from FooLib. The -rloc flag will probably become unnecessary in - future versions of obj-res. -rm code0000.FooLib.grc pref0000.FooLib.grc -mv code0001.FooLib.grc GLib0000.FooLib.grc - GLib libraries don't need the code 0 and pref 0 resources, and the - code 1 resource is renamed to GLib 0. -build-prc FooLib.prc "Foo Library" FooL GLib0000.FooLib.grc -data0000.FooLib.grc rloc0000.FooLib.grc - This command creates the FooLib.prc file by combining the GLib 0, - data 0, and rloc 0 resources. The library name ("Foo Library") and - the creator ID (FooL) need to be the same as were specified to the - stubgen command. -appl2GLib FooLib.prc - The current version of build-prc has no way to specify that the - resulting prc file is anything other than an application (type appl), so - we need to run this to change the type from appl to GLib. Download - appl2GLib.c and compile it yourself. (Remember to use your - machine's native compiler, not the PalmOS cross-compiler.) - -Finally, create the stub library libfoo_s.a from foostub.c: - -m68k-palmos-coff-gcc -O5 -c foostub.c -m68k-palmos-coff-ar rcs libfoo_s.a foostub.o - -That's it. FooLib.prc is the library users must install in order to use -programs that are linked to libfoo_s.a. Distribute FooLib.prc to end users -and distribute libfoo_s.a and the header files for libfoo.a to developers -of applications that could use the library. - + Turning a static library into a GLib shared library is quite simple. + First, make sure your static library was compiled with the upgraded + version of gcc (above). Let's call this static library libfoo.a. We + are going to create FooLib.prc (the GLib shared library), as well as + libfoo.sa, a ``stub'' library (much smaller than the static library) + that will be linked to each application that uses the GLib shared + library. + + You need to generate a list of the functions exported by your library; + save this list in a file called foo.exp. One way to do this is the + following: + +m68k-palmos-coff-exportlist libfoo.a > foo.exp + + This is equivalent (on most systems) to the following command: +m68k-palmos-coff-nm libfoo.a | grep ' T ' | cut -c12- | sort -u > foo.exp + + This will make foo.exp contain the list of functions exported by your + library, one per line. Note: the order of the functions listed in + foo.exp is important if you create a new version of the GLib library. + Existing functions should not change their positions in the list, and + new functions should be added to the end. + + Next, you need to create two ``stub'' files. The command to do this + for you is: + +m68k-palmos-coff-stubgen "Foo Library" FooL foostub.c FooLib.S < foo.exp + + Here, "Foo Library" is the (human-readable) name for your library. + FooL is the four-character creator ID (you pick this yourself, but + it's supposed to be globally unique). foostub.c and FooLib.S are files + that will be generated by stubgen. + + Now create FooLib.prc as follows: + + m68k-palmos-coff-gcc -shared -o FooLib FooLib.S libfoo.a + This creates FooLib by linking the stub FooLib.S to the static + libfoo.a library. The -shared flag tells gcc to produce a + shared library instead of a regular program. You may need to + specify the full path to libfoo.a if it is not in the current + directory. + + m68k-palmos-coff-obj-res -l FooLib + This extracts the GLib 0, data 0, and rloc 0 resources from + FooLib. These resources contain the shared code, the global + data, and the relocation information for the library, + respectively. + + build-prc -l FooLib.prc "Foo Library" FooL GLib0000.FooLib.grc + data0000.FooLib.grc rloc0000.FooLib.grc + This command creates the FooLib.prc file by combining the GLib + 0, data 0, and rloc 0 resources. The library name ("Foo + Library") and the creator ID (FooL) need to be the same as were + specified to the m68k-palmos-coff-stubgen command. The -l + option tells build-prc to build a GLib library instead of a + normal program. + + Finally, create the stub library libfoo.sa from foostub.c: +m68k-palmos-coff-gcc -c foostub.c +m68k-palmos-coff-ar rcs libfoo.sa foostub.o + + That's it. FooLib.prc is the library users must install in order to + use programs that are linked to libfoo.sa. Distribute FooLib.prc to + end users and distribute libfoo.sa and the header files for libfoo.a + to developers of applications that could use the library. + Creating applications that use GLib shared libraries -Now that you have a GLib shared library and a stub library, how do you -change your application (that was previously linked to libfoo.a) to use the -shared library instead of the static one? - -It's surprisingly simple; the application need not change at all. Just change -the link line in your Makefile, so that instead of linking with -lfoo, you now -link with -lfoo_s. - -Note the current restriction on GLib libraries: library globals are not -exported to the application. If your application needs to read or write -variables in the library's global space, you should consider modifying the -library to have access functions for them. - + Now that you have a GLib shared library and a stub library, how do you + change your application (that was previously linked to libfoo.a) to + use the shared library instead of the static one? + + It's surprisingly simple; the application need not change at all. Just + make sure that libfoo.sa is visible to gcc when you link your program + with -lfoo. If gcc finds libfoo.sa instead of (or in addition to) + libfoo.a, it will cause the program to use the GLib shared library + instead of the static one. (Note: if you have both libfoo.sa and + libfoo.a, gcc will prefer the shared version. If you want to force it + to use the static library, you can use the -static flag to gcc.) + + Note the current restriction on GLib libraries: library global + variables are not exported to the application. If your application + needs to read or write variables in the library's global space, you + should consider modifying the library to have access functions for + them. + + Another restriction: be careful if you pass function pointers around + (say, for callbacks). If a function is called via a function pointer, + it will have the globals of the caller, which would not be its own in + the case that the called function was in a shared lib, for example. In + general, the rule is: don't pass a function pointer to a GLib shared + library function from a GLib shared library to the main program, and + have the main program call it. + Using applications that use GLib shared libraries -To use an application that requires a GLib shared library, just make sure -both the application and the library are installed on your Pilot before running -the application. GLib shared libraries are just prc files; they are installed in -exactly the same way as applications (HotSync or pilot-xfer, for -example). - -If a GLib shared library is not installed, an application that uses it will still run -properly, until it tries to call a function provided by the library (at which point -you will get a Fatal Error informing you which library you're missing). - + To use an application that requires a GLib shared library, just make + sure both the application and the library are installed on your Pilot + before running the application. GLib shared libraries are just prc + files; they are installed in exactly the same way as applications + (HotSync or pilot-xfer, for example). + + If a GLib shared library is not installed, an application that uses it + will still run properly, until it tries to call a function provided by + the library (at which point you will get a Fatal Error informing you + which library you're missing). + Conclusions -Success and failure reports, comments, and questions are welcome. -Depending on the content, appropriate fora are the pilot.programmer and -pilot.programmer.gcc newsgroups hosted on news.massena.com, and -the pilot-unix mailing list at . If necessary, -I can be reached directly at the address below (be warned that my email -queue sometimes gets quite backlogged). - -Back to the ISAAC Group's Pilot page - - -IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY -PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS -SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, -EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. - -THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON -AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO -OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, -ENHANCEMENTS, OR MODIFICATIONS. + Success and failure reports, comments, and questions are welcome. + Depending on the content, appropriate fora are the pilot.programmer + and pilot.programmer.gcc newsgroups hosted on news.massena.com, and + the pilot-unix mailing list at . If + necessary, I can be reached directly at the address below (be warned + that my email queue sometimes gets quite backlogged). + + [1]Back to the ISAAC Group's Pilot page + _________________________________________________________________ + + IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY + FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY + DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND + NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND + THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE + MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + + + Ian Goldberg, [2]iang@cs.berkeley.edu + +References -Ian Goldberg, iang@cs.berkeley.edu + 1. http://www.isaac.cs.berkeley.edu/pilot/ + 2. mailto:iang@cs.berkeley.edu diff -urN prc-tools-0.5.0-orig/gdbpanel/Makefile prc-tools-0.5.0/gdbpanel/Makefile --- prc-tools-0.5.0-orig/gdbpanel/Makefile Mon Jun 16 23:05:46 1997 +++ prc-tools-0.5.0/gdbpanel/Makefile Mon Oct 5 13:48:00 1998 @@ -47,5 +47,9 @@ ln -sf ../$(LIBGLIBDIR)/gcrt0.o gcrt0.o $(CC) $(CFLAGS) $(OBJS) $(LIBS) -o $@ +install: $(PRC) + -mkdir -p $(PREFIX)/lib + install -m 644 $(PRC) $(PREFIX)/lib/$(PRC) + clean: rm -rf *.[oa] gdbpanel *.bin *.stamp *.[pg]rc diff -urN prc-tools-0.5.0-orig/libc.0.1.2/Makefile prc-tools-0.5.0/libc.0.1.2/Makefile --- prc-tools-0.5.0-orig/libc.0.1.2/Makefile Thu Jul 10 10:31:36 1997 +++ prc-tools-0.5.0/libc.0.1.2/Makefile Mon Oct 5 13:48:00 1998 @@ -37,6 +37,9 @@ cp -f libg.sa $(PREFIX)/m68k-palmos-coff/lib/libg.sa chmod 644 $(PREFIX)/m68k-palmos-coff/lib/libg.sa cp -r include/* $(PREFIX)/m68k-palmos-coff/include + -mkdir -p $(PREFIX)/lib + cp -f Libc.prc $(PREFIX)/lib/Libc.prc + chmod 644 $(PREFIX)/lib/Libc.prc .c.s: $(CC) $(CFLAGS) -S $< diff -urN prc-tools-0.5.0-orig/libglib.0.1.0/Makefile prc-tools-0.5.0/libglib.0.1.0/Makefile --- prc-tools-0.5.0-orig/libglib.0.1.0/Makefile Mon Jun 16 22:48:50 1997 +++ prc-tools-0.5.0/libglib.0.1.0/Makefile Mon Oct 5 13:48:00 1998 @@ -35,3 +35,5 @@ clean: rm -f *.[oa] + +gcrt0.o:: crt0.c diff -urN prc-tools-0.5.0-orig/libglib.0.1.0/crt0.c prc-tools-0.5.0/libglib.0.1.0/crt0.c --- prc-tools-0.5.0-orig/libglib.0.1.0/crt0.c Fri Jun 13 16:25:36 1997 +++ prc-tools-0.5.0/libglib.0.1.0/crt0.c Mon Oct 5 13:48:00 1998 @@ -3,16 +3,24 @@ * by Kresten Krab Thorup, and is in the public domain. * It is *not* under the GPL or the GLPL, you can freely link it * into your programs. + * + * Last modified 19971111 by Ian Goldberg */ #include #include #define NON_PORTABLE #include +#include -static void GccRelocateData (); +static void GccRelocateData(void); static void do_bhook(Word,Ptr,Word); static void do_ehook(Word,Ptr,Word); +static void do_ctors(void); +static void do_dtors(void); +#ifdef DASHG +int GdbStartDebug(void); +#endif register ULong reg_a4 asm("%a4"); @@ -22,6 +30,7 @@ Ptr prevGlobals; Ptr globalsPtr; ULong save_a4, result; + int did_ctors = 0; save_a4 = reg_a4; @@ -37,17 +46,27 @@ Ptr mainPBP = appInfo->cmdPBP; Word mainFlags = appInfo->launchFlags; - if (mainFlags & sysAppLaunchFlagNewGlobals) + if (mainFlags & (sysAppLaunchFlagNewGlobals|sysAppLaunchFlagSubCall)) { asm volatile ("move.l %a5,%a4; sub.l #edata,%a4"); - GccRelocateData (); } else { reg_a4 = 0; } + if (mainFlags & sysAppLaunchFlagNewGlobals) { + GccRelocateData (); + do_ctors(); + did_ctors = 1; + } do_bhook(mainCmd, mainPBP, mainFlags); +#ifdef DASHG + GdbStartDebug(); +#endif result = PilotMain (mainCmd, mainPBP, mainFlags); do_ehook(mainCmd, mainPBP, mainFlags); + if (did_ctors) { + do_dtors(); + } SysAppExit (appInfo, prevGlobals, globalsPtr); reg_a4 = save_a4; @@ -138,8 +157,8 @@ unsigned long text = (unsigned long)&start; asm ("sub.l #start, %0" : "=g" (text) : "0" (text)); - asm ("lea bhook_start(%%pc),%0" : "=a" (hookptr) :); - asm ("lea bhook_end(%%pc),%0" : "=a" (hookend) :); + asm ("lea bhook_start,%0; add.l %1,%0" : "=a" (hookptr) : "g" (text)); + asm ("lea bhook_end,%0; add.l %1,%0" : "=a" (hookend) : "g" (text)); while (hookptr < hookend) { void (*fptr)(Word,Ptr,Word) = (*(hookptr++)) + text; @@ -153,11 +172,67 @@ unsigned long text = (unsigned long)&start; asm ("sub.l #start, %0" : "=g" (text) : "0" (text)); - asm ("lea ehook_start(%%pc),%0" : "=a" (hookstart) :); - asm ("lea ehook_end(%%pc),%0" : "=a" (hookptr) :); + asm ("lea ehook_start,%0; add.l %1,%0" : "=a" (hookstart) : "g" (text)); + asm ("lea ehook_end,%0; add.l %1,%0" : "=a" (hookptr) : "g" (text)); while (hookptr > hookstart) { void (*fptr)(Word,Ptr,Word) = (*(--hookptr)) + text; fptr(cmd,PBP,flags); } } + +static void do_ctors(void) +{ + void **hookend, **hookptr; + unsigned long text = (unsigned long)&start; + asm ("sub.l #start, %0" : "=g" (text) : "0" (text)); + + asm ("lea ctors_start,%0; add.l %1,%0" : "=a" (hookptr) : "g" (text)); + asm ("lea ctors_end,%0; add.l %1,%0" : "=a" (hookend) : "g" (text)); + + while (hookptr < hookend) { + void (*fptr)(void) = (*(hookptr++)) + text; + fptr(); + } +} + +static void do_dtors(void) +{ + void **hookstart, **hookptr; + unsigned long text = (unsigned long)&start; + asm ("sub.l #start, %0" : "=g" (text) : "0" (text)); + + asm ("lea dtors_start,%0; add.l %1,%0" : "=a" (hookstart) : "g" (text)); + asm ("lea dtors_end,%0; add.l %1,%0" : "=a" (hookptr) : "g" (text)); + + while (hookptr > hookstart) { + void (*fptr)(void) = (*(--hookptr)) + text; + fptr(); + } +} + +#ifdef DASHG +int GdbStartDebug(void) +{ + DWord feature = 0; + + if (!reg_a4) return 0; + + FtrGet('gdbS', 0, &feature); + if (feature != 0x12BEEF34) return 0; + + asm(" + lea data_start(%%a4),%%a1 + move.l %%a1,%%d2 + lea bss_start(%%a4),%%a1 + move.l %%a1,%%d1 + lea start(%%pc),%%a0 + move.l %%a0,%%d0 + sub.l #start, %%d0 + lea PilotMain(%%pc),%%a0 + move.l #0x12BEEF34, %%d3 + trap #8 + " : : : "d0", "d1", "d2", "d3", "a1", "a0"); + return 1; +} +#endif diff -urN prc-tools-0.5.0-orig/libglib.0.1.0/gcrt0.c prc-tools-0.5.0/libglib.0.1.0/gcrt0.c --- prc-tools-0.5.0-orig/libglib.0.1.0/gcrt0.c Fri Jun 27 09:59:32 1997 +++ prc-tools-0.5.0/libglib.0.1.0/gcrt0.c Mon Oct 5 13:48:00 1998 @@ -1,209 +1,2 @@ -/* - * Pilot startup code for use with gcc. This code was written - * by Kresten Krab Thorup, and is in the public domain. - * It is *not* under the GPL or the GLPL, you can freely link it - * into your programs. - */ - -#pragma pack(2) - -#define NON_PORTABLE - -#include -#include -#include -#include -#include -#include -#include - -static void GccRelocateData (); -static void do_bhook(Word,Ptr,Word); -static void do_ehook(Word,Ptr,Word); -static int StartDebug(void); - -register ULong reg_a4 asm("%a4"); - -ULong -start () -{ - SysAppInfoPtr appInfo; - Ptr prevGlobals; - Ptr globalsPtr; - ULong save_a4, result; - - save_a4 = reg_a4; - - if (SysAppStartup (&appInfo, &prevGlobals, &globalsPtr) != 0) - { - SndPlaySystemSound (sndError); - reg_a4 = save_a4; - return -1; - } - else - { - Word mainCmd = appInfo->cmd; - Ptr mainPBP = appInfo->cmdPBP; - Word mainFlags = appInfo->launchFlags; - - if (mainFlags & sysAppLaunchFlagNewGlobals) - { - asm volatile ("move.l %a5,%a4; sub.l #edata,%a4"); - GccRelocateData (); - } else { - reg_a4 = 0; - } - - do_bhook(mainCmd, mainPBP, mainFlags); - StartDebug(); - result = PilotMain (mainCmd, mainPBP, mainFlags); - do_ehook(mainCmd, mainPBP, mainFlags); - SysAppExit (appInfo, prevGlobals, globalsPtr); - - reg_a4 = save_a4; - return result; - } -} - -struct pilot_reloc { - UChar type; - UChar section; - UInt offset; - ULong value ; -}; - -#define TEXT_SECTION 't' -#define DATA_SECTION 'd' -#define BSS_SECTION 'b' - -#define RELOC_ABS_32 0xbe - -/* - * This function should be called from - */ -static void -GccRelocateData () -{ - extern long data_start, bss_start; - unsigned long data = (unsigned long)&data_start; - unsigned long bss = (unsigned long)&bss_start; - unsigned long text = (unsigned long)&start; - - VoidHand relocH; - char *relocPtr; - struct pilot_reloc *relocs; - UInt count, i; - - static int done = 0; - - if (done) return; - else done = 1; - - asm ("sub.l #start, %0" : "=g" (text) : "0" (text)); - asm ("sub.l #bss_start, %0" : "=g" (bss) : "0" (bss)); - asm ("sub.l #data_start, %0" : "=g" (data) : "0" (data)); - - relocH = DmGet1Resource ('rloc', 0); - if (relocH == 0) - return; - - relocPtr = MemHandleLock (relocH); - count = *(UInt*)relocPtr; - relocs = (struct pilot_reloc*) (relocPtr + 2); - - for (i = 0; i < count; i++) - { - unsigned long *loc; - ErrFatalDisplayIf (relocs[i].type != RELOC_ABS_32, \ - "unknown reloc.type"); - - loc = (unsigned long*) ((char*)&data_start + relocs[i].offset); - - switch (relocs[i].section) - { - case TEXT_SECTION: - *loc += text; - break; - - case DATA_SECTION: - *loc += data; - break; - - case BSS_SECTION: - *loc += bss; - break; - - default: - ErrDisplay ("Unknown reloc.section"); - } - } - - MemHandleUnlock (relocH); - DmReleaseResource (relocH); - -} - -static void -do_bhook(Word cmd, Ptr PBP, Word flags) -{ - void **hookend, **hookptr; - unsigned long text = (unsigned long)&start; - asm ("sub.l #start, %0" : "=g" (text) : "0" (text)); - - asm ("lea bhook_start(%%pc),%0" : "=a" (hookptr) :); - asm ("lea bhook_end(%%pc),%0" : "=a" (hookend) :); - - while (hookptr < hookend) { - void (*fptr)(Word,Ptr,Word) = (*(hookptr++)) + text; - fptr(cmd,PBP,flags); - } -} - -static void -do_ehook(Word cmd, Ptr PBP, Word flags) -{ - void **hookstart, **hookptr; - unsigned long text = (unsigned long)&start; - asm ("sub.l #start, %0" : "=g" (text) : "0" (text)); - - asm ("lea ehook_start(%%pc),%0" : "=a" (hookstart) :); - asm ("lea ehook_end(%%pc),%0" : "=a" (hookptr) :); - - while (hookptr > hookstart) { - void (*fptr)(Word,Ptr,Word) = (*(--hookptr)) + text; - fptr(cmd,PBP,flags); - } -} - -static int -StartDebug(void) -{ - DWord feature = 0; - - if (!reg_a4) return 0; - - FtrGet('gdbS', 0, &feature); - if (feature != 0x12BEEF34) return 0; - -#if 0 - /* get the ROM version. PalmOS2 needs a flag set */ - FtrGet(sysFtrCreator, sysFtrNumROMVersion, &feature); - if (feature >= 0x02000000) { - (*(char*)257) = 1; /* Turn on debugging */ - } -#endif - - asm(" - lea data_start(%%a4),%%a1 - move.l %%a1,%%d2 - lea bss_start(%%a4),%%a1 - move.l %%a1,%%d1 - lea start(%%pc),%%a0 - move.l %%a0,%%d0 - sub.l #start, %%d0 - lea PilotMain(%%pc),%%a0 - move.l #0x12BEEF34, %%d3 - trap #8 - " : : : "d0", "d1", "d2", "d3", "a1", "a0"); - return 1; -} +#define DASHG +#include "crt0.c" diff -urN prc-tools-0.5.0-orig/libglib.0.1.0/scrt0.c prc-tools-0.5.0/libglib.0.1.0/scrt0.c --- prc-tools-0.5.0-orig/libglib.0.1.0/scrt0.c Fri Jun 27 18:07:45 1997 +++ prc-tools-0.5.0/libglib.0.1.0/scrt0.c Mon Oct 5 13:48:00 1998 @@ -11,12 +11,14 @@ } SaveEntry; void jmptable(); -static void GccRelocateData (); +static void GccRelocateData(void); static void AllocSaveTable(void); static void clean(UInt,struct LibRef *); void crt0_trampoline(void); static void do_bhook(Word,Ptr,Word); static void do_ehook(Word,Ptr,Word); +static void do_ctors(void); +static void do_dtors(void); register void *reg_a4 asm("%a4"); @@ -138,6 +140,7 @@ DmReleaseResource(dataH); reg_a4 = libref->globals; GccRelocateData(); + do_ctors(); AllocSaveTable(); do_bhook(0, NULL, 0); reg_a4 = save_a4; @@ -233,6 +236,7 @@ MemHandleUnlock(savetableHand); MemHandleFree(savetableHand); do_ehook(0, NULL, 0); + do_dtors(); reg_a4 = save_a4; #ifdef USE_DYNAMIC_MEM_ONLY MemPtrFree(libref->globals); @@ -350,31 +354,61 @@ } static void do_bhook(Word cmd, Ptr PBP, Word flags) -{ +{ void **hookend, **hookptr; unsigned long text = (unsigned long)&start; asm ("sub.l #start, %0" : "=g" (text) : "0" (text)); - asm ("lea bhook_start(%%pc),%0" : "=a" (hookptr) :); - asm ("lea bhook_end(%%pc),%0" : "=a" (hookend) :); + asm ("lea bhook_start,%0; add.l %1,%0" : "=a" (hookptr) : "g" (text)); + asm ("lea bhook_end,%0; add.l %1,%0" : "=a" (hookend) : "g" (text)); while (hookptr < hookend) { - void (*fptr)(Word,Ptr,Word) = (*(hookptr++)) + text; - fptr(cmd,PBP,flags); + void (*fptr)(Word,Ptr,Word) = (*(hookptr++)) + text; + fptr(cmd,PBP,flags); } } static void do_ehook(Word cmd, Ptr PBP, Word flags) -{ +{ + void **hookstart, **hookptr; + unsigned long text = (unsigned long)&start; + asm ("sub.l #start, %0" : "=g" (text) : "0" (text)); + + asm ("lea ehook_start,%0; add.l %1,%0" : "=a" (hookstart) : "g" (text)); + asm ("lea ehook_end,%0; add.l %1,%0" : "=a" (hookptr) : "g" (text)); + + while (hookptr > hookstart) { + void (*fptr)(Word,Ptr,Word) = (*(--hookptr)) + text; + fptr(cmd,PBP,flags); + } +} + +static void do_ctors(void) +{ + void **hookend, **hookptr; + unsigned long text = (unsigned long)&start; + asm ("sub.l #start, %0" : "=g" (text) : "0" (text)); + + asm ("lea ctors_start,%0; add.l %1,%0" : "=a" (hookptr) : "g" (text)); + asm ("lea ctors_end,%0; add.l %1,%0" : "=a" (hookend) : "g" (text)); + + while (hookptr < hookend) { + void (*fptr)(void) = (*(hookptr++)) + text; + fptr(); + } +} + +static void do_dtors(void) +{ void **hookstart, **hookptr; unsigned long text = (unsigned long)&start; asm ("sub.l #start, %0" : "=g" (text) : "0" (text)); - asm ("lea ehook_start(%%pc),%0" : "=a" (hookstart) :); - asm ("lea ehook_end(%%pc),%0" : "=a" (hookptr) :); + asm ("lea dtors_start,%0; add.l %1,%0" : "=a" (hookstart) : "g" (text)); + asm ("lea dtors_end,%0; add.l %1,%0" : "=a" (hookptr) : "g" (text)); while (hookptr > hookstart) { - void (*fptr)(Word,Ptr,Word) = (*(--hookptr)) + text; - fptr(cmd,PBP,flags); + void (*fptr)(void) = (*(--hookptr)) + text; + fptr(); } }