Skip to content

Commit

Permalink
Comments and error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
culler committed Feb 8, 2021
1 parent 57a1ed4 commit 3850d85
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion License.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

The macher program is licensed under the following simplified BSD license.
The macher program is licensed under the following Simplified BSD License.

Copyright © 2021 Marc Culler

Expand Down
24 changes: 19 additions & 5 deletions macher.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/*
* Macher is a command line tool for inspecting and modifying Mach-O binary files
* as produced by Apple's clang C compiler.
*
* Copyright © 2021 Marc Culler
*
* Macher is open source software distributed under a Simplified BSD License.
* See the file License.txt included with the source code distribution.
*
* Compile macher with the command:
* gcc -o macher macher.c
*/

#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
Expand Down Expand Up @@ -76,8 +89,9 @@ static void init_mach_o(mach_o_obj *mach_o, char *path, char *mode)
switch (magic) {
case FAT_MAGIC:
case OSSwapInt32(FAT_MAGIC):
printf("Fat binaries are not supported.\n"
"Use lipo to split the file into single-architecture binaries.\n");
printf("Fat binaries are not supported. Use\n"
" lipo <fat file> -thin <arch> -output <thin file>\n"
"to create single-architecture binaries.\n");
exit(1);
case MH_MAGIC_64:
mach_o->is_64bit = true;
Expand Down Expand Up @@ -123,7 +137,7 @@ static void init_mach_o(mach_o_obj *mach_o, char *path, char *mode)
mach_o->command_block_size = header->sizeofcmds;
if (mach_o->verbose) {
printf("The Mach-O header occupies %d bytes\n", mach_o->header_size);
printf("There are %u bytes being used to store %u load commands.\n",
printf("%u bytes are being used to store %u load commands.\n",
header->sizeofcmds, header->ncmds);
}
} else {
Expand All @@ -139,7 +153,7 @@ static void init_mach_o(mach_o_obj *mach_o, char *path, char *mode)
mach_o->num_commands = header->ncmds;
mach_o->command_block_size = header->sizeofcmds;
if (mach_o->verbose) {
printf("There are %u bytes being used to store %u load commands.\n",
printf("%u bytes are being used to store %u load commands.\n",
header->sizeofcmds, header->ncmds);
}
}
Expand Down Expand Up @@ -335,7 +349,7 @@ static void compute_command_space(mach_o_obj *mach_o)
if (command_space >= 0) {
mach_o->command_space = command_space;
if (mach_o->verbose) {
printf("There are %lu bytes available for storing load commands.\n\n",
printf("%lu bytes are available for storing load commands.\n\n",
mach_o->command_space);
}
} else {
Expand Down

0 comments on commit 3850d85

Please sign in to comment.