[PATCH] D53904: [ELF] Define PT_ANDROID_TLS_TPOFF

Ryan Prichard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 30 15:18:19 PDT 2018


rprichard created this revision.
Herald added subscribers: llvm-commits, krytarowski, srhines.

This segment only appears in executables. Its p_vaddr field contains the
offset (in bytes) from the architecture-specific thread pointer to the
start of a thread's copy of the executable's TLS segment. Typically, the
ELF ABI documentation for a CPU architecture specifies how this offset is
determined, but Android uses a different layout, mostly for
backwards-compatibility reasons.

The remaining segment fields are zero.

As for the specific value -- it starts with 0x66xxxxxx because GNU seems
to be using 0x64xxxxxx, and OpenBSD is using 0x65xxxxxx. I selected the
next 5 digits at random.


Repository:
  rL LLVM

https://reviews.llvm.org/D53904

Files:
  include/llvm/BinaryFormat/ELF.h
  tools/llvm-objdump/ELFDump.cpp
  tools/llvm-readobj/ELFDumper.cpp


Index: tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- tools/llvm-readobj/ELFDumper.cpp
+++ tools/llvm-readobj/ELFDumper.cpp
@@ -1226,6 +1226,8 @@
   LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_WXNEEDED);
   LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_BOOTDATA);
 
+  LLVM_READOBJ_ENUM_CASE(ELF, PT_ANDROID_TLS_TPOFF);
+
   default: return "";
   }
 }
@@ -1244,6 +1246,7 @@
     LLVM_READOBJ_PHDR_ENUM(ELF, PT_SUNW_UNWIND)
     LLVM_READOBJ_PHDR_ENUM(ELF, PT_GNU_STACK)
     LLVM_READOBJ_PHDR_ENUM(ELF, PT_GNU_RELRO)
+    LLVM_READOBJ_PHDR_ENUM(ELF, PT_ANDROID_TLS_TPOFF)
   default:
     // All machine specific PT_* types
     switch (Arch) {
Index: tools/llvm-objdump/ELFDump.cpp
===================================================================
--- tools/llvm-objdump/ELFDump.cpp
+++ tools/llvm-objdump/ELFDump.cpp
@@ -131,6 +131,9 @@
     case ELF::PT_OPENBSD_WXNEEDED:
       outs() << "    OPENBSD_WXNEEDED ";
       break;
+    case ELF::PT_ANDROID_TLS_TPOFF:
+      outs() << "    ANDROID_TLS_TPOFF ";
+      break;
     case ELF::PT_PHDR:
       outs() << "    PHDR ";
       break;
Index: include/llvm/BinaryFormat/ELF.h
===================================================================
--- include/llvm/BinaryFormat/ELF.h
+++ include/llvm/BinaryFormat/ELF.h
@@ -1159,6 +1159,8 @@
   PT_OPENBSD_WXNEEDED = 0x65a3dbe7,  // Program does W^X violations.
   PT_OPENBSD_BOOTDATA = 0x65a41be6,  // Section for boot arguments.
 
+  PT_ANDROID_TLS_TPOFF = 0x662df6a0, // Offset from TP to TLS segment.
+
   // ARM program header types.
   PT_ARM_ARCHEXT = 0x70000000, // Platform architecture compatibility info
   // These all contain stack unwind tables.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53904.171821.patch
Type: text/x-patch
Size: 1711 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181030/461c4d92/attachment.bin>


More information about the llvm-commits mailing list