source: rtems/testsuites/libtests/dl05/dl-load.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.9 KB
Line 
1/*
2 * Copyright (c) 2016 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#ifdef HAVE_CONFIG_H
10  #include "config.h"
11#endif
12
13#include "tmacros.h"
14
15#include <stdio.h>
16
17#include <dlfcn.h>
18
19#include <rtems/rtl/rtl-trace.h>
20
21#include "dl-load.h"
22
23#define TEST_TRACE 0
24#if TEST_TRACE
25 #define DEBUG_TRACE (RTEMS_RTL_TRACE_DETAIL | \
26                      RTEMS_RTL_TRACE_WARNING | \
27                      RTEMS_RTL_TRACE_LOAD | \
28                      RTEMS_RTL_TRACE_UNLOAD | \
29                      RTEMS_RTL_TRACE_SYMBOL | \
30                      RTEMS_RTL_TRACE_RELOC | \
31                      RTEMS_RTL_TRACE_ALLOCATOR | \
32                      RTEMS_RTL_TRACE_UNRESOLVED | \
33                      RTEMS_RTL_TRACE_ARCHIVES | \
34                      RTEMS_RTL_TRACE_GLOBAL_SYM | \
35                      RTEMS_RTL_TRACE_DEPENDENCY)
36 #define DL_DEBUG_TRACE DEBUG_TRACE /* RTEMS_RTL_TRACE_ALL */
37#else
38 #define DL_DEBUG_TRACE 0
39#endif
40
41int dl_load_test(void)
42{
43  void*       handle;
44  const char* err;
45  void        (*func)(bool );
46#if __i386__
47  /*
48   * std::runtime_error destructor locks up in atomics.
49   */
50  bool        throw_runtime = false;
51#else
52  bool        throw_runtime = true;
53#endif
54
55#if DL_DEBUG_TRACE
56  rtems_rtl_trace_set_mask (DL_DEBUG_TRACE);
57#endif
58
59  handle = dlopen("/dl05-o5.o", RTLD_GLOBAL | RTLD_NOW);
60  if (handle == NULL)
61  {
62    err = dlerror();
63    if (err != NULL)
64      printf("dlopen: %s\n", err);
65  }
66  rtems_test_assert(handle != NULL);
67
68  func = dlsym(handle, "exception_dl");
69  if (func == NULL) {
70    err = dlerror ();
71    if (err)
72      printf ("dlsym: %s\n", err);
73  }
74  rtems_test_assert(func != NULL);
75
76  exception_base(throw_runtime);
77
78  func(throw_runtime);
79
80  rtems_test_assert(dlclose(handle) == 0);
81
82  return 0;
83}
Note: See TracBrowser for help on using the repository browser.