This is an archive of the discontinued LLVM Phabricator instance.

Handle a VersymIndex of 0 as an error
ClosedPublic

Authored by rafael on Dec 14 2017, 10:04 AM.

Details

Reviewers
pcc
Summary

Hi Peter,

I just noticed that the continue this patch deletes was not tested. Trying to add a test I realized that we never put a VER_NDX_LOCAL symbol in the dynamic symbol table. Is there a reason why a linker ever would?

Diff Detail

Event Timeline

rafael created this revision.Dec 14 2017, 10:04 AM
pcc accepted this revision.Dec 14 2017, 11:24 AM

It looks like bfd and gold use this value for undefined symbols in DSOs that do not have version definitions. But at this point we are only dealing with defined symbols.

The Solaris documentation: https://docs.oracle.com/cd/E19120-01/open.solaris/819-0690/chapter6-31/index.html
also talks about this value being used for "A global symbol defined within an object that does not have a SHT_SUNW_verdef version definition section."
but that seems to be specific to their ABI.

Aside from that, I can't see a reason why a linker would deliberately use VER_NDX_LOCAL for a dynamic symbol. It could appear there because of a bug similar to the case where an STB_LOCAL appears in the dynsym. But unless we encounter an example of such a DSO I think we'd be fine erroring out on it.

This LGTM with one nit.

ELF/InputFiles.cpp
811

Can we set VersymIndex to VER_NDX_GLOBAL instead of 0 at the start of the loop body? Then I think this can just be if (VersymIndex != VER_NDX_GLOBAL).

This revision is now accepted and ready to land.Dec 14 2017, 11:24 AM
espindola closed this revision.Mar 14 2018, 3:07 PM
espindola added a subscriber: espindola.

r320817