mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-11-21 03:14:19 +08:00
c99 printf/fprintf compliance.
This commit is contained in:
parent
c7ae18dba1
commit
47776ac525
@ -254,7 +254,7 @@ void processmodule(const char *filename, struct modulenode *mod)
|
||||
mod->seginfo[seg].reloc = 0;
|
||||
outputseg[outseg].length = mod->f.seg[seg].length;
|
||||
if (options.verbose > 1)
|
||||
printf("=> %04x:%08lx (+%04lx)\n", outseg,
|
||||
printf("=> %04x:%08"PRIx32" (+%04"PRIx32")\n", outseg,
|
||||
mod->seginfo[seg].reloc, mod->f.seg[seg].length);
|
||||
break;
|
||||
|
||||
@ -281,7 +281,7 @@ void processmodule(const char *filename, struct modulenode *mod)
|
||||
outputseg[outseg].length += mod->f.seg[seg].length;
|
||||
|
||||
if (options.verbose > 1)
|
||||
printf("=> %04x:%08lx (+%04lx)\n", outseg,
|
||||
printf("=> %04x:%08"PRIx32" (+%04"PRIx32")\n", outseg,
|
||||
mod->seginfo[seg].reloc, mod->f.seg[seg].length);
|
||||
}
|
||||
|
||||
@ -349,7 +349,7 @@ void processmodule(const char *filename, struct modulenode *mod)
|
||||
if (bss_length % hr->c.align != 0)
|
||||
bss_length += hr->c.align - (bss_length % hr->c.align);
|
||||
if (options.verbose > 1) {
|
||||
printf("%s %04x common '%s' => 0002:%08lx (+%04lx)\n",
|
||||
printf("%s %04x common '%s' => 0002:%08"PRIx32" (+%04"PRIx32")\n",
|
||||
filename, hr->c.segment, hr->c.label,
|
||||
bss_length, hr->c.size);
|
||||
}
|
||||
@ -374,7 +374,7 @@ void processmodule(const char *filename, struct modulenode *mod)
|
||||
|
||||
mod->bss_reloc = bss_length;
|
||||
if (options.verbose > 1) {
|
||||
printf("%s 0002 [ BSS] => 0002:%08lx (+%04lx)\n",
|
||||
printf("%s 0002 [ BSS] => 0002:%08"PRIx32" (+%04"PRIx32")\n",
|
||||
filename, bss_length, bssamount);
|
||||
}
|
||||
bss_length += bssamount;
|
||||
@ -883,7 +883,7 @@ void write_output(const char *filename)
|
||||
if (offset < -127 || offset > 128)
|
||||
fprintf(error_file,
|
||||
"warning: relocation out of range "
|
||||
"at %s(%02x:%08lx)\n", cur->name,
|
||||
"at %s(%02x:%08"PRIx32")\n", cur->name,
|
||||
(int)hr->r.segment, hr->r.offset);
|
||||
*data = (char)offset;
|
||||
break;
|
||||
@ -892,7 +892,7 @@ void write_output(const char *filename)
|
||||
if (offset < -32767 || offset > 32768)
|
||||
fprintf(error_file,
|
||||
"warning: relocation out of range "
|
||||
"at %s(%02x:%08lx)\n", cur->name,
|
||||
"at %s(%02x:%08"PRIx32")\n", cur->name,
|
||||
(int)hr->r.segment, hr->r.offset);
|
||||
*(int16_t *)data = (int16_t)offset;
|
||||
break;
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "rdfload.h"
|
||||
#include "../nasmlib.h"
|
||||
#include "nasmlib.h"
|
||||
|
||||
int32_t origin = 0;
|
||||
int align = 16;
|
||||
@ -81,7 +81,7 @@ int main(int argc, char **argv)
|
||||
rdfperror("rdf2bin", *argv);
|
||||
return 1;
|
||||
}
|
||||
printf("relocating %s: origin=%lx, align=%d\n", *argv, origin, align);
|
||||
printf("relocating %s: origin=%"PRIx32", align=%d\n", *argv, origin, align);
|
||||
|
||||
m->textrel = origin;
|
||||
m->datarel = origin + m->f.seg[0].length;
|
||||
@ -98,7 +98,7 @@ int main(int argc, char **argv)
|
||||
} else
|
||||
datapad = 0;
|
||||
|
||||
printf("code: %08lx\ndata: %08lx\nbss: %08lx\n",
|
||||
printf("code: %08"PRIx32"\ndata: %08"PRIx32"\nbss: %08"PRIx32"\n",
|
||||
m->textrel, m->datarel, m->bssrel);
|
||||
|
||||
rdf_relocate(m);
|
||||
|
@ -88,7 +88,7 @@ int main(int argc, char **argv)
|
||||
rdfperror("rdf2ihx", *argv);
|
||||
return 1;
|
||||
}
|
||||
printf("relocating %s: origin=%lx, align=%d\n", *argv, origin, align);
|
||||
printf("relocating %s: origin=%"PRIx32", align=%d\n", *argv, origin, align);
|
||||
|
||||
m->textrel = origin;
|
||||
m->datarel = origin + m->f.seg[0].length;
|
||||
@ -107,7 +107,7 @@ int main(int argc, char **argv)
|
||||
pad[1] = 0;
|
||||
}
|
||||
|
||||
printf("code: %08lx\ndata: %08lx\nbss: %08lx\n",
|
||||
printf("code: %08"PRIx32"\ndata: %08"PRIx32"\nbss: %08"PRIx32"\n",
|
||||
m->textrel, m->datarel, m->bssrel);
|
||||
|
||||
rdf_relocate(m);
|
||||
@ -150,7 +150,7 @@ int main(int argc, char **argv)
|
||||
segaddr = ((s->segment & 0xffff) << 16) + ((s->offset) & 0xffff);
|
||||
fprintf(of, ":04000003"); /* Record mark, reclen, load offset & rectyp
|
||||
fields for start seg. addr. record */
|
||||
fprintf(of, "%08lX", segaddr); /* CS/IP field */
|
||||
fprintf(of, "%08"PRIX32"", segaddr); /* CS/IP field */
|
||||
checksum = 0x04 + /* reclen */
|
||||
0x0000 + /* load offset */
|
||||
0x03 + /* Rectyp */
|
||||
|
@ -38,7 +38,7 @@ void print_header(int32_t length, int rdf_version)
|
||||
fread(&o, 4, 1, infile);
|
||||
fread(&l, 1, 1, infile);
|
||||
fread(&rs, 2, 1, infile);
|
||||
printf(" %s: location (%04x:%08lx), length %d, "
|
||||
printf(" %s: location (%04x:%08"PRIx32"), length %d, "
|
||||
"referred seg %04x\n",
|
||||
t == 1 ? "relocation" : "seg relocation", (int)s,
|
||||
translateint32_t(o), (int)l, translateint16_t(rs));
|
||||
@ -100,7 +100,7 @@ void print_header(int32_t length, int rdf_version)
|
||||
printf(" proc");
|
||||
if (flags & SYM_DATA)
|
||||
printf(" data");
|
||||
printf(": (%04x:%08lx) = %s\n", (int)s, translateint32_t(o), buf);
|
||||
printf(": (%04x:%08"PRIx32") = %s\n", (int)s, translateint32_t(o), buf);
|
||||
if (rdf_version == 1)
|
||||
length -= ll + 6;
|
||||
break;
|
||||
@ -126,7 +126,7 @@ void print_header(int32_t length, int rdf_version)
|
||||
|
||||
case RDFREC_BSS: /* BSS reservation */
|
||||
fread(&ll, 4, 1, infile);
|
||||
printf(" bss reservation: %08lx bytes\n", translateint32_t(ll));
|
||||
printf(" bss reservation: %08"PRIx32" bytes\n", translateint32_t(ll));
|
||||
if (rdf_version == 1)
|
||||
length -= 5;
|
||||
if (rdf_version > 1 && reclen != 4)
|
||||
@ -142,7 +142,7 @@ void print_header(int32_t length, int rdf_version)
|
||||
fread(&align, 2, 1, infile);
|
||||
for (ll = 0; ll < reclen - 8; ll++)
|
||||
fread(buf + ll, 1, 1, infile);
|
||||
printf(" common: segment %04x = %s, %ld:%d\n",
|
||||
printf(" common: segment %04x = %s, %"PRId32":%d\n",
|
||||
translateint16_t(seg), buf, translateint32_t(size),
|
||||
translateint16_t(align));
|
||||
break;
|
||||
@ -218,24 +218,24 @@ int main(int argc, char **argv)
|
||||
if (version > 1) {
|
||||
fread(&l, 4, 1, infile);
|
||||
objectlength = translateint32_t(l);
|
||||
printf("Object content size: %ld bytes\n", objectlength);
|
||||
printf("Object content size: %"PRId32" bytes\n", objectlength);
|
||||
}
|
||||
|
||||
fread(&l, 4, 1, infile);
|
||||
headerlength = translateint32_t(l);
|
||||
printf("Header (%ld bytes):\n", headerlength);
|
||||
printf("Header (%"PRId32" bytes):\n", headerlength);
|
||||
print_header(headerlength, version);
|
||||
|
||||
if (version == 1) {
|
||||
fread(&l, 4, 1, infile);
|
||||
l = translateint32_t(l);
|
||||
printf("\nText segment length = %ld bytes\n", l);
|
||||
printf("\nText segment length = %"PRId32" bytes\n", l);
|
||||
offset = 0;
|
||||
while (l--) {
|
||||
fread(id, 1, 1, infile);
|
||||
if (verbose) {
|
||||
if (offset % 16 == 0)
|
||||
printf("\n%08lx ", offset);
|
||||
printf("\n%08"PRIx32" ", offset);
|
||||
printf(" %02x", (int)(uint8_t)id[0]);
|
||||
offset++;
|
||||
}
|
||||
@ -245,14 +245,14 @@ int main(int argc, char **argv)
|
||||
|
||||
fread(&l, 4, 1, infile);
|
||||
l = translateint32_t(l);
|
||||
printf("Data segment length = %ld bytes\n", l);
|
||||
printf("Data segment length = %"PRId32" bytes\n", l);
|
||||
|
||||
if (verbose) {
|
||||
offset = 0;
|
||||
while (l--) {
|
||||
fread(id, 1, 1, infile);
|
||||
if (offset % 16 == 0)
|
||||
printf("\n%08lx ", offset);
|
||||
printf("\n%08"PRIx32" ", offset);
|
||||
printf(" %02x", (int)(uint8_t)id[0]);
|
||||
offset++;
|
||||
}
|
||||
@ -277,7 +277,7 @@ int main(int argc, char **argv)
|
||||
printf(" Resrvd = %04X\n", (int)translateint16_t(s));
|
||||
fread(&l, 4, 1, infile);
|
||||
l = translateint32_t(l);
|
||||
printf(" Length = %ld bytes\n", l);
|
||||
printf(" Length = %"PRId32" bytes\n", l);
|
||||
segmentcontentlength += l;
|
||||
|
||||
offset = 0;
|
||||
@ -285,7 +285,7 @@ int main(int argc, char **argv)
|
||||
fread(id, 1, 1, infile);
|
||||
if (verbose) {
|
||||
if (offset % 16 == 0)
|
||||
printf("\n%08lx ", offset);
|
||||
printf("\n%08"PRIx32" ", offset);
|
||||
printf(" %02x", (int)(uint8_t)id[0]);
|
||||
offset++;
|
||||
}
|
||||
@ -298,14 +298,14 @@ int main(int argc, char **argv)
|
||||
"NULL segment not found\n");
|
||||
|
||||
printf("\nTotal number of segments: %d\n", nsegments);
|
||||
printf("Total segment content length: %ld bytes\n",
|
||||
printf("Total segment content length: %"PRId32" bytes\n",
|
||||
segmentcontentlength);
|
||||
|
||||
/* calculate what the total object content length should have been */
|
||||
l = segmentcontentlength + 10 * (nsegments + 1) + headerlength + 4;
|
||||
if (l != objectlength)
|
||||
printf("Warning: actual object length (%ld) != "
|
||||
"stored object length (%ld)\n", l, objectlength);
|
||||
printf("Warning: actual object length (%"PRId32") != "
|
||||
"stored object length (%"PRId32")\n", l, objectlength);
|
||||
}
|
||||
fclose(infile);
|
||||
return 0;
|
||||
|
@ -70,6 +70,8 @@ static void int32_ttolocal(int32_t *l)
|
||||
t = p[1];
|
||||
p[1] = p[2];
|
||||
p[2] = p[1];
|
||||
#else
|
||||
(void)l; /* placate optimizers */
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -245,14 +247,14 @@ int main(int argc, char **argv)
|
||||
l = copyint32_t(fp, fp2);
|
||||
|
||||
if (argv[1][0] == 't')
|
||||
printf(" %ld bytes content\n", l);
|
||||
printf(" %"PRId32" bytes content\n", l);
|
||||
|
||||
copybytes(fp, fp2, l);
|
||||
} else if ((c = copybytes(fp, fp2, 6)) >= '2') { /* version 2 or above */
|
||||
l = copyint32_t(fp, fp2);
|
||||
|
||||
if (argv[1][0] == 't')
|
||||
printf("RDOFF%c %ld bytes content\n", c, l);
|
||||
printf("RDOFF%c %"PRId32" bytes content\n", c, l);
|
||||
copybytes(fp, fp2, l); /* entire object */
|
||||
} else {
|
||||
if (argv[1][0] == 't')
|
||||
|
@ -6,7 +6,10 @@
|
||||
#define RDOFF_RDLAR_H 1
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* For non-POSIX operating systems */
|
||||
#ifndef HAVE_GETUID
|
||||
|
@ -234,7 +234,7 @@ int rdfopenhere(rdffile * f, FILE * fp, int *refcount, const char *name)
|
||||
/* fix this to be portable! */
|
||||
fputs("*** this program requires a little endian machine\n",
|
||||
stderr);
|
||||
fprintf(stderr, "01020304h = %08lxh\n", translateint32_t(0x01020304));
|
||||
fprintf(stderr, "01020304h = %08"PRIx32"h\n", translateint32_t(0x01020304));
|
||||
exit(3);
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ int rdfopenhere(rdffile * f, FILE * fp, int *refcount, const char *name)
|
||||
}
|
||||
|
||||
if (f->eof_offset != ftell(f->fp) + 8) { /* +8 = skip null segment header */
|
||||
fprintf(stderr, "warning: eof_offset [%ld] and actual eof offset "
|
||||
fprintf(stderr, "warning: eof_offset [%"PRId32"] and actual eof offset "
|
||||
"[%ld] don't match\n", f->eof_offset, ftell(f->fp) + 8);
|
||||
}
|
||||
fseek(f->fp, initpos, SEEK_SET);
|
||||
|
@ -116,7 +116,7 @@ void symtabDump(void *stab, FILE * of)
|
||||
if ((l->ent.segment) == -1) {
|
||||
fprintf(of, "%-32s Unresolved reference\n", l->ent.name);
|
||||
} else {
|
||||
fprintf(of, "%-32s %s:%08lx (%ld)\n", l->ent.name,
|
||||
fprintf(of, "%-32s %s:%08"PRIx32" (%"PRId32")\n", l->ent.name,
|
||||
SegNames[l->ent.segment],
|
||||
l->ent.offset, l->ent.flags);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user