-048914caa26b34eebabd0423ed48ee3ac34c919c
+adc6eb826f156d0980f0ad9f9efc5c919ec4905e
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
{
if (this->fndecl_ == NULL)
{
- std::string asm_name;
bool is_visible = false;
+ bool is_init_fn = false;
+ Type* rtype = NULL;
if (no->package() != NULL)
;
else if (this->enclosing_ != NULL || Gogo::is_thunk(no))
else if (no->name() == gogo->get_init_fn_name())
{
is_visible = true;
- asm_name = no->name();
+ is_init_fn = true;
}
else if (Gogo::unpack_hidden_name(no->name()) == "main"
&& gogo->is_main_package())
{
if (!this->is_unnamed_type_stub_method_)
is_visible = true;
- Type* rtype = NULL;
if (this->type_->is_method())
rtype = this->type_->receiver()->type();
- asm_name = gogo->function_asm_name(no->name(), NULL, rtype);
}
+ std::string asm_name;
if (!this->asm_name_.empty())
{
asm_name = this->asm_name_;
+
+ // If an assembler name is explicitly specified, there must
+ // be some reason to refer to the symbol from a different
+ // object file.
is_visible = true;
}
+ else if (is_init_fn)
+ {
+ // These names appear in the export data and are used
+ // directly in the assembler code. If we change this here
+ // we need to change Gogo::init_imports.
+ asm_name = no->name();
+ }
+ else
+ asm_name = gogo->function_asm_name(no->name(), NULL, rtype);
// If a function calls the predeclared recover function, we
// can't inline it, because recover behaves differently in a
if ((this->pragmas_ & GOPRAGMA_NOSPLIT) != 0)
disable_split_stack = true;
- // Encode name if asm_name not already set at this point
- if (asm_name.empty())
- asm_name = gogo->unexported_function_asm_name(no->name());
-
// This should go into a unique section if that has been
// requested elsewhere, or if this is a nointerface function.
// We want to put a nointerface function into a unique section
function_asm_name(const std::string& go_name, const Package*,
const Type* receiver);
- // Return the assembler name to use for an unexported function.
- std::string
- unexported_function_asm_name(const std::string& go_name);
-
// Return the name to use for a function descriptor.
std::string
function_descriptor_name(Named_object*);
return go_encode_id(ret);
}
-// Return the assembler name to use for an unexported function.
-// FIXME: This should probably be removed and the callers changed to
-// simply call function_name.
-
-std::string
-Gogo::unexported_function_asm_name(const std::string& go_name)
-{
- std::string ret = this->package_name();
- ret.append(1, '.');
- ret.append(Gogo::unpack_hidden_name(go_name));
- return go_encode_id(ret);
-}
-
// Return the name to use for a function descriptor. These symbols
// are globally visible.
std::string
Gogo::global_var_asm_name(const std::string& go_name, const Package* package)
{
- // FIXME: Using package_name for hidden names and pkgpath_symbol for
- // non-hidden names doesn't make sense, but it dates back to the
- // first public commit of the gofrontend repo.
- std::string ret;
- if (Gogo::is_hidden_name(go_name))
- ret = (package != NULL
- ? package->package_name()
- : this->package_name());
- else
- ret = (package != NULL
- ? package->pkgpath_symbol()
- : this->pkgpath_symbol());
+ std::string ret = (package != NULL
+ ? package->pkgpath_symbol()
+ : this->pkgpath_symbol());
ret.push_back('.');
ret.append(Gogo::unpack_hidden_name(go_name));
return go_encode_id(ret);