diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-21 18:13:02 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-21 18:13:02 +0000 |
commit | 54db30ce18663e6c2991958f3b5d18362e8e93c4 (patch) | |
tree | 4aa6442802570767398cc83ba484e97b1309bdc2 /contrib/llvm/lib/Target/BPF/BTF.h | |
parent | 35284c22e9c8348159b7ce032ea45f2cdeb65298 (diff) | |
parent | e6d1592492a3a379186bfb02bd0f4eda0669c0d5 (diff) |
Merge llvm trunk r366426, resolve conflicts, and update FREEBSD-Xlist.
Notes
Notes:
svn path=/projects/clang900-import/; revision=351344
Diffstat (limited to 'contrib/llvm/lib/Target/BPF/BTF.h')
-rw-r--r-- | contrib/llvm/lib/Target/BPF/BTF.h | 98 |
1 files changed, 83 insertions, 15 deletions
diff --git a/contrib/llvm/lib/Target/BPF/BTF.h b/contrib/llvm/lib/Target/BPF/BTF.h index 1e1680faf1b8..ad56716710a6 100644 --- a/contrib/llvm/lib/Target/BPF/BTF.h +++ b/contrib/llvm/lib/Target/BPF/BTF.h @@ -1,9 +1,8 @@ //===-- BTF.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// @@ -18,7 +17,7 @@ /// /// The binary layout for .BTF.ext section: /// struct ExtHeader -/// FuncInfo and LineInfo subsections +/// FuncInfo, LineInfo, OffsetReloc and ExternReloc subsections /// The FuncInfo subsection is defined as below: /// BTFFuncInfo Size /// struct SecFuncInfo for ELF section #1 @@ -33,6 +32,20 @@ /// struct SecLineInfo for ELF section #2 /// A number of struct BPFLineInfo for ELF section #2 /// ... +/// The OffsetReloc subsection is defined as below: +/// BPFOffsetReloc Size +/// struct SecOffsetReloc for ELF section #1 +/// A number of struct BPFOffsetReloc for ELF section #1 +/// struct SecOffsetReloc for ELF section #2 +/// A number of struct BPFOffsetReloc for ELF section #2 +/// ... +/// The ExternReloc subsection is defined as below: +/// BPFExternReloc Size +/// struct SecExternReloc for ELF section #1 +/// A number of struct BPFExternReloc for ELF section #1 +/// struct SecExternReloc for ELF section #2 +/// A number of struct BPFExternReloc for ELF section #2 +/// ... /// /// The section formats are also defined at /// https://github.com/torvalds/linux/blob/master/include/uapi/linux/btf.h @@ -50,16 +63,21 @@ enum : uint32_t { MAGIC = 0xeB9F, VERSION = 1 }; /// Sizes in bytes of various things in the BTF format. enum { HeaderSize = 24, - ExtHeaderSize = 24, + ExtHeaderSize = 40, CommonTypeSize = 12, BTFArraySize = 12, BTFEnumSize = 8, BTFMemberSize = 12, BTFParamSize = 8, + BTFDataSecVarSize = 12, SecFuncInfoSize = 8, SecLineInfoSize = 8, + SecOffsetRelocSize = 8, + SecExternRelocSize = 8, BPFFuncInfoSize = 8, - BPFLineInfoSize = 16 + BPFLineInfoSize = 16, + BPFOffsetRelocSize = 12, + BPFExternRelocSize = 8, }; /// The .BTF section header definition. @@ -77,7 +95,7 @@ struct Header { }; enum : uint32_t { - MAX_VLEN = 0xffff ///< Max # of struct/union/enum members or func args + MAX_VLEN = 0xffff ///< Max # of struct/union/enum members or func args }; enum TypeKinds : uint8_t { @@ -104,7 +122,7 @@ struct CommonType { /// "Size" tells the size of the type it is describing. /// /// "Type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT, - /// FUNC and FUNC_PROTO. + /// FUNC, FUNC_PROTO and VAR. /// "Type" is a type_id referring to another type. union { uint32_t Size; @@ -122,7 +140,11 @@ struct CommonType { // BTF_INT_BITS(VAL) : ((VAL) & 0x000000ff) /// Attributes stored in the INT_ENCODING. -enum : uint8_t { INT_SIGNED = (1 << 0), INT_CHAR = (1 << 1), INT_BOOL = (1 << 2) }; +enum : uint8_t { + INT_SIGNED = (1 << 0), + INT_CHAR = (1 << 1), + INT_BOOL = (1 << 2) +}; /// BTF_KIND_ENUM is followed by multiple "struct BTFEnum". /// The exact number of btf_enum is stored in the vlen (of the @@ -163,6 +185,23 @@ struct BTFParam { uint32_t Type; }; +/// Variable scoping information. +enum : uint8_t { + VAR_STATIC = 0, ///< Linkage: InternalLinkage + VAR_GLOBAL_ALLOCATED = 1, ///< Linkage: ExternalLinkage + VAR_GLOBAL_TENTATIVE = 2, ///< Linkage: CommonLinkage + VAR_GLOBAL_EXTERNAL = 3, ///< Linkage: ExternalLinkage +}; + +/// BTF_KIND_DATASEC are followed by multiple "struct BTFDataSecVar". +/// The exist number of BTFDataSec is stored in the vlen (of the info +/// in "struct CommonType"). +struct BTFDataSec { + uint32_t Type; ///< A BTF_KIND_VAR type + uint32_t Offset; ///< In-section offset + uint32_t Size; ///< Occupied memory size +}; + /// The .BTF.ext section header definition. struct ExtHeader { uint16_t Magic; @@ -170,10 +209,14 @@ struct ExtHeader { uint8_t Flags; uint32_t HdrLen; - uint32_t FuncInfoOff; ///< Offset of func info section - uint32_t FuncInfoLen; ///< Length of func info section - uint32_t LineInfoOff; ///< Offset of line info section - uint32_t LineInfoLen; ///< Length of line info section + uint32_t FuncInfoOff; ///< Offset of func info section + uint32_t FuncInfoLen; ///< Length of func info section + uint32_t LineInfoOff; ///< Offset of line info section + uint32_t LineInfoLen; ///< Length of line info section + uint32_t OffsetRelocOff; ///< Offset of offset reloc section + uint32_t OffsetRelocLen; ///< Length of offset reloc section + uint32_t ExternRelocOff; ///< Offset of extern reloc section + uint32_t ExternRelocLen; ///< Length of extern reloc section }; /// Specifying one function info. @@ -199,10 +242,35 @@ struct BPFLineInfo { /// Specifying line info's in one section. struct SecLineInfo { - uint32_t SecNameOff; ///< Section name index in the .BTF string tble + uint32_t SecNameOff; ///< Section name index in the .BTF string table uint32_t NumLineInfo; ///< Number of line info's in this section }; +/// Specifying one offset relocation. +struct BPFOffsetReloc { + uint32_t InsnOffset; ///< Byte offset in this section + uint32_t TypeID; ///< TypeID for the relocation + uint32_t OffsetNameOff; ///< The string to traverse types +}; + +/// Specifying offset relocation's in one section. +struct SecOffsetReloc { + uint32_t SecNameOff; ///< Section name index in the .BTF string table + uint32_t NumOffsetReloc; ///< Number of offset reloc's in this section +}; + +/// Specifying one offset relocation. +struct BPFExternReloc { + uint32_t InsnOffset; ///< Byte offset in this section + uint32_t ExternNameOff; ///< The string for external variable +}; + +/// Specifying extern relocation's in one section. +struct SecExternReloc { + uint32_t SecNameOff; ///< Section name index in the .BTF string table + uint32_t NumExternReloc; ///< Number of extern reloc's in this section +}; + } // End namespace BTF. } // End namespace llvm. |