| 1 | // Copyright 2018 The gVisor Authors. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package linux |
| 16 | |
| 17 | // Linux auxiliary vector entry types. |
| 18 | const ( |
| 19 | // AT_NULL is the end of the auxiliary vector. |
| 20 | AT_NULL = 0 |
| 21 | |
| 22 | // AT_IGNORE should be ignored. |
| 23 | AT_IGNORE = 1 |
| 24 | |
| 25 | // AT_EXECFD is the file descriptor of the program. |
| 26 | AT_EXECFD = 2 |
| 27 | |
| 28 | // AT_PHDR points to the program headers. |
| 29 | AT_PHDR = 3 |
| 30 | |
| 31 | // AT_PHENT is the size of a program header entry. |
| 32 | AT_PHENT = 4 |
| 33 | |
| 34 | // AT_PHNUM is the number of program headers. |
| 35 | AT_PHNUM = 5 |
| 36 | |
| 37 | // AT_PAGESZ is the system page size. |
| 38 | AT_PAGESZ = 6 |
| 39 | |
| 40 | // AT_BASE is the base address of the interpreter. |
| 41 | AT_BASE = 7 |
| 42 | |
| 43 | // AT_FLAGS are flags. |
| 44 | AT_FLAGS = 8 |
| 45 | |
| 46 | // AT_ENTRY is the program entry point. |
| 47 | AT_ENTRY = 9 |
| 48 | |
| 49 | // AT_NOTELF indicates that the program is not an ELF binary. |
| 50 | AT_NOTELF = 10 |
| 51 | |
| 52 | // AT_UID is the real UID. |
| 53 | AT_UID = 11 |
| 54 | |
| 55 | // AT_EUID is the effective UID. |
| 56 | AT_EUID = 12 |
| 57 | |
| 58 | // AT_GID is the real GID. |
| 59 | AT_GID = 13 |
| 60 | |
| 61 | // AT_EGID is the effective GID. |
| 62 | AT_EGID = 14 |
| 63 | |
| 64 | // AT_PLATFORM is a string identifying the CPU. |
| 65 | AT_PLATFORM = 15 |
| 66 | |
| 67 | // AT_HWCAP are arch-dependent CPU capabilities. |
| 68 | AT_HWCAP = 16 |
| 69 | |
| 70 | // AT_CLKTCK is the frequency used by times(2). |
| 71 | AT_CLKTCK = 17 |
| 72 | |
| 73 | // AT_SECURE indicate secure mode. |
| 74 | AT_SECURE = 23 |
| 75 | |
| 76 | // AT_BASE_PLATFORM is a string identifying the "real" platform. It may |
| 77 | // differ from AT_PLATFORM. |
| 78 | AT_BASE_PLATFORM = 24 |
| 79 | |
| 80 | // AT_RANDOM points to 16-bytes of random data. |
| 81 | AT_RANDOM = 25 |
| 82 | |
| 83 | // AT_HWCAP2 is an extension of AT_HWCAP. |
| 84 | AT_HWCAP2 = 26 |
| 85 | |
| 86 | // AT_EXECFN is the path used to execute the program. |
| 87 | AT_EXECFN = 31 |
| 88 | |
| 89 | // AT_SYSINFO_EHDR is the address of the VDSO. |
| 90 | AT_SYSINFO_EHDR = 33 |
| 91 | ) |
| 92 | |
| 93 | // ELF ET_CORE and ptrace GETREGSET/SETREGSET register set types. |
| 94 | // |
| 95 | // See include/uapi/linux/elf.h. |
| 96 | const ( |
| 97 | // NT_PRSTATUS is for general purpose register. |
| 98 | NT_PRSTATUS = 0x1 |
| 99 | |
| 100 | // NT_PRFPREG is for float point register. |
| 101 | NT_PRFPREG = 0x2 |
| 102 | |
| 103 | // NT_X86_XSTATE is for x86 extended state using xsave. |
| 104 | NT_X86_XSTATE = 0x202 |
| 105 | |
| 106 | // NT_ARM_TLS is for ARM TLS register. |
| 107 | NT_ARM_TLS = 0x401 |
| 108 | ) |
| 109 | |
| 110 | // ElfHeader64 is the ELF64 file header. |
| 111 | // |
| 112 | // +marshal |
| 113 | type ElfHeader64 struct { |
| 114 | Ident [16]byte // File identification. |
| 115 | Type uint16 // File type. |
| 116 | Machine uint16 // Machine architecture. |
| 117 | Version uint32 // ELF format version. |
| 118 | Entry uint64 // Entry point. |
| 119 | Phoff uint64 // Program header file offset. |
| 120 | Shoff uint64 // Section header file offset. |
| 121 | Flags uint32 // Architecture-specific flags. |
| 122 | Ehsize uint16 // Size of ELF header in bytes. |
| 123 | Phentsize uint16 // Size of program header entry. |
| 124 | Phnum uint16 // Number of program header entries. |
| 125 | Shentsize uint16 // Size of section header entry. |
| 126 | Shnum uint16 // Number of section header entries. |
| 127 | Shstrndx uint16 // Section name strings section. |
| 128 | } |
| 129 | |
| 130 | // ElfSection64 is the ELF64 Section header. |
| 131 | // |
| 132 | // +marshal |
| 133 | type ElfSection64 struct { |
| 134 | Name uint32 // Section name (index into the section header string table). |
| 135 | Type uint32 // Section type. |
| 136 | Flags uint64 // Section flags. |
| 137 | Addr uint64 // Address in memory image. |
| 138 | Off uint64 // Offset in file. |
| 139 | Size uint64 // Size in bytes. |
| 140 | Link uint32 // Index of a related section. |
| 141 | Info uint32 // Depends on section type. |
| 142 | Addralign uint64 // Alignment in bytes. |
| 143 | Entsize uint64 // Size of each entry in section. |
| 144 | } |
| 145 | |
| 146 | // ElfProg64 is the ELF64 Program header. |
| 147 | // |
| 148 | // +marshal |
| 149 | type ElfProg64 struct { |
| 150 | Type uint32 // Entry type. |
| 151 | Flags uint32 // Access permission flags. |
| 152 | Off uint64 // File offset of contents. |
| 153 | Vaddr uint64 // Virtual address in memory image. |
| 154 | Paddr uint64 // Physical address (not used). |
| 155 | Filesz uint64 // Size of contents in file. |
| 156 | Memsz uint64 // Size of contents in memory. |
| 157 | Align uint64 // Alignment in memory and file. |
| 158 | } |