File:  [DVB] / dietlibc / dyn_start.c
Revision 1.7: download - view: text, annotated - select for diffs
Mon Feb 25 16:00:49 2002 UTC (22 years, 3 months ago) by olaf
Branches: MAIN
CVS tags: finnland_test_200301, branch_rc14_fieldtest_finnland, branch_rc13_fieldtest_finnland, branch_rc12_fieldtest_finnland, branch_rc10_fieldtest_finnland, RELEASE_finnland_200301_1, RC12_FIELDTEST_FINNLAND, RC10_FIELDTEST_FINNLAND, HEAD
Assembler and PIC code the source of all evel in the dynamic-section....
Added a helper for x86 and modified the assembler sources (now the
libdietc.so is NON textrel again....). S390 fixed a typo.
Fixed diet so dynamic binaries uses the "correct" dynamic-linker...

#include "dietfeatures.h"

#ifdef WANT_DYNAMIC
#include <stdlib.h>

typedef void(*structor)(void);

__attribute__((section(".ctors")))
static structor __CTOR_LIST__[1]={((structor)-1)};

__attribute__((section(".dtors")))
static structor __DTOR_LIST__[1]={((structor)-1)};

static void __do_global_dtors_aux(void)
{
  structor *df=__CTOR_LIST__;	/* ugly trick to prevent warning */
  for (df=((__DTOR_LIST__)+1);(*df) != (structor)0; df++) (*df)();
}

void _fini(void) __attribute__((section(".fini")));
__attribute__((section(".fini"))) void _fini(void)
{
  __do_global_dtors_aux();
}

#ifndef __DYN_LIB_SHARED
/* pre main, post _start */
int _dyn_start(int argc, char **argv, char **envp, structor dl_init);
int _dyn_start(int argc, char **argv, char **envp, structor dl_init)
{
  static __attribute__((section(".init"))) void _init(void);
  int main(int argc, char **argv, char **envp);

  if (dl_init) atexit(dl_init);
  _init();
  atexit(_fini);
  return main(argc, argv, envp);
}
#endif
#endif

LinuxTV legacy CVS <linuxtv.org/cvs>