This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Initial support for symbols visibility
AbandonedPublic

Authored by davide on Mar 13 2015, 11:35 AM.

Details

Summary

This can't be committed until I modify llvm-objdump -t to print visibility properly for ELF symbols, but the lld bits should be all there, so this is ready for review.
I'll add an unit test once I'll figure out the llvm-objdump bits properly.

P.S. This also makes _GLOBAL_OFFSET_TABLE hidden by default. Probably should be committed separately.

Diff Detail

Event Timeline

davide updated this revision to Diff 21942.Mar 13 2015, 11:35 AM
davide retitled this revision from to [ELF] Initial support for symbols visibility.
davide updated this object.
davide edited the test plan for this revision. (Show Details)
davide set the repository for this revision to rL LLVM.
davide added a project: lld.
davide added subscribers: Unknown Object (MLST), emaste.
ruiu accepted this revision.Mar 13 2015, 12:12 PM
ruiu edited edge metadata.

Maybe this patch is too small to review since it doesn't include any use of the newly-added member. If you have another patch to use the member, please send it for review.

This revision is now accepted and ready to land.Mar 13 2015, 12:12 PM

hmm, maybe I'm misunderstanding what you say but this patch sets also visibility for the global offset table atom. What is unused?

ruiu added a comment.Mar 13 2015, 12:37 PM

Apologies, I missed the change you made to ELF/Atom.h. LGTM.

shankarke requested changes to this revision.Mar 13 2015, 10:19 PM
shankarke added a reviewer: shankarke.
shankarke added a subscriber: shankarke.

I dont think we need a separate visibility field in DefinedAtoms. The visibility is already modeled as part of Scope.

<snip>

/// The scope in which this atom is acessible to other atoms.
enum Scope {
¦ scopeTranslationUnit,  ///< Accessible only to atoms in the same translation
¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦      ///  unit (e.g. a C static).
¦ scopeLinkageUnit,      ///< Accessible to atoms being linked but not visible
¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦      ///  to runtime loader (e.g. visibility=hidden).
¦ scopeGlobal            ///< Accessible to all atoms and visible to runtime
¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦      ///  loader (e.g. visibility=default).
};

</end snip>

This revision now requires changes to proceed.Mar 13 2015, 10:19 PM

Yes protected need to be added to this as it's missing.

davide updated this revision to Diff 21991.Mar 14 2015, 1:23 PM
davide edited edge metadata.
davide removed rL LLVM as the repository for this revision.

Updated to address Shankar and Joerg comments

Forgot to mention about your previous change, that you need to add changes to ReaderWriterYAML(YAML Testing) and ReaderNative and WriterNative(Native formats) too.

Adding other reviewers here.

lib/ReaderWriter/ELF/SectionChunks.h
790

This is very confusing, if you see line 771. We set binding for local symbols to be STB_LOCAL if scope is set to scopeTranslationUnit, so visibility would need to be set as STV_DEFAULT ? No ?

804

could this be sym.st_other = sym.st_other & ~0x3 |llvm::ELF::STV_HIDDEN ?

814

assert

davide abandoned this revision.May 14 2015, 5:32 PM