platform_bionic/linker/linker_relocs.h
Ryan Prichard 6d601458de Renumber arm64 TLS to match GNU values
The AArch64 ELF specification originally specified these relocations:

  R_AARCH64_TLS_DTPREL64          1028
  R_AARCH64_TLS_DTPMOD64          1029

However, the GNU toolchain implemented them as:

  R_AARCH64_TLS_DTPMOD64          1028
  R_AARCH64_TLS_DTPREL64          1029

The AArch64 ELF specification has been updated to replace the relocations
with R_AARCH64_TLS_IMPDEF1 and with R_AARCH64_TLS_IMPDEF2, where each
implementation can choose which interpretation it implements, but with a
suggestion to follow the GNU behavior.

Also: remove the 64 suffixes from the TLS relocations. The newest version
of the AArch64 ELF specification (version f) also omits the suffixes, as
do the glibc headers.

Bug: http://b/123385182
Bug: https://bugs.llvm.org/show_bug.cgi?id=40507
Test: build device, it boots
Change-Id: Ie98b7624752982973f0ac969d646454a86784cab
2019-07-30 16:30:46 -07:00

79 lines
3.1 KiB
C

/*
* Copyright (C) 2015 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * 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.
*/
#pragma once
#include <elf.h>
#define R_GENERIC_NONE 0 // R_*_NONE is always 0
#if defined (__aarch64__)
#define R_GENERIC_JUMP_SLOT R_AARCH64_JUMP_SLOT
#define R_GENERIC_GLOB_DAT R_AARCH64_GLOB_DAT
#define R_GENERIC_RELATIVE R_AARCH64_RELATIVE
#define R_GENERIC_IRELATIVE R_AARCH64_IRELATIVE
#define R_GENERIC_TLS_DTPMOD R_AARCH64_TLS_DTPMOD
#define R_GENERIC_TLS_DTPREL R_AARCH64_TLS_DTPREL
#define R_GENERIC_TLS_TPREL R_AARCH64_TLS_TPREL
#define R_GENERIC_TLSDESC R_AARCH64_TLSDESC
#elif defined (__arm__)
#define R_GENERIC_JUMP_SLOT R_ARM_JUMP_SLOT
#define R_GENERIC_GLOB_DAT R_ARM_GLOB_DAT
#define R_GENERIC_RELATIVE R_ARM_RELATIVE
#define R_GENERIC_IRELATIVE R_ARM_IRELATIVE
#define R_GENERIC_TLS_DTPMOD R_ARM_TLS_DTPMOD32
#define R_GENERIC_TLS_DTPREL R_ARM_TLS_DTPOFF32
#define R_GENERIC_TLS_TPREL R_ARM_TLS_TPOFF32
#define R_GENERIC_TLSDESC R_ARM_TLS_DESC
#elif defined (__i386__)
#define R_GENERIC_JUMP_SLOT R_386_JMP_SLOT
#define R_GENERIC_GLOB_DAT R_386_GLOB_DAT
#define R_GENERIC_RELATIVE R_386_RELATIVE
#define R_GENERIC_IRELATIVE R_386_IRELATIVE
#define R_GENERIC_TLS_DTPMOD R_386_TLS_DTPMOD32
#define R_GENERIC_TLS_DTPREL R_386_TLS_DTPOFF32
#define R_GENERIC_TLS_TPREL R_386_TLS_TPOFF
#define R_GENERIC_TLSDESC R_386_TLS_DESC
#elif defined (__x86_64__)
#define R_GENERIC_JUMP_SLOT R_X86_64_JUMP_SLOT
#define R_GENERIC_GLOB_DAT R_X86_64_GLOB_DAT
#define R_GENERIC_RELATIVE R_X86_64_RELATIVE
#define R_GENERIC_IRELATIVE R_X86_64_IRELATIVE
#define R_GENERIC_TLS_DTPMOD R_X86_64_DTPMOD64
#define R_GENERIC_TLS_DTPREL R_X86_64_DTPOFF64
#define R_GENERIC_TLS_TPREL R_X86_64_TPOFF64
#define R_GENERIC_TLSDESC R_X86_64_TLSDESC
#endif