This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Implemented --no-undefined-version flag
ClosedPublic

Authored by grimar on Jun 27 2016, 2:57 AM.

Details

Summary

The GNU ld option --no-undefined-version is defined as follows:

Normally when a symbol has an undefined version, the linker will
ignore it.  This option disallows symbols with undefined version
and a fatal error will be issued instead.

Description in not very clear in my opinion about what it should do.
Fortunately, Ian Lance Tailor leaved a message in binutils maillist
(https://sourceware.org/ml/binutils/2010-01/msg00092.html)

From there:
"what the option actually does is this:

For each version defined in a version script:

for each global symbol pattern in that version listed in the script:
  if the pattern is a literal string--not a wildcard pattern:
    if the pattern does not match any symbol defined in the link:
      give an error.

In other words, the option does not check for symbols with undefined
versions. It checks for cases where a version script explicitly lists
a symbol, but the symbol is not defined."

Patch implements that behavior. This fixes PR27448.

Diff Detail

Event Timeline

grimar updated this revision to Diff 61950.Jun 27 2016, 2:57 AM
grimar retitled this revision from to [ELF] - Implemented --no-undefined-version flag.
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar.
ruiu added inline comments.Jun 27 2016, 6:47 AM
ELF/Options.td
112 ↗(On Diff #61950)
"Report version scripts that refer nonexistent symbols."
ELF/SymbolTable.cpp
619–622

This can be

if (!B || B->isUndefined()) {
  if (Config->NoUndefinedVersion)
    error("version script refers an undefined symbol: " + Name);
  continue;
}

?

(is "version script lists not defined symbol" the error message that gold uses?)

grimar added inline comments.Jun 27 2016, 6:59 AM
ELF/Options.td
112 ↗(On Diff #61950)

nonexistent != undefined, but we also report about undefined ones (that is also what gold do).

"Report version scripts that refer non defines symbols." ?

ELF/SymbolTable.cpp
619–622

Yes, I think this can be, there is no point to assign version to undefined symbol I think.

gold uses something like "gold: error: version script assignment of LIBSAMPLE_3.0 to symbol d failed: symbol not defined".

ruiu added inline comments.Jun 27 2016, 7:02 AM
ELF/Options.td
112 ↗(On Diff #61950)

How about "Report version scripts that refer undefined symbols." Strictly speaking, we may not have an ELF undefined symbol here, but the fact that a symbol is not defined is true.

grimar added inline comments.Jun 27 2016, 7:05 AM
ELF/Options.td
112 ↗(On Diff #61950)

Ok.

grimar updated this revision to Diff 62060.Jun 27 2016, 11:20 PM
grimar marked 2 inline comments as done.
  • Addressed review comments.
ruiu accepted this revision.Jun 27 2016, 11:34 PM
ruiu edited edge metadata.

LGTM with a nit.

ELF/SymbolTable.cpp
621

Please change the error message to be the same as gold. I think gold's error message is better.

This revision is now accepted and ready to land.Jun 27 2016, 11:34 PM
This revision was automatically updated to reflect the committed changes.
grimar marked an inline comment as done.
grimar updated this revision to Diff 62367.Jun 30 2016, 8:27 AM
grimar edited edge metadata.
grimar removed rL LLVM as the repository for this revision.

That probably looks a bit better. May be a wrong place for Reverser,
or may be we have something like that in LLVM already ? I did not find.

Uploaded diff to wrong page, sorry.