More libfile problems

Alex Waugh ajw498 at ecs.soton.ac.uk
Thu Mar 28 16:11:46 PST 2002


On Mon, 25 Feb 2002, Theo Markettos wrote:

> I'm building a C++ library which makes use of templates.  All the object
> files are compiled, and I want to build a library from them.  The problem
> is that when I call libfile, I get an unspecified error:
[snip]
> Termination signal received: RISC OS error

This error ocours because libfile can't open the output file.

> Using Acorn's libfile (using an old version or the latest 32 bit release)
> works fine.  If I call it libga (without an extension), it claims to
> complete successfully, but only gives a 112 byte output file with ALF
> header and nothing else.  Attempting to supply filenames in o.foo
> format doesn't help.

Files need to be specified in o.foo format, otherwise libfile can't find
them. However there is a bug in OS_GBPB.s that meant libfile would never
find any files, even if they existed.

The following patch fixes the bug in OS_GBPB.s, changes all of the SWI
wrappers to return an error pointer, or NULL, gives a more freindly error
message if it can't open the output file, and gives a warning if it can't
find an input file.

Cheers

Alex


Index: riscos-aof/libfile/Buffer.cc
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/libfile/Buffer.cc,v
retrieving revision 1.3.2.1
diff -u -r1.3.2.1 Buffer.cc
--- riscos-aof/libfile/Buffer.cc	2002/02/28 18:55:19	1.3.2.1
+++ riscos-aof/libfile/Buffer.cc	2002/03/28 23:59:30
@@ -10,8 +10,8 @@
 #include "BError.h"

 #ifndef CROSS_COMPILE
-extern "C" void OS_File(int *);
-extern "C" void OS_GBPB(int *);
+extern "C" void *OS_File(int *);
+extern "C" void *OS_GBPB(int *);
 #endif

 Buffer::Buffer()
@@ -238,7 +238,8 @@
  	reg[4] = (int) m_data;
  	reg[5] = reg[4] + m_length;

- 	OS_File(reg);
+ 	if (OS_File(reg) != NULL)
+	  THROW_SPEC_ERR(BError::CantOpenFile);
 #endif
  }
 }
Index: riscos-aof/libfile/Chunk.cc
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/libfile/Chunk.cc,v
retrieving revision 1.2.2.3
diff -u -r1.2.2.3 Chunk.cc
--- riscos-aof/libfile/Chunk.cc	2002/02/28 18:55:19	1.2.2.3
+++ riscos-aof/libfile/Chunk.cc	2002/03/28 23:59:30
@@ -7,7 +7,7 @@
 #include "BError.h"

 #ifndef CROSS_COMPILE
-extern "C" void OS_File(int *);
+extern "C" void *OS_File(int *);
 #endif

 Chunk::Chunk()
Index: riscos-aof/libfile/LibData.cc
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/libfile/LibData.cc,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 LibData.cc
--- riscos-aof/libfile/LibData.cc	2002/02/28 18:55:19	1.2.2.1
+++ riscos-aof/libfile/LibData.cc	2002/03/28 23:59:30
@@ -4,7 +4,7 @@
 #include "BError.h"

 #ifndef CROSS_COMPILE
-extern "C" void OS_File(int *);
+extern "C" void *OS_File(int *);
 #endif

 LibData::LibData(Library *a_owner) : Chunk("LIB_DATA", a_owner)
Index: riscos-aof/libfile/LibDir.cc
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/libfile/LibDir.cc,v
retrieving revision 1.3.2.1
diff -u -r1.3.2.1 LibDir.cc
--- riscos-aof/libfile/LibDir.cc	2002/02/28 18:55:19	1.3.2.1
+++ riscos-aof/libfile/LibDir.cc	2002/03/28 23:59:30
@@ -7,7 +7,7 @@
 #include "Path.h"

 #ifndef CROSS_COMPILE
-extern "C" void OS_File(int *);
+extern "C" void *OS_File(int *);
 #endif

 LibDir::LibDir(Library *a_owner) : Chunk("LIB_DIRY", a_owner)
Index: riscos-aof/libfile/LibFile_o.cc
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/libfile/LibFile_o.cc,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 LibFile_o.cc
--- riscos-aof/libfile/LibFile_o.cc	2002/02/28 18:55:19	1.2.2.1
+++ riscos-aof/libfile/LibFile_o.cc	2002/03/28 23:59:30
@@ -3,7 +3,7 @@
 #include <iostream>

 #ifndef CROSS_COMPILE
-extern "C" void OS_File(int *);
+extern "C" void *OS_File(int *);
 #endif

 void writeInt(FILE *a_out,int a_data);
Index: riscos-aof/libfile/LibTimeBas.cc
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/libfile/LibTimeBas.cc,v
retrieving revision 1.2
diff -u -r1.2 LibTimeBas.cc
--- riscos-aof/libfile/LibTimeBas.cc	2001/01/02 09:24:29	1.2
+++ riscos-aof/libfile/LibTimeBas.cc	2002/03/28 23:59:30
@@ -3,7 +3,7 @@
 #include "BError.h"

 #ifndef CROSS_COMPILE
-extern "C" void OS_File(int *);
+extern "C" void *OS_File(int *);
 #endif

 LibTimeBas::LibTimeBas(const BString &a_chunkName, Library *a_owner)
Index: riscos-aof/libfile/OS_CnvtDT.s
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/libfile/OS_CnvtDT.s,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 OS_CnvtDT.s
--- riscos-aof/libfile/OS_CnvtDT.s	2000/11/08 09:38:58	1.1.1.1
+++ riscos-aof/libfile/OS_CnvtDT.s	2002/03/28 23:59:30
@@ -7,18 +7,19 @@
 		IMPORT	|__errno|

 OS_ConvertDataAndTime
