source: rtems/testsuites/libtests/dl02/dl-o1.c @ 6c9f017

5
Last change on this file since 6c9f017 was 6c9f017, checked in by Chris Johns <chrisj@…>, on 02/02/19 at 04:09:53

libdl: Add powerpc large memory and small data support.

  • Add support for architecure sections that can be handled by the architecture back end.
  • Add trampoline/fixup support for PowerPC. This means the PowerPC now supports large memory loading of applications.
  • Add a bit allocator to manage small block based regions of memory.
  • Add small data (sdata/sbss) support for the PowerPC. The support makes the linker allocated small data region of memory a global resource available to libdl loaded object files.

Updates #3687
Updates #3685

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 * Copyright (c) 2014 Chris Johns <chrisj@rtems.org>.  All rights reserved.
3 *
4 * The license and distribution terms for this file may be
5 * found in the file LICENSE in this distribution or at
6 * http://www.rtems.org/license/LICENSE.
7 */
8
9#include "dl-o2.h"
10
11#include <dlfcn.h>
12
13#include <rtems/test.h>
14
15#define printf(...) rtems_printf(&rtems_test_printer, __VA_ARGS__);
16
17typedef int (*func1_t)(int argc, const char* argv[]);
18
19static void* find_sym(const char* name)
20{
21  void* sym = dlsym(RTLD_DEFAULT, name);
22  if (sym == NULL)
23    printf("dlsym failed: not found: %s\n", name);
24  return sym;
25}
26
27static int dl_o1_callback(const char* message, int count)
28{
29  printf("dl_o1_callback: %s\n", message);
30  return count + 1;
31}
32
33/*
34 * Yes a decl in the source. This is a modules main and I could not find which
35 * header main is defined in.
36 */
37int rtems_main (int argc, const char* argv[]);
38
39#define PDOUBLE(_d) ((int) (_d)), (int) ((_d) * 100.0) % 100
40
41int rtems_main (int argc, const char* argv[])
42{
43  func1_t f1;
44  double  f2_ret;
45  int     arg;
46  int     ret;
47
48  printf("Loaded module: argc:%d [%s]\n", argc, __FILE__);
49  for (arg = 0; arg < argc; ++arg)
50    printf("  %d: %s\n", arg, argv[arg]);
51
52  f1 = find_sym ("dl_o2_func1");
53  if (f1 == NULL)
54    return 0;
55
56  if (f1 (argc, argv) != argc)
57  {
58    printf("rtems_main: dl_o2_func1 returned bad value\n");
59    return 0;
60  }
61
62  f2_ret = dl_o2_func2 (7.1, 33.0);
63  printf("rtems_main: dl_o2_func2 returned: %d.%02d\n",
64         PDOUBLE(f2_ret));
65  if (f2_ret != (7.1 * 33.0))
66  {
67    printf("rtems_main: dl_o2_func2 returned a bad\n");
68    return 0;
69  }
70
71  ret = dl_o2_func3 (dl_o1_callback, 1);
72  printf ("rtems_main: callback count: %d\n", ret);
73
74  return argc;
75}
Note: See TracBrowser for help on using the repository browser.