Changeset 5500232 in rtems


Ignore:
Timestamp:
08/08/22 14:23:48 (16 months ago)
Author:
Ryan Long <ryan.long@…>
Branches:
master
Children:
7219d3c
Parents:
c3c4525
git-author:
Ryan Long <ryan.long@…> (08/08/22 14:23:48)
git-committer:
Joel Sherrill <joel@…> (08/08/22 17:02:03)
Message:

libdl: Refactor shared code in ARM and AArch64

rtl-mdreloc-arm.c was used as the basis for rtl-mdreloc-aarch64.c. This lead
to some code being shared by the two files. The code was consolidated into
rtl-unwind-arm.c.

Closes #4686

Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libdl/rtl-mdreloc-aarch64.c

    rc3c4525 r5500232  
    7474#include <sys/stat.h>
    7575#include <sys/endian.h>
    76 #include <unwind.h>
    7776
    7877#include <rtems/rtl/rtl.h>
     
    8079#include "rtl-error.h"
    8180#include <rtems/rtl/rtl-trace.h>
    82 #include "rtl-unwind.h"
    83 
    84 typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
    85 typedef _Unwind_Word _uw;
     81#include "rtl-unwind-arm.h"
    8682
    8783struct tls_data {
     
    523519  return rtems_rtl_elf_rel_failure;
    524520}
    525 
    526 bool
    527 rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
    528                             const char*          name,
    529                             uint32_t             flags)
    530 {
    531   /*
    532    * We location the EH sections in section flags.
    533    */
    534   return false;
    535 }
    536 
    537 bool
    538 rtems_rtl_elf_unwind_register (rtems_rtl_obj* obj)
    539 {
    540   return true;
    541 }
    542 
    543 bool
    544 rtems_rtl_elf_unwind_deregister (rtems_rtl_obj* obj)
    545 {
    546   obj->loader = NULL;
    547   return true;
    548 }
    549 
    550 /* An exception index table entry.  */
    551 typedef struct __EIT_entry
    552 {
    553   _uw fnoffset;
    554   _uw content;
    555 } __EIT_entry;
    556 
    557 /* The exception index table location in the base module */
    558 extern __EIT_entry __exidx_start;
    559 extern __EIT_entry __exidx_end;
    560 
    561 /*
    562  * A weak reference is in libgcc, provide a real version and provide a way to
    563  * manage loaded modules.
    564  *
    565  * Passed in the return address and a reference to the number of records
    566  * found. We set the start of the exidx data and the number of records.
    567  */
    568 _Unwind_Ptr __gnu_Unwind_Find_exidx (_Unwind_Ptr return_address,
    569                                      int*        nrec) __attribute__ ((__noinline__,
    570                                                                        __used__,
    571                                                                        __noclone__));
    572 
    573 _Unwind_Ptr __gnu_Unwind_Find_exidx (_Unwind_Ptr return_address,
    574                                      int*        nrec)
    575 {
    576   rtems_rtl_data*   rtl;
    577   rtems_chain_node* node;
    578   __EIT_entry*      exidx_start = &__exidx_start;
    579   __EIT_entry*      exidx_end = &__exidx_end;
    580 
    581   rtl = rtems_rtl_lock ();
    582 
    583   node = rtems_chain_first (&rtl->objects);
    584   while (!rtems_chain_is_tail (&rtl->objects, node)) {
    585     rtems_rtl_obj* obj = (rtems_rtl_obj*) node;
    586     if (rtems_rtl_obj_text_inside (obj, (void*) return_address)) {
    587       exidx_start = (__EIT_entry*) obj->eh_base;
    588       exidx_end = (__EIT_entry*) (obj->eh_base + obj->eh_size);
    589       break;
    590     }
    591     node = rtems_chain_next (node);
    592   }
    593 
    594   rtems_rtl_unlock ();
    595 
    596   *nrec = exidx_end - exidx_start;
    597 
    598   return (_Unwind_Ptr) exidx_start;
    599 }
  • cpukit/libdl/rtl-mdreloc-arm.c

    rc3c4525 r5500232  
    1313#include <sys/types.h>
    1414#include <sys/stat.h>
    15 #include <unwind.h>
    16 #include <unwind-arm-common.h>
    1715
    1816#include <rtems/rtl/rtl.h>
     
    2018#include "rtl-error.h"
    2119#include <rtems/rtl/rtl-trace.h>
    22 #include "rtl-unwind.h"
     20#include "rtl-unwind-arm.h"
    2321
    2422/*
     
    598596                                  false);
    599597}
    600 
    601 bool
    602 rtems_rtl_elf_unwind_parse (const rtems_rtl_obj* obj,
    603                             const char*          name,
    604                             uint32_t             flags)
    605 {
    606   /*
    607    * We location the EH sections in section flags.
    608    */
    609   return false;
    610 }
    611 
    612 bool
    613 rtems_rtl_elf_unwind_register (rtems_rtl_obj* obj)
    614 {
    615   return true;
    616 }
    617 
    618 bool
    619 rtems_rtl_elf_unwind_deregister (rtems_rtl_obj* obj)
    620 {
    621   obj->loader = NULL;
    622   return true;
    623 }
    624 
    625 /* An exception index table entry.  */
    626 typedef struct __EIT_entry
    627 {
    628   _uw fnoffset;
    629   _uw content;
    630 } __EIT_entry;
    631 
    632 /* The exception index table location in the base module */
    633 extern __EIT_entry __exidx_start;
    634 extern __EIT_entry __exidx_end;
    635 
    636 /*
    637  * A weak reference is in libgcc, provide a real version and provide a way to
    638  * manage loaded modules.
    639  *
    640  * Passed in the return address and a reference to the number of records
    641  * found. We set the start of the exidx data and the number of records.
    642  */
    643 _Unwind_Ptr __gnu_Unwind_Find_exidx (_Unwind_Ptr return_address,
    644                                      int*        nrec) __attribute__ ((__noinline__,
    645                                                                        __used__,
    646                                                                        __noclone__));
    647 
    648 _Unwind_Ptr __gnu_Unwind_Find_exidx (_Unwind_Ptr return_address,
    649                                      int*        nrec)
    650 {
    651   rtems_rtl_data*   rtl;
    652   rtems_chain_node* node;
    653   __EIT_entry*      exidx_start = &__exidx_start;
    654   __EIT_entry*      exidx_end = &__exidx_end;
    655 
    656   rtl = rtems_rtl_lock ();
    657 
    658   node = rtems_chain_first (&rtl->objects);
    659   while (!rtems_chain_is_tail (&rtl->objects, node)) {
    660     rtems_rtl_obj* obj = (rtems_rtl_obj*) node;
    661     if (rtems_rtl_obj_text_inside (obj, (void*) return_address)) {
    662       exidx_start = (__EIT_entry*) obj->eh_base;
    663       exidx_end = (__EIT_entry*) (obj->eh_base + obj->eh_size);
    664       break;
    665     }
    666     node = rtems_chain_next (node);
    667   }
    668 
    669   rtems_rtl_unlock ();
    670 
    671   *nrec = exidx_end - exidx_start;
    672 
    673   return (_Unwind_Ptr) exidx_start;
    674 }
  • spec/build/cpukit/objdlaarch64.yml

    rc3c4525 r5500232  
    1313source:
    1414- cpukit/libdl/rtl-mdreloc-aarch64.c
     15- cpukit/libdl/rtl-unwind-arm.c
    1516type: build
  • spec/build/cpukit/objdlarm.yml

    rc3c4525 r5500232  
    1313source:
    1414- cpukit/libdl/rtl-mdreloc-arm.c
     15- cpukit/libdl/rtl-unwind-arm.c
    1516type: build
Note: See TracChangeset for help on using the changeset viewer.