Changeset d3662980 in rtems


Ignore:
Timestamp:
01/12/23 21:45:46 (14 months ago)
Author:
Kinsey Moore <kinsey.moore@…>
Branches:
master
Children:
81085ca9
Parents:
189539f
git-author:
Kinsey Moore <kinsey.moore@…> (01/12/23 21:45:46)
git-committer:
Joel Sherrill <joel@…> (01/20/23 14:26:35)
Message:

cpukit/libdl: Add AArch64 TLS reloc support

This adds basic TLS relocation support for AArch64 to libdl. This lets
loadable modules use TLS symbols hosted in the main binary. This does
not allow loadable modules to host their own TLS symbols.

File:
1 edited

Legend:

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

    r189539f rd3662980  
    8080#include <rtems/rtl/rtl-trace.h>
    8181#include "rtl-unwind-arm.h"
     82#include <rtems/score/tls.h>
    8283
    8384struct tls_data {
     
    238239   * P - the address of the place being relocated (derived from r_offset)
    239240   * Page(expr) - the page address of the expression expr, defined as (expr & ~0xFFF).
     241   * TPREL(expr) - the thread pointer offset of the expression expr
    240242   */
    241243  switch (ELF_R_TYPE(rela->r_info)) {
     
    285287       */
    286288      printf("rtl: reloc COPY (please report)\n");
     289      break;
     290
     291    case R_AARCH64_ADD_TPREL_HI12: /* TPREL(S + A) */
     292    case R_AARCH64_ADD_TPREL_LO12:
     293    case R_AARCH64_ADD_TPREL_LO12_NC:
     294      uint32_t of_check = 0;
     295      switch (ELF_R_TYPE(rela->r_info)) {
     296        case R_AARCH64_ADD_TPREL_LO12:
     297          of_check = 212;
     298        /* fallthrough */
     299        case R_AARCH64_ADD_TPREL_LO12_NC:
     300          shift = 0;
     301          break;
     302        case R_AARCH64_ADD_TPREL_HI12:
     303          of_check = 224;
     304          shift = 12;
     305          break;
     306        default:
     307          printf("illegal rtype: %ld\n", ELF_R_TYPE(rela->r_info));
     308          break;
     309      }
     310
     311      if (!parsing) {
     312        target = (Elf_Addr)symvalue + rela->r_addend;
     313        /* Calculate offset accounting for the DTV */
     314        target -= (uintptr_t)_TLS_Data_begin;
     315        target += sizeof(TLS_Dynamic_thread_vector);
     316
     317        target >>= shift;
     318        target &= WIDTHMASK(12);
     319        if (of_check && target >= of_check) {
     320          return rtems_rtl_elf_rel_failure;
     321        }
     322        *insn = htole32(
     323            (le32toh(*insn) & ~__BITS(21,10)) | (target << 10));
     324      }
    287325      break;
    288326
Note: See TracChangeset for help on using the changeset viewer.