2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2011-01-24 00:56:40 -08:00
|
|
|
#ifdef DEF
|
|
|
|
DEF(This)
|
|
|
|
DEF(is)
|
|
|
|
DEF(a)
|
|
|
|
DEF(test)
|
|
|
|
DEF(of)
|
|
|
|
DEF(string)
|
|
|
|
DEF(array)
|
|
|
|
DEF(for)
|
|
|
|
DEF(use)
|
|
|
|
DEF(with)
|
|
|
|
DEF(elfhack)
|
|
|
|
DEF(to)
|
|
|
|
DEF(see)
|
|
|
|
DEF(whether)
|
|
|
|
DEF(it)
|
|
|
|
DEF(breaks)
|
|
|
|
DEF(anything)
|
|
|
|
DEF(but)
|
|
|
|
DEF(one)
|
|
|
|
DEF(needs)
|
|
|
|
DEF(quite)
|
|
|
|
DEF(some)
|
|
|
|
DEF(strings)
|
|
|
|
DEF(before)
|
|
|
|
DEF(the)
|
|
|
|
DEF(program)
|
|
|
|
DEF(can)
|
|
|
|
DEF(do)
|
|
|
|
DEF(its)
|
|
|
|
DEF(work)
|
|
|
|
DEF(efficiently)
|
|
|
|
DEF(Without)
|
|
|
|
DEF(enough)
|
|
|
|
DEF(data)
|
|
|
|
DEF(relocation)
|
|
|
|
DEF(sections)
|
|
|
|
DEF(are)
|
|
|
|
DEF(not)
|
|
|
|
DEF(sufficiently)
|
|
|
|
DEF(large)
|
|
|
|
DEF(and)
|
|
|
|
DEF(injected)
|
|
|
|
DEF(code)
|
|
|
|
DEF(wouldnt)
|
|
|
|
DEF(fit)
|
|
|
|
DEF(Said)
|
|
|
|
DEF(otherwise)
|
|
|
|
DEF(we)
|
|
|
|
DEF(need)
|
|
|
|
DEF(more)
|
|
|
|
DEF(words)
|
|
|
|
DEF(than)
|
|
|
|
DEF(up)
|
|
|
|
DEF(here)
|
|
|
|
DEF(so)
|
|
|
|
DEF(that)
|
|
|
|
DEF(relocations)
|
|
|
|
DEF(take)
|
|
|
|
DEF(significant)
|
|
|
|
DEF(bytes)
|
|
|
|
DEF(amounts)
|
|
|
|
DEF(which)
|
|
|
|
DEF(isnt)
|
|
|
|
DEF(exactly)
|
|
|
|
DEF(easily)
|
|
|
|
DEF(achieved)
|
|
|
|
DEF(like)
|
|
|
|
DEF(this)
|
|
|
|
DEF(Actually)
|
|
|
|
DEF(I)
|
|
|
|
DEF(must)
|
|
|
|
DEF(cheat)
|
|
|
|
DEF(by)
|
|
|
|
DEF(including)
|
|
|
|
DEF(these)
|
|
|
|
DEF(phrases)
|
|
|
|
DEF(several)
|
|
|
|
DEF(times)
|
|
|
|
|
|
|
|
#else
|
2011-06-27 23:25:48 -07:00
|
|
|
#pragma GCC visibility push(default)
|
2011-01-24 00:56:40 -08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define DEF(w) static const char str_ ## w[] = #w;
|
|
|
|
#include "test.c"
|
|
|
|
#undef DEF
|
|
|
|
|
|
|
|
const char *strings[] = {
|
|
|
|
#define DEF(w) str_ ## w,
|
|
|
|
#include "test.c"
|
|
|
|
#include "test.c"
|
|
|
|
#include "test.c"
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Create a hole between two zones of relative relocations */
|
|
|
|
const int hole[] = {
|
|
|
|
42, 42, 42, 42
|
|
|
|
};
|
|
|
|
|
|
|
|
const char *strings2[] = {
|
|
|
|
#include "test.c"
|
|
|
|
#include "test.c"
|
|
|
|
#include "test.c"
|
|
|
|
#include "test.c"
|
|
|
|
#include "test.c"
|
|
|
|
#undef DEF
|
|
|
|
};
|
|
|
|
|
2011-01-28 00:22:58 -08:00
|
|
|
static int ret = 1;
|
|
|
|
|
2011-06-27 23:25:48 -07:00
|
|
|
int print_status() {
|
2011-01-28 00:22:58 -08:00
|
|
|
fprintf(stderr, "%s\n", ret ? "FAIL" : "PASS");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-01-24 00:56:40 -08:00
|
|
|
/* On ARM, this creates a .tbss section before .init_array, which
|
2011-06-06 23:26:17 -07:00
|
|
|
* elfhack could then pick instead of .init_array.
|
|
|
|
* Also, when .tbss is big enough, elfhack may wrongfully consider
|
|
|
|
* following sections as part of the PT_TLS segment. */
|
|
|
|
__thread int foo[1024];
|
2011-01-24 00:56:40 -08:00
|
|
|
|
|
|
|
__attribute__((constructor)) void end_test() {
|
|
|
|
static int count = 0;
|
2011-01-28 00:22:58 -08:00
|
|
|
/* Only exit when both constructors have been called */
|
2011-01-28 00:22:58 -08:00
|
|
|
if (++count == 2)
|
|
|
|
ret = 0;
|
2011-01-24 00:56:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__((constructor)) void test() {
|
|
|
|
int i = 0, j = 0;
|
|
|
|
#define DEF_(a,i,w) \
|
2011-01-28 00:22:58 -08:00
|
|
|
if (a[i++] != str_ ## w) return;
|
2011-01-24 00:56:40 -08:00
|
|
|
#define DEF(w) DEF_(strings,i,w)
|
|
|
|
#include "test.c"
|
|
|
|
#include "test.c"
|
|
|
|
#include "test.c"
|
|
|
|
#undef DEF
|
|
|
|
#define DEF(w) DEF_(strings2,j,w)
|
|
|
|
#include "test.c"
|
|
|
|
#include "test.c"
|
|
|
|
#include "test.c"
|
|
|
|
#include "test.c"
|
|
|
|
#include "test.c"
|
|
|
|
#undef DEF
|
|
|
|
if (i != sizeof(strings)/sizeof(strings[0]) &&
|
|
|
|
j != sizeof(strings2)/sizeof(strings2[0]))
|
|
|
|
fprintf(stderr, "WARNING: Test doesn't cover the whole array\n");
|
|
|
|
end_test();
|
|
|
|
}
|
|
|
|
|
2011-06-27 23:25:48 -07:00
|
|
|
#pragma GCC visibility pop
|
2011-01-24 00:56:40 -08:00
|
|
|
#endif
|