硬汉嵌入式论坛

 找回密码
 立即注册
查看: 389|回复: 4
收起左侧

[其它] gcc里面有没有类似$sub$$的实现?

[复制链接]

38

主题

194

回帖

318

积分

高级会员

积分
318
发表于 2024-3-16 14:37:53 | 显示全部楼层 |阅读模式
有一份stm32上的代码用到了$sub$$这个特性,然后想移植到esp32上去.

不知道有没有类似的实现方式?如果没有的话,就重写一个函数放到原来函数的前面了。

回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106678
QQ
发表于 2024-3-16 15:15:12 | 显示全部楼层
RTT代码对应这个问题做了个整理,做的很好,可以看下,应该是不支持
https://club.rt-thread.org/ask/question/9dfbbb02ed1f6b71.html
回复

使用道具 举报

38

主题

194

回帖

318

积分

高级会员

积分
318
 楼主| 发表于 2024-3-16 15:31:35 | 显示全部楼层
eric2013 发表于 2024-3-16 15:15
RTT代码对应这个问题做了个整理,做的很好,可以看下,应该是不支持
https://club.rt-thread.org/ask/ques ...

OK了解了。
回复

使用道具 举报

3

主题

335

回帖

344

积分

高级会员

积分
344
发表于 2024-3-16 20:19:53 | 显示全部楼层
楼主搜索关键字gcc的--wrap选项
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106678
QQ
发表于 2024-3-16 21:57:17 | 显示全部楼层
glory 发表于 2024-3-16 20:19
楼主搜索关键字gcc的--wrap选项




https://stackoverflow.com/questi ... ap-option-correctly
https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html

[C] 纯文本查看 复制代码
--wrap symbol
Use a wrapper function for symbol. Any undefined reference to symbol will be resolved to __wrap_symbol. Any undefined reference to __real_symbol will be resolved to symbol. This can be used to provide a wrapper for a system function. The wrapper function should be called __wrap_symbol. If it wishes to call the system function, it should call __real_symbol. Here is a trivial example:
void *
__wrap_malloc (int c)
{
  printf ("malloc called with %ld\n", c);
  return __real_malloc (c);
}
If you link other code with this file using --wrap malloc, then all calls to malloc will call the function __wrap_malloc instead. The call to __real_malloc in __wrap_malloc will call the real malloc function. You may wish to provide a __real_malloc function as well, so that links without the --wrap option will succeed. If you do this, you should not put the definition of __real_malloc in the same file as __wrap_malloc; if you do, the assembler may resolve the call before the linker has a chance to wrap it to malloc.

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-4-29 08:48 , Processed in 0.161587 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表