强制GCC放弃某些零全局 [英] Force GCC to forgo zeroing certain globals

查看:92
本文介绍了强制GCC放弃某些零全局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法告诉GCC不要初始化一个特定的全局数组为零?

Is there any way to tell GCC to not initialize a particular global array to zero?

我要预订一大块内存,用于存储我的code管理一个大的数据结构,所以我说:

I want to reserve a large chunk of memory for storing a large data structure that my code manages, so I say:

#define SIZE_16_MB 0x01000000
BYTE mChunkSpace[SIZE_16_MB];

问题在于crtinit()接受一百万美元对这个空间初始化为零,并且它不是在所有必要的

The problem is that crtinit() takes a million years to initialize this space to zero, and it is not at all necessary.

有没有什么办法可以迫使它不能初始化空间?

Is there any way I can force it not to initialize that space?

目前,我硬编码内存地址是什么外链接器知道,但是这不是做事情的一种特别可靠的方法。

Currently I am hard-coding a memory address that is outside what the linker knows about, but that is not a particularly robust way of doing things.

此外,这是一个缓慢的嵌入式PROC(50MHz的Microblaze的),所以不要以为我说的是一台PC。它确实需要很长的时间设为零空间。

Additionally, this is a slow embedded proc (50MHz Microblaze), so don't assume that i am talking about a PC. It really does take a long time to zero that space.

推荐答案

您可以使用 GCC 属性的对象存储在另一个新的内存部分,例如像在在 .noinit 内存部分。

You can use the gcc attributes to store the object in another new memory section, like for example in the .noinit memory section.

 BYTE mChunkSpace[SIZE_16_MB] __attribute__ ((section (".noinit")));

这篇关于强制GCC放弃某些零全局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