Skip to content

Commit

Permalink
Added a size field to the binary info.
Browse files Browse the repository at this point in the history
Might as well, since we've probably got 4080 bytes worth of padding here.
  • Loading branch information
icculus committed Sep 7, 2009
1 parent 661b118 commit 3596b9d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/fatelf.h
Expand Up @@ -15,7 +15,7 @@
#define FATELF_FORMAT_VERSION (1)

/* This does not count padding for page alignment at the end. */
#define FATELF_DISK_FORMAT_SIZE(bins) (8 + (16 * (bins)))
#define FATELF_DISK_FORMAT_SIZE(bins) (8 + (24 * (bins)))

/* Values on disk are always littleendian, and align like Elf64. */
typedef struct FATELF_binary_info
Expand All @@ -25,6 +25,7 @@ typedef struct FATELF_binary_info
uint16_t machine;
uint16_t reserved0;
uint64_t offset;
uint64_t size;
} FATELF_binary_info;

/* Values on disk are always littleendian, and align like Elf64. */
Expand Down
3 changes: 2 additions & 1 deletion utils/fatelf-glue.c
Expand Up @@ -52,7 +52,8 @@ static int fatelf_glue(const char *out, const char **bins, const int bincount)

// append this binary to the final file, padded to page alignment.
xwrite_zeros(out, outfd, (size_t) (binary_offset - offset));
offset += binary_offset + xcopyfile(fname, fd, out, outfd);
info->size = xcopyfile(fname, fd, out, outfd);
offset = binary_offset + info->size;

// done with this binary!
xclose(fname, fd);
Expand Down
1 change: 1 addition & 0 deletions utils/fatelf-info.c
Expand Up @@ -33,6 +33,7 @@ static int fatelf_info(const char *fname)
(unsigned int) bin->machine, machine ? machine->name : "???",
machine ? ": " : "", machine ? machine->desc : "");
printf(" Offset %llu\n", (unsigned long long) bin->offset);
printf(" Size %llu\n", (unsigned long long) bin->size);
} // for

xclose(fname, fd);
Expand Down
2 changes: 2 additions & 0 deletions utils/fatelf-utils.c
Expand Up @@ -238,6 +238,7 @@ void xwrite_fatelf_header(const char *fname, const int fd,
ptr = putui16(ptr, header->binaries[i].machine);
ptr = putui16(ptr, header->binaries[i].reserved0);
ptr = putui64(ptr, header->binaries[i].offset);
ptr = putui64(ptr, header->binaries[i].size);
} // for

assert(ptr == (buf + buflen));
Expand Down Expand Up @@ -288,6 +289,7 @@ FATELF_header *xread_fatelf_header(const char *fname, const int fd)
ptr = getui16(ptr, &header->binaries[i].machine);
ptr = getui16(ptr, &header->binaries[i].reserved0);
ptr = getui64(ptr, &header->binaries[i].offset);
ptr = getui64(ptr, &header->binaries[i].size);
} // for

assert(ptr == (fullbuf + buflen));
Expand Down

0 comments on commit 3596b9d

Please sign in to comment.