C/C++ object code informations

D

davide galassi

Hi,
I'm doing my thesis...it's about a virtual 3d device state machine
that executes already compiled binary code that represents vertex and
pixel shaders...the code it's nothing more than a function, with
parameters and global variables.
That's how it have to work:
The machine load a object code from the disk in from af a binary
string ...and that's easy but i have to know, at this poin,t in some
way what aare the parameters, the types of the parameters, the address
of the entry point to jump to that function from the main program, and
the addresses and types of the global variables to fill them before
jump.

I found that from the binary code it's not easy right? ( if it's not
imopssible ) i need a tool that at compilation time do that job and
put all the infos needed in a separate file or ( better ) at the end
of the binary file so i can read it from there.

A good idea is to have the binary file with the entry point ( code to
jump ) that start's at a fixed physical address 0x4 and have in the
first double word the address from where start reading the informatin
stored in the binary about the program stored in some readable form.
For example xml.

Thank you
Davide
 
M

Michael Doubez

I'm doing my thesis...it's about a virtual 3d device state machine
that executes already compiled binary code that represents vertex and
pixel shaders...the  code it's nothing more than a function, with
parameters and global variables.
That's how it have to work:
The machine load a object code from the disk in from af a binary
string ...and that's easy but i have to know, at this poin,t in some
way what aare the parameters, the types of the parameters, the address
of the entry point to jump to that function from the main program, and
the addresses and types of the global variables to fill them before
jump.

The prototype is usually known beforehand or you need to embedded some
reflection mecanism (from your compiler or that you build yourself).
I found that from the binary code it's not easy right? ( if it's not
imopssible ) i need a tool that at compilation time do that job and
put all the infos needed in a separate file or ( better ) at the end
of the binary file so i can read it from there.

A good idea is to have the binary file with the entry point ( code to
jump ) that start's at a fixed physical address 0x4 and have in the
first double word the address from  where start reading the informatin
stored in the binary about the program stored in some readable form.
For example xml.

This highly dependent on your platform and compiler.

Namely, this is OT here. You should ask your question in a group
related to your platform.

Cheers,
 
D

davide galassi

The prototype is usually known beforehand or you need to embedded some
reflection mecanism (from your compiler or that you build yourself).



This highly dependent on your platform and compiler.

Namely, this is OT here. You should ask your question in a group
related to your platform.

Cheers,

The prototype of the function is not known.... But will be very easy.
I have visual studio but i can use gcc as well (mingw).

How i can compile a c program and have the entry point of the program
and the .data section at a fixed known address? in binary form without
headers or something like that...
if that thing is possible then i can just assume that parameters to be
fixed and who write the program shader that will be loaded manally
write an associated xml program:

FOR example...the C program will be in this form:


int gWVP;
int gWorld;

struct VS_IN
{
float x;
float y;
};

struct VS_OUT
{
float a;
float b;
};

VS_OUT VS( VS_IN vIn )
{
VS_OUT vOut;
vOut.a = vIn.x;
vOut.b = vIn.y * 10;
return vOut;
}

At this point if the VS function is at a fixed address in the binary
for example 0x10000 and the .data section is at 0x20000
whi write the program can simply associate a document af this form:

<global_buffer addr=0x20000>
<gloabal_var gWVP type="int" offset="0" >
<gloabal_var gWorld type="int" offset="4" >
<gloabal_buffer>
<function name="VS" addr=0x10000>
<INPUT>
<param x type="float">
<param y type="float">
</INPUT>
<OUTPUT>
<param a type="float">
<param b type="float">
</OUTPUT>
</function>

<CDATA>
buffer="......binary of the program that can be read...."
<CDATA>

so now the situation is easyer...for me a solution like that is's ok.

So my new question is.... how can compile in binary for and put the
functions and the .data section at a fixed known address????

Thanks a lot
David
 
A

Andrew Poelstra

So my new question is.... how can compile in binary for and put the
functions and the .data section at a fixed known address????

You need to configure your linker to do this. Check a group
or mailing list (or FAQ) for your specific linker.
 
M

Michael Doubez

[snip]

You are still off topic.
How i can compile a c program and have the entry point of the program
and the .data section at a fixed known address? in binary form without
headers or something like that...

IMHO it would be too long to give you an answer and your problem space
is quite special.
Perhaps you should get some background in dynamic loading:
http://www.iecc.com/linker/

[snip]
So my new question is.... how can compile in binary for and put the
functions and the .data section at a fixed known address????

Easy: create a script for your linker and tell it to do so.
Don't forget to generate PIC code and handle dependencies.

More seriously, it would be easier if you simply compiled your code
into a dynamic library and use dlopen() to load it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top