5 Star 0 Fork 28

OpenHarmony/third_party_libabigail

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
VISIBILITY 2.51 KB
一键复制 编辑 原始数据 按行查看 历史
Randy MacLeod 提交于 2022-02-09 03:32 +08:00 . Improve some grammar
PLEASE READ ALL OF THIS FILE, ESPECIALLY IF YOU ARE DEFINING A NEW
PUBLIC HEADER IN LIBABIGAIL.
How symbols that are exported are controlled in libabigail
==========================================================
We try to limit the number of ELF symbols that are exported by the
libabigail.so shared library. We call this, "symbol visibility control".
As GNU/Linux is our development platform, we control symbol visibility
by using the visibility support of the G++ compiler.
How to do so is properly explained at https://gcc.gnu.org/wiki/Visibility.
All symbols are hidden by default
=================================
When building translation units that make up the libabigail.so shared
library, G++ is invoked with the -fvisibility=hidden directive. Which
instructs it to make symbols of functions and global variables
*locally* defined in the shared library, *NOT* exported (or global).
Exporting symbols of entities declared in public headers
========================================================
In a translation unit that is part of the libabigail.so shared
library, before including a header file that is a public libabigail
header (e.g, abg-ir.h), one need to declare:
#include "abg-internal.h"
ABG_BEGIN_EXPORT_DECLARATIONS
then all the public header files inclusion (using #include directives)
follow. At the end of these public header files inclusion, one need
to declare:
ABG_END_EXPORT_DECLARATIONS
The ABG_BEGIN_EXPORT_DECLARATIONS is a macro defined in abg-internal.h
which expands to:
#pragma GCC visibility push(default)
This instructs G++ to export the symbol of all global functions and
variables definitions that are declared from that point on.
The ABG_END_EXPORT_DECLARATIONS is a macro defined in abg-internal.h
which expands to:
#pragma GCC visibility pop
It instructs G++ to stop exporting symbols of global functions and
variable definition from that point on.
In practice, the pair ABG_BEGIN_EXPORT_DECLARATIONS,
ABG_END_EXPORT_DECLARATIONS allows us to only export symbols of
global functions and variables declared in the block denoted by these
two macros. Symbols of anything else that is declared outside of that block
are going to be hidden, thanks to the -fvisibility=hidden option
passed to G++.
So whenever you are defining a new header file with declarations that
ought to be part of the API of libabigail, the *definition* file which
defines the declarations of the header file must use
the ABG_BEGIN_EXPORT_DECLARATIONS and ABG_END_EXPORT_DECLARATIONS
macro to include the public header.
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony/third_party_libabigail.git
git@gitee.com:openharmony/third_party_libabigail.git
openharmony
third_party_libabigail
third_party_libabigail
master

搜索帮助