1 # CHECK_FOR_GOLD_T22266
2 # ----------------------
4 # Test for binutils #22266. This bug manifested as GHC bug #14328 (see also:
7 # https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=033bfb739b525703bfe23f151d09e9beee3a2afe
10 # Sets $result to 0 if not affected, 1 otherwise
11 AC_DEFUN([CHECK_FOR_GOLD_T22266],[
12 AC_MSG_CHECKING([for ld.gold object merging bug (binutils 22266)])
13 if ! $1 --version | grep -q "GNU gold" 2>/dev/null; then
16 elif test "$cross_compiling" = "yes"; then
17 AC_MSG_RESULT([cross-compiling, assuming LD can merge objects correctly.])
20 FPTOOLS_WRITE_FILE([conftest.a.c], [
21 __attribute__((section(".data.a")))
22 static int int_from_a_1 = 0x11223344;
24 __attribute__((section(".data.rel.ro.a")))
25 int *p_int_from_a_2 = &int_from_a_1;
27 const char *hello (void);
32 return "XXXHello, world!" + 3;
36 FPTOOLS_WRITE_FILE([conftest.main.c], [
40 extern int *p_int_from_a_2;
41 extern const char *hello (void);
44 if (*p_int_from_a_2 != 0x11223344)
46 if (strcmp(hello(), "Hello, world!") != 0)
52 FPTOOLS_WRITE_FILE([conftest.t], [
60 *(.rodata .rodata.* .gnu.linkonce.r.*)
74 $CC -c -o conftest.a.o conftest.a.c || AC_MSG_ERROR([Failed to compile test])
75 $MergeObjsCmd $MergeObjsArgs -T conftest.t conftest.a.o -o conftest.ar.o || AC_MSG_ERROR([Failed to merge test object])
77 $CC -c -o conftest.main.o conftest.main.c || AC_MSG_ERROR([Failed to compile test driver])
78 $CC conftest.ar.o conftest.main.o -o conftest || AC_MSG_ERROR([Failed to link test driver])
81 AC_MSG_RESULT([not affected])
84 AC_MSG_RESULT([affected])
87 rm -f conftest.a.o conftest.a.c conttest.ar.o conftest.main.c conftest.main.o conftest