genode/repos/os/src/server/nic_router/main.cc
Christian Helmuth cb43e04691 ldso: defer execution of static constructors
Ldso now does not automatically execute static constructors of the
binary and shared libraries the binary depends on. If static
construction is required (e.g., if a shared library with constructor is
used or a compilation unit contains global statics) the component needs
to execute the constructors explicitly in Component::construct() via
Genode::Env::exec_static_constructors().

In the case of libc components this is done by the libc startup code
(i.e., the Component::construct() implementation in the libc).

The loading of shared objects at runtime is not affected by this change
and constructors of those objects are executed immediately.

Fixes #2332
2017-03-24 16:20:04 +01:00

69 lines
1.5 KiB
C++

/*
* \brief Server component for Network Address Translation on NIC sessions
* \author Martin Stein
* \date 2016-08-24
*/
/*
* Copyright (C) 2016-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
/* Genode */
#include <base/component.h>
#include <base/heap.h>
#include <base/attached_rom_dataspace.h>
#include <os/timer.h>
#include <nic/xml_node.h>
#include <timer_session/connection.h>
/* local includes */
#include <component.h>
#include <uplink.h>
#include <configuration.h>
using namespace Net;
using namespace Genode;
class Main
{
private:
Timer::Connection _timer_connection;
Genode::Timer _timer;
Genode::Heap _heap;
Genode::Attached_rom_dataspace _config_rom;
Configuration _config;
Uplink _uplink;
Net::Root _root;
public:
Main(Env &env);
};
Main::Main(Env &env)
:
_timer_connection(env), _timer(_timer_connection, env.ep()),
_heap(&env.ram(), &env.rm()), _config_rom(env, "config"),
_config(_config_rom.xml(), _heap),
_uplink(env, _timer, _heap, _config),
_root(env.ep(), _timer, _heap, _uplink.router_mac(), _config, env.ram(),
env.rm())
{
env.parent().announce(env.ep().manage(_root));
}
void Component::construct(Env &env)
{
/* XXX execute constructors of global statics */
env.exec_static_constructors();
static Main main(env);
}