This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Implemented version script hierarchies.
ClosedPublic

Authored by grimar on Jun 21 2016, 7:44 AM.

Details

Summary

Patch implements hierarchies for version scripts.
This allows to handle script files with dependencies, like next one has:

LIBSAMPLE_1.0{
  global:
  a;
};

LIBSAMPLE_2.0
{
  global:
  b;
}LIBSAMPLE_1.0;

Diff Detail

Event Timeline

grimar updated this revision to Diff 61371.Jun 21 2016, 7:44 AM
grimar retitled this revision from to [ELF] - Implemented version script hierarchies..
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar.
grimar updated this revision to Diff 61374.Jun 21 2016, 7:49 AM
  • Improved testcase.
emaste added a subscriber: emaste.Jun 21 2016, 10:27 AM
davide added a subscriber: davide.Jun 21 2016, 11:15 AM
davide added inline comments.
ELF/OutputSections.cpp
1510

It could be just me, but I'd rather prefer this -1 to be assigned to a variable or adding a comment to explain what this code does.

ruiu added inline comments.Jun 21 2016, 3:49 PM
ELF/OutputSections.cpp
1478

static size_t?

ELF/SymbolListFile.cpp
97

I'd do

if (!Version.empty() && peek() != ";")
  Config->SymbolVersions.back().Dependency = next();
expect(";");
grimar updated this revision to Diff 61517.Jun 22 2016, 1:58 AM
grimar marked 3 inline comments as done.
  • Addressed review comments.
  • Renamed "dependency" to "parent"
ELF/OutputSections.cpp
1478

Right..

1510

Ok, added comment. It is in common in versioning relative methods around here, btw.

ELF/SymbolListFile.cpp
97

Done.

ruiu accepted this revision.Jun 22 2016, 2:49 AM
ruiu edited edge metadata.

LGTM with a few nits.

ELF/Config.h
2

Yup, I think this is a better name. I'd move this line after Name since Name is more important.

ELF/OutputSections.cpp
23–1

Update comment.

28

I don't think this comment helps reader to understand this piece of code. Instead, we could avoid [-1] by doing this, but I'd think your code is easier to read. So I'd just do without comment.

Verdaux->vda_name = StrTabOffset;
if (HasParent) {
  Verdaux->vda_next = sizeof(Elf_Verdaux);
  ++Verdaux;
  Verdaux->vda_name = getVersionNameStrTabOffset(ParentName);
  Verdaux->vda_next = 0;
} else {
  Verdaux->vda_next = 0;
}
++Verdaux;

One thing I would do is to not do early return in this function. I believe this is easier to read in this case.

This revision is now accepted and ready to land.Jun 22 2016, 2:49 AM

Ok, thanks !
I`ll commit right after D21552 be landed as this one's testcase relies on it heavily.

grimar marked an inline comment as done.Jun 22 2016, 3:12 AM
grimar added inline comments.
ELF/OutputSections.cpp
28

btw, may be ?

Verdaux->vda_name = StrTabOffset;
if (HasParent) {
  Verdaux->vda_next = sizeof(Elf_Verdaux);
  ++Verdaux;
  Verdaux->vda_name = getVersionNameStrTabOffset(ParentName);
} 

Verdaux->vda_next = 0;
++Verdaux;
ruiu added inline comments.Jun 22 2016, 3:18 AM
ELF/OutputSections.cpp
28

It might be easier to read, but I'm okay with either one. It's up to you.

This revision was automatically updated to reflect the committed changes.
grimar marked an inline comment as done.