-		STMFD	sp!,{r0-r4,lr}
+		STMFD	sp!,{r4,lr}
 		STMFD	sp!,{r0}
 		LDR	r1,[r0,#4]
 		LDR	r2,[r0,#8]
 		LDR	r3,[r0,#12]
 		LDR	r0,[r0]
-		SWI	&C1
+		SWI	&200C1
 		LDMFD	sp!,{r4}
 		STR	r0,[r4]
 		STR	r1,[r4,#4]
 		STR	r2,[r4,#8]
 		STR	r3,[r4,#12]
-		LDMFD	sp!,{r0-r4,pc}^
+		MOVVC	r0, #0
+		LDMFD	sp!,{r4,pc}^

 		END
Index: riscos-aof/libfile/OS_File.s
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/libfile/OS_File.s,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 OS_File.s
--- riscos-aof/libfile/OS_File.s	2000/11/08 09:38:58	1.1.1.1
+++ riscos-aof/libfile/OS_File.s	2002/03/28 23:59:30
@@ -7,7 +7,7 @@
 		IMPORT	|__errno|

 OS_File
-		STMFD	sp!,{r0-r6,lr}
+		STMFD	sp!,{r4-r6,lr}
 		STMFD	sp!,{r0}
 		LDR	r1,[r0,#4]
 		LDR	r2,[r0,#8]
@@ -15,7 +15,7 @@
 		LDR	r4,[r0,#16]
 		LDR	r5,[r0,#20]
 		LDR	r0,[r0]
-		SWI	&08
+		SWI	&20008
 		LDMFD	sp!,{r6}
 		STR	r0,[r6]
 		STR	r1,[r6,#4]
@@ -23,6 +23,7 @@
 		STR	r3,[r6,#12]
 		STR	r4,[r6,#16]
 		STR	r5,[r6,#20]
-		LDMFD	sp!,{r0-r6,pc}^
+		MOVVC	r0, #0
+		LDMFD	sp!,{r4-r6,pc}^

 		END
Index: riscos-aof/libfile/OS_GBPB.s
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/libfile/OS_GBPB.s,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 OS_GBPB.s
--- riscos-aof/libfile/OS_GBPB.s	2000/11/08 09:38:58	1.1.1.1
+++ riscos-aof/libfile/OS_GBPB.s	2002/03/28 23:59:30
@@ -7,13 +7,14 @@
 		IMPORT	|__errno|

 OS_GBPB
-		STMFD	sp!,{r0-r6,lr}
+		STMFD	sp!,{r4-r6,lr}
 		STMFD	sp!,{r0}
 		LDR	r1,[r0,#4]
 		LDR	r2,[r0,#8]
 		LDR	r3,[r0,#12]
 		LDR	r4,[r0,#16]
 		LDR	r5,[r0,#20]
+		LDR	r6,[r0,#24]
 		LDR	r0,[r0]
 		SWI	&2000C
 		LDMFD	sp!,{r6}
@@ -24,6 +25,7 @@
 		MVNVS	r4,#0
 		STR	r4,[r6,#16]
 		STR	r5,[r6,#20]
-		LDMFD	sp!,{r0-r6,pc}^
+		MOVVC	r0, #0
+		LDMFD	sp!,{r4-r6,pc}^

 		END
Index: riscos-aof/libfile/OS_Word.s
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/libfile/OS_Word.s,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 OS_Word.s
--- riscos-aof/libfile/OS_Word.s	2000/11/08 09:38:58	1.1.1.1
+++ riscos-aof/libfile/OS_Word.s	2002/03/28 23:59:30
@@ -7,8 +7,9 @@
 		IMPORT	|__errno|

 OS_Word
-		STMFD	sp!,{r0-r1,lr}
-		SWI	&07
-		LDMFD	sp!,{r0-r1,pc}^
+		STMFD	sp!,{lr}
+		SWI	&20007
+		MOVVC	r0, #0
+		LDMFD	sp!,{pc}^

 		END
Index: riscos-aof/libfile/Path.cc
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/libfile/Path.cc,v
retrieving revision 1.2.2.2
diff -u -r1.2.2.2 Path.cc
--- riscos-aof/libfile/Path.cc	2002/02/28 18:55:19	1.2.2.2
+++ riscos-aof/libfile/Path.cc	2002/03/28 23:59:30
@@ -4,7 +4,7 @@
 #include "Path.h"

 #ifndef CROSS_COMPILE
-extern "C" void OS_GBPB(int *);
+extern "C" void *OS_GBPB(int *);
 #endif

 #ifdef CROSS_COMPILE
@@ -109,6 +109,8 @@
  		if((type == 1) && (match(a_wildName, file)))
  			result.put(file);
 #endif
+	if (result.length() == 0)
+		cout << "Warning: File '" << a_wildName() << "' not found" << endl;

 	return result;
 }
Index: riscos-aof/libfile/TimeStamp.h
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/libfile/TimeStamp.h,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 TimeStamp.h
--- riscos-aof/libfile/TimeStamp.h	2002/02/28 18:55:19	1.2.2.1
+++ riscos-aof/libfile/TimeStamp.h	2002/03/28 23:59:30
@@ -9,9 +9,9 @@
 #include "Buffer.h"

 #ifndef CROSS_COMPILE
-extern "C" void OS_File(int *);
-extern "C" void OS_Word(int, int);
-extern "C" void OS_ConvertDataAndTime(int *);
+extern "C" void *OS_File(int *);
+extern "C" void *OS_Word(int, int);
+extern "C" void *OS_ConvertDataAndTime(int *);
 #endif

 class TimeStamp



-- 
Alex Waugh                               alex at alexwaugh.com

PHP, Roots, WebJames and more from http://www.alexwaugh.com/




More information about the gcc mailing list