Hi,

Thank you for the help, it did work. I've reduced it to only needing `-c` 
(compile, but do not link) as the extra option.

Thanks again,
Boldizsár Palotás



From:   Chris Johns <[email protected]>
To:     [email protected], [email protected]
Date:   2018.09.18 08:18
Subject:        Re: Link a simple program and load into RTEMS with dlopen



On 18/09/2018 01:29, [email protected] wrote:
> Hi,

Hi, and welcome.

> I'm using RTEMS 4.11 and the builtin POSIX API functions to dynamically 
load a
> program image into memory. The program image is loaded in RTEMS using 
the
> following code:
> void* handle = dlopen(prog_name, RTLD_NOW | RTLD_GLOBAL);
> if (!handle)
>    printf("dlopen: %s\n", dlerror());

This looks fine.

> I'm using the GCC built by RTEMS Source Builder to compile the object 
located at
> prog_namein the in-memory filesystem.

Great.

> What command line should I use to properly compile a single C file to be 
loaded
> this way?

You need to use the same command line used to compile any source to an 
object
file. The dynamic loader in RTEMS supports a relocatable ELF file the 
compiler
creates with out the need for special options.

> For reference, I've tried the following command line options, but got an 
error:
> $ /opt/rtems-4.11/bin/sparc-rtems4.11-gcc test.c -c -o test.elf -shared 
-fPIC

Do not use the `-shared` option, also the `-fPIC` option is not needed for 
RTEMS
loadable code.

The RTEMS loader is not like the Linux or FreeBSD libdl loaders. The RTEMS
loader will perform a standard link-edit process to locate the code in 
your
address space.

> $ # Run in emulator, result:
> $ # dlopen: global symbol not found: _GLOBAL_OFFSET_TABLE_

This will be related to either the -shared or -fPIC options.

> I have also tried some other combinations and also using the rtems-ld 
program.

The rtems-ld command is used to managing more complex sets of object 
files. You
can load the ELF files directly.

> Any ideas?

I hope this helps.

Chris



This message is intended only for the recipient(s) named above. It may contain 
proprietary information and/or
protected content. Any unauthorised disclosure, use, retention or dissemination 
is prohibited. If you have received
this e-mail in error, please notify the sender immediately. ESA applies 
appropriate organisational measures to protect
personal data, in case of data privacy queries, please contact the ESA Data 
Protection Officer ([email protected]).

_______________________________________________
users mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/users

Reply via email to