This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Warn rather than error when duplicate version assignments occur
ClosedPublic

Authored by MaskRay on Jul 11 2019, 1:00 AM.

Details

Summary

In lvm2, libdevmapper.so is linked with a version script with duplicate
version assignments:

DM_1_02_138 { global: ... dm_bitset_parse_list; ... };
DM_1_02_129 { global: ... dm_bitset_parse_list; ... };

ld.bfd silently accepts this while gold issues a warning. We currently
error, thus inhibit producing the executable. Change the error to
warning to allow this case, and improve the message.

There are some cases where ld.bfd error
anonymous version tag cannot be combined with other version tags
but we just warn. It is probably OK for now.

Diff Detail

Repository
rL LLVM

Event Timeline

MaskRay created this revision.Jul 11 2019, 1:00 AM
ruiu added inline comments.Jul 11 2019, 1:06 AM
ELF/SymbolTable.cpp
212–214 ↗(On Diff #209140)

Is there any way to do early-continue to reduce indentation?

215 ↗(On Diff #209140)

I would inline this and remove the variable.

grimar added inline comments.Jul 11 2019, 1:15 AM
test/ELF/version-script-reassign.s
23 ↗(On Diff #209140)

Does it make sence to print the old version of foo in this message too?
like

symbol 'foo' of version X was reassigned to version 'Y'

MaskRay updated this revision to Diff 209143.Jul 11 2019, 1:52 AM
MaskRay edited the summary of this revision. (Show Details)

Improve warning message.
Update tests.

Note this doesn't fix PR38549, but it is related. And I can fix it in another change

MaskRay marked 3 inline comments as done.Jul 11 2019, 1:55 AM
MaskRay updated this revision to Diff 209148.Jul 11 2019, 2:37 AM

Delete %t2w.s which will be included in my next change

grimar accepted this revision.Jul 11 2019, 2:45 AM

LGTM, but please wait until someone else take another look too.

ELF/SymbolTable.cpp
227 ↗(On Diff #209148)

Seems you can omit the conversion to .str(), since warn takes const Twine&:

warn("attempt to reassign symbol '" + ver.name + "' of " +
      getName(sym->versionId) + " to " + getName(versionId));
This revision is now accepted and ready to land.Jul 11 2019, 2:45 AM
MaskRay updated this revision to Diff 209151.Jul 11 2019, 2:51 AM

Delete redundant .str()

ruiu accepted this revision.Jul 11 2019, 3:29 AM

LGTM

ELF/SymbolTable.cpp
204 ↗(On Diff #209151)

It looks like this function doesn't capture anything, so I believe you can remove &.

MaskRay updated this revision to Diff 209163.Jul 11 2019, 4:07 AM

Remove & from the capture

MaskRay marked 2 inline comments as done.Jul 11 2019, 4:08 AM
This revision was automatically updated to reflect the committed changes.