summaryrefslogtreecommitdiff
blob: 423c703f7ffb7e06657963b6c698ba8c1b9d1677 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Backported from 1.0.0:
======================================================================
commit 008e470a9b8751de0a3745e511cbc05b68759688
Author: Aaro Koskinen <aaro.koskinen@iki.fi>
Date:   Mon May 12 08:28:46 2014 -0500

    configure: fix test-for-synth check with GCC 4.9.0
    
    With GCC 4.9.0 oprofile 0.9.9 build fails on non-PPC platfroms because
    the "test-for-synth" configure check result is incorrect: There is a NULL
    pointer dereference in the test program, so the compiler seems to optimize
    the rest of the code away, and the test will always succeed regardless
    whether powerpc_elf64_vec/bfd_elf64_powerpc_vec are present or not.
    Fix by allocating the referred struct statically.
    
    While at it, also include stdio.h to avoid a compiler warning.
    
    Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>

diff --git a/m4/binutils.m4 b/m4/binutils.m4
index 25fb15a..d7948c1 100644
--- a/m4/binutils.m4
+++ b/m4/binutils.m4
@@ -27,8 +27,10 @@ if test "$OS" = "Linux"; then
 	AC_MSG_CHECKING([whether bfd_get_synthetic_symtab() exists in BFD library])
 	rm -f test-for-synth
 	AC_LANG_CONFTEST(
-		[AC_LANG_PROGRAM([[#include <bfd.h>]],
-			[[asymbol * synthsyms;	bfd * ibfd = 0; 
+		[AC_LANG_PROGRAM([[#include <bfd.h>]
+                        [#include <stdio.h>]
+                        [static bfd _ibfd;]],
+                        [[asymbol * synthsyms;	bfd * ibfd = &_ibfd;
 			long synth_count = bfd_get_synthetic_symtab(ibfd, 0, 0, 0, 0, &synthsyms);
 			extern const bfd_target bfd_elf64_powerpc_vec;
 			extern const bfd_target bfd_elf64_powerpcle_vec;