From c70ff9f9be0c7360a37519ec68ac4dd41e8d0a3c Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 31 Aug 2019 03:01:15 +0000 Subject: compiler, runtime: support and use single argument go:linkname The gc compiler has started permitting go:linkname comments with a single argument to mean that a function should be externally visible outside the package. Implement this in the Go frontend. Change the libgo runtime package to use it, rather than repeating the name just to export a function. Remove a couple of unnecessary go:linkname comments on declarations. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/192197 From-SVN: r275239 --- gcc/go/gofrontend/gogo.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'gcc/go/gofrontend/gogo.h') diff --git a/gcc/go/gofrontend/gogo.h b/gcc/go/gofrontend/gogo.h index 087e890..e742b6e 100644 --- a/gcc/go/gofrontend/gogo.h +++ b/gcc/go/gofrontend/gogo.h @@ -547,7 +547,9 @@ class Gogo { this->file_block_names_[name] = location; } // Add a linkname, from the go:linkname compiler directive. This - // changes the externally visible name of go_name to be ext_name. + // changes the externally visible name of GO_NAME to be EXT_NAME. + // If EXT_NAME is the empty string, GO_NAME is unchanged, but the + // symbol is made publicly visible. void add_linkname(const std::string& go_name, bool is_exported, const std::string& ext_name, Location location); @@ -1359,6 +1361,11 @@ class Function set_asm_name(const std::string& asm_name) { this->asm_name_ = asm_name; } + // Mark this symbol as exported by a linkname directive. + void + set_is_exported_by_linkname() + { this->is_exported_by_linkname_ = true; } + // Return the pragmas for this function. unsigned int pragmas() const @@ -1706,6 +1713,9 @@ class Function // True if this function is referenced from an inlined body that // will be put into the export data. bool is_referenced_by_inline_ : 1; + // True if we should make this function visible to other packages + // because of a go:linkname directive. + bool is_exported_by_linkname_ : 1; }; // A snapshot of the current binding state. -- cgit v1.1