Skip to content
Permalink
Browse files

cpp: support for 64-bit constructors

Make constructors work in a 64-bit build.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
  • Loading branch information...
Nicolas Pitre authored and andrewboie committed Jul 30, 2019
1 parent 2e3bd4b commit 2bdfede0f80d33583bcd89bcff0e252fd9776aff
Showing with 11 additions and 2 deletions.
  1. +10 −1 include/linker/common-rom.ld
  2. +1 −1 subsys/cpp/cpp_ctors.c
@@ -17,17 +17,26 @@
{
/*
* The compiler fills the constructor pointers table below,
* hence symbol __CTOR_LIST__ must be aligned on 4 byte
* hence symbol __CTOR_LIST__ must be aligned on word
* boundary. To align with the C++ standard, the first elment
* of the array contains the number of actual constructors. The
* last element is NULL.
*/
#ifdef CONFIG_64BIT
. = ALIGN(8);
__CTOR_LIST__ = .;
QUAD((__CTOR_END__ - __CTOR_LIST__) / 8 - 2)
KEEP(*(SORT_BY_NAME(".ctors*")))
QUAD(0)
__CTOR_END__ = .;
#else
. = ALIGN(4);
__CTOR_LIST__ = .;
LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
KEEP(*(SORT_BY_NAME(".ctors*")))
LONG(0)
__CTOR_END__ = .;
#endif
} GROUP_LINK_IN(ROMABLE_REGION)

SECTION_PROLOGUE(init_array,,)
@@ -35,7 +35,7 @@ void __do_global_ctors_aux(void)
{
unsigned int nCtors;

nCtors = (unsigned int)__CTOR_LIST__[0];
nCtors = (unsigned long)__CTOR_LIST__[0];

while (nCtors >= 1U) {
__CTOR_LIST__[nCtors--]();

0 comments on commit 2bdfede

Please sign in to comment.
You can’t perform that action at this time.