File: test_pthread_dlopen_side.c

package info (click to toggle)
emscripten 3.1.69%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 121,860 kB
  • sloc: ansic: 636,110; cpp: 425,974; javascript: 78,401; python: 58,404; sh: 49,154; pascal: 5,237; makefile: 3,366; asm: 2,415; lisp: 1,869
file content (34 lines) | stat: -rw-r--r-- 790 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>

typedef int (*myfunc_type)();

static int mydata[10] = { 44 };

static void dtor() {
  puts("side module atexit ..");
}

__attribute__((constructor)) static void ctor() {
  puts("side module ctor");
  atexit(dtor);
}

static int myfunc() {
  return 43;
}

// Exposing the address of `mydata` in this way forces it to
// be present in the .data segment with its address calculated
// relative the `__memory_base` at which the DSO is loaded.
int* side_data_address() {
  return mydata;
}

// Exposing the address of `mydata` in this way forces it to
// be present in static table region on the DSO and its
// address will be calculated relative to the `__table_base`
// at which the DSO is loaded.
myfunc_type side_func_address() {
  return &myfunc;
}