Browse Source

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.
msnyder-reverse-20080609-branch
Ian Lance Taylor 18 years ago
parent
commit
04bf70729d
  1. 24
      gold/ChangeLog
  2. 3
      gold/config.in
  3. 67
      gold/configure
  4. 16
      gold/configure.ac
  5. 2
      gold/debug.h
  6. 2
      gold/dwarf_reader.cc
  7. 12
      gold/gold.h
  8. 3
      gold/main.cc
  9. 31
      gold/object.cc
  10. 1
      gold/options.cc
  11. 1
      gold/output.cc
  12. 5
      gold/script.cc
  13. 1
      gold/script.h
  14. 2
      gold/symtab.cc
  15. 2
      gold/target-select.cc
  16. 2
      gold/testsuite/testmain.cc
  17. 2
      gold/version.cc
  18. 2
      gold/x86_64.cc

24
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".

3
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

67
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'

16
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

2
gold/debug.h

@ -23,6 +23,8 @@
#ifndef GOLD_DEBUG_H
#define GOLD_DEBUG_H
#include <cstring>
#include "parameters.h"
#include "errors.h"

2
gold/dwarf_reader.cc

@ -22,6 +22,8 @@
#include "gold.h"
#include <algorithm>
#include "elfcpp_swap.h"
#include "dwarf.h"
#include "object.h"

12
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>

3
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"

31
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

1
gold/options.cc

@ -23,6 +23,7 @@
#include "gold.h"
#include <cstdlib>
#include <cstring>
#include <vector>
#include <iostream>
#include <sys/stat.h>

1
gold/output.cc

@ -23,6 +23,7 @@
#include "gold.h"
#include <cstdlib>
#include <cstring>
#include <cerrno>
#include <fcntl.h>
#include <unistd.h>

5
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"

1
gold/script.h

@ -31,6 +31,7 @@
#define GOLD_SCRIPT_H
#include <cstdio>
#include <string>
#include <vector>
#include "script-sections.h"

2
gold/symtab.cc

@ -22,7 +22,9 @@
#include "gold.h"
#include <cstring>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <string>
#include <utility>

2
gold/target-select.cc

@ -22,6 +22,8 @@
#include "gold.h"
#include <cstring>
#include "elfcpp.h"
#include "target-select.h"

2
gold/testsuite/testmain.cc

@ -22,6 +22,8 @@
#include "gold.h"
#include <cstdlib>
#include "test.h"
using namespace gold_testsuite;

2
gold/version.cc

@ -22,6 +22,8 @@
#include "gold.h"
#include <string>
#include "../bfd/bfdver.h"
namespace gold

2
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'));
}

Loading…
Cancel
Save