1 /* 2 * Copyright 2002-2015 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _ELF_H 6 #define _ELF_H 7 8 9 #include <SupportDefs.h> 10 #include <ByteOrder.h> 11 12 13 typedef uint32 Elf32_Addr; 14 typedef uint16 Elf32_Half; 15 typedef uint32 Elf32_Off; 16 typedef int32 Elf32_Sword; 17 typedef uint32 Elf32_Word; 18 19 typedef Elf32_Half Elf32_Versym; 20 21 typedef uint64 Elf64_Addr; 22 typedef uint64 Elf64_Off; 23 typedef uint16 Elf64_Half; 24 typedef uint32 Elf64_Word; 25 typedef int32 Elf64_Sword; 26 typedef uint64 Elf64_Xword; 27 typedef int64 Elf64_Sxword; 28 29 typedef Elf64_Half Elf64_Versym; 30 31 32 /*** ELF header ***/ 33 34 #define EI_NIDENT 16 35 36 typedef struct { 37 uint8 e_ident[EI_NIDENT]; 38 Elf32_Half e_type; 39 Elf32_Half e_machine; 40 Elf32_Word e_version; 41 Elf32_Addr e_entry; 42 Elf32_Off e_phoff; 43 Elf32_Off e_shoff; 44 Elf32_Word e_flags; 45 Elf32_Half e_ehsize; 46 Elf32_Half e_phentsize; 47 Elf32_Half e_phnum; 48 Elf32_Half e_shentsize; 49 Elf32_Half e_shnum; 50 Elf32_Half e_shstrndx; 51 52 #ifdef __cplusplus 53 bool IsHostEndian() const; 54 #endif 55 } Elf32_Ehdr; 56 57 typedef struct { 58 uint8 e_ident[EI_NIDENT]; 59 Elf64_Half e_type; 60 Elf64_Half e_machine; 61 Elf64_Word e_version; 62 Elf64_Addr e_entry; 63 Elf64_Off e_phoff; 64 Elf64_Off e_shoff; 65 Elf64_Word e_flags; 66 Elf64_Half e_ehsize; 67 Elf64_Half e_phentsize; 68 Elf64_Half e_phnum; 69 Elf64_Half e_shentsize; 70 Elf64_Half e_shnum; 71 Elf64_Half e_shstrndx; 72 73 #ifdef __cplusplus 74 bool IsHostEndian() const; 75 #endif 76 } Elf64_Ehdr; 77 78 #define ELF_MAGIC "\x7f""ELF" 79 80 /* e_ident[] indices */ 81 #define EI_MAG0 0 82 #define EI_MAG1 1 83 #define EI_MAG2 2 84 #define EI_MAG3 3 85 #define EI_CLASS 4 86 #define EI_DATA 5 87 #define EI_VERSION 6 88 #define EI_PAD 7 89 90 /* e_type (Object file type) */ 91 #define ET_NONE 0 /* No file type */ 92 #define ET_REL 1 /* Relocatable file */ 93 #define ET_EXEC 2 /* Executable file */ 94 #define ET_DYN 3 /* Shared-object file */ 95 #define ET_CORE 4 /* Core file */ 96 #define ET_LOOS 0xfe00 /* OS-specific range start */ 97 #define ET_HIOS 0xfeff /* OS-specific range end */ 98 #define ET_LOPROC 0xff00 /* Processor-specific range start */ 99 #define ET_HIPROC 0xffff /* Processor-specific range end */ 100 101 /* e_machine (Architecture) */ 102 #define EM_NONE 0 /* No machine */ 103 #define EM_M32 1 /* AT&T WE 32100 */ 104 #define EM_SPARC 2 /* Sparc */ 105 #define EM_386 3 /* Intel 80386 */ 106 #define EM_68K 4 /* Motorola m68k family */ 107 #define EM_88K 5 /* Motorola m88k family */ 108 #define EM_486 6 /* Intel 80486, Reserved for future use */ 109 #define EM_860 7 /* Intel 80860 */ 110 #define EM_MIPS 8 /* MIPS R3000 (officially, big-endian only) */ 111 #define EM_S370 9 /* IBM System/370 */ 112 #define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian, Deprecated */ 113 #define EM_PARISC 15 /* HPPA */ 114 #define EM_VPP550 17 /* Fujitsu VPP500 */ 115 #define EM_SPARC32PLUS 18 /* Sun "v8plus" */ 116 #define EM_960 19 /* Intel 80960 */ 117 #define EM_PPC 20 /* PowerPC */ 118 #define EM_PPC64 21 /* 64-bit PowerPC */ 119 #define EM_S390 22 /* IBM S/390 */ 120 #define EM_V800 36 /* NEC V800 series */ 121 #define EM_FR20 37 /* Fujitsu FR20 */ 122 #define EM_RH32 38 /* TRW RH32 */ 123 #define EM_MCORE 39 /* Motorola M*Core */ 124 #define EM_RCE 39 /* Old name for MCore */ 125 #define EM_ARM 40 /* ARM */ 126 #define EM_OLD_ALPHA 41 /* Digital Alpha */ 127 #define EM_SH 42 /* Renesas / SuperH SH */ 128 #define EM_SPARCV9 43 /* SPARC v9 64-bit */ 129 #define EM_TRICORE 44 /* Siemens Tricore embedded processor */ 130 #define EM_ARC 45 /* ARC Cores */ 131 #define EM_H8_300 46 /* Renesas H8/300 */ 132 #define EM_H8_300H 47 /* Renesas H8/300H */ 133 #define EM_H8S 48 /* Renesas H8S */ 134 #define EM_H8_500 49 /* Renesas H8/500 */ 135 #define EM_IA_64 50 /* Intel IA-64 Processor */ 136 #define EM_MIPS_X 51 /* Stanford MIPS-X */ 137 #define EM_COLDFIRE 52 /* Motorola Coldfire */ 138 #define EM_68HC12 53 /* Motorola M68HC12 */ 139 #define EM_MMA 54 /* Fujitsu Multimedia Accelerator */ 140 #define EM_PCP 55 /* Siemens PCP */ 141 #define EM_NCPU 56 /* Sony nCPU embedded RISC processor */ 142 #define EM_NDR1 57 /* Denso NDR1 microprocesspr */ 143 #define EM_STARCORE 58 /* Motorola Star*Core processor */ 144 #define EM_ME16 59 /* Toyota ME16 processor */ 145 #define EM_ST100 60 /* STMicroelectronics ST100 processor */ 146 #define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ embedded processor */ 147 #define EM_X86_64 62 /* Advanced Micro Devices X86-64 processor */ 148 149 /* architecture class (EI_CLASS) */ 150 #define ELFCLASS32 1 151 #define ELFCLASS64 2 152 /* endian (EI_DATA) */ 153 #define ELFDATA2LSB 1 /* little endian */ 154 #define ELFDATA2MSB 2 /* big endian */ 155 156 157 /*** section header ***/ 158 159 typedef struct { 160 Elf32_Word sh_name; 161 Elf32_Word sh_type; 162 Elf32_Word sh_flags; 163 Elf32_Addr sh_addr; 164 Elf32_Off sh_offset; 165 Elf32_Word sh_size; 166 Elf32_Word sh_link; 167 Elf32_Word sh_info; 168 Elf32_Word sh_addralign; 169 Elf32_Word sh_entsize; 170 } Elf32_Shdr; 171 172 typedef struct { 173 Elf64_Word sh_name; 174 Elf64_Word sh_type; 175 Elf64_Xword sh_flags; 176 Elf64_Addr sh_addr; 177 Elf64_Off sh_offset; 178 Elf64_Xword sh_size; 179 Elf64_Word sh_link; 180 Elf64_Word sh_info; 181 Elf64_Xword sh_addralign; 182 Elf64_Xword sh_entsize; 183 } Elf64_Shdr; 184 185 /* special section indices */ 186 #define SHN_UNDEF 0 187 #define SHN_LORESERVE 0xff00 188 #define SHN_LOPROC 0xff00 189 #define SHN_HIPROC 0xff1f 190 #define SHN_ABS 0xfff1 191 #define SHN_COMMON 0xfff2 192 #define SHN_HIRESERVE 0xffff 193 194 /* section header type */ 195 #define SHT_NULL 0 196 #define SHT_PROGBITS 1 197 #define SHT_SYMTAB 2 198 #define SHT_STRTAB 3 199 #define SHT_RELA 4 200 #define SHT_HASH 5 201 #define SHT_DYNAMIC 6 202 #define SHT_NOTE 7 203 #define SHT_NOBITS 8 204 #define SHT_REL 9 205 #define SHT_SHLIB 10 206 #define SHT_DYNSYM 11 207 208 #define SHT_GNU_verdef 0x6ffffffd /* version definition section */ 209 #define SHT_GNU_verneed 0x6ffffffe /* version needs section */ 210 #define SHT_GNU_versym 0x6fffffff /* version symbol table */ 211 212 #define SHT_LOPROC 0x70000000 213 #define SHT_HIPROC 0x7fffffff 214 #define SHT_LOUSER 0x80000000 215 #define SHT_HIUSER 0xffffffff 216 217 /* section header flags */ 218 #define SHF_WRITE 1 219 #define SHF_ALLOC 2 220 #define SHF_EXECINSTR 4 221 222 #define SHF_MASKPROC 0xf0000000 223 224 225 /*** program header ***/ 226 227 typedef struct { 228 Elf32_Word p_type; 229 Elf32_Off p_offset; /* offset from the beginning of the file of the segment */ 230 Elf32_Addr p_vaddr; /* virtual address for the segment in memory */ 231 Elf32_Addr p_paddr; 232 Elf32_Word p_filesz; /* the size of the segment in the file */ 233 Elf32_Word p_memsz; /* the size of the segment in memory */ 234 Elf32_Word p_flags; 235 Elf32_Word p_align; 236 237 #ifdef __cplusplus 238 bool IsReadWrite() const; 239 bool IsExecutable() const; 240 #endif 241 } Elf32_Phdr; 242 243 typedef struct { 244 Elf64_Word p_type; 245 Elf64_Word p_flags; 246 Elf64_Off p_offset; /* offset from the beginning of the file of the segment */ 247 Elf64_Addr p_vaddr; /* virtual address for the segment in memory */ 248 Elf64_Addr p_paddr; 249 Elf64_Xword p_filesz; /* the size of the segment in the file */ 250 Elf64_Xword p_memsz; /* the size of the segment in memory */ 251 Elf64_Xword p_align; 252 253 #ifdef __cplusplus 254 bool IsReadWrite() const; 255 bool IsExecutable() const; 256 #endif 257 } Elf64_Phdr; 258 259 /* program header segment types */ 260 #define PT_NULL 0 261 #define PT_LOAD 1 262 #define PT_DYNAMIC 2 263 #define PT_INTERP 3 264 #define PT_NOTE 4 265 #define PT_SHLIB 5 266 #define PT_PHDR 6 267 #define PT_TLS 7 268 #define PT_STACK 0x6474e551 269 #define PT_RELRO 0x6474e552 270 271 #define PT_LOPROC 0x70000000 272 #define PT_ARM_UNWIND 0x70000001 273 #define PT_HIPROC 0x7fffffff 274 275 /* program header segment flags */ 276 #define PF_EXECUTE 0x1 277 #define PF_WRITE 0x2 278 #define PF_READ 0x4 279 #define PF_PROTECTION_MASK (PF_EXECUTE | PF_WRITE | PF_READ) 280 281 #define PF_MASKPROC 0xf0000000 282 283 284 /* symbol table entry */ 285 286 typedef struct { 287 Elf32_Word st_name; 288 Elf32_Addr st_value; 289 Elf32_Word st_size; 290 uint8 st_info; 291 uint8 st_other; 292 Elf32_Half st_shndx; 293 294 #ifdef __cplusplus 295 uint8 Bind() const; 296 uint8 Type() const; 297 void SetInfo(uint8 bind, uint8 type); 298 #endif 299 } Elf32_Sym; 300 301 typedef struct { 302 Elf64_Word st_name; 303 uint8 st_info; 304 uint8 st_other; 305 Elf64_Half st_shndx; 306 Elf64_Addr st_value; 307 Elf64_Xword st_size; 308 309 #ifdef __cplusplus 310 uint8 Bind() const; 311 uint8 Type() const; 312 void SetInfo(uint8 bind, uint8 type); 313 #endif 314 } Elf64_Sym; 315 316 #define ELF32_ST_BIND(i) ((i) >> 4) 317 #define ELF32_ST_TYPE(i) ((i) & 0xf) 318 #define ELF32_ST_INFO(b, t) (((b) << 4) + ((t) & 0xf)) 319 320 #define ELF64_ST_BIND(i) ((i) >> 4) 321 #define ELF64_ST_TYPE(i) ((i) & 0xf) 322 #define ELF64_ST_INFO(b, t) (((b) << 4) + ((t) & 0xf)) 323 324 /* symbol types */ 325 #define STT_NOTYPE 0 326 #define STT_OBJECT 1 327 #define STT_FUNC 2 328 #define STT_SECTION 3 329 #define STT_FILE 4 330 #define STT_TLS 6 331 #define STT_LOPROC 13 332 #define STT_HIPROC 15 333 334 /* symbol binding */ 335 #define STB_LOCAL 0 336 #define STB_GLOBAL 1 337 #define STB_WEAK 2 338 #define STB_LOPROC 13 339 #define STB_HIPROC 15 340 341 /* special symbol indices */ 342 #define STN_UNDEF 0 343 344 345 /* relocation table entry */ 346 347 typedef struct { 348 Elf32_Addr r_offset; 349 Elf32_Word r_info; 350 351 #ifdef __cplusplus 352 uint8 SymbolIndex() const; 353 uint8 Type() const; 354 #endif 355 } Elf32_Rel; 356 357 typedef struct { 358 Elf64_Addr r_offset; 359 Elf64_Xword r_info; 360 361 #ifdef __cplusplus 362 uint8 SymbolIndex() const; 363 uint8 Type() const; 364 #endif 365 } Elf64_Rel; 366 367 #ifdef __cplusplus 368 typedef struct Elf32_Rela : public Elf32_Rel { 369 #else 370 typedef struct { 371 Elf32_Addr r_offset; 372 Elf32_Word r_info; 373 #endif 374 Elf32_Sword r_addend; 375 } Elf32_Rela; 376 377 #ifdef __cplusplus 378 typedef struct Elf64_Rela : public Elf64_Rel { 379 #else 380 typedef struct { 381 Elf64_Addr r_offset; 382 Elf64_Xword r_info; 383 #endif 384 Elf64_Sxword r_addend; 385 } Elf64_Rela; 386 387 #define ELF32_R_SYM(i) ((i) >> 8) 388 #define ELF32_R_TYPE(i) ((unsigned char)(i)) 389 #define ELF32_R_INFO(s, t) (((s) << 8) + (unsigned char)(t)) 390 391 #define ELF64_R_SYM(i) ((i) >> 32) 392 #define ELF64_R_TYPE(i) ((i) & 0xffffffffL) 393 #define ELF64_R_INFO(s, t) ((((Elf64_Xword)(s)) << 32) + ((t) & 0xffffffffL)) 394 395 396 /* dynamic section entry */ 397 398 typedef struct { 399 Elf32_Sword d_tag; 400 union { 401 Elf32_Word d_val; 402 Elf32_Addr d_ptr; 403 } d_un; 404 } Elf32_Dyn; 405 406 typedef struct { 407 Elf64_Sxword d_tag; 408 union { 409 Elf64_Xword d_val; 410 Elf64_Addr d_ptr; 411 } d_un; 412 } Elf64_Dyn; 413 414 /* dynamic entry type */ 415 #define DT_NULL 0 416 #define DT_NEEDED 1 417 #define DT_PLTRELSZ 2 418 #define DT_PLTGOT 3 419 #define DT_HASH 4 420 #define DT_STRTAB 5 421 #define DT_SYMTAB 6 422 #define DT_RELA 7 423 #define DT_RELASZ 8 424 #define DT_RELAENT 9 425 #define DT_STRSZ 10 426 #define DT_SYMENT 11 427 #define DT_INIT 12 428 #define DT_FINI 13 429 #define DT_SONAME 14 430 #define DT_RPATH 15 431 #define DT_SYMBOLIC 16 432 #define DT_REL 17 433 #define DT_RELSZ 18 434 #define DT_RELENT 19 435 #define DT_PLTREL 20 436 #define DT_DEBUG 21 437 #define DT_TEXTREL 22 438 #define DT_JMPREL 23 439 #define DT_BIND_NOW 24 /* no lazy binding */ 440 #define DT_INIT_ARRAY 25 /* init function array */ 441 #define DT_FINI_ARRAY 26 /* termination function array */ 442 #define DT_INIT_ARRAYSZ 27 /* init function array size */ 443 #define DT_FINI_ARRAYSZ 28 /* termination function array size */ 444 #define DT_RUNPATH 29 /* library search path (supersedes DT_RPATH) */ 445 #define DT_FLAGS 30 /* flags (see below) */ 446 #define DT_ENCODING 32 447 #define DT_PREINIT_ARRAY 32 /* preinitialization array */ 448 #define DT_PREINIT_ARRAYSZ 33 /* preinitialization array size */ 449 450 #define DT_VERSYM 0x6ffffff0 /* symbol version table */ 451 #define DT_VERDEF 0x6ffffffc /* version definition table */ 452 #define DT_VERDEFNUM 0x6ffffffd /* number of version definitions */ 453 #define DT_VERNEED 0x6ffffffe /* table with needed versions */ 454 #define DT_VERNEEDNUM 0x6fffffff /* number of needed versions */ 455 456 #define DT_LOPROC 0x70000000 457 #define DT_HIPROC 0x7fffffff 458 459 /* DT_FLAGS values */ 460 #define DF_ORIGIN 0x01 461 #define DF_SYMBOLIC 0x02 462 #define DF_TEXTREL 0x04 463 #define DF_BIND_NOW 0x08 464 #define DF_STATIC_TLS 0x10 465 466 467 /* version definition section */ 468 469 typedef struct { 470 Elf32_Half vd_version; /* version revision */ 471 Elf32_Half vd_flags; /* version information flags */ 472 Elf32_Half vd_ndx; /* version index as specified in the 473 symbol version table */ 474 Elf32_Half vd_cnt; /* number of associated verdaux entries */ 475 Elf32_Word vd_hash; /* version name hash value */ 476 Elf32_Word vd_aux; /* byte offset to verdaux array */ 477 Elf32_Word vd_next; /* byte offset to next verdef entry */ 478 } Elf32_Verdef; 479 480 typedef struct { 481 Elf64_Half vd_version; /* version revision */ 482 Elf64_Half vd_flags; /* version information flags */ 483 Elf64_Half vd_ndx; /* version index as specified in the 484 symbol version table */ 485 Elf64_Half vd_cnt; /* number of associated verdaux entries */ 486 Elf64_Word vd_hash; /* version name hash value */ 487 Elf64_Word vd_aux; /* byte offset to verdaux array */ 488 Elf64_Word vd_next; /* byte offset to next verdef entry */ 489 } Elf64_Verdef; 490 491 /* values for vd_version (version revision) */ 492 #define VER_DEF_NONE 0 /* no version */ 493 #define VER_DEF_CURRENT 1 /* current version */ 494 #define VER_DEF_NUM 2 /* given version number */ 495 496 /* values for vd_flags (version information flags) */ 497 #define VER_FLG_BASE 0x1 /* version definition of file itself */ 498 #define VER_FLG_WEAK 0x2 /* weak version identifier */ 499 500 /* values for versym symbol index */ 501 #define VER_NDX_LOCAL 0 /* symbol is local */ 502 #define VER_NDX_GLOBAL 1 /* symbol is global/unversioned */ 503 #define VER_NDX_INITIAL 2 /* initial version -- that's the one given 504 to symbols when a library becomes 505 versioned; handled by the linker (and 506 runtime loader) similar to 507 VER_NDX_GLOBAL */ 508 #define VER_NDX_LORESERVE 0xff00 /* beginning of reserved entries */ 509 #define VER_NDX_ELIMINATE 0xff01 /* symbol is to be eliminated */ 510 511 #define VER_NDX_FLAG_HIDDEN 0x8000 /* flag: version is hidden */ 512 #define VER_NDX_MASK 0x7fff /* mask to get the actual version index */ 513 #define VER_NDX(x) ((x) & VER_NDX_MASK) 514 515 516 /* auxiliary version information */ 517 518 typedef struct { 519 Elf32_Word vda_name; /* string table offset to version or dependency 520 name */ 521 Elf32_Word vda_next; /* byte offset to next verdaux entry */ 522 } Elf32_Verdaux; 523 524 typedef struct { 525 Elf64_Word vda_name; /* string table offset to version or dependency 526 name */ 527 Elf64_Word vda_next; /* byte offset to next verdaux entry */ 528 } Elf64_Verdaux; 529 530 531 /* version dependency section */ 532 533 typedef struct { 534 Elf32_Half vn_version; /* version of structure */ 535 Elf32_Half vn_cnt; /* number of associated vernaux entries */ 536 Elf32_Word vn_file; /* byte offset to file name for this 537 dependency */ 538 Elf32_Word vn_aux; /* byte offset to vernaux array */ 539 Elf32_Word vn_next; /* byte offset to next verneed entry */ 540 } Elf32_Verneed; 541 542 typedef struct { 543 Elf64_Half vn_version; /* version of structure */ 544 Elf64_Half vn_cnt; /* number of associated vernaux entries */ 545 Elf64_Word vn_file; /* byte offset to file name for this 546 dependency */ 547 Elf64_Word vn_aux; /* byte offset to vernaux array */ 548 Elf64_Word vn_next; /* byte offset to next verneed entry */ 549 } Elf64_Verneed; 550 551 /* values for vn_version (version revision) */ 552 #define VER_NEED_NONE 0 /* no version */ 553 #define VER_NEED_CURRENT 1 /* current version */ 554 #define VER_NEED_NUM 2 /* given version number */ 555 556 557 /* auxiliary needed version information */ 558 559 typedef struct { 560 Elf32_Word vna_hash; /* dependency name hash value */ 561 Elf32_Half vna_flags; /* dependency specific information flags */ 562 Elf32_Half vna_other; /* version index as specified in the symbol 563 version table */ 564 Elf32_Word vna_name; /* string table offset to dependency name */ 565 Elf32_Word vna_next; /* byte offset to next vernaux entry */ 566 } Elf32_Vernaux; 567 568 typedef struct { 569 Elf64_Word vna_hash; /* dependency name hash value */ 570 Elf64_Half vna_flags; /* dependency specific information flags */ 571 Elf64_Half vna_other; /* version index as specified in the symbol 572 version table */ 573 Elf64_Word vna_name; /* string table offset to dependency name */ 574 Elf64_Word vna_next; /* byte offset to next vernaux entry */ 575 } Elf64_Vernaux; 576 577 /* values for vna_flags */ 578 #define VER_FLG_WEAK 0x2 /* weak version identifier */ 579 580 581 /*** inline functions ***/ 582 583 #ifdef __cplusplus 584 585 inline bool 586 Elf32_Ehdr::IsHostEndian() const 587 { 588 #if B_HOST_IS_LENDIAN 589 return e_ident[EI_DATA] == ELFDATA2LSB; 590 #elif B_HOST_IS_BENDIAN 591 return e_ident[EI_DATA] == ELFDATA2MSB; 592 #endif 593 } 594 595 596 inline bool 597 Elf64_Ehdr::IsHostEndian() const 598 { 599 #if B_HOST_IS_LENDIAN 600 return e_ident[EI_DATA] == ELFDATA2LSB; 601 #elif B_HOST_IS_BENDIAN 602 return e_ident[EI_DATA] == ELFDATA2MSB; 603 #endif 604 } 605 606 607 inline bool 608 Elf32_Phdr::IsReadWrite() const 609 { 610 return !(~p_flags & (PF_READ | PF_WRITE)); 611 } 612 613 614 inline bool 615 Elf32_Phdr::IsExecutable() const 616 { 617 return (p_flags & PF_EXECUTE) != 0; 618 } 619 620 621 inline bool 622 Elf64_Phdr::IsReadWrite() const 623 { 624 return !(~p_flags & (PF_READ | PF_WRITE)); 625 } 626 627 628 inline bool 629 Elf64_Phdr::IsExecutable() const 630 { 631 return (p_flags & PF_EXECUTE) != 0; 632 } 633 634 635 inline uint8 636 Elf32_Sym::Bind() const 637 { 638 return ELF32_ST_BIND(st_info); 639 } 640 641 642 inline uint8 643 Elf32_Sym::Type() const 644 { 645 return ELF32_ST_TYPE(st_info); 646 } 647 648 649 inline void 650 Elf32_Sym::SetInfo(uint8 bind, uint8 type) 651 { 652 st_info = ELF32_ST_INFO(bind, type); 653 } 654 655 656 inline uint8 657 Elf64_Sym::Bind() const 658 { 659 return ELF64_ST_BIND(st_info); 660 } 661 662 663 inline uint8 664 Elf64_Sym::Type() const 665 { 666 return ELF64_ST_TYPE(st_info); 667 } 668 669 670 inline void 671 Elf64_Sym::SetInfo(uint8 bind, uint8 type) 672 { 673 st_info = ELF64_ST_INFO(bind, type); 674 } 675 676 677 inline uint8 678 Elf32_Rel::SymbolIndex() const 679 { 680 return ELF32_R_SYM(r_info); 681 } 682 683 684 inline uint8 685 Elf32_Rel::Type() const 686 { 687 return ELF32_R_TYPE(r_info); 688 } 689 690 691 inline uint8 692 Elf64_Rel::SymbolIndex() const 693 { 694 return ELF64_R_SYM(r_info); 695 } 696 697 698 inline uint8 699 Elf64_Rel::Type() const 700 { 701 return ELF64_R_TYPE(r_info); 702 } 703 704 #endif /* __cplusplus */ 705 706 707 #endif /* _ELF_H */ 708