diff options
author | Yuri Zaporogets <yuriz@users.sourceforge.net> | 2004-09-15 06:54:34 +0000 |
---|---|---|
committer | Yuri Zaporogets <yuriz@users.sourceforge.net> | 2004-09-15 06:54:34 +0000 |
commit | e0c059ab4e1e5d471372aa42caa57573de912655 (patch) | |
tree | f496dd3cd93c4ec4126ab9dd327474a589ac9ae1 /rdoff/rdfload.c | |
parent | 7549d149982c8c89991485d5ef359d22a3416a1f (diff) | |
download | nasm-e0c059ab4e1e5d471372aa42caa57573de912655.tar.gz nasm-e0c059ab4e1e5d471372aa42caa57573de912655.tar.bz2 nasm-e0c059ab4e1e5d471372aa42caa57573de912655.zip |
outrdf2.c now uses the same definitions of RDOFF2 format that RDOFF utils.
Export/import/common label size is increased from 33 to 64. Fixed the bug
that caused wrong behavior of rdfgetheaderrec() if label length was 32.
Changed error codes from numeric values to symbolic constants.
Moved some routines from rdfdump.c to rdoff.c. They will be utilized also
by rdfdisasm, which is being developed.
Diffstat (limited to 'rdoff/rdfload.c')
-rw-r--r-- | rdoff/rdfload.c | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/rdoff/rdfload.c b/rdoff/rdfload.c index 8fb6ca3..2f8bf6b 100644 --- a/rdoff/rdfload.c +++ b/rdoff/rdfload.c @@ -23,7 +23,6 @@ #include "rdfload.h" #include "symtab.h" -#include "rdoff.h" #include "collectn.h" extern int rdf_errno; @@ -36,17 +35,15 @@ rdfmodule * rdfload(const char *filename) rdfheaderrec *r; f = malloc(sizeof(rdfmodule)); - if (f == NULL) - { - rdf_errno = 6; /* out of memory */ + if (f == NULL) { + rdf_errno = RDF_ERR_NOMEM; return NULL; } f->symtab = symtabNew(); - if (!f->symtab) - { + if (!f->symtab) { free(f); - rdf_errno = 6; + rdf_errno = RDF_ERR_NOMEM; return NULL; } @@ -63,7 +60,7 @@ rdfmodule * rdfload(const char *filename) hdr = malloc (f->f.header_len); if (! f->t || ! f->d || !hdr) { - rdf_errno = 6; + rdf_errno = RDF_ERR_NOMEM; rdfclose(&f->f); if (f->t) free(f->t); if (f->d) free(f->d); @@ -87,20 +84,18 @@ rdfmodule * rdfload(const char *filename) /* Allocate BSS segment; step through header and count BSS records */ - while ( ( r = rdfgetheaderrec (&f->f) ) ) - { + while ((r = rdfgetheaderrec(&f->f))) { if (r->type == 5) bsslength += r->b.amount; } f->b = malloc ( bsslength ); - if (bsslength && (!f->b)) - { + if (bsslength && (!f->b)) { free(f->t); free(f->d); free(f); free(hdr); - rdf_errno = 6; + rdf_errno = RDF_ERR_NOMEM; return NULL; } @@ -121,13 +116,11 @@ int rdf_relocate(rdfmodule * m) long rel; unsigned char * seg; - rdfheaderrewind ( & m->f ); + rdfheaderrewind (&m->f); collection_init(&imports); - while ( (r = rdfgetheaderrec ( & m->f ) ) ) - { - switch (r->type) - { + while ((r = rdfgetheaderrec(&m->f))) { + switch (r->type) { case 1: /* Relocation record */ /* calculate relocation factor */ @@ -154,7 +147,7 @@ int rdf_relocate(rdfmodule * m) seg[r->r.offset] += (char) rel; break; case 2: - *(int16 *)(seg + r->r.offset) += (int16) rel; + *(uint16 *)(seg + r->r.offset) += (uint16) rel; break; case 4: *(long *)(seg + r->r.offset) += rel; |