summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSachin Gupta <sgupta2m@in.ibm.com>2015-10-08 04:23:00 -0500
committerGregory S. Still <stillgs@us.ibm.com>2015-10-15 21:15:23 -0500
commit43aaa85b59ba06dce6e0f7063234235384e31135 (patch)
tree7bce534bface7892fda3a0a504e985a1f1d6597c
parent4d0a0ca7b6375ad21614ecc4538da9fdf5ea8b7a (diff)
downloadtalos-sbe-43aaa85b59ba06dce6e0f7063234235384e31135.tar.gz
talos-sbe-43aaa85b59ba06dce6e0f7063234235384e31135.zip
Global constructor support
Change-Id: I3073787372f8405adc2b8d11f41413e3b61688ce Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/21036 Tested-by: Jenkins Server Reviewed-by: Martin Peschke <mpeschke@de.ibm.com> Reviewed-by: Gregory S. Still <stillgs@us.ibm.com>
-rw-r--r--hwpf/plat/src/target.C5
-rw-r--r--sbe/image/linksbe.cmd11
-rw-r--r--sbe/sbefw/sbemain.C25
3 files changed, 32 insertions, 9 deletions
diff --git a/hwpf/plat/src/target.C b/hwpf/plat/src/target.C
index be9727f9..c70fc42c 100644
--- a/hwpf/plat/src/target.C
+++ b/hwpf/plat/src/target.C
@@ -307,11 +307,6 @@ fapi_try_exit:
G_ex_attributes_ptr = &G_ex_attributes;
- // This is workaround. Currently we do not have code to initialise
- // global objects. So initializing global objects against using local
- // initialized object
- std::vector<fapi2::plat_target_handle_t> targets1;
- G_vec_targets = std::move(targets1);
std::vector<fapi2::plat_target_handle_t>::iterator tgt_iter;
uint32_t l_beginning_offset;
diff --git a/sbe/image/linksbe.cmd b/sbe/image/linksbe.cmd
index 0f7435db..cea69a2b 100644
--- a/sbe/image/linksbe.cmd
+++ b/sbe/image/linksbe.cmd
@@ -30,15 +30,18 @@ SECTIONS
// SDA2 constant sections .sdata2 and .sbss2 must be adjacent to each
// other. Our SDATA sections are small so we'll use strictly positive
- // offsets.
+ // offsets.
_SDA2_BASE_ = .;
.sdata2 . : { *(.sdata2) } > sram
.sbss2 . : { *(.sbss2) } > sram
- // Other read-only data.
-
- .rodata . : { *(.rodata*) *(.got2) } > sram
+ // Other read-only data.
+
+ .rodata . : { ctor_start_address = .;
+ *(.ctors) *(.ctors.*)
+ ctor_end_address = .;
+ *(rodata*) *(.got2) } > sram
_RODATA_SECTION_SIZE = . - _RODATA_SECTION_BASE;
diff --git a/sbe/sbefw/sbemain.C b/sbe/sbefw/sbemain.C
index 65d91f4d..a10c1799 100644
--- a/sbe/sbefw/sbemain.C
+++ b/sbe/sbefw/sbemain.C
@@ -50,6 +50,26 @@ PkThread g_sbeSyncCommandProcessor_thread;
////////////////////////////////////////////////////////////////
PkThread g_sbeAsyncCommandProcessor_thread;
+extern "C"
+{
+// These variables are declared in linker script to keep track of
+// global constructor pointer functions.
+extern void (*ctor_start_address)() __attribute__ ((section (".rodata")));
+extern void (*ctor_end_address)() __attribute__ ((section (".rodata")));
+// This function will be used to do any C++ handling required before doing
+// any main job. Ideally the call to this function should get generated by
+// compiler. But as this is not happening in our codebase,
+// we are calling it explicitly in our main code.
+void __eabi()
+{
+ void(**ctors)() = &ctor_start_address;
+ while( ctors != &ctor_end_address)
+ {
+ (*ctors)();
+ ctors++;
+ }
+}
+} // end extern "C"
////////////////////////////////////////////////////////////////
// @brief sbeInitSems - Create the necessary semaphores
@@ -216,6 +236,11 @@ uint32_t main(int argc, char **argv)
SBE_ENTER(SBE_FUNC);
int l_rc = 0;
+ //@NOTE: This should be first function to call as this will do
+ //C++ initialisation. We may want to move it to loader butPK is not
+ // initialised at that time and some constroctors may depend on pk code.
+ __eabi();
+
// @TODO via RTC : 128818
// Explore on reclaiming the stack
// used by this Initialization code
OpenPOWER on IntegriCloud