惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
L
LINUX DO - 最新话题
Stack Overflow Blog
Stack Overflow Blog
月光博客
月光博客
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
V
Visual Studio Blog
Attack and Defense Labs
Attack and Defense Labs
O
OpenAI News
The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
B
Blog RSS Feed
H
Help Net Security
量子位
小众软件
小众软件
SecWiki News
SecWiki News
N
Netflix TechBlog - Medium
TaoSecurity Blog
TaoSecurity Blog
美团技术团队
博客园 - 司徒正美
Hacker News - Newest:
Hacker News - Newest: "LLM"
Recent Commits to openclaw:main
Recent Commits to openclaw:main
The Cloudflare Blog
N
News and Events Feed by Topic
C
Cybersecurity and Infrastructure Security Agency CISA
The Last Watchdog
The Last Watchdog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Scott Helme
Scott Helme
T
The Exploit Database - CXSecurity.com
K
Kaspersky official blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
Application and Cybersecurity Blog
Application and Cybersecurity Blog
U
Unit 42
Google DeepMind News
Google DeepMind News
J
Java Code Geeks
Schneier on Security
Schneier on Security
G
Google Developers Blog
Forbes - Security
Forbes - Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
Y
Y Combinator Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Palo Alto Networks Blog
A
Arctic Wolf
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Hacker News
The Hacker News
B
Blog
D
DataBreaches.Net
Simon Willison's Weblog
Simon Willison's Weblog

博客园 - 刘伟_luvi

C项目错误情况小记 s3c2440设置从nfs或从board启动 Hash Functions for Hash Table Lookup 自写linux下的简单man帮助文件 错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token Linux MAN命令 C数组测试 - 刘伟_luvi - 博客园 在本地计算机无法启动MySQL服务。错误1067:进程意外终止 对C语言中结构体的测试分析 悄悄地,你走了 AMBA片上总线 Linux系统环境下的Socket编程详细解析 C语言宏定义技巧(常用宏定义)【转】 s3c2410 MMU详述 可重入函数与不可重入函数(转) 程序的书写规则(程序的编码规范) ARM中C和汇编混合编程及示例 嵌入式系统 Boot Loader 技术内幕(转) 关于Linux系统下网卡手写配置文件的介绍
嵌入式中地址-函数之间的转换
刘伟_luvi · 2008-05-23 · via 博客园 - 刘伟_luvi

      经常见到嵌入式设计中,将某一程序段的入口地址转换为一个函数,我们来分析一下它的成分:
      如在bootloader的0x00000020地址上的双字单元中有这样一条语句:
@Address is 0x00000020
      b powerdown          @Jump to the flag "powerdown"
...
...
powerdown:
...
...
      然后在某一C头文件中可以见到这样的宏声明:
#define EnterPWDN(clkcon) ((void (*)(int))0x20)(clkcon)
      初一看,乱七八糟的,现在,我们来整理一下。
      不难看出,当我们编程调用EnterPWDN(clkcon)函数的时候,编译器在编译前首先把EnterPWDN(clkcon)转换为
((void (*)(int))0x20)(clkcon)语句。
对于这个语句,我们将之分解成3部分来看。
      1:(void (*)(int)
      2:0x20
      3:(clkcon)

      (clkcon)是函数的参数,就不用说了。0x20呢?当然就是要转换的函数的入口地址了。那对于(void (*)(int)呢??呵呵……,这一部分作为一个整体,描述了转换后的函数的类型,即无返回值,带一个整形参数。而中间那个”(*)“,就表示要转换成一个函数(或者说把0x20转换为一个地址,因为在ARM汇编中,就把C语言的函数名当作一个地址标号看待了)。就像我们平常用的强制类型转换一样,(int)temp,只不过这里是将一个数转换为另一类型,而那是将一个地址转换为一个函数罢了。
      至于编译器内部是如何实现这个转换的,这就要看编译器对函数的实现机制了。我也不懂了。
      纯属个人理解,如有错误,或者您对这个转换机制有更深的理解,请不吝赐教!