at linux show execute file symbol table

本文详细探讨了编程领域的核心技术,包括但不限于前端开发、后端开发、移动开发、游戏开发等细分领域。从基础到进阶,涵盖了开发工具、大数据开发、测试、DevOps、操作系统、云计算厂商等多个方面,为开发者提供全面的技术指导与实践建议。

nm -D  xxx.so

nm      xxxx.a


objdump -T   xxx.so

objdump -s   xxxx.a



PE signature found File Type: DLL FILE HEADER VALUES 8664 machine (x64) 2 number of sections E04F9911 time date stamp 0 file pointer to symbol table 0 number of symbols F0 size of optional header 2022 characteristics Executable Application can handle large (>2GB) addresses DLL OPTIONAL HEADER VALUES 20B magic # (PE32+) 48.00 linker version 1DDA00 size of code 400 size of initialized data 0 size of uninitialized data 0 entry point 2000 base of code 180000000 image base (0000000180000000 to 00000001801E1FFF) 2000 section alignment 200 file alignment 4.00 operating system version 0.00 image version 6.00 subsystem version 0 Win32 version 1E2000 size of image 200 size of headers 0 checksum 3 subsystem (Windows CUI) 8560 DLL characteristics High Entropy Virtual Addresses Dynamic base NX compatible No structured exception handler Terminal Server Aware 400000 size of stack reserve 4000 size of stack commit 100000 size of heap reserve 2000 size of heap commit 0 loader flags 10 number of directories 0 [ 0] RVA [size] of Export Directory 0 [ 0] RVA [size] of Import Directory 1E0000 [ 38C] RVA [size] of Resource Directory 0 [ 0] RVA [size] of Exception Directory 0 [ 0] RVA [size] of Certificates Directory 0 [ 0] RVA [size] of Base Relocation Directory 1DF918 [ 38] RVA [size] of Debug Directory 0 [ 0] RVA [size] of Architecture Directory 0 [ 0] RVA [size] of Global Pointer Directory 0 [ 0] RVA [size] of Thread Storage Directory 0 [ 0] RVA [size] of Load Configuration Directory 0 [ 0] RVA [size] of Bound Import Directory 0 [ 0] RVA [size] of Import Address Table Directory 0 [ 0] RVA [size] of Delay Import Directory 2000 [ 48] RVA [size] of COM Descriptor Directory 0 [ 0] RVA [size] of Reserved Directory SECTION HEADER #1 .text name 1DD9B7 virtual size 2000 virtual address (0000000180002000 to 00000001801DF9B6) 1DDA00 size of raw data 200 file pointer to raw data (00000200 to 001DDBFF) 0 file pointer to relocation table 0 file pointer to line numbers 0 number of relocations 0 number of line numbers 60000020 flags Code Execute Read Debug Directories Time Type Size RVA Pointer -------- ------- -------- -------- -------- EF5D2053 cv 67 001DF950 1DDB50 Format: RSDS, {39633015-CF28-40B4-A779-FEC96A23033D}, 1, C:\Users\Administrator\source\repos\0X0RAT\Stubdll\obj\x64\Release\Stubdll.pdb 00000000 repro 0 00000000 0 SECTION HEADER #2 .rsrc name 38C virtual size 1E0000 virtual address (00000001801E0000 to 00000001801E038B) 400 size of raw data 1DDC00 file pointer to raw data (001DDC00 to 001DDFFF) 0 file pointer to relocation table 0 file pointer to line numbers 0 number of relocations 0 number of line numbers 40000040 flags Initialized Data Read Only Summary 2000 .rsrc 1DE000 .text
06-09
### C# DLL PE结构分析与DllExport导出函数 C# 生成的 DLL 文件遵循 Windows 的 PE(Portable Executable)格式,包含多个节(Section),如 `.text`(代码节)、`.rsrc`(资源节)等。通过分析 PE 结构,可以深入了解 DLL 的内部布局和功能。 #### 1. C# DLL 的 PE 结构分析 C# 编译生成的 DLL 包含以下主要部分: - **PE 头**:描述文件的基本信息,包括目标架构(如 x86 或 x64)、入口点地址等[^1]。 - **CLR 头**:特定于 .NET 的元数据,包含托管代码的版本信息、元数据表位置等。 - **代码节 (.text)**:存储编译后的 MSIL(Microsoft Intermediate Language)代码。 - **资源节 (.rsrc)**:存储图标、字符串等资源。 使用工具如 `dumpbin` 可以查看 DLL 的 PE 结构。例如: ```bash dumpbin /headers Stubdll.dll ``` 输出中可以看到类似以下内容: ``` FILE HEADER VALUES 8664 machine (x64) 5 number of sections 60F32B4D time date stamp 0 file pointer to symbol table 0 number of symbols F0 size of optional header 2102 characteristics Executable Application can handle large (>2GB) addresses ``` 上述信息表明该 DLL 是为 x64 架构编译的,并支持大地址空间。 #### 2. DllExport 导出函数分析 `[DllExport]` 属性由第三方库 `UnmanagedExports` 提供,用于将托管方法导出为非托管调用接口。以下是 `_add` 和 `saySomething` 方法的导出分析: - **_add 方法** ```csharp [DllExport] public static int _add(int a, int b) { return a + b; } ``` 该方法被导出为非托管函数,名称默认为 `_add`,调用约定为 `StdCall`。可以通过以下命令验证其导出情况: ```bash dumpbin /exports Stubdll.dll ``` 如果配置正确,输出应包含类似以下内容: ``` ordinal hint RVA name 1 0 00001234 _add ``` - **saySomething 方法** ```csharp [DllExport] public static bool saySomething() { DialogResult dlgres = MessageBox.Show( "Hello from managed environment !", ".NET clr", MessageBoxButtons.OKCancel ); return dlgres == DialogResult.OK; } ``` 该方法同样被导出为非托管函数,名称为 `saySomething`,调用约定为 `StdCall`。验证方式与 `_add` 方法相同。 #### 3. x64 特性分析 在 x64 架构下,C# 生成的 DLL 具有以下特性: - **更大的虚拟地址空间**:x64 支持更大的内存地址范围,适合处理大规模数据。 - **寄存器优化**:x64 架构提供更多的通用寄存器,有助于提高性能。 - **调用约定**:默认情况下,x64 使用 `fastcall` 调用约定,参数通过寄存器传递,而非栈。 在 `[DllExport]` 中,可以显式指定调用约定以确保兼容性。例如: ```csharp [DllExport("Add", CallingConvention = CallingConvention.StdCall)] public static int Add(int a, int b) { return a + b; } ``` #### 4. 工具支持 以下工具可用于分析 C# DLL 的 PE 结构和导出函数: - **dumpbin**:显示 PE 头、导出表等信息。 - **Dependency Walker**:可视化工具,显示 DLL 的依赖关系和导出符号。 - **CFF Explorer**:编辑 PE 文件头和资源节。 --- ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值