c在内存中编程二进制/图像 [英] c program binary/image in memory

查看:61
本文介绍了c在内存中编程二进制/图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨大家好,

我想了解存储在内存中的图像(编译好的b $ bc代码并加载到内存中)到底是怎样的。


链接器脚本究竟是什么?


我每天都使用大量的c代码,但我真的很好。

不明白:


各部分

如何文字,bss,数据等

工作?


究竟是什么?


我相信链接器脚本描述了这种布局。


捆绑图像究竟是什么?


究竟什么是微码?

究竟是什么''固件' '?


我承认我经常使用这些条款,但

没有太多清晰度。


无论如何

中的任何信息或指针(互联网网址)都非常有用。


如果有帮助,我的工作涉及很多驱动程序代码

in C on s ystems使用MIPS处理器。


非常感谢...

解决方案

tele-commuter写道:

嗨伙计,

我想了解存储在内存中的图像(编译后的c代码并加载到内存中)到底是怎样的。



您的问题不属于这个新闻组,只有

符合ISO标准C.


良好的起始链接:

http://www.iecc .com / linker /


tele-commuteraécrit:

嗨大家好,

我想了解存储在内存中的图像(编译后的代码并加载到内存中)究竟是什么。

链接器脚本究竟是什么?


这是GNU链接器的扩展,允许GNU人员配置其链接器。普通用户

不应该使用它,至少我不明白

关于它的任何事情。这是GNU特定的,所以关闭主题

这里。

我每天使用大量的c代码,但我真的不明白:

部分
如何文本,bss,数据等。


本节介绍以下部分语言:


1)text section是编译器,程序文本的翻译输出。例如


int fn(void){/ * ... * /


此函数中的指令序列将被存储

在text中部分。这部分通常不是可写的。


2)bss部分实现零初始化数据。例如

当你写的时候


int b [23];


这个数组将被映射到bss部分。当程序加载时,操作系统会将此部分
归零。

标准规定在程序开始之前必须将其归零

开始。请注意,bss部分和数据部分是可写的,即可以修改。


3)数据部分对应于程序的初始化数据。


比如你写的时候:


int c [] = {1,2,3};


整数序列1,2,3将存储在数据部分中。


简而言之,C程序由程序指令组成,未初始化
数据和初始化数据。程序的这个逻辑部分

分别映射到text,bss和data。


可能存在其他部分,例如包含debug
信息,但它们是可选的。


编写一个只包含文本部分的程序是合法的,没有任何

bss /数据部分。比如这个程序:


int main(int argc,char * argv [])

{

return(argc * argc);

}


只有一个文本部分,没有数据/ bss部分。


显然无论如何,这个程序最终可能会有一个数据/ bss部分

