This is an archive of the discontinued LLVM Phabricator instance.

Add some dllexport tests
ClosedPublic

Authored by wristow on Mar 31 2016, 11:12 PM.

Details

Summary

Adds some dllexport tests to verify that:

  • Variables in bss are exported appropriately
  • Non-dllexport symbols aliased to dllexport symbols are not exported
  • Symbols declared as dllexport but are not defined are not exported

We plan to enable dllimport/dllexport support for the PS4, and these
additional tests are for points we noticed in our internal testing.

Diff Detail

Repository
rL LLVM

Event Timeline

wristow updated this revision to Diff 52326.Mar 31 2016, 11:12 PM
wristow retitled this revision from to Add some dllexport tests.
wristow updated this object.
wristow added reviewers: rnk, majnemer, silvas.
wristow added a subscriber: llvm-commits.
silvas edited edge metadata.Apr 1 2016, 5:21 PM

This would be easier to review as separate patches.

silvas added a comment.Apr 1 2016, 5:23 PM

(by that I mean that I can't really review it without it being separate patches with clear explanations; Reid or other people knowledgeable about this stuff can probably make a judgment at a glance)

I'll explain, but maybe Reid or someone else will jump in.

The three items being added, and explanations, are:

  • Variables in bss are exported appropriately

    Added a definition of an exported new variable WeakVar3, which is identical to the existing (exported) variable WeakVar1, except for the value it is initialized to. WeakVar3 is initialized to 0, making it a candidate for the bss section (WeakVar1 was non-zero, specifically 1, so it could not be in bss). Previously, there weren't any bss variables that were exported, and with this new test, there is one. So we're making sure the dllexport attribute for a variable in bss is handled, by checking that WeakVar3 is in .bss, and that WeakVar3 appears in the export table.
  • Non-dllexport symbols aliased to dllexport symbols are not exported

    The function f1() is exported, and an alias for f1 has been defined, where the aliasing symbol is _not_ exported, specifically aliasNotExported. The test makes sure that aliasNotExported doesn't appear in the export table. I.e., it makes sure that the dllexport attribute from f1 doesn't incorrectly "propagate through" to aliasNotExported. (Note that the dual of this test already existed, in that there is an unexported function, notExported(), and an alias for notExported was defined (specifically alias3), and alias3 _is_ exported. The test checks that alias3 appears in the export table. With the proposed change, we will also check the other way around.)
  • Symbols declared as dllexport but are not defined are not exported

    The variable exportedButNotDefinedVariable has been added, and declared as dllexport (and it is used), but no defition of the variable appears. Similarly, the function exportedButNotDefinedFunction() has been declared as dllexport (and used), but there isn't a definition. Even though they are declared as dllexport, since there is no definition, they cannot be exported. So they should not appear in the export table. The test checks that they don't appear in the table.
rnk accepted this revision.Apr 4 2016, 11:29 AM
rnk edited edge metadata.

These are all reasonable test changes to tighten things up. Sean, do you mind applying the patch?

This revision is now accepted and ready to land.Apr 4 2016, 11:29 AM
This revision was automatically updated to reflect the committed changes.