diff options
author | Cary Coutant <ccoutant@google.com> | 2010-07-09 01:34:31 +0000 |
---|---|---|
committer | Cary Coutant <ccoutant@google.com> | 2010-07-09 01:34:31 +0000 |
commit | ce279a62c420e20c2d33e89641b6d9ed581a90c2 (patch) | |
tree | 10299dc3eb7f6c0fddb969fa11ae0dc079165aa0 /gold/testsuite | |
parent | 2ee2fea80422d6e481541aa20a5d4e26ca8f0192 (diff) | |
download | gdb-ce279a62c420e20c2d33e89641b6d9ed581a90c2.zip gdb-ce279a62c420e20c2d33e89641b6d9ed581a90c2.tar.gz gdb-ce279a62c420e20c2d33e89641b6d9ed581a90c2.tar.bz2 |
* resolve.cc (Symbol_table::resolve): Remember whether undef was
weak when resolving to a dynamic def.
(Symbol_table::should_override): Add adjust_dyndef flag; set it
for weak undef/dynamic def cases. Adjust callers.
* symtab.cc (Symbol::init_fields): Initialize undef_binding_set_ and
undef_binding_weak_.
(Symbol_table::sized_write_globals): Adjust symbol binding.
(Symbol_table::sized_write_symbol): Add binding parameter.
* symtab.h (Symbol::set_undef_binding): New method.
(Symbol::is_undef_binding_weak): New method.
(Symbol::undef_binding_set_, Symbol::undef_binding_weak_): New members.
(Symbol_table::should_override): Add new parameter.
(Symbol_table::sized_write_symbol): Add new parameter.
* testsuite/weak_undef_file1.cc: Add new test case.
* testsuite/weak_undef_file2.cc: Fix header comment.
* testsuite/weak_undef_test.cc: Add new test case.
Diffstat (limited to 'gold/testsuite')
-rw-r--r-- | gold/testsuite/weak_undef_file1.cc | 10 | ||||
-rw-r--r-- | gold/testsuite/weak_undef_file2.cc | 4 | ||||
-rw-r--r-- | gold/testsuite/weak_undef_test.cc | 17 |
3 files changed, 27 insertions, 4 deletions
diff --git a/gold/testsuite/weak_undef_file1.cc b/gold/testsuite/weak_undef_file1.cc index 743eea6..fd28870 100644 --- a/gold/testsuite/weak_undef_file1.cc +++ b/gold/testsuite/weak_undef_file1.cc @@ -1,6 +1,6 @@ // weak_undef_file1.cc -- test handling of weak undefined symbols for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright 2008, 2010 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. @@ -33,13 +33,19 @@ // so that we can detect whether the symbol was left for runtime // resolution. - #include <cstdio> #include "weak_undef.h" int is_such_symbol_ = 1; +// We also define a symbol that is not defined by the alternate +// library. The main program contains a weak reference to this +// symbol, and tests that the reference remains weak even after +// the definition was found at link time. + +int link_time_only = 1; + extern int v2 __attribute__ ((weak)); int *v3 = &v2; diff --git a/gold/testsuite/weak_undef_file2.cc b/gold/testsuite/weak_undef_file2.cc index 610c25e..33701b2 100644 --- a/gold/testsuite/weak_undef_file2.cc +++ b/gold/testsuite/weak_undef_file2.cc @@ -1,6 +1,6 @@ -// weak_undef_file1.cc -- test handling of weak undefined symbols for gold +// weak_undef_file2.cc -- test handling of weak undefined symbols for gold -// Copyright 2008 Free Software Foundation, Inc. +// Copyright 2008, 2010 Free Software Foundation, Inc. // Written by Cary Coutant <ccoutant@google.com>. // This file is part of gold. diff --git a/gold/testsuite/weak_undef_test.cc b/gold/testsuite/weak_undef_test.cc index 962b6bf..880d5cd 100644 --- a/gold/testsuite/weak_undef_test.cc +++ b/gold/testsuite/weak_undef_test.cc @@ -34,14 +34,24 @@ // so that we can detect whether the symbol was left for runtime // resolution. +// Similarly, this file will be linked with a shared library that +// does define a different symbol, and loaded with an alternate +// shared library that does not define that symbol. We check that +// the weak reference remains weak, and that it is resolved to +// zero at runtime. + #include <cstdio> #include "weak_undef.h" extern int no_such_symbol_ __attribute__ ((weak)); +extern int link_time_only __attribute__ ((weak)); + int *p1 = &no_such_symbol_; +int *p2 = &link_time_only; + int v2 = 42; int @@ -85,5 +95,12 @@ main() status = 1; } + if (p2 != NULL) + { + fprintf(stderr, "FAILED weak undef test 6: %s\n", + "p2 is not NULL"); + status = 1; + } + return status; } |