C/C++ object code informations

Discussion in 'C++' started by davide galassi, Apr 23, 2010.

  1. 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
     
    davide galassi, Apr 23, 2010
    #1
    1. Advertising

  2. On 23 avr, 13:00, davide galassi <> wrote:
    > 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,

    --
    Michael
     
    Michael Doubez, Apr 23, 2010
    #2
    1. Advertising

  3. On Apr 23, 1:23 pm, Michael Doubez <> wrote:
    > On 23 avr, 13:00, davide galassi <> wrote:
    >
    > > 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,
    >
    > --
    > Michael


    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
     
    davide galassi, Apr 24, 2010
    #3
  4. On 2010-04-24, davide galassi <> wrote:
    >
    > 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.

    --
    Andrew Poelstra
    http://www.wpsoftware.net/andrew
     
    Andrew Poelstra, Apr 24, 2010
    #4
  5. On 24 avr, 19:48, davide galassi <> wrote:
    > On Apr 23, 1:23 pm, Michael Doubez <> wrote:
    > > On 23 avr, 13:00, davide galassi <> wrote:

    [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.

    --
    Michael
     
    Michael Doubez, Apr 24, 2010
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lionel
    Replies:
    0
    Views:
    415
    Lionel
    Aug 23, 2004
  2. =?Utf-8?B?RmxvcmVudA==?=

    Loosing informations when PostBack

    =?Utf-8?B?RmxvcmVudA==?=, Apr 27, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    391
    Martin Dechev
    Apr 27, 2004
  3. Lionel

    IPTC informations

    Lionel, Jan 28, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,298
    Kevin Spencer
    Jan 28, 2005
  4. John Holgerson
    Replies:
    3
    Views:
    45,026
  5. Ravi Ambros Wallau
    Replies:
    3
    Views:
    409
    Jim Cheshire
    Jan 16, 2006
Loading...

Share This Page