,因为在main之前运行的代码(托管实现中的启动代码

jacob

''捆绑图像'究竟是什么?'


不知道

究竟什么是''微码''?


Microcode是在CPU本身运行的软件。现代

CPU提供带寄存器,ALU等的用户界面。内部

高级指令被分解为更小的更多

基本指令。它们的一系列实现了用户可见的

指令。这是更多与硬件相关的问题,这里不再是主题。

究竟是什么''固件''?




这是提供的软件由硬件制造商。再次,

这是与硬件相关的主题。


非常感谢您提供的信息。


现在让我提供上下文。


我使用网络设备(分布式系统)。


多CPU system.The主CPU运行一个单片图像

(我在帖子中将其称为捆绑图像)。


部分内容在
系统初始化/启动期间下载到机箱中的其他卡。


我想要详细了解的是主CPU是如何获得的/>
完成这项工作

将部分代码下载到其他卡上。我认为这与代码的方式相关



写的,如何编写makefile,以及如何在
内存中设置二进制文件来实现这个

功能等。


我确实理解我的部分查询不在话题但我正在尝试

得到一些清晰度

所有这些真正的语言/因此编译器/链接器/加载器

依赖还是

如何将这些工具结合起来实现一些复杂的能力,比如

我所描述的背景

描述。


非常感谢所有的帮助。


我提出的所有问题都牢记这一点。


Hi folks,

I want to understand how exactly is an image(compiled
c code and loaded into memory) stored in memory.

What exactly is a linker script?

I work with a lot of c code on a daily basis but I really
don''t understand :

How exactly the sections
like "text,bss,data etc."
work?

What exactly are they?

I believe the linker script describes this layout.

What exactly is a ''bundled image''?

What exactly is ''microcode''?
What exactly is ''firmware''?

I admit I use these terms myself pretty often,but
without much clarity.

Anyways any information or pointers(internet urls) in
this regard would be very helpful.

If it helps,my work involves a lot of driver code
in C on systems using MIPS processors.

Thanks a bunch..

解决方案

tele-commuter wrote:

Hi folks,

I want to understand how exactly is an image(compiled
c code and loaded into memory) stored in memory.



None of your questions are topical to this newsgroup, which deals only
with ISO standard C.

A good starting link:

http://www.iecc.com/linker/


tele-commuter a écrit :

Hi folks,

I want to understand how exactly is an image(compiled
c code and loaded into memory) stored in memory.

What exactly is a linker script?

This is an extension of the GNU linkers that allows
GNU people to configure their linker. Normal users
are not supposed to use that, at least I didn''t understand
anything about it. This is GNU specific, so off topic
here.
I work with a lot of c code on a daily basis but I really
don''t understand :

How exactly the sections
like "text,bss,data etc."
This sections map following parts of the language:

1) The "text" section is the translated output of
the compiler, the program text. For instance

int fn(void) { /* ... */

the sequence of instructions in this function will be stored
in the "text" section. This section is normally not
writable.

2) The bss section implements the zero initialized data. For instance
when you write

int b[23];

This array will be mapped into the bss section. This section will
be zeroed by the operating system when the program is loaded.
The standard specifies that this must be zeroed before the program
starts. Note that the bss sections and the data sections are
writable, i.e. can be modified.

3) The data section corresponds to the initialized data of your program.

For instance when you write:

int c[] = { 1,2,3};

The sequence of integers 1,2,3 will be stored in the data section.

In short, a C program consists of program instructions, uninitialized
data and initialized data. This logical sections of the program
are mapped into text,bss,and data, respectively.

Other sections may exist, for instance sections containing debug
information, but they are optional.

It is legal to write a program with only the text section, without any
bss/data sections. For instance this program:

int main(int argc,char *argv[])
{
return (argc*argc);
}

has only a text section, and no data/bss section.

Obviously this program could end up having a data/bss section
anyway, since the code that runs before main (the startup code
in a hosted implementation) could need those sections.
jacob
What exactly is a ''bundled image''?

No idea
What exactly is ''microcode''?
Microcode is the software that runs in the CPU itself. Modern
CPUs present a user interface with registers, ALU, etc. Internally
the high level instructions are decomposed into smaller and more
basic instructions. A sequence of them implements the user visible
instructions. This is more hardware related and it is off topic here.
What exactly is ''firmware''?



It is the software supplied by the hardware manufacturer. Again,
this is hardware related and off topic here.


Thanks a lot for the information.

Now let me provide the context.

I work with a network device (a distributed system).

Its a multiple CPU system.The main CPU runs a single monolithic image
(i referred to this as a "bundled image" in my post).

Portions of it get downloaded to other cards in the chassis during
system initialization/bootup.

What I wanted to understand in some detail was how the main CPU gets
this work done
of downloading portions of code onto other cards.I presume this is
related to way the code
is written,how makefiles are written,and how the binary is laid out in
memory to achieve this
functionality etc.

I do understand portions of my queries are off topic but I am trying to
get some clarity on
how much of all this really language/and hence compiler/linker/loader
dependant and also
how these tools come together to achieve some complicated ability like
the context I have
described.

Thanks anyways for all the help.

All the questions I have asked were keeping this situation in mind.


这篇关于c在内存中编程二进制/图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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