diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:28:42 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:28:42 -0800 |
commit | 88b607994a148f4af5bffee163e39ce8296750c6 (patch) | |
tree | fa249ff843e976cf034f2029437d3362a8396321 /tools/bin2asm/data | |
parent | 05806d7af62e07c6225b2e7103a1b115ecf6c9ad (diff) | |
download | build-88b607994a148f4af5bffee163e39ce8296750c6.zip build-88b607994a148f4af5bffee163e39ce8296750c6.tar.gz build-88b607994a148f4af5bffee163e39ce8296750c6.tar.bz2 |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'tools/bin2asm/data')
-rw-r--r-- | tools/bin2asm/data | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tools/bin2asm/data b/tools/bin2asm/data new file mode 100644 index 0000000..3be865f --- /dev/null +++ b/tools/bin2asm/data @@ -0,0 +1,52 @@ +/* + * Convert a data file into a .S file suitable for assembly. + * This reads from stdin and writes to stdout and takes a single + * argument for the name of the symbol in the assembly file. + */ + +#include <stdio.h> + +int main(int argc, char *argv[]) { + unsigned char buf[4096]; + size_t amt; + size_t i; + int col = 0; + char *name = argv[1]; + + printf("\ +#ifdef __APPLE_CC__\n\ +/*\n\ + * The mid-2007 version of gcc that ships with Macs requires a\n\ + * comma on the .section line, but the rest of the world thinks\n\ + * that's a syntax error. It also wants globals to be explicitly\n\ + * prefixed with \"_\" as opposed to modern gccs that do the\n\ + * prefixing for you.\n\ + */\n\ +.globl _%s\n\ + .section .rodata,\n\ + .align 8\n\ +_%s:\n\ +#else\n\ +.globl %s\n\ + .section .rodata\n\ + .align 8\n\ +%s:\n\ +#endif\n\ +", name, name, name, name); + + while (! feof(stdin)) { + amt = fread(buf, 1, sizeof(buf), stdin); + for (i = 0; i < amt; i++) { + printf((col == 0) ? ".byte %3d" : ",%3d", buf[i]); + col++; + if (col == 16) { + printf("\n"); + col = 0; + } + } + } + + if (col != 0) { + printf("\n"); + } +} |