aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gold/ChangeLog24
-rw-r--r--gold/config.in3
-rwxr-xr-xgold/configure67
-rw-r--r--gold/configure.ac16
-rw-r--r--gold/debug.h2
-rw-r--r--gold/dwarf_reader.cc2
-rw-r--r--gold/gold.h12
-rw-r--r--gold/main.cc3
-rw-r--r--gold/object.cc31
-rw-r--r--gold/options.cc1
-rw-r--r--gold/output.cc1
-rw-r--r--gold/script.cc5
-rw-r--r--gold/script.h1
-rw-r--r--gold/symtab.cc2
-rw-r--r--gold/target-select.cc2
-rw-r--r--gold/testsuite/testmain.cc2
-rw-r--r--gold/version.cc2
-rw-r--r--gold/x86_64.cc2
18 files changed, 171 insertions, 7 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 5a98a0784eb..0e207acaaea 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,27 @@
+2008-03-26 Ian Lance Taylor <iant@google.com>
+
+ PR gold/5986
+ Fix problems building gold with gcc 4.3.0.
+ * gold.h (TEMPLATE_ATTRIBUTE_PRINTF_4): Define.
+ (gold_error_at_location, gold_warning_at_location): Use it.
+ * configure.ac: Check whether we can compile and use a template
+ function with a printf attribute.
+ * x86_64.cc (Target_x86_64::do_code_fill): Swap out a 32-bit value
+ when jumping over bytes.
+ * object.cc: Instantiate Object::read_section_data.
+ * debug.h: Include <cstring>
+ * dwarf_reader.cc: Include <algorithm>
+ * main.cc: Include <cstring>.
+ * options.cc: Include <cstring>.
+ * output.cc: Include <cstring>.
+ * script.cc: Include <cstring>.
+ * script.h: Include <string>.
+ * symtab.cc: Include <cstring> and <algorithm>.
+ * target-select.cc: Include <cstring>.
+ * version.cc: Include <string>.
+ * testsuite/testmain.cc: Include <cstdlib>.
+ * configure, config.in: Rebuild.
+
2008-03-25 Ian Lance Taylor <iant@google.com>
* options.cc: Include "../bfd/bfdver.h".
diff --git a/gold/config.in b/gold/config.in
index 81da6aaad33..4f544fc8dc2 100644
--- a/gold/config.in
+++ b/gold/config.in
@@ -64,6 +64,9 @@
/* Define to support 64-bit little-endian targets */
#undef HAVE_TARGET_64_LITTLE
+/* Define if attributes work on C++ templates */
+#undef HAVE_TEMPLATE_ATTRIBUTES
+
/* Define to 1 if you have the <tr1/unordered_map> header file. */
#undef HAVE_TR1_UNORDERED_MAP
diff --git a/gold/configure b/gold/configure
index 45e84d968cb..01cdf169d06 100755
--- a/gold/configure
+++ b/gold/configure
@@ -4666,6 +4666,16 @@ echo "$as_me: error: bad value ${enableval} for --enable-werror" >&2;}
esac
fi;
+# Enable -Wno-format by default when using gcc on mingw
+case "${host}" in
+ *-*-mingw32*)
+ if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+ GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
+ fi
+ ;;
+ *) ;;
+esac
+
# Enable -Werror by default when using gcc
if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
ERROR_ON_WARNING=yes
@@ -6233,6 +6243,63 @@ fi
done
+# gcc 4.3.0 doesn't recognize the printf attribute on a template
+# function. Check for that. This is gcc bug 35546. This test can
+# probably be removed after the bug has been fixed for a while.
+echo "$as_me:$LINENO: checking whether we can use attributes with template functions" >&5
+echo $ECHO_N "checking whether we can use attributes with template functions... $ECHO_C" >&6
+if test "${gold_cv_template_attribute+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+
+template<typename T> extern void foo(const char*, ...)
+ __attribute__ ((__format__ (__printf__, 1, 2)));
+template<typename T> void foo(const char* format, ...) {}
+void bar() { foo<int>("%s\n", "foo"); }
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_cxx_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ gold_cv_template_attribute=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+gold_cv_template_attribute=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $gold_cv_template_attribute" >&5
+echo "${ECHO_T}$gold_cv_template_attribute" >&6
+if test "$gold_cv_template_attribute" = "yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_TEMPLATE_ATTRIBUTES 1
+_ACEOF
+
+fi
+
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
diff --git a/gold/configure.ac b/gold/configure.ac
index e930fd6cb7f..d9d965e1c36 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -244,6 +244,22 @@ AC_CHECK_HEADERS(tr1/unordered_set tr1/unordered_map)
AC_CHECK_HEADERS(ext/hash_map ext/hash_set)
AC_CHECK_FUNCS(mallinfo)
+# gcc 4.3.0 doesn't recognize the printf attribute on a template
+# function. Check for that. This is gcc bug 35546. This test can
+# probably be removed after the bug has been fixed for a while.
+AC_CACHE_CHECK([whether we can use attributes with template functions],
+[gold_cv_template_attribute],
+[AC_COMPILE_IFELSE([
+template<typename T> extern void foo(const char*, ...)
+ __attribute__ ((__format__ (__printf__, 1, 2)));
+template<typename T> void foo(const char* format, ...) {}
+void bar() { foo<int>("%s\n", "foo"); }
+], [gold_cv_template_attribute=yes], [gold_cv_template_attribute=no])])
+if test "$gold_cv_template_attribute" = "yes"; then
+ AC_DEFINE(HAVE_TEMPLATE_ATTRIBUTES, 1,
+ [Define if attributes work on C++ templates])
+fi
+
AC_LANG_POP(C++)
AM_MAINTAINER_MODE
diff --git a/gold/debug.h b/gold/debug.h
index 9bc9c855110..8428dc81f07 100644
--- a/gold/debug.h
+++ b/gold/debug.h
@@ -23,6 +23,8 @@
#ifndef GOLD_DEBUG_H
#define GOLD_DEBUG_H
+#include <cstring>
+
#include "parameters.h"
#include "errors.h"
diff --git a/gold/dwarf_reader.cc b/gold/dwarf_reader.cc
index f2ae53a955f..7ce6c7effe2 100644
--- a/gold/dwarf_reader.cc
+++ b/gold/dwarf_reader.cc
@@ -22,6 +22,8 @@
#include "gold.h"
+#include <algorithm>
+
#include "elfcpp_swap.h"
#include "dwarf.h"
#include "object.h"
diff --git a/gold/gold.h b/gold/gold.h
index b34e0320b06..1b1a84c1b02 100644
--- a/gold/gold.h
+++ b/gold/gold.h
@@ -157,13 +157,21 @@ gold_error(const char* msg, ...) ATTRIBUTE_PRINTF_1;
extern void
gold_warning(const char* msg, ...) ATTRIBUTE_PRINTF_1;
+// Work around a bug in gcc 4.3.0. http://gcc.gnu.org/PR35546 . This
+// can probably be removed after the bug has been fixed for a while.
+#ifdef HAVE_TEMPLATE_ATTRIBUTES
+#define TEMPLATE_ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF_4
+#else
+#define TEMPLATE_ATTRIBUTE_PRINTF_4
+#endif
+
// This function is called to issue an error at the location of a
// reloc.
template<int size, bool big_endian>
extern void
gold_error_at_location(const Relocate_info<size, big_endian>*,
size_t, off_t, const char* format, ...)
- ATTRIBUTE_PRINTF_4;
+ TEMPLATE_ATTRIBUTE_PRINTF_4;
// This function is called to issue a warning at the location of a
// reloc.
@@ -171,7 +179,7 @@ template<int size, bool big_endian>
extern void
gold_warning_at_location(const Relocate_info<size, big_endian>*,
size_t, off_t, const char* format, ...)
- ATTRIBUTE_PRINTF_4;
+ TEMPLATE_ATTRIBUTE_PRINTF_4;
// This function is called to report an undefined symbol.
template<int size, bool big_endian>
diff --git a/gold/main.cc b/gold/main.cc
index e4f9003b215..2966d0351ed 100644
--- a/gold/main.cc
+++ b/gold/main.cc
@@ -22,9 +22,12 @@
#include "gold.h"
+#include <cstring>
+
#ifdef HAVE_MALLINFO
#include <malloc.h>
#endif
+
#include "libiberty.h"
#include "script.h"
diff --git a/gold/object.cc b/gold/object.cc
index 6c81f231bc6..378238d3fdc 100644
--- a/gold/object.cc
+++ b/gold/object.cc
@@ -1546,8 +1546,35 @@ make_elf_object(const std::string& name, Input_file* input_file, off_t offset,
}
}
-// Instantiate the templates we need. We could use the configure
-// script to restrict this to only the ones for implemented targets.
+// Instantiate the templates we need.
+
+#ifdef HAVE_TARGET_32_LITTLE
+template
+void
+Object::read_section_data<32, false>(elfcpp::Elf_file<32, false, Object>*,
+ Read_symbols_data*);
+#endif
+
+#ifdef HAVE_TARGET_32_BIG
+template
+void
+Object::read_section_data<32, true>(elfcpp::Elf_file<32, true, Object>*,
+ Read_symbols_data*);
+#endif
+
+#ifdef HAVE_TARGET_64_LITTLE
+template
+void
+Object::read_section_data<64, false>(elfcpp::Elf_file<64, false, Object>*,
+ Read_symbols_data*);
+#endif
+
+#ifdef HAVE_TARGET_64_BIG
+template
+void
+Object::read_section_data<64, true>(elfcpp::Elf_file<64, true, Object>*,
+ Read_symbols_data*);
+#endif
#ifdef HAVE_TARGET_32_LITTLE
template
diff --git a/gold/options.cc b/gold/options.cc
index 58ac9cf9ac5..b6e4711881c 100644
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -23,6 +23,7 @@
#include "gold.h"
#include <cstdlib>
+#include <cstring>
#include <vector>
#include <iostream>
#include <sys/stat.h>
diff --git a/gold/output.cc b/gold/output.cc
index 3a11aa48e80..d4fc2a7a9a3 100644
--- a/gold/output.cc
+++ b/gold/output.cc
@@ -23,6 +23,7 @@
#include "gold.h"
#include <cstdlib>
+#include <cstring>
#include <cerrno>
#include <fcntl.h>
#include <unistd.h>
diff --git a/gold/script.cc b/gold/script.cc
index b8ecf9d9acf..a808b2e31d1 100644
--- a/gold/script.cc
+++ b/gold/script.cc
@@ -22,11 +22,12 @@
#include "gold.h"
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <fnmatch.h>
#include <string>
#include <vector>
-#include <cstdio>
-#include <cstdlib>
#include "filenames.h"
#include "elfcpp.h"
diff --git a/gold/script.h b/gold/script.h
index 26abd463ac4..af0f53cb4ae 100644
--- a/gold/script.h
+++ b/gold/script.h
@@ -31,6 +31,7 @@
#define GOLD_SCRIPT_H
#include <cstdio>
+#include <string>
#include <vector>
#include "script-sections.h"
diff --git a/gold/symtab.cc b/gold/symtab.cc
index 3bd38337179..5ad5ae83c71 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -22,7 +22,9 @@
#include "gold.h"
+#include <cstring>
#include <stdint.h>
+#include <algorithm>
#include <set>
#include <string>
#include <utility>
diff --git a/gold/target-select.cc b/gold/target-select.cc
index 092a1df46fa..b81f5a28ea8 100644
--- a/gold/target-select.cc
+++ b/gold/target-select.cc
@@ -22,6 +22,8 @@
#include "gold.h"
+#include <cstring>
+
#include "elfcpp.h"
#include "target-select.h"
diff --git a/gold/testsuite/testmain.cc b/gold/testsuite/testmain.cc
index 47c59b60745..ac99000edc7 100644
--- a/gold/testsuite/testmain.cc
+++ b/gold/testsuite/testmain.cc
@@ -22,6 +22,8 @@
#include "gold.h"
+#include <cstdlib>
+
#include "test.h"
using namespace gold_testsuite;
diff --git a/gold/version.cc b/gold/version.cc
index 9e3ec2877a2..4b034b99d3c 100644
--- a/gold/version.cc
+++ b/gold/version.cc
@@ -22,6 +22,8 @@
#include "gold.h"
+#include <string>
+
#include "../bfd/bfdver.h"
namespace gold
diff --git a/gold/x86_64.cc b/gold/x86_64.cc
index 26f73480924..973787fe7d1 100644
--- a/gold/x86_64.cc
+++ b/gold/x86_64.cc
@@ -2161,7 +2161,7 @@ Target_x86_64::do_code_fill(section_size_type length) const
// Build a jmpq instruction to skip over the bytes.
unsigned char jmp[5];
jmp[0] = 0xe9;
- elfcpp::Swap_unaligned<64, false>::writeval(jmp + 1, length - 5);
+ elfcpp::Swap_unaligned<32, false>::writeval(jmp + 1, length - 5);
return (std::string(reinterpret_cast<char*>(&jmp[0]), 5)
+ std::string(length - 5, '\0'));
}