[AD] Fix and document limitations of dat2s

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


As discovered by Andy Goth, dat2s doesn't properly work on platforms other 
than DOS and Windows because it emits a .ctor section.  Now .ctor is a pure 
DOSism, which is ignored by the GNU linker on all ELF-based platforms.

Fixed by making it emit a .ctors section, except on DOS because I verified 
that the DJGPP linker still doesn't grok .ctors (contrary to the MinGW 
linker) as of binutils 2.13.

However, this change means that the compiled datafiles are now always 
constructed, including within shared objects on Linux.  As Andy experienced, 
this may not work so I didn't make the change in the 4.0.x series.

I also documented the limitations of dat2s on both branches respectively.

Applied to mainline and 4.0 branch.

-- 
Eric Botcazou
Index: tools/dat2s.c
===================================================================
RCS file: /cvsroot/alleg/allegro/tools/dat2s.c,v
retrieving revision 1.20
diff -u -p -r1.20 dat2s.c
--- tools/dat2s.c	1 Nov 2003 14:04:00 -0000	1.20
+++ tools/dat2s.c	14 Feb 2004 10:59:02 -0000
@@ -605,7 +605,7 @@ int main(int argc, char *argv[])
 
       fprintf(outfile, ".text\n");
       fprintf(outfile, ".balign 4\n");
-      fprintf(outfile, ALLEGRO_ASM_PREFIX "_construct_me:\n");
+      fprintf(outfile, "construct_me:\n");
       fprintf(outfile, "\tpushl %%ebp\n");
       fprintf(outfile, "\tmovl %%esp, %%ebp\n");
       fprintf(outfile, "\tpushl $" ALLEGRO_ASM_PREFIX "%s%s\n", prefix, dataname);
@@ -613,8 +613,12 @@ int main(int argc, char *argv[])
       fprintf(outfile, "\taddl $4, %%esp\n");
       fprintf(outfile, "\tleave\n");
       fprintf(outfile, "\tret\n\n");
+      #ifdef ALLEGRO_DJGPP      
       fprintf(outfile, ".section .ctor\n");
-      fprintf(outfile, "\t.long " ALLEGRO_ASM_PREFIX "_construct_me\n");
+      #else
+      fprintf(outfile, ".section .ctors\n");
+      #endif
+      fprintf(outfile, "\t.long construct_me\n");
 
    #endif
 
Index: setup/setup.c
===================================================================
RCS file: /cvsroot/alleg/allegro/setup/setup.c,v
retrieving revision 1.36
diff -u -p -r1.36 setup.c
--- setup/setup.c	22 Oct 2003 13:49:21 -0000	1.36
+++ setup/setup.c	14 Feb 2004 10:59:06 -0000
@@ -2854,7 +2854,9 @@ int main(void)
    set_palette(black_palette);
 
  #ifdef SETUP_USE_COMPILED_DATAFILES
+ #ifndef ALLEGRO_USE_CONSTRUCTOR
    fixup_datafile(setup_data);
+ #endif
  #else
    setup_data = load_datafile(uconvert_ascii("#", tmp1));
 
Index: tools/grabber.txt
===================================================================
RCS file: /cvsroot/alleg/allegro/tools/grabber.txt,v
retrieving revision 1.20
diff -u -p -r1.20 grabber.txt
--- tools/grabber.txt	7 Feb 2004 08:29:37 -0000	1.20
+++ tools/grabber.txt	14 Feb 2004 11:00:01 -0000
@@ -773,6 +773,9 @@ Note that compiled sprites are not suppo
 abort whenever it encounters one of them. However you can use the '-S'
 option to instruct dat2s to convert them to regular BITMAP objects.
 
+Note that datafiles compiled by dat2s must not be appended to shared objects,
+only to standalone executables. Use dat2c for this purpose.
+
 
 
 ======================================================
Index: tools/grabber.txt
===================================================================
RCS file: /cvsroot/alleg/allegro/tools/grabber.txt,v
retrieving revision 1.3.2.5
diff -u -p -r1.3.2.5 grabber.txt
--- tools/grabber.txt	7 Feb 2004 08:30:23 -0000	1.3.2.5
+++ tools/grabber.txt	14 Feb 2004 11:00:56 -0000
@@ -749,6 +749,10 @@ Note that compiled datafiles appended to
 don't work under Windows in this release (they will fail to link). This
 problem has been corrected in the 4.1.1 WIP and later releases.
 
+Note that you must always call fixup_datafile() on platforms other than DOS
+and Windows in this release. This problem has been corrected in the 4.1.13 WIP
+and later releases.
+
 
 
 ================================


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/