Linux应用编程
w335191658
这个作者很懒,什么都没留下…
展开
-
gcc替换libc库函数
#include <stdio.h>#include <stdlib.h>void* __wrap_malloc(int size){ printf("test\r\n");}int main(){ malloc(10);}使用gcc test.c -Wl,--wrap=malloc编译原创 2021-07-09 16:38:54 · 547 阅读 · 0 评论 -
Linux应用程序地址布局
Linux应用程序地址布局如下图所示,由于使用的虚拟地址,所以Linux应用程序的起始地址都是相同且固定的。因为它们使用了相同的链接地址。查看一个程序的地址布局使用cat /proc/pid(程序进程号)/maps上图分析:1.代码段具有可读可执行(rx)权限,我们的应用程序是addr,所以根据分析,它的地址为0x08048000-0x080490002.接下来原创 2016-04-04 22:46:12 · 385 阅读 · 0 评论 -
mdio读写接口
#include #include #include #include #include #include #include typedef unsigned long U32;typedef unsigned short U16;#define HI_FAILURE (-1)#define HI_SUCCESS (0)/* * NOTE! This ctype doe原创 2016-11-30 17:14:50 · 9694 阅读 · 0 评论 -
16进制字符串转16进制数字
int tolower(int c){ if ((c >= 'A') && (c <= 'Z')) return c + ('a' - 'A'); return c;}int htoi(char s[]){ int i; int n = 0; if (s[0] == '0' && (s[1]=='x' || s[1]=='X')) { i = 2; } else原创 2017-07-10 09:11:52 · 1124 阅读 · 0 评论