summaryrefslogtreecommitdiff
path: root/rdoff/rdflib.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2002-05-04 05:42:30 +0000
committerH. Peter Anvin <hpa@zytor.com>2002-05-04 05:42:30 +0000
commit27cf503e03f4765e0eaaffa6aaef6d75ff1de226 (patch)
tree9567ba927109804467ccdd98a91e8c2f3cf7c0a9 /rdoff/rdflib.c
parent87242df32dd2bfad17d88570cee3509d0c3cc88d (diff)
downloadnasm-27cf503e03f4765e0eaaffa6aaef6d75ff1de226.tar.gz
RDOFF patch from Yuri Zaporogets:
- Panos Minos's LDRDF fix (correct export of relocation records); - Panos Minos's symtab.c verbose dump fix; - Librarian (rdflib) now puts a signature block when creating a library (instead of creating an empty file). In theory it doesn't break binary compatibility, but due to a bug in the original 'rdlib.c' you can't use old LDRDF with new libraries. Fix this bug as well. - Other minor changes in LDRDF.
Diffstat (limited to 'rdoff/rdflib.c')
-rw-r--r--rdoff/rdflib.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/rdoff/rdflib.c b/rdoff/rdflib.c
index c8bab74b..1f19913e 100644
--- a/rdoff/rdflib.c
+++ b/rdoff/rdflib.c
@@ -3,7 +3,13 @@
/*
* an rdoff library is simply a sequence of RDOFF object files, each
* preceded by the name of the module, an ASCII string of up to 255
- * characters, terminated by a zero.
+ * characters, terminated by a zero.
+ *
+ * When a library is being created, special signature block is placed
+ * in the beginning of the file. It is a string 'RDLIB' followed by a
+ * version number, then long content size and a long time stamp.
+ * The module name of the signature block is '.sig'.
+ *
*
* There may be an optional directory placed on the end of the file.
* The format of the directory will be 'RDLDD' followed by a version
@@ -11,16 +17,17 @@
* directory, the format of which has not yet been designed.
* The module name of the directory must be '.dir'.
*
- * All module names beginning with '.' are reserved
- * for possible future extensions. The linker ignores all such modules,
- * assuming they have the format of a six byte type & version identifier
- * followed by long content size, followed by data.
+ * All module names beginning with '.' are reserved for possible future
+ * extensions. The linker ignores all such modules, assuming they have
+ * the format of a six byte type & version identifier followed by long
+ * content size, followed by data.
*/
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
+#include <time.h>
/* functions supported:
* create a library (no extra operands required)
@@ -41,6 +48,9 @@ const char *usage =
" r - replace (module-name filename)\n"
" d - delete (module-name)\n"
" t - list\n";
+
+/* Library signature */
+const char *rdl_signature = "RDLIB2", *sig_modname = ".sig";
char **_argv;
@@ -114,10 +124,11 @@ long copylong(FILE *fp, FILE *fp2)
int main(int argc, char **argv)
{
- FILE *fp, *fp2, *fptmp;
+ FILE *fp, *fp2 = NULL, *fptmp;
char *p, buf[256], c;
int i;
long l;
+ time_t t;
char tmptempl[L_tmpnam], rdbuf[10];
_argv = argv;
@@ -137,6 +148,11 @@ int main(int argc, char **argv)
perror("rdflib");
exit(1);
}
+ fwrite(sig_modname, 1, strlen(sig_modname)+1, fp);
+ fwrite(rdl_signature, 1, strlen(rdl_signature), fp);
+ l = sizeof(t = time(NULL));
+ fwrite(&l, sizeof(l), 1, fp);
+ fwrite(&t, 1, l, fp);
fclose(fp);
break;