trouble with Dynamic load application

Chris Johns chrisj at
Thu Aug 3 03:32:54 UTC 2017

On 03/08/2017 13:22, jameszxj wrote:
>> On 03/08/2017 11:48, jameszxj wrote:
>> > Hi
>> >   I run RTEMS on my xilinx z7k board and dynamic load application from shell.
>> > when the app just has 1 source file,
>> > dynamic is ok. when the app have more than 1 files, for example a.c b.c,
>> > function a() in file a.c function b() in b.c
>> > and function a() call b(), dynamic failed.
>> >
>> > compiler command line
>> > 1 file: a.c
>> >    arm-rtems4.12-gcc -c -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard
>> > -mtune=cortex-a9 -mlong-calls a.c
>> >
>> > more than 1 file: a.c b.c
>> >    arm-rtems4.12-gcc -r -nostdlib -march=armv7-a -mthumb -mfpu=neon
>> > -mfloat-abi=hard -mtune=cortex-a9 -mlong-calls a.c b.c -o app.elf
>> >
>> I have never tested the loading of incrementally linked ELF files. This is new
>> ground.
>   my previous project, we work in this way. OS is vxworks, complier is gcc.

Ah ok. It would be nice to have incremental linking supported.

>   I just notice that tornado link every .o file with a linkscript file. so i
> analyzed the
>   object file use objdump, i found that link with a linkscript has the uniform
> text section,
>   for example *.text *.bss ...  But my app.elf has many sections, *.text.a
> *.text.b ...
>   every function has a text section.
>   I am trying to write a linkscript file to test if it is the problem.

We use a section per function options so we eliminate functions that are not needed.

>> Did you build RTEMS with '-mlong-calls'? I am not sure if adding this option
>> changes the ABI and if it safe with just the dynamically loaded object files. It
>> would be nice if it was.
> if no '-mlong-call' option, function call only in +-24M address range, my board
> have 512M ram, dynamic do not work.
> I reduce ram to 32M in linkscript file, '-mlong-call' is not need.

Understood. I have an outstanding task to implement veneers on ARM and void this
but it is not a simple couple of hours change.

>> Why not do:
>>  arm-rtems4.12-gcc -march=armv7-a -mthumb -mfpu=neon \
>>      -mfloat-abi=hard -mtune=cortex-a9 a.c -o a.o
>>  arm-rtems4.12-gcc -march=armv7-a -mthumb -mfpu=neon \
>>      -mfloat-abi=hard -mtune=cortex-a9 b.c -o b.o
>> And then load both files?
> application has many c files, load every file is troublesome.

Agreed. Incremental linking is the solution here.

>> The RTEMS dynamic loader can load from archives using 'archive:file' so you only
>> need to manage a single file on the target, for example 'my.a:a.o' and 'my.a:b.o'.
> It is a way to solve my problem, thanks.

It would but there is a trade off here which incremental linking avoids and that
is the internal symbols and relocs are resolved and so lowers the overhead on
the target.


More information about the users mailing list