1 /* 2 * Copyright (c) 2020 Google Inc. All rights reserved 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files 6 * (the "Software"), to deal in the Software without restriction, 7 * including without limitation the rights to use, copy, modify, merge, 8 * publish, distribute, sublicense, and/or sell copies of the Software, 9 * and to permit persons to whom the Software is furnished to do so, 10 * subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be 13 * included in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 */ 23 24 #pragma once 25 26 #include <lib/trusty/elf.h> 27 28 /* 29 * Symbol table entry 30 */ 31 typedef struct { 32 Elf32_Word st_name; /* symbol name (.strtab index) */ 33 Elf32_Addr st_value; /* symbol value */ 34 Elf32_Word st_size; /* symbol size */ 35 unsigned char st_info; /* symbol type and binding */ 36 unsigned char st_other; /* symbol visibility */ 37 Elf32_Half st_shndx; /* section index */ 38 } Elf32_Sym; 39 40 typedef struct { 41 Elf64_Word st_name; /* symbol name (.strtab index) */ 42 unsigned char st_info; /* symbol type and binding */ 43 unsigned char st_other; /* symbol visibility */ 44 Elf64_Half st_shndx; /* section index */ 45 Elf64_Addr st_value; /* symbol value */ 46 Elf64_Xword st_size; /* symbol size */ 47 } Elf64_Sym; 48 49 /* Symbol bindings */ 50 #define STB_LOCAL 0 51 #define STB_GLOBAL 1 52 #define STB_WEAK 2 53 54 /* Symbol types */ 55 #define STT_NOTYPE 0 56 #define STT_OBJECT 1 57 #define STT_FUNC 2 58 #define STT_SECTION 3 59 #define STT_FILE 4 60 #define STT_COMMON 5 61 #define STT_TLS 6 62 63 #define ELF_ST_BIND(x) ((x) >> 4) 64 #define ELF_ST_TYPE(x) (((unsigned int)x) & 0xf) 65