Skip to content

Commit 1a221d3

Browse files
author
Cary Coutant
committed
Fix issues with gold undefined symbol diagnostics.
PR binutils/15435 complains that gold issues a visibility error for an weak undefined symbol with hidden visibility. The message should be suppressed if the symbol is a weak undef. An earlier patch to add an extra note about key functions when a class's vtable symbol is undefined missed a case where the reference to the vtable came from a shared library. This patch moves the check to a lower-level routine that catches both cases. gold/ 2014-02-05 Cary Coutant <[email protected]> * errors.cc (Errors::undefined_symbol): Move undef vtable symbol check to here. * target-reloc.h (is_strong_undefined): New function. (relocate_section): Move undef vtable symbol check from here. Check for is_strong_undefined.
1 parent e889f0a commit 1a221d3

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

Diff for: gold/ChangeLog

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2014-02-05 Cary Coutant <[email protected]>
2+
3+
Fix issues with gold undefined symbol diagnostics.
4+
5+
PR binutils/15435
6+
* errors.cc (Errors::undefined_symbol): Move undef vtable symbol
7+
check to here.
8+
* target-reloc.h (is_strong_undefined): New function.
9+
(relocate_section): Move undef vtable symbol check from here.
10+
Check for is_strong_undefined.
11+
112
2014-02-05 Cary Coutant <[email protected]>
213

314
Fix problems with the --dynamic-list option.

Diff for: gold/errors.cc

+5
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ Errors::undefined_symbol(const Symbol* sym, const std::string& location)
193193
fprintf(stderr,
194194
_("%s: %s: undefined reference to '%s', version '%s'\n"),
195195
location.c_str(), zmsg, sym->demangled_name().c_str(), version);
196+
197+
if (sym->is_cxx_vtable())
198+
gold_info(_("%s: the vtable symbol may be undefined because "
199+
"the class is missing its key function"),
200+
program_name);
196201
}
197202

198203
// Issue a debugging message.

Diff for: gold/target-reloc.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ class Default_comdat_behavior
144144
}
145145
};
146146

147+
inline bool
148+
is_strong_undefined(const Symbol* sym)
149+
{
150+
return sym->is_undefined() && sym->binding() != elfcpp::STB_WEAK;
151+
}
152+
147153
// Give an error for a symbol with non-default visibility which is not
148154
// defined locally.
149155

@@ -411,16 +417,10 @@ relocate_section(
411417
}
412418

413419
if (issue_undefined_symbol_error(sym))
414-
{
415-
gold_undefined_symbol_at_location(sym, relinfo, i, offset);
416-
if (sym->is_cxx_vtable())
417-
gold_info(_("%s: the vtable symbol may be undefined because "
418-
"the class is missing its key function"),
419-
program_name);
420-
}
420+
gold_undefined_symbol_at_location(sym, relinfo, i, offset);
421421
else if (sym != NULL
422422
&& sym->visibility() != elfcpp::STV_DEFAULT
423-
&& (sym->is_undefined() || sym->is_from_dynobj()))
423+
&& (is_strong_undefined(sym) || sym->is_from_dynobj()))
424424
visibility_error(sym);
425425

426426
if (sym != NULL && sym->has_warning())

0 commit comments

Comments
 (0)