summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/rtl
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2019-05-03 10:15:20 +1000
committerChris Johns <chrisj@rtems.org>2019-05-03 10:15:20 +1000
commitb36c52097f52012f9a52dff6fc8393d63805158b (patch)
tree011b4cb678d343e0e6422d36bbcce982fdf48e30 /cpukit/include/rtems/rtl
parentbsp/motorola_powerpc: Fix debug output (diff)
downloadrtems-b36c52097f52012f9a52dff6fc8393d63805158b.tar.bz2
libdl: Do not access the ELF file while the allocator is locked.
- Load symbols before allocation. - Parse reloc records and place any reloc recs in a cache to use while the allocator is locked. - Relocate symbols after section allocation. - Split section loading into allocation/locating and loading. - Update all arch back-ends with a new reloc interface to control tramp handling. - Add `-a` and `-t` to the object list shell command. Closes #3741
Diffstat (limited to 'cpukit/include/rtems/rtl')
-rw-r--r--cpukit/include/rtems/rtl/rtl-obj.h38
-rw-r--r--cpukit/include/rtems/rtl/rtl-unresolved.h22
-rw-r--r--cpukit/include/rtems/rtl/rtl.h2
3 files changed, 52 insertions, 10 deletions
diff --git a/cpukit/include/rtems/rtl/rtl-obj.h b/cpukit/include/rtems/rtl/rtl-obj.h
index 9c2b4f0300..f27ae3259d 100644
--- a/cpukit/include/rtems/rtl/rtl-obj.h
+++ b/cpukit/include/rtems/rtl/rtl-obj.h
@@ -207,7 +207,7 @@ struct rtems_rtl_obj
size_t text_size; /**< The size of the text section. */
void* const_base; /**< The base address of the const section
* in memory. */
- size_t const_size; /**< The size of the const section. */
+ size_t const_size; /**< The size of the const section. */
void* eh_base; /**< The base address of the eh section in
* memory. */
size_t eh_size; /**< The size of the eh section. */
@@ -227,10 +227,14 @@ struct rtems_rtl_obj
* obj. */
void* trampoline; /**< Trampoline memory. Used for fixups or
* veneers */
- size_t tramp_size; /**< Size of the tramopline memory. */
+ size_t tramp_size; /**< Size of a tramopline slot. */
+ size_t tramps_size; /**< Size of the trampoline memory. */
void* tramp_brk; /**< Trampoline memory allocator. MD
* relocators can take memory from the
* break upto the size. */
+ size_t tramp_relocs; /**< Number of slots reserved for
+ * relocs. The remainder are for
+ * unresolved symbols. */
struct link_map* linkmap; /**< For GDB. */
void* loader; /**< The file details specific to a
* loader. */
@@ -370,11 +374,35 @@ static inline bool rtems_rtl_obj_has_symbol (const rtems_rtl_obj* obj,
* @param size The size to be allocated.
* @retval bool Returns @true if the space is available.
*/
-static inline bool rtems_rtl_obj_has_ramp_space (const rtems_rtl_obj* obj,
- const size_t size)
+static inline bool rtems_rtl_obj_has_tramp_space (const rtems_rtl_obj* obj,
+ const size_t size)
{
return (obj->trampoline != NULL &&
- ((obj->tramp_brk - obj->trampoline) + size) <= obj->tramp_size);
+ ((obj->tramp_brk - obj->trampoline) + size) <= obj->tramps_size);
+}
+
+/**
+ * Trampoline slots.
+ *
+ * @param obj The object file's descriptor.
+ * @retval size_t The number of trampoline slots.
+ */
+static inline size_t rtems_rtl_obj_trampoline_slots (const rtems_rtl_obj* obj)
+{
+ return obj->trampoline == NULL || obj->tramp_size == 0 ?
+ 0 : obj->tramps_size / obj->tramp_size;
+}
+
+/**
+ * Number of trampolines.
+ *
+ * @param obj The object file's descriptor.
+ * @retval size_t The number of trampolines.
+ */
+static inline size_t rtems_rtl_obj_trampolines (const rtems_rtl_obj* obj)
+{
+ return obj->trampoline == NULL || obj->tramp_size == 0 ?
+ 0 : (obj->tramp_brk - obj->trampoline) / obj->tramp_size;
}
/**
diff --git a/cpukit/include/rtems/rtl/rtl-unresolved.h b/cpukit/include/rtems/rtl/rtl-unresolved.h
index efc9ce220f..df07ecb1ba 100644
--- a/cpukit/include/rtems/rtl/rtl-unresolved.h
+++ b/cpukit/include/rtems/rtl/rtl-unresolved.h
@@ -1,5 +1,5 @@
/*
- * COPYRIGHT (c) 2012, 2018 Chris Johns <chrisj@rtems.org>
+ * COPYRIGHT (c) 2012, 2019 Chris Johns <chrisj@rtems.org>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
@@ -73,7 +73,8 @@ typedef enum rtems_rtl_unresolved_rtype
{
rtems_rtl_unresolved_empty = 0, /**< The records is empty. Must always be 0 */
rtems_rtl_unresolved_symbol = 1, /**< The record is a symbol. */
- rtems_rtl_unresolved_reloc = 2 /**< The record is a relocation record. */
+ rtems_rtl_unresolved_reloc = 2, /**< The record is a relocation record. */
+ rtems_rtl_trampoline_reloc = 3 /**< The record is a trampoline relocation record. */
} rtems_rtl_unresolved_rtype;
/**
@@ -101,7 +102,7 @@ typedef struct rtems_rtl_unresolv_symbol
/**
* Unresolved externals symbols require the relocation records to be held
- * and references.
+ * and referenced.
*/
typedef struct rtems_rtl_unresolv_reloc
{
@@ -113,6 +114,18 @@ typedef struct rtems_rtl_unresolv_reloc
} rtems_rtl_unresolv_reloc;
/**
+ * Trampolines require the relocation records to be held
+ */
+typedef struct rtems_rtl_tramp_reloc
+{
+ rtems_rtl_obj* obj; /**< The relocation's object file. */
+ uint16_t flags; /**< Format specific flags. */
+ uint16_t sect; /**< The target section. */
+ rtems_rtl_word symvalue; /**< The symbol's value. */
+ rtems_rtl_word rel[3]; /**< Relocation record. */
+} rtems_rtl_tramp_reloc;
+
+/**
* Unresolved externals records.
*/
typedef struct rtems_rtl_unresolv_rec
@@ -121,7 +134,8 @@ typedef struct rtems_rtl_unresolv_rec
union
{
rtems_rtl_unresolv_symbol name; /**< The symbol, or */
- rtems_rtl_unresolv_reloc reloc; /**< the relocation record. */
+ rtems_rtl_unresolv_reloc reloc; /**< The relocation record. */
+ rtems_rtl_tramp_reloc tramp; /**< The trampoline relocation record. */
} rec;
} rtems_rtl_unresolv_rec;
diff --git a/cpukit/include/rtems/rtl/rtl.h b/cpukit/include/rtems/rtl/rtl.h
index f13e33dbcb..67d7e96be3 100644
--- a/cpukit/include/rtems/rtl/rtl.h
+++ b/cpukit/include/rtems/rtl/rtl.h
@@ -72,7 +72,7 @@ extern "C" {
/**
* The number of relocation record per block in the unresolved table.
*/
-#define RTEMS_RTL_UNRESOLVED_BLOCK_SIZE (64)
+#define RTEMS_RTL_UNRESOLVED_BLOCK_SIZE (256)
/**
* The number of dependency record per block in the dependency table.