summaryrefslogtreecommitdiff
path: root/output/outmacho.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-02-09 11:03:33 +0100
committerH. Peter Anvin <hpa@zytor.com>2009-02-21 17:24:08 -0800
commit999868f06f49ec6450872f224a7cc0a43214b063 (patch)
tree30f34b5c0133c948654ebcb386f0b53127d4309d /output/outmacho.c
parent04616f4e85d7c5c8501432f7124cf15f440aeae1 (diff)
downloadnasm-999868f06f49ec6450872f224a7cc0a43214b063.tar.gz
nasm-999868f06f49ec6450872f224a7cc0a43214b063.tar.bz2
nasm-999868f06f49ec6450872f224a7cc0a43214b063.zip
Unify all-zero buffers; add fwritezero()
We have a number of all-zero buffers in the code. Put a single all-zero buffer in nasmlib.c. Additionally, add fwritezero() which can be used to write an arbitrary number of all-zero bytes; this prevents the situation where the all-zero buffer is simply too small.
Diffstat (limited to 'output/outmacho.c')
-rw-r--r--output/outmacho.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/output/outmacho.c b/output/outmacho.c
index 30234a9..5387e99 100644
--- a/output/outmacho.c
+++ b/output/outmacho.c
@@ -880,7 +880,7 @@ static uint32_t macho_write_segment (uint32_t offset)
/* in an MH_OBJECT file all sections are in one unnamed (name
** all zeros) segment */
- fwrite("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16, 1, machofp);
+ fwritezero(16, machofp);
fwriteint32_t(0, machofp); /* in-memory offset */
fwriteint32_t(seg_vmsize, machofp); /* in-memory size */
fwriteint32_t(offset, machofp); /* in-file offset to data */
@@ -956,7 +956,6 @@ static void macho_write_section (void)
{
struct section *s, *s2;
struct reloc *r;
- char *rel_paddata = "\0\0\0";
uint8_t *p, *q, blk[4];
int32_t l;
@@ -1013,7 +1012,7 @@ static void macho_write_section (void)
}
/* pad last section up to reloc entries on int32_t boundary */
- fwrite(rel_paddata, rel_padcnt, 1, machofp);
+ fwritezero(rel_padcnt, machofp);
/* emit relocation entries */
for (s = sects; s != NULL; s = s->next)