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-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".
/* 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
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
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'
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
#ifndef GOLD_DEBUG_H
#define GOLD_DEBUG_H
+#include <cstring>
+
#include "parameters.h"
#include "errors.h"
#include "gold.h"
+#include <algorithm>
+
#include "elfcpp_swap.h"
#include "dwarf.h"
#include "object.h"
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.
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>
#include "gold.h"
+#include <cstring>
+
#ifdef HAVE_MALLINFO
#include <malloc.h>
#endif
+
#include "libiberty.h"
#include "script.h"
}
}
-// 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
#include "gold.h"
#include <cstdlib>
+#include <cstring>
#include <vector>
#include <iostream>
#include <sys/stat.h>
#include "gold.h"
#include <cstdlib>
+#include <cstring>
#include <cerrno>
#include <fcntl.h>
#include <unistd.h>
#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"
#define GOLD_SCRIPT_H
#include <cstdio>
+#include <string>
#include <vector>
#include "script-sections.h"
#include "gold.h"
+#include <cstring>
#include <stdint.h>
+#include <algorithm>
#include <set>
#include <string>
#include <utility>
#include "gold.h"
+#include <cstring>
+
#include "elfcpp.h"
#include "target-select.h"
#include "gold.h"
+#include <cstdlib>
+
#include "test.h"
using namespace gold_testsuite;
#include "gold.h"
+#include <string>
+
#include "../bfd/bfdver.h"
namespace gold
// 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'));
}