Combining multiple object files into one at link-time

Pavel Pisa ppisa4lists at pikron.com
Wed Aug 24 16:28:03 UTC 2016


Hello Saeed,

On Wednesday 24 of August 2016 16:44:25 Saeed Ehteshamifar wrote:
> Hello,
>
> In Linux, one can make a shared library that has the binary code for
> several objects like this:
> gcc -shared -fpic obj1.o obj2.o -o obj.so
>
> Is it possible to do the same with RTEMS objects?
> The problem is that I have two separate source files, where one (the test
> case) uses the other one (the test setting). I want to dynamically load
> *one* object file that contains the binary code for both files.

RTEMS uses ELF or RAP objects before final image linking.
This means that you need to multiple combine object files
to single relocatable object file, see ld flag -r/--relocatable

  {i386,arm,...}-rtems4.12-ld -r -o combined.o obj1.o obj2.o

I have not tested that for RTEMS yet, but should work.

I consider to modify RTEMS OMK rules to replace shared
libraries targets/rules to behave this way for RTEMS
case to obtain what is expected by user.

Other option is to place multiple object to single
archive

  ar r combined.a obj1.o obj2.o

I think, that it should work in RTEMS elf loader,
??? Chris, can you comment, please  ???

You can call dlopen multiple times from application
as well to have modular/separate test and settings.

Best wishes,

              Pavel



More information about the users mailing list