Back to index

enigmail  1.4.3
test.c
Go to the documentation of this file.
00001 #ifdef DEF
00002 DEF(This)
00003 DEF(is)
00004 DEF(a)
00005 DEF(test)
00006 DEF(of)
00007 DEF(string)
00008 DEF(array)
00009 DEF(for)
00010 DEF(use)
00011 DEF(with)
00012 DEF(elfhack)
00013 DEF(to)
00014 DEF(see)
00015 DEF(whether)
00016 DEF(it)
00017 DEF(breaks)
00018 DEF(anything)
00019 DEF(but)
00020 DEF(one)
00021 DEF(needs)
00022 DEF(quite)
00023 DEF(some)
00024 DEF(strings)
00025 DEF(before)
00026 DEF(the)
00027 DEF(program)
00028 DEF(can)
00029 DEF(do)
00030 DEF(its)
00031 DEF(work)
00032 DEF(efficiently)
00033 DEF(Without)
00034 DEF(enough)
00035 DEF(data)
00036 DEF(relocation)
00037 DEF(sections)
00038 DEF(are)
00039 DEF(not)
00040 DEF(sufficiently)
00041 DEF(large)
00042 DEF(and)
00043 DEF(injected)
00044 DEF(code)
00045 DEF(wouldnt)
00046 DEF(fit)
00047 DEF(Said)
00048 DEF(otherwise)
00049 DEF(we)
00050 DEF(need)
00051 DEF(more)
00052 DEF(words)
00053 DEF(than)
00054 DEF(up)
00055 DEF(here)
00056 DEF(so)
00057 DEF(that)
00058 DEF(relocations)
00059 DEF(take)
00060 DEF(significant)
00061 DEF(bytes)
00062 DEF(amounts)
00063 DEF(which)
00064 DEF(isnt)
00065 DEF(exactly)
00066 DEF(easily)
00067 DEF(achieved)
00068 DEF(like)
00069 DEF(this)
00070 DEF(Actually)
00071 DEF(I)
00072 DEF(must)
00073 DEF(cheat)
00074 DEF(by)
00075 DEF(including)
00076 DEF(these)
00077 DEF(phrases)
00078 DEF(several)
00079 DEF(times)
00080 
00081 #else
00082 #pragma GCC visibility push(default)
00083 #include <stdlib.h>
00084 #include <stdio.h>
00085 
00086 #define DEF(w) static const char str_ ## w[] = #w;
00087 #include "test.c"
00088 #undef DEF
00089 
00090 const char *strings[] = {
00091 #define DEF(w) str_ ## w,
00092 #include "test.c"
00093 #include "test.c"
00094 #include "test.c"
00095 };
00096 
00097 /* Create a hole between two zones of relative relocations */
00098 const int hole[] = {
00099     42, 42, 42, 42
00100 };
00101 
00102 const char *strings2[] = {
00103 #include "test.c"
00104 #include "test.c"
00105 #include "test.c"
00106 #include "test.c"
00107 #include "test.c"
00108 #undef DEF
00109 };
00110 
00111 static int ret = 1;
00112 
00113 int print_status() {
00114     fprintf(stderr, "%s\n", ret ? "FAIL" : "PASS");
00115     return ret;
00116 }
00117 
00118 /* On ARM, this creates a .tbss section before .init_array, which
00119  * elfhack could then pick instead of .init_array.
00120  * Also, when .tbss is big enough, elfhack may wrongfully consider
00121  * following sections as part of the PT_TLS segment. */
00122 __thread int foo[1024];
00123 
00124 __attribute__((constructor)) void end_test() {
00125     static int count = 0;
00126     /* Only exit when both constructors have been called */
00127     if (++count == 2)
00128         ret = 0;
00129 }
00130 
00131 __attribute__((constructor)) void test() {
00132     int i = 0, j = 0;
00133 #define DEF_(a,i,w) \
00134     if (a[i++] != str_ ## w) return;
00135 #define DEF(w) DEF_(strings,i,w)
00136 #include "test.c"
00137 #include "test.c"
00138 #include "test.c"
00139 #undef DEF
00140 #define DEF(w) DEF_(strings2,j,w)
00141 #include "test.c"
00142 #include "test.c"
00143 #include "test.c"
00144 #include "test.c"
00145 #include "test.c"
00146 #undef DEF
00147     if (i != sizeof(strings)/sizeof(strings[0]) &&
00148         j != sizeof(strings2)/sizeof(strings2[0]))
00149         fprintf(stderr, "WARNING: Test doesn't cover the whole array\n");
00150     end_test();
00151 }
00152 
00153 #pragma GCC visibility pop
00154 #endif