当前位置:网站首页>Hide symbol of dynamic library
Hide symbol of dynamic library
2022-06-22 05:23:00 【alex_mianmian】
os_api.c
#include <stdio.h>
void func_os_api(void)
{
printf("I am OS API\n");
}os_api.h
#ifndef __OS_API_H__
#define __OS_API_H__
extern void func_os_api(void);
#endifcall_os_api.c
#include <stdio.h>
#include "os_api.h"
void call_os_api(void)
{
printf("call_os_api start\n");
func_os_api();
printf("call_os_api end\n");
}call_os_api.h
#ifndef __CALL_OS_API_H__
#define __CALL_OS_API_H__
extern void call_os_api(void);
#endifnative_os_api.c
#include <stdio.h>
void __attribute__((visibility("hidden")))func_os_api(void)
{
printf("I am native os API\n");
}app.c
#include <stdio.h>
#include "os_api.h"
#include "call_os_api.h"
int main(int argc,char** argv)
{
func_os_api();
call_os_api();
return 0;
}Makefile
CC = gcc
all: libosapi.so libcallosapi.so app
libosapi.so: os_api.c
$(CC) -o [email protected] $^ -I. -fPIC -shared
libcallosapi.so: call_os_api.c libosapi.so
$(CC) -o [email protected] $< -I. -fPIC -shared -L. -l:libosapi.so
app: app.c native_os_api.c
$(CC) -o [email protected] $^ -I. -L. -l:libcallosapi.so -l:libosapi.so
%.o: %.c
$(CC) -I. -c $^
clean:
rm *.so
rm app>make
>export LD_LIBRARY_PATH=/home/chunxie/test_symb_hidden/
>./app

We can see two func_os_api() calls to different implementations.
We can use this feature when we need implement an OS API but avoid override OS API when some one really want it.
边栏推荐
- 89--- Dirac delta function
- LeetCode热题 HOT1-50
- 部署SuperMap iServer war包时的服务迁移
- 在Vs Code中搭建JSP开发环境
- C#中Cookie设置与读取
- Lua notes
- 2022深圳福田区专精特新小巨人企业申报条件,补贴50万
- When idea creates a method, it uses annotations to prompt method parameters (param), return value (return), and method function (description)
- Flink deployment mode (I) - standalone and Application
- Monorepo丝滑方法论:引用模块热更新
猜你喜欢

9. Gateway cross domain processing

Record local project startup error: invalid source distribution: 8

在线文本代码对比工具

Kubernetes——裸机搭建集群环境
![[chrome] Google tips Google browser comes with scrolling screenshot (full screen shot)](/img/9b/6ad704959a77abf9cb28fdd33b81b5.png)
[chrome] Google tips Google browser comes with scrolling screenshot (full screen shot)

Yarn application submission process

1108. Defanging an IP Address

畢業回饋!Apache Doris 社區所有貢獻者來領禮品啦!

Kubernetes——使用minikube搭建环境

Rétroaction sur la remise des diplômes! Tous les contributeurs de la communauté Apache Doris sont ici pour recevoir des cadeaux!
随机推荐
Opencv function usage details 1~10, including code examples
Gateway uses global filter for token verification
Six sides tmall has already offered. After a review of my experience, is it really that difficult to enter a big factory?
Some templates about bisection
jedispool的使用
DTS迁移秘籍-SQLSERVER篇
IDP depth | what kind of data analysis and mining tools do enterprises need?
Build JSP development environment in vs Code
js正则表达式实现千分位符
强制删除 Terminating 状态的 namespace
8. Gateway request logging
【云原生】2.2 kubeadm创建集群
The benefits of implementing the standard of intellectual property in Miyun District, Beijing, with a subsidy of 50000-100000 yuan
Does the air valve perform the en 1634-1 fire resistance test for 4 hours?
Traveler's budget (Los Angeles Valley)
【毕业季·进击的技术er】一个读研学生的唠唠嗑
Some notes on the use of C language strings
TIDB-performance overview面板
Squoosh - 谷歌出品的免费开源图片压缩工具,图片大小减少90%!支持 API 开发调用
花式优化器整理