当前位置:网站首页>Hide symbol of dynamic library
Hide symbol of dynamic library
2022-06-22 05:40: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.
边栏推荐
- Remove then add string from variable of Makefile
- CLion安装下载
- 用简单方法实现对象的深克隆封装js
- [graduation season · advanced technology Er] a graduate student's chatter
- 《双内核实时系统下各个进程间通信方法的性能分析和测试》
- Wanzi detailed data warehouse, data lake, data middle platform and lake warehouse are integrated
- 为什么说“ CPS联盟营销 ” 是性价比最高的推广方式?
- 机器学习笔记 六:逻辑回归中的多分类问题之数字识别
- Running yolov5 reports an error attributeerror: cant get attribute sppf on module models common
- Throw away electron and embrace Tauri based on Rust
猜你喜欢

nacos server 源码运行实现

2022 Shanxi secondary vocational group "Cyberspace Security" event module b- web page penetration

《MATLAB 神经网络43个案例分析》:第29章 极限学习机在回归拟合及分类问题中的应用研究——对比实验

Data storage (Advanced)

Analysis of 43 cases of MATLAB neural network: Chapter 28 Application Research of decision tree classifier - breast cancer diagnosis

Yarn application submission process

网络、IO流、反射、多线程、异常

JS regular expression to implement the thousands separator

我不建议你工作太拼命

Kubernetes -- setting up an environment using minicube
随机推荐
Parameter serialization
Report on global and Chinese direct coupled actuator market demand and future development planning recommendations 2022-2027
移动端布局适配
Xshell下载安装(解决评估过期问题)
我不建议你工作太拼命
数据的存储(进阶)
Performance analysis and test of interprocess communication methods under dual core real-time system
P1077 [NOIP2012 普及组] 摆花
Detailed explanation of OpenCV function usage 11~20, including code examples
Analysis of 43 cases of MATLAB neural network: Chapter 28 Application Research of decision tree classifier - breast cancer diagnosis
Global and Chinese carbon conductive filler market demand trend and future prospect report 2022-2027
c files always get rebuild when make -------- . PHONY in Makefile
P1061 [NOIP2006 普及组] Jam 的计数法
通达OA漏洞分析合集
Cookie setting and reading in C #
Zhiyuan OA vulnerability analysis, utilization and protection collection
open source hypervisor
用简单方法实现对象的深克隆封装js
Why is "CPS alliance marketing" the most cost-effective promotion method?
Global and Chinese silicon carbide barrier Schottky diode market demand and future prospect report 2022-2027