michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifdef DEF michael@0: DEF(This) michael@0: DEF(is) michael@0: DEF(a) michael@0: DEF(test) michael@0: DEF(of) michael@0: DEF(string) michael@0: DEF(array) michael@0: DEF(for) michael@0: DEF(use) michael@0: DEF(with) michael@0: DEF(elfhack) michael@0: DEF(to) michael@0: DEF(see) michael@0: DEF(whether) michael@0: DEF(it) michael@0: DEF(breaks) michael@0: DEF(anything) michael@0: DEF(but) michael@0: DEF(one) michael@0: DEF(needs) michael@0: DEF(quite) michael@0: DEF(some) michael@0: DEF(strings) michael@0: DEF(before) michael@0: DEF(the) michael@0: DEF(program) michael@0: DEF(can) michael@0: DEF(do) michael@0: DEF(its) michael@0: DEF(work) michael@0: DEF(efficiently) michael@0: DEF(Without) michael@0: DEF(enough) michael@0: DEF(data) michael@0: DEF(relocation) michael@0: DEF(sections) michael@0: DEF(are) michael@0: DEF(not) michael@0: DEF(sufficiently) michael@0: DEF(large) michael@0: DEF(and) michael@0: DEF(injected) michael@0: DEF(code) michael@0: DEF(wouldnt) michael@0: DEF(fit) michael@0: DEF(Said) michael@0: DEF(otherwise) michael@0: DEF(we) michael@0: DEF(need) michael@0: DEF(more) michael@0: DEF(words) michael@0: DEF(than) michael@0: DEF(up) michael@0: DEF(here) michael@0: DEF(so) michael@0: DEF(that) michael@0: DEF(relocations) michael@0: DEF(take) michael@0: DEF(significant) michael@0: DEF(bytes) michael@0: DEF(amounts) michael@0: DEF(which) michael@0: DEF(isnt) michael@0: DEF(exactly) michael@0: DEF(easily) michael@0: DEF(achieved) michael@0: DEF(like) michael@0: DEF(this) michael@0: DEF(Actually) michael@0: DEF(I) michael@0: DEF(must) michael@0: DEF(cheat) michael@0: DEF(by) michael@0: DEF(including) michael@0: DEF(these) michael@0: DEF(phrases) michael@0: DEF(several) michael@0: DEF(times) michael@0: michael@0: #else michael@0: #pragma GCC visibility push(default) michael@0: #include michael@0: #include michael@0: michael@0: #define DEF(w) static const char str_ ## w[] = #w; michael@0: #include "test.c" michael@0: #undef DEF michael@0: michael@0: const char *strings[] = { michael@0: #define DEF(w) str_ ## w, michael@0: #include "test.c" michael@0: #include "test.c" michael@0: #include "test.c" michael@0: }; michael@0: michael@0: /* Create a hole between two zones of relative relocations */ michael@0: const int hole[] = { michael@0: 42, 42, 42, 42 michael@0: }; michael@0: michael@0: const char *strings2[] = { michael@0: #include "test.c" michael@0: #include "test.c" michael@0: #include "test.c" michael@0: #include "test.c" michael@0: #include "test.c" michael@0: #undef DEF michael@0: }; michael@0: michael@0: static int ret = 1; michael@0: michael@0: int print_status() { michael@0: fprintf(stderr, "%s\n", ret ? "FAIL" : "PASS"); michael@0: return ret; michael@0: } michael@0: michael@0: /* On ARM, this creates a .tbss section before .init_array, which michael@0: * elfhack could then pick instead of .init_array. michael@0: * Also, when .tbss is big enough, elfhack may wrongfully consider michael@0: * following sections as part of the PT_TLS segment. michael@0: * Finally, gold makes TLS segments end on an aligned virtual address, michael@0: * even when the underlying section ends before that, and elfhack michael@0: * sanity checks may yield an error. */ michael@0: __thread int foo; michael@0: __thread long long int bar[512]; michael@0: michael@0: void end_test() { michael@0: static int count = 0; michael@0: /* Only exit when both constructors have been called */ michael@0: if (++count == 2) michael@0: ret = 0; michael@0: } michael@0: michael@0: void test() { michael@0: int i = 0, j = 0; michael@0: #define DEF_(a,i,w) \ michael@0: if (a[i++] != str_ ## w) return; michael@0: #define DEF(w) DEF_(strings,i,w) michael@0: #include "test.c" michael@0: #include "test.c" michael@0: #include "test.c" michael@0: #undef DEF michael@0: #define DEF(w) DEF_(strings2,j,w) michael@0: #include "test.c" michael@0: #include "test.c" michael@0: #include "test.c" michael@0: #include "test.c" michael@0: #include "test.c" michael@0: #undef DEF michael@0: if (i != sizeof(strings)/sizeof(strings[0]) && michael@0: j != sizeof(strings2)/sizeof(strings2[0])) michael@0: fprintf(stderr, "WARNING: Test doesn't cover the whole array\n"); michael@0: end_test(); michael@0: } michael@0: michael@0: #pragma GCC visibility pop michael@0: #endif