Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 10 additions & 37 deletions src/rt/sections_android.d
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ struct SectionGroup

@property immutable(FuncTable)[] ehTables() const
{
auto pbeg = cast(immutable(FuncTable)*)&_deh_beg;
auto pend = cast(immutable(FuncTable)*)&_deh_end;
auto pbeg = cast(immutable(FuncTable)*)&__start_deh;
auto pend = cast(immutable(FuncTable)*)&__stop_deh;
return pbeg[0 .. pend - pbeg];
}

Expand All @@ -62,7 +62,10 @@ private:
void initSections()
{
pthread_key_create(&_tlsKey, null);
_sections.moduleGroup = ModuleGroup(getModuleInfos());

auto mbeg = cast(immutable ModuleInfo**)&__start_minfo;
auto mend = cast(immutable ModuleInfo**)&__stop_minfo;
_sections.moduleGroup = ModuleGroup(mbeg[0 .. mend - mbeg]);

auto pbeg = cast(void*)&etext;
auto pend = cast(void*)&_end;
Expand Down Expand Up @@ -148,47 +151,17 @@ ref void[] getTLSBlockAlloc()

__gshared SectionGroup _sections;

// This linked list is created by a compiler generated function inserted
// into the .ctor list by the compiler.
struct ModuleReference
{
ModuleReference* next;
ModuleInfo* mod;
}

extern (C) __gshared immutable(ModuleReference*) _Dmodule_ref; // start of linked list

immutable(ModuleInfo*)[] getModuleInfos()
out (result)
{
foreach(m; result)
assert(m !is null);
}
body
{
size_t len;
immutable(ModuleReference)* mr;

for (mr = _Dmodule_ref; mr; mr = mr.next)
len++;
auto result = (cast(immutable(ModuleInfo)**).malloc(len * size_t.sizeof))[0 .. len];
len = 0;
for (mr = _Dmodule_ref; mr; mr = mr.next)
{ result[len] = mr.mod;
len++;
}
return cast(immutable)result;
}

extern(C)
{
/* Symbols created by the compiler/linker and inserted into the
* object file that 'bracket' sections.
*/
extern __gshared
{
void* _deh_beg;
void* _deh_end;
void* __start_deh;
void* __stop_deh;
void* __start_minfo;
void* __stop_minfo;

size_t etext;
size_t _end;
Expand Down
46 changes: 9 additions & 37 deletions src/rt/sections_solaris.d
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ struct SectionGroup

@property immutable(FuncTable)[] ehTables() const
{
auto pbeg = cast(immutable(FuncTable)*)&_deh_beg;
auto pend = cast(immutable(FuncTable)*)&_deh_end;
auto pbeg = cast(immutable(FuncTable)*)&__start_deh;
auto pend = cast(immutable(FuncTable)*)&__stop_deh;
return pbeg[0 .. pend - pbeg];
}

Expand All @@ -58,7 +58,9 @@ private:

void initSections()
{
_sections.moduleGroup = ModuleGroup(getModuleInfos());
auto mbeg = cast(immutable ModuleInfo**)&__start_minfo;
auto mend = cast(immutable ModuleInfo**)&__stop_minfo;
_sections.moduleGroup = ModuleGroup(mbeg[0 .. mend - mbeg]);

auto pbeg = cast(void*)&__dso_handle;
auto pend = cast(void*)&_end;
Expand Down Expand Up @@ -90,47 +92,17 @@ private:

__gshared SectionGroup _sections;

// This linked list is created by a compiler generated function inserted
// into the .ctor list by the compiler.
struct ModuleReference
{
ModuleReference* next;
ModuleInfo* mod;
}

extern (C) __gshared immutable(ModuleReference*) _Dmodule_ref; // start of linked list

immutable(ModuleInfo*)[] getModuleInfos()
out (result)
{
foreach(m; result)
assert(m !is null);
}
body
{
size_t len;
immutable(ModuleReference)* mr;

for (mr = _Dmodule_ref; mr; mr = mr.next)
len++;
auto result = (cast(immutable(ModuleInfo)**).malloc(len * size_t.sizeof))[0 .. len];
len = 0;
for (mr = _Dmodule_ref; mr; mr = mr.next)
{ result[len] = mr.mod;
len++;
}
return cast(immutable)result;
}

extern(C)
{
/* Symbols created by the compiler/linker and inserted into the
* object file that 'bracket' sections.
*/
extern __gshared
{
void* _deh_beg;
void* _deh_end;
void* __start_deh;
void* __stop_deh;
void* __start_minfo;
void* __stop_minfo;
int __dso_handle;
int _end;
}
Expand Down