aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2015-07-24 18:47:54 -0700
committerAndrew Waterman <waterman@cs.berkeley.edu>2015-07-24 18:47:54 -0700
commita710501a3ff60e41aefc80ff004bd4eabee83d7d (patch)
tree57d85992e85403e4aae9e98a571865aae14f3b74
parent6aa84fd30d23e109f66f9c05e87eda9d4ce7290f (diff)
downloadpk-a710501a3ff60e41aefc80ff004bd4eabee83d7d.zip
pk-a710501a3ff60e41aefc80ff004bd4eabee83d7d.tar.gz
pk-a710501a3ff60e41aefc80ff004bd4eabee83d7d.tar.bz2
Store RV logo in rodata, rather than making it on the fly
This works around a stack overflow.
-rw-r--r--pk/logo.c69
1 files changed, 25 insertions, 44 deletions
diff --git a/pk/logo.c b/pk/logo.c
index 8f868e8..2a214c5 100644
--- a/pk/logo.c
+++ b/pk/logo.c
@@ -1,51 +1,32 @@
#include <string.h>
#include "file.h"
-#define W 46
-#define D 21
-#define T 5
+static const char logo[] =
+" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\n"
+" vvvvvvvvvvvvvvvvvvvvvvvvvvvv\n"
+"rrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvvvv\n"
+"rrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv\n"
+"rrrrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv\n"
+"rrrrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv\n"
+"rrrrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvvvv\n"
+"rrrrrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvv \n"
+"rrrrrrrrrrrrr vvvvvvvvvvvvvvvvvvvvvv \n"
+"rr vvvvvvvvvvvvvvvvvvvvvv \n"
+"rr vvvvvvvvvvvvvvvvvvvvvvvv rr\n"
+"rrrr vvvvvvvvvvvvvvvvvvvvvvvvvv rrrr\n"
+"rrrrrr vvvvvvvvvvvvvvvvvvvvvv rrrrrr\n"
+"rrrrrrrr vvvvvvvvvvvvvvvvvv rrrrrrrr\n"
+"rrrrrrrrrr vvvvvvvvvvvvvv rrrrrrrrrr\n"
+"rrrrrrrrrrrr vvvvvvvvvv rrrrrrrrrrrr\n"
+"rrrrrrrrrrrrrr vvvvvv rrrrrrrrrrrrrr\n"
+"rrrrrrrrrrrrrrrr vv rrrrrrrrrrrrrrrr\n"
+"rrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrr\n"
+"rrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrr\n"
+"rrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrr\n"
+"\n"
+" INSTRUCTION SETS WANT TO BE FREE\n";
void print_logo()
{
- static const char end[] = "\n INSTRUCTION SETS WANT TO BE FREE\n\n";
- static const char fill[T] = {'r', ' ', 'v', ' ', 'r'};
- static const char logo[D][T] =
- {{0, 14, 46, 46, 46},
- {0, 18, 46, 46, 46},
- {13, 20, 46, 46, 46},
- {16, 22, 46, 46, 46},
- {18, 22, 46, 46, 46},
- {18, 22, 46, 46, 46},
- {18, 22, 46, 46, 46},
- {16, 22, 44, 46, 46},
- {13, 20, 42, 46, 46},
- {2, 18, 40, 46, 46},
- {2, 14, 38, 44, 46},
- {4, 10, 36, 42, 46},
- {6, 12, 34, 40, 46},
- {8, 14, 32, 38, 46},
- {10, 16, 30, 36, 46},
- {12, 18, 28, 34, 46},
- {14, 20, 26, 32, 46},
- {16, 22, 24, 30, 46},
- {18, 22, 22, 28, 46},
- {20, 20, 20, 26, 46},
- {22, 22, 22, 24, 46}};
-
- char result[D*(W+1) + sizeof(end)];
- char* pos = result;
- for (size_t i = 0; i < D; i++) {
- for (size_t j = 0, p = 0; j < T; j++) {
- if (p == logo[i][j])
- continue;
- do {
- *pos++ = fill[j];
- p++;
- } while (p < logo[i][j]);
- }
- *pos++ = '\n';
- }
- memcpy(pos, end, sizeof(end));
-
- file_write(stderr, result, (pos - result) + sizeof(end));
+ file_write(stderr, logo, sizeof logo);
}