Re: [PATCH 1/5] microblaze: Add libdl support

2023-08-27 Thread Chris Johns
On 28/8/2023 11:30 am, Alex White wrote:
> ---
>  cpukit/libdl/rtl-mdreloc-microblaze.c | 291 ++
>  cpukit/libdl/rtl-tls.c|   2 +-
>  .../microblaze/include/machine/elf_machdep.h  |  83 +
>  spec/build/cpukit/cpumicroblaze.yml   |   3 +
>  spec/build/cpukit/objdl.yml   |   2 +
>  spec/build/cpukit/objdlmicroblaze.yml |  15 +
>  spec/build/cpukit/optlibdl.yml|   1 +
>  7 files changed, 396 insertions(+), 1 deletion(-)
>  create mode 100644 cpukit/libdl/rtl-mdreloc-microblaze.c

There is an additional call in my changes to fix trampolines I have posted for
review. You will need to add that for the microblaze.

My trampoline fixes change the allocation order of the sections and that has
exposed an issue on powerpc that I am looking into. That issue will be a
separate patch.

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 1/5] microblaze: Add libdl support

2023-08-27 Thread Alex White
---
 cpukit/libdl/rtl-mdreloc-microblaze.c | 291 ++
 cpukit/libdl/rtl-tls.c|   2 +-
 .../microblaze/include/machine/elf_machdep.h  |  83 +
 spec/build/cpukit/cpumicroblaze.yml   |   3 +
 spec/build/cpukit/objdl.yml   |   2 +
 spec/build/cpukit/objdlmicroblaze.yml |  15 +
 spec/build/cpukit/optlibdl.yml|   1 +
 7 files changed, 396 insertions(+), 1 deletion(-)
 create mode 100644 cpukit/libdl/rtl-mdreloc-microblaze.c
 create mode 100644 cpukit/score/cpu/microblaze/include/machine/elf_machdep.h
 create mode 100644 spec/build/cpukit/objdlmicroblaze.yml

diff --git a/cpukit/libdl/rtl-mdreloc-microblaze.c 
b/cpukit/libdl/rtl-mdreloc-microblaze.c
new file mode 100644
index 00..b8834b203b
--- /dev/null
+++ b/cpukit/libdl/rtl-mdreloc-microblaze.c
@@ -0,0 +1,291 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/*
+ * Copyright (C) 2023 On-Line Applications Research Corporation (OAR)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include "rtl-elf.h"
+#include "rtl-error.h"
+#include 
+#include "rtl-unwind.h"
+#include "rtl-unwind-dw2.h"
+
+uint32_t
+rtems_rtl_elf_section_flags (const rtems_rtl_obj* obj,
+ const Elf_Shdr*  shdr) {
+  (void) obj;
+  (void) shdr;
+  return 0;
+}
+
+uint32_t
+rtems_rtl_elf_arch_parse_section (const rtems_rtl_obj* obj,
+  int  section,
+  const char*  name,
+  const Elf_Shdr*  shdr,
+  const uint32_t   flags) {
+  (void) obj;
+  (void) section;
+  (void) name;
+  (void) shdr;
+  return flags;
+}
+
+bool
+rtems_rtl_elf_arch_section_alloc (const rtems_rtl_obj* obj,
+  rtems_rtl_obj_sect*  sect) {
+  (void) obj;
+  (void) sect;
+  return false;
+}
+
+bool
+rtems_rtl_elf_arch_section_free (const rtems_rtl_obj* obj,
+ rtems_rtl_obj_sect*  sect) {
+  (void) obj;
+  (void) sect;
+  return false;
+}
+
+bool
+rtems_rtl_elf_rel_resolve_sym (Elf_Word type) {
+  return type != 0;
+}
+
+size_t
+rtems_rtl_elf_relocate_tramp_max_size (void) {
+  /*
+   * Disable by returning 0.
+   */
+  return 0;
+}
+
+rtems_rtl_elf_rel_status
+rtems_rtl_elf_relocate_rel_tramp (rtems_rtl_obj*obj,
+  const Elf_Rel*rel,
+  const rtems_rtl_obj_sect* sect,
+  const char*   symname,
+  const Elf_Bytesyminfo,
+  const Elf_Wordsymvalue) {
+  (void) obj;
+  (void) rel;
+  (void) sect;
+  (void) symname;
+  (void) syminfo;
+  (void) symvalue;
+  return rtems_rtl_elf_rel_no_error;
+}
+
+static void write16le(void *loc, uint16_t val) {
+  *((uint16_t *) loc) = val;
+}
+
+static void write32le(void *loc, uint32_t val) {
+  *((uint32_t *) loc) = val;
+}
+
+static uint16_t read16le(void *loc) {
+  return *((uint16_t *) loc);
+}
+
+static uint32_t read32le(void *loc) {
+  return *((uint32_t *) loc);
+}
+
+static rtems_rtl_elf_rel_status
+rtems_rtl_elf_reloc_rela (rtems_rtl_obj*obj,
+  const Elf_Rela*   rela,
+  const rtems_rtl_obj_sect* sect,
+  const char*   symname,
+  const Elf_Bytesyminfo,
+  const Elf_Wordsymvalue,
+  const bo