It was a bug in the linker command file. See attached patches. ----- Am 28. Feb 2018 um 12:50 schrieb Thanassis Tsiodras thanassis.tsiod...@esa.int:
>> However, I am not able to reproduce this problem. > > Hi Sebastian. > > Look at the reply I sent this morning to the mailing list - I uploaded the > code in a GitHub repository and provided instructions in the mailing list > with the exact invocations that reproduce the issue. > > Hope this helps! > Thanassis. > > Thanassis Tsiodras > Real-time Embedded Software Engineer > System, Software and Technology Department > > ESTEC > Keplerlaan 1, PO Box 299 > NL-2200 AG Noordwijk, The Netherlands > thanassis.tsiod...@esa.int | www.esa.int > T +31 71 565 5332 > > > > From: Sebastian Huber <sebastian.hu...@embedded-brains.de> > To: Thanassis Tsiodras <thanassis.tsiod...@esa.int> > Cc: devel <devel@rtems.org> > Date: 28/02/2018 12:11 > Subject: Re: N2X, GR740 and coverage: The impact of a linkcmds > patch from 2014 to gcov_init calls > > > > ----- Am 27. Feb 2018 um 17:30 schrieb Thanassis Tsiodras > thanassis.tsiod...@esa.int: > > [...] >> After quite a lot of hunting, we traced this failure to a patch in the >> "linkcmds.base" - done back in 2014 ( commit 95cb09ed746 ) : >> >> This commit changed > "c/src/lib/libbsp/sparc/shared/startup/linkcmds.base" >> from this: >> >> KEEP (*(SORT(.ctors.*))) >> KEEP (*(.ctors)) >> KEEP (*crtbegin.o(.dtors)) >> KEEP (*crtbegin?.o(.dtors)) >> KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) >> KEEP (*(SORT(.dtors.*))) >> KEEP (*(.dtors)) >> >> ...to this: >> >> KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) >> KEEP (*(SORT(.ctors*))) >> KEEP (*crtbegin.o(.dtors)) >> KEEP (*crtbegin?.o(.dtors)) >> KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) >> KEEP (*(SORT(.dtors*))) >> >> Reverting this change, the gcov stubs revert back to their proper place, >> and __gcov_inits are called properly. >> >> The reason I tried this patch, was because I noticed that the coverage >> stubs are no longer placed in ".ctor" sections - they are instead placed >> by the newer compilers at ".ctor.NUMBER" sections (with NUMBER set to >> 65435 in my case - but I am guessing this will change from invocation to >> invocation). >> >> The comment provided by Joel back in 2014, only indicated that this > patch >> was done to address C++ concerns: >> >> commit 95cb09ed746e7daeca2158c7ecdf0249cfcbc5c8 >> Author: Joel Sherrill <joel.sherr...@oarcorp.com> >> Date: Wed Apr 2 11:39:20 2014 -0500 >> >> sparc/shared/.../linkcmds.base: Correct C++ support >> Add KEEP() for .eh_frame*, .ctor*, and .dtor*. > > It could be a bug in the linker. The standard sections should be exactly > like the Binutils default: > > sparc-rtems5-ld --verbose | grep ctor -C 3 > *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) > *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) > *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) > *(.rela.ctors) > *(.rela.dtors) > *(.rela.got) > *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) > -- > .init_array : > { > PROVIDE_HIDDEN (__init_array_start = .); > KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) > SORT_BY_INIT_PRIORITY(.ctors.*))) > KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o > *crtend?.o ) .ctors)) > PROVIDE_HIDDEN (__init_array_end = .); > } > .fini_array : > -- > KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o > *crtend?.o ) .dtors)) > PROVIDE_HIDDEN (__fini_array_end = .); > } > .ctors : > { > /* gcc uses crtbegin.o to find the start of > the constructors, so we make sure it is > first. Because this is a wildcard, it > doesn't matter if the user does not > actually link against crtbegin.o; the > linker won't look for a file to match a > wildcard. The wildcard also means that it > doesn't matter which directory crtbegin.o > is in. */ > KEEP (*crtbegin.o(.ctors)) > KEEP (*crtbegin?.o(.ctors)) > /* We don't want to include the .ctor section from > the crtend.o file until after the sorted ctors. > The .ctor section from the crtend file contains the > end of ctors marker and it must be last */ > KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) > KEEP (*(SORT(.ctors.*))) > KEEP (*(.ctors)) > } > .dtors : > { > > However, I am not able to reproduce this problem. For example in the > sptls04 linker map file (-Wl,-Map,map.txt) we have this: > > *crtbegin.o(.ctors) > .ctors 0x0000000002011330 0x4 > /opt/rtems/5/lib/gcc/sparc-rtems5/7.3.0/crtbegin.o > *crtbegin?.o(.ctors) > *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) > .ctors 0x0000000002011334 0x4 init.o > *(SORT_BY_NAME(.ctors*)) > .ctors 0x0000000002011338 0x4 > /opt/rtems/5/lib/gcc/sparc-rtems5/7.3.0/crtend.o > > Who do the linker map files look in your test case? > > > > This message and any attachments are intended for the use of the addressee or > addressees only. > The unauthorised disclosure, use, dissemination or copying (either in whole or > in part) of its > content is not permitted. > If you received this message in error, please notify the sender and delete it > from your system. > Emails can be altered and their integrity cannot be guaranteed by the sender. > > Please consider the environment before printing this email.
From be61988bd48facafc318cb15a02787f791e35299 Mon Sep 17 00:00:00 2001 From: Sebastian Huber <sebastian.hu...@embedded-brains.de> Date: Wed, 28 Feb 2018 13:02:55 +0100 Subject: [PATCH 1/2] spglobalcon02: New test --- testsuites/sptests/Makefile.am | 1 + testsuites/sptests/configure.ac | 1 + testsuites/sptests/spglobalcon02/Makefile.am | 19 +++++ testsuites/sptests/spglobalcon02/init.c | 93 ++++++++++++++++++++++ testsuites/sptests/spglobalcon02/spglobalcon02.doc | 11 +++ testsuites/sptests/spglobalcon02/spglobalcon02.scn | 7 ++ 6 files changed, 132 insertions(+) create mode 100644 testsuites/sptests/spglobalcon02/Makefile.am create mode 100644 testsuites/sptests/spglobalcon02/init.c create mode 100644 testsuites/sptests/spglobalcon02/spglobalcon02.doc create mode 100644 testsuites/sptests/spglobalcon02/spglobalcon02.scn diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 9bd53c58a2..2813062d6d 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -71,6 +71,7 @@ if HAS_CPLUSPLUS _SUBDIRS += spglobalcon01 _SUBDIRS += sptls02 endif +_SUBDIRS += spglobalcon02 _SUBDIRS += sptls01 _SUBDIRS += spintrcritical20 _SUBDIRS += spintrcritical21 diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac index 36ae9ac56a..2ebc5541c9 100644 --- a/testsuites/sptests/configure.ac +++ b/testsuites/sptests/configure.ac @@ -59,6 +59,7 @@ sptimecounter03/Makefile sptimecounter04/Makefile spatomic01/Makefile spglobalcon01/Makefile +spglobalcon02/Makefile spintrcritical22/Makefile spsem03/Makefile spmrsp01/Makefile diff --git a/testsuites/sptests/spglobalcon02/Makefile.am b/testsuites/sptests/spglobalcon02/Makefile.am new file mode 100644 index 0000000000..3df53efddb --- /dev/null +++ b/testsuites/sptests/spglobalcon02/Makefile.am @@ -0,0 +1,19 @@ +rtems_tests_PROGRAMS = spglobalcon02 +spglobalcon02_SOURCES = init.c + +dist_rtems_tests_DATA = spglobalcon02.scn spglobalcon02.doc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(spglobalcon02_OBJECTS) +LINK_LIBS = $(spglobalcon02_LDLIBS) + +spglobalcon02$(EXEEXT): $(spglobalcon02_OBJECTS) $(spglobalcon02_DEPENDENCIES) + @rm -f spglobalcon02$(EXEEXT) + $(make-exe) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/sptests/spglobalcon02/init.c b/testsuites/sptests/spglobalcon02/init.c new file mode 100644 index 0000000000..5ce7264dea --- /dev/null +++ b/testsuites/sptests/spglobalcon02/init.c @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2018 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rt...@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdlib.h> + +#include <tmacros.h> + +const char rtems_test_name[] = "SPGLOBALCON 2"; + +static int i; + +static __attribute__((__constructor__(1000))) void c0(void) +{ + rtems_test_assert(i == 0); + ++i; +} + +static __attribute__((__constructor__(1001))) void c1(void) +{ + rtems_test_assert(i == 1); + ++i; +} + +static __attribute__((__constructor__(1002))) void c2(void) +{ + rtems_test_assert(i == 2); + ++i; +} + +static __attribute__((__constructor__)) void c(void) +{ + rtems_test_assert(i == 3); + ++i; +} + +static __attribute__((__destructor__(1000))) void d0(void) +{ + rtems_test_assert(i == 8); + TEST_END(); + rtems_test_exit(0); +} + +static __attribute__((__destructor__(1001))) void d1(void) +{ + rtems_test_assert(i == 7); + ++i; +} + +static __attribute__((__destructor__(1002))) void d2(void) +{ + rtems_test_assert(i == 6); + ++i; +} + +static __attribute__((__destructor__)) void d(void) +{ + rtems_test_assert(i == 5); + ++i; +} + +static void Init(rtems_task_argument arg) +{ + TEST_BEGIN(); + rtems_test_assert(i == 4); + ++i; + exit(0); +} + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS 1 + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT + +#include <rtems/confdefs.h> diff --git a/testsuites/sptests/spglobalcon02/spglobalcon02.doc b/testsuites/sptests/spglobalcon02/spglobalcon02.doc new file mode 100644 index 0000000000..401f211fbb --- /dev/null +++ b/testsuites/sptests/spglobalcon02/spglobalcon02.doc @@ -0,0 +1,11 @@ +This file describes the directives and concepts tested by this test set. + +test set name: spglobalcon02 + +directives: + + TBD + +concepts: + + - Ensure global construction and destruction works. diff --git a/testsuites/sptests/spglobalcon02/spglobalcon02.scn b/testsuites/sptests/spglobalcon02/spglobalcon02.scn new file mode 100644 index 0000000000..714bc3ef88 --- /dev/null +++ b/testsuites/sptests/spglobalcon02/spglobalcon02.scn @@ -0,0 +1,7 @@ +*** BEGIN OF TEST SPGLOBALCON 2 *** +*** TEST VERSION: 5.0.0.5b7a1e145df3d278f315ead280bc55c67184b943 +*** TEST STATE: EXPECTED-PASS +*** TEST BUILD: RTEMS_NETWORKING RTEMS_POSIX_API RTEMS_SMP +*** TEST TOOLS: 7.3.0 20180125 (RTEMS 5, RSB 6d9c77c77d271d1fc2dfe8493d6713930b52a6dd, Newlib 3.0.0) + +*** END OF TEST SPGLOBALCON 2 *** -- 2.13.6
From 2afd2f4bef480bea4c0235942e9606aebc2611b7 Mon Sep 17 00:00:00 2001 From: Sebastian Huber <sebastian.hu...@embedded-brains.de> Date: Wed, 28 Feb 2018 13:03:19 +0100 Subject: [PATCH 2/2] bsps/sparc: Fix global construction/destruction See spglobalcon02 test case. --- c/src/lib/libbsp/sparc/shared/startup/linkcmds.base | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/c/src/lib/libbsp/sparc/shared/startup/linkcmds.base b/c/src/lib/libbsp/sparc/shared/startup/linkcmds.base index b4e1c28121..4c7750dfe0 100644 --- a/c/src/lib/libbsp/sparc/shared/startup/linkcmds.base +++ b/c/src/lib/libbsp/sparc/shared/startup/linkcmds.base @@ -88,11 +88,13 @@ SECTIONS The .ctor section from the crtend file contains the end of ctors marker and it must be last */ KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) - KEEP (*(SORT(.ctors*))) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) KEEP (*crtbegin.o(.dtors)) KEEP (*crtbegin?.o(.dtors)) KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) - KEEP (*(SORT(.dtors*))) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) _rodata_start = . ; *(.rodata*) -- 2.13.6
_______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel