aboutsummaryrefslogtreecommitdiff
path: root/gold
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2010-07-27 08:22:49 +0000
committerIan Lance Taylor <ian@airs.com>2010-07-27 08:22:49 +0000
commit9691462bab74c130fe4fdfd5b755b1bd89e1444c (patch)
treeecf2d8bae45bc3eadf5dafbc6ad9b044adfb2cea /gold
parentac0b195c018851569c96409a9d13f203f0592535 (diff)
downloadgdb-9691462bab74c130fe4fdfd5b755b1bd89e1444c.zip
gdb-9691462bab74c130fe4fdfd5b755b1bd89e1444c.tar.gz
gdb-9691462bab74c130fe4fdfd5b755b1bd89e1444c.tar.bz2
* testsuite/debug_msg.sh: Test mixed weak/strong symbol behavior.
* gold/testsuite/debug_msg.cc: Likewise. * gold/testsuite/odr_violation1.cc * gold/testsuite/odr_violation2.cc
Diffstat (limited to 'gold')
-rw-r--r--gold/ChangeLog7
-rw-r--r--gold/testsuite/debug_msg.cc10
-rwxr-xr-xgold/testsuite/debug_msg.sh16
-rw-r--r--gold/testsuite/odr_violation1.cc5
-rw-r--r--gold/testsuite/odr_violation2.cc9
5 files changed, 47 insertions, 0 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index c6741b6..ac14538 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,10 @@
+2010-07-27 Jeffrey Yasskin <jyasskin@google.com>
+
+ * testsuite/debug_msg.sh: Test mixed weak/strong symbol behavior.
+ * gold/testsuite/debug_msg.cc: Likewise.
+ * gold/testsuite/odr_violation1.cc
+ * gold/testsuite/odr_violation2.cc
+
2010-07-21 Cary Coutant <ccoutant@google.com>
* merge.h (Output_merge_string::Merged_string): Remove object, shndx,
diff --git a/gold/testsuite/debug_msg.cc b/gold/testsuite/debug_msg.cc
index 9a951f9..1d77bc9 100644
--- a/gold/testsuite/debug_msg.cc
+++ b/gold/testsuite/debug_msg.cc
@@ -59,6 +59,13 @@ class Derived : public Base
void SortAscending(int array[], int size); // in odr_violation1.cc
void SortDescending(int array[], int size); // in odr_violation2.cc
+extern "C" int OverriddenCFunction(int i); // in odr_violation*.cc
+
+inline int SometimesInlineFunction(int i) { // strong in odr_violation2.cc.
+ return i;
+}
+
+
int main()
{
testfn(5);
@@ -75,5 +82,8 @@ int main()
int kSize2 = sizeof(kInput2) / sizeof(int);
SortDescending(kInput2, kSize2);
+ OverriddenCFunction(3);
+ SometimesInlineFunction(3);
+
return 0;
}
diff --git a/gold/testsuite/debug_msg.sh b/gold/testsuite/debug_msg.sh
index 750261e..74b4b05 100755
--- a/gold/testsuite/debug_msg.sh
+++ b/gold/testsuite/debug_msg.sh
@@ -75,6 +75,16 @@ check debug_msg.err "debug_msg.o: in function int testfn<double>(double):.*/debu
check debug_msg.err ": symbol 'Ordering::operator()(int, int)' defined in multiple places (possible ODR violation):"
check debug_msg.err "odr_violation1.cc:5"
check debug_msg.err "odr_violation2.cc:5"
+# We block ODR detection for combinations of C weak and strong
+# symbols, to allow people to use the linker to override things. We
+# still flag it for C++ symbols since those are more likely to be
+# unintentional.
+check_missing debug_msg.err ": symbol 'OverriddenCFunction' defined in multiple places (possible ODR violation):"
+check_missing debug_msg.err "odr_violation1.cc:15"
+check_missing debug_msg.err "odr_violation2.cc:17"
+check debug_msg.err ": symbol 'SometimesInlineFunction(int)' defined in multiple places (possible ODR violation):"
+check debug_msg.err "debug_msg.cc:64"
+check debug_msg.err "odr_violation2.cc:21"
# When linking together .so's, we don't catch the line numbers, but we
# still find all the undefined variables, and the ODR violation.
@@ -84,6 +94,12 @@ check debug_msg_so.err "debug_msg.so: error: undefined reference to 'undef_int'"
check debug_msg_so.err ": symbol 'Ordering::operator()(int, int)' defined in multiple places (possible ODR violation):"
check debug_msg_so.err "odr_violation1.cc:5"
check debug_msg_so.err "odr_violation2.cc:5"
+check_missing debug_msg.err ": symbol 'OverriddenCFunction' defined in multiple places (possible ODR violation):"
+check_missing debug_msg.err "odr_violation1.cc:15"
+check_missing debug_msg.err "odr_violation2.cc:17"
+check debug_msg.err ": symbol 'SometimesInlineFunction(int)' defined in multiple places (possible ODR violation):"
+check debug_msg.err "debug_msg.cc:64"
+check debug_msg.err "odr_violation2.cc:21"
# These messages shouldn't need any debug info to detect:
check debug_msg_ndebug.err "debug_msg_ndebug.so: error: undefined reference to 'undef_fn1()'"
diff --git a/gold/testsuite/odr_violation1.cc b/gold/testsuite/odr_violation1.cc
index 7f6f6d9..6c40496 100644
--- a/gold/testsuite/odr_violation1.cc
+++ b/gold/testsuite/odr_violation1.cc
@@ -10,3 +10,8 @@ class Ordering {
void SortAscending(int array[], int size) {
std::sort(array, array + size, Ordering());
}
+
+extern "C" int OverriddenCFunction(int i) __attribute__ ((weak));
+extern "C" int OverriddenCFunction(int i) {
+ return i;
+}
diff --git a/gold/testsuite/odr_violation2.cc b/gold/testsuite/odr_violation2.cc
index d569279..09940d4 100644
--- a/gold/testsuite/odr_violation2.cc
+++ b/gold/testsuite/odr_violation2.cc
@@ -12,3 +12,12 @@ class Ordering {
void SortDescending(int array[], int size) {
std::sort(array, array + size, Ordering());
}
+
+// This is weak in odr_violation1.cc.
+extern "C" int OverriddenCFunction(int i) {
+ return i * i;
+}
+// This is inline in debug_msg.cc, which makes it a weak symbol too.
+int SometimesInlineFunction(int i) {
+ return i * i;
+}