cpp: support for 64-bit constructors

Make constructors work in a 64-bit build.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit is contained in:
Nicolas Pitre 2019-07-30 17:38:00 -04:00 committed by Andrew Boie
commit 2bdfede0f8
2 changed files with 11 additions and 2 deletions

View file

@ -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,,)