Thread: Dynamically load obj file at runtime?

  1. #1
    Registered User TheEngineer's Avatar
    Join Date
    Aug 2009
    Posts
    50

    Dynamically load obj file at runtime?

    I have an exe program that requires several arguments to be passed to it, including a test file, input/output file, errorfile, print level, etc. They are passed to the executable by using an .rc batch script that simply runs the program and passes the file locations etc. to it.

    This program started its life as an m68k executable that read an s-record test file (the rest of the inputs are text files or numbers), but has been changed and re-compiled to run on the i686. However, since the s-record format is unique to the m68k, the only way I can think of to pass the test file to the program is through the use of an object file.

    There doesn't seem to be a lot of info about this so I was wondering if there is a way to essentially link the .o file when the program is run rather than when the program itself is linked? Since there will be multiple test files, it is not efficient to link each .o file with its own version of the main program.

    Thoughts?

  2. #2
    Registered User TheEngineer's Avatar
    Join Date
    Aug 2009
    Posts
    50
    Would the dlopen() command work if the file was converted to a lib file?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    I'm confused, S-records are just text files. Why is it an issue to read them?

    Sure, what they encode is very machine specific, but that's another problem.

    Are you saying that you have s-record files encoding m68k binary data, and you want to "run" that on your intel?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User TheEngineer's Avatar
    Join Date
    Aug 2009
    Posts
    50
    Quote Originally Posted by Salem View Post
    I'm confused, S-records are just text files. Why is it an issue to read them?

    Sure, what they encode is very machine specific, but that's another problem.

    Are you saying that you have s-record files encoding m68k binary data, and you want to "run" that on your intel?
    Yes I could read the files, but like you said the code is machine specific. Since the i686 creates .o files when it compiles a program, I figured that was the way to go.

    The files were originally m68k but have been converted and compiled to an i686 executable

  5. #5
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    The difference between making a .o and a .s is a -c and -s option to gcc, both can be created for both the m68k and the i686. What you're asking for is a whole other level of hard. You're asking for how to change asm code for one processor into asm code for another, which would be a pain to do by hand by would be suicidal to try to code the logic for. What you're asking for is, and I hate to say it, reasonably impossible(infeasible).

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    So where is the "source" code for your s-records?

    Why not just recompile from source, using the tool-chain on your new platform, to produce executable programs on your new platform.

    Alternatively - Category:68k emulators - Wikipedia, the free encyclopedia
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User TheEngineer's Avatar
    Join Date
    Aug 2009
    Posts
    50
    Quote Originally Posted by Salem View Post
    So where is the "source" code for your s-records?

    Why not just recompile from source, using the tool-chain on your new platform, to produce executable programs on your new platform.

    Alternatively - Category:68k emulators - Wikipedia, the free encyclopedia
    The problem I run in to is that the test file (which is now an executable) needs to be an argument to the main program. For instance, the Main program takes arguments of a testfile, input file, etc. All arguments except for the test file are .txt files or numbers. So what I am trying to figure out is how to run the main program (an executable) with the test file (also an executable) as an argument

  8. #8
    Registered User TheEngineer's Avatar
    Join Date
    Aug 2009
    Posts
    50
    My latest thoughts are to use Objective-C code to write a class that could open the testfile as well as pass the other arguments to the program at run time rather than compile time. Does anyone have experience with this and know if it will work?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  3. File send app - md5 checksum different when load is put on server.
    By (Slith++) in forum Networking/Device Communication
    Replies: 5
    Last Post: 12-31-2007, 01:23 PM
  4. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM