[PATCH] libtests/dl06: Add -lm

Chris Johns chrisj at rtems.org
Tue Nov 10 23:58:50 UTC 2020


On 10/11/20 6:32 pm, Sebastian Huber wrote:
> On 09/11/2020 23:42, Chris Johns wrote:
> 
>> On 9/11/20 6:24 pm, Sebastian Huber wrote:
>>> On 09/11/2020 02:23, Chris Johns wrote:
>>>
>>>> On 3/11/20 3:39 am, Sebastian Huber wrote:
>>>>> There is probably something wrong with this test program.  If it is compiled
>>>>> without function/data sections, no optimization, and no linker garbage
>>>>> collection, then there is an undefined reference to atan2() and tan().
>>>> These symbols are referenced in the loaded module ...
>>>>
>>>> https://git.rtems.org/rtems/tree/testsuites/libtests/dl06/dl06-o2.c
>>>>
>>>> This test gets rtems-ld with the RAP format to collect the atan1 and tan code
>>>> into the loaded module. They should not be present in the base image. The libm
>>>> library is used because it is_not_  part of the standard libraries linked
>>>> and is
>>>> available everywhere.
>>>>
>>>>> Fix this issue by adding -lm.
>>>> Is the error linking the base kernel image or the RAP loadable module?
>>>>
>>>> If it is the loadable module and this is how you add the libraries to be
>>>> searched to the rtems-ld command then the fix is needed and there is no
>>>> problem.
>>>> If the error was in the base kernel image then I suggest something else is
>>>> wrong
>>>> because those symbols should not be present in the base image. If the build
>>>> system can support options for just rtems-ld then adding it there would be
>>>> good.
>>> The error is in this command:
>>>
>>>
>>> [4044/4050] Processing link:
>>> build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl06/dl06-o1.o
>>> build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl06/dl06-o2.o
>>> build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl06/dl06-tar.o
>>> build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl06/init.o
>>> build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl06/dl-load.o
>>> build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl06/dl06-sym.o ->
>>> build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl06.exe
>>> 08:21:03 runner ['/build/rtems/6/bin/arm-rtems6-gcc', '-qnolinkcmds', '-T',
>>> 'linkcmds.realview_pbx_a9_qemu',
>>> '/home/EB/sebastian_h/git-rtems-6/build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl06/dl06-o1.o',
>>>
>>> '/home/EB/sebastian_h/git-rtems-6/build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl06/dl06-o2.o',
>>>
>> These should not be linked into the base image. They are in the RAP image in
>> dl06-tar.o.
> What shouldn't be linked in? The entire object files or only some functions in it?

In this test dl06-o1.o and dl06-o2.o.

In general any code placed in the tar file to be dynamically load. Linking the
code to be loaded into the base image potentinally breaks the test.

>>> '/home/EB/sebastian_h/git-rtems-6/build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl06/dl06-tar.o',
>>>
>>> '/home/EB/sebastian_h/git-rtems-6/build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl06/init.o',
>>>
>>> '/home/EB/sebastian_h/git-rtems-6/build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl06/dl-load.o',
>>>
>>> '/home/EB/sebastian_h/git-rtems-6/build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl06/dl06-sym.o',
>>>
>>> '-o/home/EB/sebastian_h/git-rtems-6/build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl06.exe',
>>>
>>> '-Wl,--wrap=printf', '-Wl,--wrap=puts', '-L.', '-lrtemscpu', '-lrtemsbsp',
>>> '-lrtemstest', '-qrtems', '-march=armv7-a', '-mthumb', '-mfpu=neon',
>>> '-mfloat-abi=hard', '-mtune=cortex-a9',
>>> '-L/home/EB/sebastian_h/git-rtems-6/bsps/arm/shared/start',
>>> '-L/home/EB/sebastian_h/git-rtems-6/bsps/arm/realview-pbx-a9/start']
>>> /build/rtems/6/lib/gcc/arm-rtems6/10.2.1/../../../../arm-rtems6/bin/ld:
>>> /home/EB/sebastian_h/git-rtems-6/build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl06/dl06-o2.o:
>>>
>>> in function `dl_o2_func2':
>>> /home/EB/sebastian_h/git-rtems-6/testsuites/libtests/dl06/dl06-o2.c:31:
>>> undefined reference to `atan2'
>>> /build/rtems/6/lib/gcc/arm-rtems6/10.2.1/../../../../arm-rtems6/bin/ld:
>>> /home/EB/sebastian_h/git-rtems-6/build/arm/realview_pbx_a9_qemu/testsuites/libtests/dl06/dl06-o2.o:
>>>
>>> in function `dl_o2_func3':
>>>
>>> /home/EB/sebastian_h/git-rtems-6/testsuites/libtests/dl06/dl06-o2.c:37:
>>> undefined reference to `tan'
>>>
>>> I used the following config.ini:
>>>
>>> [arm/realview_pbx_a9_qemu]
>>> BUILD_LIBTESTS = True
>>> OPTIMIZATION_FLAGS = -O0 -g
>>> LDFLAGS =
>>>
>>>> More of a concern is no error. I wonder if the code is being inlined when there
>>>> is FPU support. Maybe the test needs to create a library linking to it to be
>>>> more robust?
>>> Using these functions without -fno-builtin is not really robust.
>> Would adding a pragma for this option to dl06-o1.c and dl06-o2.c be acceptable
>> as a solution?
> I am not sure if a pragma works for these options. We can add -fno-builtin=tan
> -fno-builtin=atan2. We can use also some global volatile variables which seems
> to work for the math tests.

But only for dl06-o1.o and dl06-o2.o in the test?

Chris


More information about the devel mailing list