This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Fix for: Bug 30521 - lld exits non-zero return value linking a library with no entry symbol
ClosedPublic

Authored by grimar on Sep 26 2016, 6:39 AM.

Details

Summary

PR30521 was about linking shared library. After r282295 code when linking -shared produced
"entry symbol not found" warning, what in combination with --fatal-errors failed linkage.

Patch fixes logic (and adds testcases) to follow next rules:

  • If entry was specified and not found report warning.
  • If entry was not specified then:
    1. Emit warning if not -shared.
    2. Do not emit warning if -shared.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar updated this revision to Diff 72475.Sep 26 2016, 6:39 AM
grimar retitled this revision from to [ELF] - Fix for: Bug 30521 - lld exits non-zero return value linking a library with no entry symbol.
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, emaste, evgeny777.

I'm not sure this is right: shared libraries normally don't use entry but they can in some cases - for example I think glibc's rtld is built with an entry point and can be executed directly. FreeBSD's rtld has some commented-out build infrastructure to build with entry but it is not used in the default case.

My guess at the logic would be: not shared produces a warning for missing entry. Shared case never emits a warning. Set entry if specified, if not specified set to zero with no warning.

grimar added a comment.EditedSep 26 2016, 7:36 AM

I'm not sure this is right: shared libraries normally don't use entry but they can in some cases - for example I think glibc's rtld is built with an entry point and can be executed directly. FreeBSD's rtld has some commented-out build infrastructure to build with entry but it is not used in the default case.

My guess at the logic would be: not shared produces a warning for missing entry. Shared case never emits a warning. Set entry if specified, if not specified set to zero with no warning.

I am not sure we do not want to print something in case if entry was specified but not found then. That can hide a mistype for example.

So ideally behavior that seems to be the most correct is:

  • If entry was specified and not found report warning.
  • If entry was not specified then:
    1. Emit warning if not -shared.
    2. Do not emit warning if -shared.
grimar updated this revision to Diff 72488.Sep 26 2016, 8:06 AM
grimar updated this object.
  • Updated.
ruiu edited edge metadata.Sep 26 2016, 9:57 AM

I think this conflicts with https://reviews.llvm.org/D24899.

ruiu accepted this revision.Sep 26 2016, 11:09 AM
ruiu edited edge metadata.

LGTM

This revision is now accepted and ready to land.Sep 26 2016, 11:09 AM
This revision was automatically updated to reflect the committed changes.