Skip to content

Conversation

@WalterBright
Copy link
Member

Because #6956 has some controversy, I factored out the uncontroversial bits into this one.

I.e. redo Obj.funcptr() to make its name reflective of what it does, and remove its dependency on the specifics of the identifier so it can be ported to other platforms.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

/***************************************
* Stuff pointer to function in its own segment.
* Used for static ctor and dtor lists.
* Set up function to be called as static constructor on program
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stuff pointer to function in its own segment.

This is useful information.
please keep it.

@dlang-bot dlang-bot merged commit ffe62e4 into dlang:master Jul 3, 2017
@WalterBright WalterBright deleted the setModuleCtorDtor branch July 4, 2017 00:44
@MartinNowak
Copy link
Member

MartinNowak commented Aug 16, 2017

See https://www.airs.com/blog/archives/51 @WalterBright for Info on ELF ctors/dtors.
Basically this

void foo() __attribute__((constructor, destructor));
void foo() {}

will generate two entries, one in the .init_array section (using DT_INIT_ARRAY), one in .fini_array (using DT_FINI_ARRAY).

  [ 4] .init_array       INIT_ARRAY       0000000000000000  00000048
       0000000000000008  0000000000000008  WA       0     0     8
  [ 6] .fini_array       FINI_ARRAY       0000000000000000  00000050
       0000000000000008  0000000000000008  WA       0     0     8

BTW, I find the function name setModuleCtorDtor misleading, as this is NOT using the module ctor/dtor mechanism, but the earlier C ctors/dtors one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants