Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit ede231d

Browse files
authored
Export named globals even in non-relocatable code (#269)
This allows native code to export the address of globals using the normal EMSCRIPTEN_KEEPALIVE mechanism.
1 parent d421109 commit ede231d

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

Diff for: lib/Target/JSBackend/JSBackend.cpp

+9-11
Original file line numberDiff line numberDiff line change
@@ -3695,17 +3695,15 @@ void JSWriter::processConstants() {
36953695
parseConstant(I->getName().str(), I->getInitializer(), I->getAlignment(), false);
36963696
}
36973697
}
3698-
if (Relocatable) {
3699-
for (Module::const_global_iterator II = TheModule->global_begin(),
3700-
E = TheModule->global_end(); II != E; ++II) {
3701-
auto I = &*II;
3702-
if (I->hasInitializer() && !I->hasInternalLinkage()) {
3703-
std::string Name = I->getName().str();
3704-
if (GlobalAddresses.find(Name) != GlobalAddresses.end()) {
3705-
std::string JSName = getJSName(I).substr(1);
3706-
if (Name == JSName) { // don't export things that have weird internal names, that C can't dlsym anyhow
3707-
NamedGlobals[Name] = getGlobalAddress(Name);
3708-
}
3698+
for (Module::const_global_iterator II = TheModule->global_begin(),
3699+
E = TheModule->global_end(); II != E; ++II) {
3700+
auto I = &*II;
3701+
if (I->hasInitializer() && !I->hasInternalLinkage()) {
3702+
std::string Name = I->getName().str();
3703+
if (GlobalAddresses.find(Name) != GlobalAddresses.end()) {
3704+
std::string JSName = getJSName(I).substr(1);
3705+
if (Name == JSName) { // don't export things that have weird internal names, that C can't dlsym anyhow
3706+
NamedGlobals[Name] = getGlobalAddress(Name);
37093707
}
37103708
}
37113709
}

0 commit comments

Comments
 (0)