当前位置:网站首页>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.
边栏推荐
- Service migration when deploying SuperMap iserver war package
- Traveler's budget (Los Angeles Valley)
- 【毕业季·进击的技术er】一个读研学生的唠唠嗑
- tmux -- ssh terminal can be closed without impact the server process
- C#中Cookie设置与读取
- 用简单方法实现对象的深克隆封装js
- 中小企业签署ERP合同时,需要留意这几点
- P1077 [noip2012 popularization group] flower display
- Kubernetes - bare metal cluster environment
- long start = currentTimeMillis();
猜你喜欢

大厂晋升学习方法三:链式学习法

机器学习笔记 八:Octave实现神经网络的手写数字识别

Data storage (Advanced)

JS regular expression to implement the thousands separator

Stockage des données (avancé)

删除弹窗组件的封装使用

SCM future employment development direction, learn SCM must know some entry-level knowledge and industry prospects, read the benefit

Record local project startup error: invalid source distribution: 8

Kubernetes - bare metal cluster environment

总有人问我:独立站该怎么玩?3个案例,你看完就懂了
随机推荐
Sourcetree reported an error SSH failure
printf becomes puts
Service migration when deploying SuperMap iserver war package
vscode 远程连接错误:Server status check failed - waiting and retrying
关于图片懒加载的实现(总结梳理)
The "decentralization" mode of independent stations has risen, sweeping the tide of cross-border enterprise transformation
Go语言使用JWT
中小企业签署ERP合同时,需要留意这几点
Stockage des données (avancé)
大厂晋升学习方法四:Play 学习法
Global and Chinese silicon carbide barrier Schottky diode market demand and future prospect report 2022-2027
深圳南山区专精特新小巨人企业申报指标,补贴50万
机器学习笔记 八:Octave实现神经网络的手写数字识别
随鼠标移动的提示框
Yarn application submission process
Optimization direction of code walk through (convenient interface requests, long dynamic class judgment conditions, removal of useless consoles, separation of public methods)
亚马逊和独立站,不是简单的二选一
Global and Chinese carbon conductive filler market demand trend and future prospect report 2022-2027
MinGW下载安装
P1160 队列安排