elfdump.c (289071) | elfdump.c (295577) |
---|---|
1/*- 2 * Copyright (c) 2007-2012 Kai Wang 3 * Copyright (c) 2003 David O'Brien. All rights reserved. 4 * Copyright (c) 2001 Jake Burkholder 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 36 unchanged lines hidden (view full) --- 45 46#ifdef USE_LIBARCHIVE_AR 47#include <archive.h> 48#include <archive_entry.h> 49#endif 50 51#include "_elftc.h" 52 | 1/*- 2 * Copyright (c) 2007-2012 Kai Wang 3 * Copyright (c) 2003 David O'Brien. All rights reserved. 4 * Copyright (c) 2001 Jake Burkholder 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 36 unchanged lines hidden (view full) --- 45 46#ifdef USE_LIBARCHIVE_AR 47#include <archive.h> 48#include <archive_entry.h> 49#endif 50 51#include "_elftc.h" 52 |
53ELFTC_VCSID("$Id: elfdump.c 3250 2015-10-06 13:56:15Z emaste $"); | 53ELFTC_VCSID("$Id: elfdump.c 3391 2016-02-05 19:43:01Z emaste $"); |
54 55#if defined(ELFTC_NEED_ELF_NOTE_DEFINITION) 56#include "native-elf-format.h" 57#if ELFTC_CLASS == ELFCLASS32 58typedef Elf32_Nhdr Elf_Note; 59#else 60typedef Elf64_Nhdr Elf_Note; 61#endif --- 88 unchanged lines hidden (view full) --- 150 return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]); 151} 152#endif 153 154/* http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#tag_encodings */ 155static const char * 156d_tags(uint64_t tag) 157{ | 54 55#if defined(ELFTC_NEED_ELF_NOTE_DEFINITION) 56#include "native-elf-format.h" 57#if ELFTC_CLASS == ELFCLASS32 58typedef Elf32_Nhdr Elf_Note; 59#else 60typedef Elf64_Nhdr Elf_Note; 61#endif --- 88 unchanged lines hidden (view full) --- 150 return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]); 151} 152#endif 153 154/* http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#tag_encodings */ 155static const char * 156d_tags(uint64_t tag) 157{ |
158 static char unknown_buf[64]; 159 |
|
158 switch (tag) { | 160 switch (tag) { |
159 case 0: return "DT_NULL"; 160 case 1: return "DT_NEEDED"; 161 case 2: return "DT_PLTRELSZ"; 162 case 3: return "DT_PLTGOT"; 163 case 4: return "DT_HASH"; 164 case 5: return "DT_STRTAB"; 165 case 6: return "DT_SYMTAB"; 166 case 7: return "DT_RELA"; 167 case 8: return "DT_RELASZ"; 168 case 9: return "DT_RELAENT"; 169 case 10: return "DT_STRSZ"; 170 case 11: return "DT_SYMENT"; 171 case 12: return "DT_INIT"; 172 case 13: return "DT_FINI"; 173 case 14: return "DT_SONAME"; 174 case 15: return "DT_RPATH"; 175 case 16: return "DT_SYMBOLIC"; 176 case 17: return "DT_REL"; 177 case 18: return "DT_RELSZ"; 178 case 19: return "DT_RELENT"; 179 case 20: return "DT_PLTREL"; 180 case 21: return "DT_DEBUG"; 181 case 22: return "DT_TEXTREL"; 182 case 23: return "DT_JMPREL"; 183 case 24: return "DT_BIND_NOW"; 184 case 25: return "DT_INIT_ARRAY"; 185 case 26: return "DT_FINI_ARRAY"; 186 case 27: return "DT_INIT_ARRAYSZ"; 187 case 28: return "DT_FINI_ARRAYSZ"; 188 case 29: return "DT_RUNPATH"; 189 case 30: return "DT_FLAGS"; 190 case 32: return "DT_PREINIT_ARRAY"; /* XXX: DT_ENCODING */ 191 case 33: return "DT_PREINIT_ARRAYSZ"; | 161 case DT_NULL: return "DT_NULL"; 162 case DT_NEEDED: return "DT_NEEDED"; 163 case DT_PLTRELSZ: return "DT_PLTRELSZ"; 164 case DT_PLTGOT: return "DT_PLTGOT"; 165 case DT_HASH: return "DT_HASH"; 166 case DT_STRTAB: return "DT_STRTAB"; 167 case DT_SYMTAB: return "DT_SYMTAB"; 168 case DT_RELA: return "DT_RELA"; 169 case DT_RELASZ: return "DT_RELASZ"; 170 case DT_RELAENT: return "DT_RELAENT"; 171 case DT_STRSZ: return "DT_STRSZ"; 172 case DT_SYMENT: return "DT_SYMENT"; 173 case DT_INIT: return "DT_INIT"; 174 case DT_FINI: return "DT_FINI"; 175 case DT_SONAME: return "DT_SONAME"; 176 case DT_RPATH: return "DT_RPATH"; 177 case DT_SYMBOLIC: return "DT_SYMBOLIC"; 178 case DT_REL: return "DT_REL"; 179 case DT_RELSZ: return "DT_RELSZ"; 180 case DT_RELENT: return "DT_RELENT"; 181 case DT_PLTREL: return "DT_PLTREL"; 182 case DT_DEBUG: return "DT_DEBUG"; 183 case DT_TEXTREL: return "DT_TEXTREL"; 184 case DT_JMPREL: return "DT_JMPREL"; 185 case DT_BIND_NOW: return "DT_BIND_NOW"; 186 case DT_INIT_ARRAY: return "DT_INIT_ARRAY"; 187 case DT_FINI_ARRAY: return "DT_FINI_ARRAY"; 188 case DT_INIT_ARRAYSZ: return "DT_INIT_ARRAYSZ"; 189 case DT_FINI_ARRAYSZ: return "DT_FINI_ARRAYSZ"; 190 case DT_RUNPATH: return "DT_RUNPATH"; 191 case DT_FLAGS: return "DT_FLAGS"; 192 case DT_PREINIT_ARRAY: return "DT_PREINIT_ARRAY"; /* XXX DT_ENCODING */ 193 case DT_PREINIT_ARRAYSZ:return "DT_PREINIT_ARRAYSZ"; |
192 /* 0x6000000D - 0x6ffff000 operating system-specific semantics */ | 194 /* 0x6000000D - 0x6ffff000 operating system-specific semantics */ |
193 case 0x6ffffdf5: return "DT_GNU_PRELINKED"; 194 case 0x6ffffdf6: return "DT_GNU_CONFLICTSZ"; 195 case 0x6ffffdf7: return "DT_GNU_LIBLISTSZ"; 196 case 0x6ffffdf8: return "DT_SUNW_CHECKSUM"; 197 case 0x6ffffdf9: return "DT_PLTPADSZ"; 198 case 0x6ffffdfa: return "DT_MOVEENT"; 199 case 0x6ffffdfb: return "DT_MOVESZ"; 200 case 0x6ffffdfc: return "DT_FEATURE"; 201 case 0x6ffffdfd: return "DT_POSFLAG_1"; 202 case 0x6ffffdfe: return "DT_SYMINSZ"; 203 case 0x6ffffdff: return "DT_SYMINENT (DT_VALRNGHI)"; 204 case 0x6ffffe00: return "DT_ADDRRNGLO"; 205 case 0x6ffffef5: return "DT_GNU_HASH"; 206 case 0x6ffffef8: return "DT_GNU_CONFLICT"; 207 case 0x6ffffef9: return "DT_GNU_LIBLIST"; 208 case 0x6ffffefa: return "DT_CONFIG"; 209 case 0x6ffffefb: return "DT_DEPAUDIT"; 210 case 0x6ffffefc: return "DT_AUDIT"; 211 case 0x6ffffefd: return "DT_PLTPAD"; 212 case 0x6ffffefe: return "DT_MOVETAB"; 213 case 0x6ffffeff: return "DT_SYMINFO (DT_ADDRRNGHI)"; 214 case 0x6ffffff9: return "DT_RELACOUNT"; 215 case 0x6ffffffa: return "DT_RELCOUNT"; 216 case 0x6ffffffb: return "DT_FLAGS_1"; 217 case 0x6ffffffc: return "DT_VERDEF"; 218 case 0x6ffffffd: return "DT_VERDEFNUM"; 219 case 0x6ffffffe: return "DT_VERNEED"; 220 case 0x6fffffff: return "DT_VERNEEDNUM"; 221 case 0x6ffffff0: return "DT_GNU_VERSYM"; | 195 case 0x6ffffdf5: return "DT_GNU_PRELINKED"; 196 case 0x6ffffdf6: return "DT_GNU_CONFLICTSZ"; 197 case 0x6ffffdf7: return "DT_GNU_LIBLISTSZ"; 198 case 0x6ffffdf8: return "DT_SUNW_CHECKSUM"; 199 case DT_PLTPADSZ: return "DT_PLTPADSZ"; 200 case DT_MOVEENT: return "DT_MOVEENT"; 201 case DT_MOVESZ: return "DT_MOVESZ"; 202 case 0x6ffffdfc: return "DT_FEATURE"; 203 case DT_POSFLAG_1: return "DT_POSFLAG_1"; 204 case DT_SYMINSZ: return "DT_SYMINSZ"; 205 case DT_SYMINENT: return "DT_SYMINENT (DT_VALRNGHI)"; 206 case DT_ADDRRNGLO: return "DT_ADDRRNGLO"; 207 case DT_GNU_HASH: return "DT_GNU_HASH"; 208 case 0x6ffffef8: return "DT_GNU_CONFLICT"; 209 case 0x6ffffef9: return "DT_GNU_LIBLIST"; 210 case 0x6ffffefa: return "DT_CONFIG"; 211 case 0x6ffffefb: return "DT_DEPAUDIT"; 212 case 0x6ffffefc: return "DT_AUDIT"; 213 case 0x6ffffefd: return "DT_PLTPAD"; 214 case 0x6ffffefe: return "DT_MOVETAB"; 215 case DT_SYMINFO: return "DT_SYMINFO (DT_ADDRRNGHI)"; 216 case DT_RELACOUNT: return "DT_RELACOUNT"; 217 case DT_RELCOUNT: return "DT_RELCOUNT"; 218 case DT_FLAGS_1: return "DT_FLAGS_1"; 219 case DT_VERDEF: return "DT_VERDEF"; 220 case DT_VERDEFNUM: return "DT_VERDEFNUM"; 221 case DT_VERNEED: return "DT_VERNEED"; 222 case DT_VERNEEDNUM: return "DT_VERNEEDNUM"; 223 case 0x6ffffff0: return "DT_GNU_VERSYM"; |
222 /* 0x70000000 - 0x7fffffff processor-specific semantics */ | 224 /* 0x70000000 - 0x7fffffff processor-specific semantics */ |
223 case 0x70000000: return "DT_IA_64_PLT_RESERVE"; 224 case 0x7ffffffd: return "DT_SUNW_AUXILIARY"; 225 case 0x7ffffffe: return "DT_SUNW_USED"; 226 case 0x7fffffff: return "DT_SUNW_FILTER"; 227 default: return "ERROR: TAG NOT DEFINED"; | 225 case 0x70000000: return "DT_IA_64_PLT_RESERVE"; 226 case 0x7ffffffd: return "DT_SUNW_AUXILIARY"; 227 case 0x7ffffffe: return "DT_SUNW_USED"; 228 case 0x7fffffff: return "DT_SUNW_FILTER"; |
228 } | 229 } |
230 231 snprintf(unknown_buf, sizeof(unknown_buf), 232 "<unknown: %#llx>", (unsigned long long)tag); 233 return (unknown_buf); |
|
229} 230 231static const char * 232e_machines(unsigned int mach) 233{ 234 static char machdesc[64]; 235 236 switch (mach) { --- 71 unchanged lines hidden (view full) --- 308 snprintf(num, sizeof(num), "%d", ndx); 309 return (num); 310 } 311 } 312} 313 314/* http://www.sco.com/developers/gabi/latest/ch4.sheader.html#sh_type */ 315static const char * | 234} 235 236static const char * 237e_machines(unsigned int mach) 238{ 239 static char machdesc[64]; 240 241 switch (mach) { --- 71 unchanged lines hidden (view full) --- 313 snprintf(num, sizeof(num), "%d", ndx); 314 return (num); 315 } 316 } 317} 318 319/* http://www.sco.com/developers/gabi/latest/ch4.sheader.html#sh_type */ 320static const char * |
316sh_types(u_int64_t sht) { 317 switch (sht) { 318 case 0: return "SHT_NULL"; 319 case 1: return "SHT_PROGBITS"; 320 case 2: return "SHT_SYMTAB"; 321 case 3: return "SHT_STRTAB"; 322 case 4: return "SHT_RELA"; 323 case 5: return "SHT_HASH"; 324 case 6: return "SHT_DYNAMIC"; 325 case 7: return "SHT_NOTE"; 326 case 8: return "SHT_NOBITS"; 327 case 9: return "SHT_REL"; 328 case 10: return "SHT_SHLIB"; 329 case 11: return "SHT_DYNSYM"; 330 case 14: return "SHT_INIT_ARRAY"; 331 case 15: return "SHT_FINI_ARRAY"; 332 case 16: return "SHT_PREINIT_ARRAY"; 333 case 17: return "SHT_GROUP"; 334 case 18: return "SHT_SYMTAB_SHNDX"; 335 /* 0x60000000 - 0x6fffffff operating system-specific semantics */ 336 case 0x6ffffff0: return "XXX:VERSYM"; 337 case 0x6ffffff4: return "SHT_SUNW_dof"; 338 case 0x6ffffff6: return "SHT_GNU_HASH"; 339 case 0x6ffffff7: return "SHT_GNU_LIBLIST"; 340 case 0x6ffffffc: return "XXX:VERDEF"; 341 case 0x6ffffffd: return "SHT_SUNW(GNU)_verdef"; 342 case 0x6ffffffe: return "SHT_SUNW(GNU)_verneed"; 343 case 0x6fffffff: return "SHT_SUNW(GNU)_versym"; 344 /* 0x70000000 - 0x7fffffff processor-specific semantics */ 345 case 0x70000000: return "SHT_IA_64_EXT"; 346 case 0x70000001: return "SHT_IA_64_UNWIND"; 347 case 0x7ffffffd: return "XXX:AUXILIARY"; 348 case 0x7fffffff: return "XXX:FILTER"; 349 /* 0x80000000 - 0xffffffff application programs */ 350 default: return "ERROR: SHT NOT DEFINED"; | 321sh_types(uint64_t mach, uint64_t sht) { 322 static char unknown_buf[64]; 323 324 if (sht < 0x60000000) { 325 switch (sht) { 326 case SHT_NULL: return "SHT_NULL"; 327 case SHT_PROGBITS: return "SHT_PROGBITS"; 328 case SHT_SYMTAB: return "SHT_SYMTAB"; 329 case SHT_STRTAB: return "SHT_STRTAB"; 330 case SHT_RELA: return "SHT_RELA"; 331 case SHT_HASH: return "SHT_HASH"; 332 case SHT_DYNAMIC: return "SHT_DYNAMIC"; 333 case SHT_NOTE: return "SHT_NOTE"; 334 case SHT_NOBITS: return "SHT_NOBITS"; 335 case SHT_REL: return "SHT_REL"; 336 case SHT_SHLIB: return "SHT_SHLIB"; 337 case SHT_DYNSYM: return "SHT_DYNSYM"; 338 case SHT_INIT_ARRAY: return "SHT_INIT_ARRAY"; 339 case SHT_FINI_ARRAY: return "SHT_FINI_ARRAY"; 340 case SHT_PREINIT_ARRAY: return "SHT_PREINIT_ARRAY"; 341 case SHT_GROUP: return "SHT_GROUP"; 342 case SHT_SYMTAB_SHNDX: return "SHT_SYMTAB_SHNDX"; 343 } 344 } else if (sht < 0x70000000) { 345 /* 0x60000000-0x6fffffff operating system-specific semantics */ 346 switch (sht) { 347 case 0x6ffffff0: return "XXX:VERSYM"; 348 case SHT_SUNW_dof: return "SHT_SUNW_dof"; 349 case SHT_GNU_HASH: return "SHT_GNU_HASH"; 350 case 0x6ffffff7: return "SHT_GNU_LIBLIST"; 351 case 0x6ffffffc: return "XXX:VERDEF"; 352 case SHT_SUNW_verdef: return "SHT_SUNW(GNU)_verdef"; 353 case SHT_SUNW_verneed: return "SHT_SUNW(GNU)_verneed"; 354 case SHT_SUNW_versym: return "SHT_SUNW(GNU)_versym"; 355 } 356 } else if (sht < 0x80000000) { 357 /* 0x70000000 - 0x7fffffff processor-specific semantics */ 358 switch (mach) { 359 case EM_ARM: 360 switch (sht) { 361 case SHT_ARM_EXIDX: return "SHT_ARM_EXIDX"; 362 case SHT_ARM_PREEMPTMAP: return "SHT_ARM_PREEMPTMAP"; 363 case SHT_ARM_ATTRIBUTES: return "SHT_ARM_ATTRIBUTES"; 364 case SHT_ARM_DEBUGOVERLAY: 365 return "SHT_ARM_DEBUGOVERLAY"; 366 case SHT_ARM_OVERLAYSECTION: 367 return "SHT_ARM_OVERLAYSECTION"; 368 } 369 break; 370 case EM_IA_64: 371 switch (sht) { 372 case 0x70000000: return "SHT_IA_64_EXT"; 373 case 0x70000001: return "SHT_IA_64_UNWIND"; 374 } 375 break; 376 case EM_MIPS: 377 switch (sht) { 378 case SHT_MIPS_REGINFO: return "SHT_MIPS_REGINFO"; 379 case SHT_MIPS_OPTIONS: return "SHT_MIPS_OPTIONS"; 380 case SHT_MIPS_ABIFLAGS: return "SHT_MIPS_ABIFLAGS"; 381 } 382 break; 383 } 384 switch (sht) { 385 case 0x7ffffffd: return "XXX:AUXILIARY"; 386 case 0x7fffffff: return "XXX:FILTER"; 387 } |
351 } | 388 } |
389 /* 0x80000000 - 0xffffffff application programs */ 390 391 snprintf(unknown_buf, sizeof(unknown_buf), 392 "<unknown: %#llx>", (unsigned long long)sht); 393 return (unknown_buf); |
|
352} 353 354/* 355 * Define known section flags. These flags are defined in the order 356 * they are to be printed out. 357 */ 358#define DEFINE_SHFLAGS() \ 359 DEFINE_SHF(WRITE) \ --- 25 unchanged lines hidden (view full) --- 385 386 DEFINE_SHFLAGS() 387 388 flg[strlen(flg) - 1] = '\0'; /* Remove the trailing "|". */ 389 390 return (flg); 391} 392 | 394} 395 396/* 397 * Define known section flags. These flags are defined in the order 398 * they are to be printed out. 399 */ 400#define DEFINE_SHFLAGS() \ 401 DEFINE_SHF(WRITE) \ --- 25 unchanged lines hidden (view full) --- 427 428 DEFINE_SHFLAGS() 429 430 flg[strlen(flg) - 1] = '\0'; /* Remove the trailing "|". */ 431 432 return (flg); 433} 434 |
393static const char *st_types[] = { 394 "STT_NOTYPE", "STT_OBJECT", "STT_FUNC", "STT_SECTION", "STT_FILE", 395 "STT_COMMON", "STT_TLS" 396}; | 435static const char * 436st_type(unsigned int mach, unsigned int type) 437{ 438 static char s_type[32]; |
397 | 439 |
398static const char *st_types_S[] = { 399 "NOTY", "OBJT", "FUNC", "SECT", "FILE" 400}; | 440 switch (type) { 441 case STT_NOTYPE: return "STT_NOTYPE"; 442 case STT_OBJECT: return "STT_OBJECT"; 443 case STT_FUNC: return "STT_FUNC"; 444 case STT_SECTION: return "STT_SECTION"; 445 case STT_FILE: return "STT_FILE"; 446 case STT_COMMON: return "STT_COMMON"; 447 case STT_TLS: return "STT_TLS"; 448 case 13: 449 if (mach == EM_SPARCV9) 450 return "STT_SPARC_REGISTER"; 451 break; 452 } 453 snprintf(s_type, sizeof(s_type), "<unknown: %#x>", type); 454 return (s_type); 455} |
401 | 456 |
402static const char *st_bindings[] = { 403 "STB_LOCAL", "STB_GLOBAL", "STB_WEAK" 404}; | 457static const char * 458st_type_S(unsigned int type) 459{ 460 static char s_type[32]; |
405 | 461 |
406static const char *st_bindings_S[] = { 407 "LOCL", "GLOB", "WEAK" 408}; | 462 switch (type) { 463 case STT_NOTYPE: return "NOTY"; 464 case STT_OBJECT: return "OBJT"; 465 case STT_FUNC: return "FUNC"; 466 case STT_SECTION: return "SECT"; 467 case STT_FILE: return "FILE"; 468 } 469 snprintf(s_type, sizeof(s_type), "<unknown: %#x>", type); 470 return (s_type); 471} |
409 | 472 |
473static const char * 474st_bindings(unsigned int sbind) 475{ 476 static char s_sbind[32]; 477 478 switch (sbind) { 479 case STB_LOCAL: return "STB_LOCAL"; 480 case STB_GLOBAL: return "STB_GLOBAL"; 481 case STB_WEAK: return "STB_WEAK"; 482 case STB_GNU_UNIQUE: return "STB_GNU_UNIQUE"; 483 default: 484 if (sbind >= STB_LOOS && sbind <= STB_HIOS) 485 return "OS"; 486 else if (sbind >= STB_LOPROC && sbind <= STB_HIPROC) 487 return "PROC"; 488 else 489 snprintf(s_sbind, sizeof(s_sbind), "<unknown: %#x>", 490 sbind); 491 return (s_sbind); 492 } 493} 494 495static const char * 496st_bindings_S(unsigned int sbind) 497{ 498 static char s_sbind[32]; 499 500 switch (sbind) { 501 case STB_LOCAL: return "LOCL"; 502 case STB_GLOBAL: return "GLOB"; 503 case STB_WEAK: return "WEAK"; 504 case STB_GNU_UNIQUE: return "UNIQ"; 505 default: 506 if (sbind >= STB_LOOS && sbind <= STB_HIOS) 507 return "OS"; 508 else if (sbind >= STB_LOPROC && sbind <= STB_HIPROC) 509 return "PROC"; 510 else 511 snprintf(s_sbind, sizeof(s_sbind), "<%#x>", 512 sbind); 513 return (s_sbind); 514 } 515} 516 |
|
410static unsigned char st_others[] = { 411 'D', 'I', 'H', 'P' 412}; 413 414static const char * 415r_type(unsigned int mach, unsigned int type) 416{ 417 switch(mach) { 418 case EM_NONE: return ""; 419 case EM_386: 420 case EM_IAMCU: 421 switch(type) { 422 case 0: return "R_386_NONE"; 423 case 1: return "R_386_32"; 424 case 2: return "R_386_PC32"; 425 case 3: return "R_386_GOT32"; 426 case 4: return "R_386_PLT32"; 427 case 5: return "R_386_COPY"; 428 case 6: return "R_386_GLOB_DAT"; | 517static unsigned char st_others[] = { 518 'D', 'I', 'H', 'P' 519}; 520 521static const char * 522r_type(unsigned int mach, unsigned int type) 523{ 524 switch(mach) { 525 case EM_NONE: return ""; 526 case EM_386: 527 case EM_IAMCU: 528 switch(type) { 529 case 0: return "R_386_NONE"; 530 case 1: return "R_386_32"; 531 case 2: return "R_386_PC32"; 532 case 3: return "R_386_GOT32"; 533 case 4: return "R_386_PLT32"; 534 case 5: return "R_386_COPY"; 535 case 6: return "R_386_GLOB_DAT"; |
429 case 7: return "R_386_JMP_SLOT"; | 536 case 7: return "R_386_JUMP_SLOT"; |
430 case 8: return "R_386_RELATIVE"; 431 case 9: return "R_386_GOTOFF"; 432 case 10: return "R_386_GOTPC"; 433 case 14: return "R_386_TLS_TPOFF"; 434 case 15: return "R_386_TLS_IE"; 435 case 16: return "R_386_TLS_GOTIE"; 436 case 17: return "R_386_TLS_LE"; 437 case 18: return "R_386_TLS_GD"; --- 326 unchanged lines hidden (view full) --- 764 switch(type) { 765 case 0: return "R_X86_64_NONE"; 766 case 1: return "R_X86_64_64"; 767 case 2: return "R_X86_64_PC32"; 768 case 3: return "R_X86_64_GOT32"; 769 case 4: return "R_X86_64_PLT32"; 770 case 5: return "R_X86_64_COPY"; 771 case 6: return "R_X86_64_GLOB_DAT"; | 537 case 8: return "R_386_RELATIVE"; 538 case 9: return "R_386_GOTOFF"; 539 case 10: return "R_386_GOTPC"; 540 case 14: return "R_386_TLS_TPOFF"; 541 case 15: return "R_386_TLS_IE"; 542 case 16: return "R_386_TLS_GOTIE"; 543 case 17: return "R_386_TLS_LE"; 544 case 18: return "R_386_TLS_GD"; --- 326 unchanged lines hidden (view full) --- 871 switch(type) { 872 case 0: return "R_X86_64_NONE"; 873 case 1: return "R_X86_64_64"; 874 case 2: return "R_X86_64_PC32"; 875 case 3: return "R_X86_64_GOT32"; 876 case 4: return "R_X86_64_PLT32"; 877 case 5: return "R_X86_64_COPY"; 878 case 6: return "R_X86_64_GLOB_DAT"; |
772 case 7: return "R_X86_64_JMP_SLOT"; | 879 case 7: return "R_X86_64_JUMP_SLOT"; |
773 case 8: return "R_X86_64_RELATIVE"; 774 case 9: return "R_X86_64_GOTPCREL"; 775 case 10: return "R_X86_64_32"; 776 case 11: return "R_X86_64_32S"; 777 case 12: return "R_X86_64_16"; 778 case 13: return "R_X86_64_PC16"; 779 case 14: return "R_X86_64_8"; 780 case 15: return "R_X86_64_PC8"; --- 822 unchanged lines hidden (view full) --- 1603 PRT("\nSection Header[%d]:", i); 1604 PRT(" sh_name: %s\n", s->name); 1605 PRT(" sh_addr: %#-14jx", (uintmax_t)s->addr); 1606 if (s->flags != 0) 1607 PRT(" sh_flags: [ %s ]\n", sh_flags(s->flags)); 1608 else 1609 PRT(" sh_flags: 0\n"); 1610 PRT(" sh_size: %#-14jx", (uintmax_t)s->sz); | 880 case 8: return "R_X86_64_RELATIVE"; 881 case 9: return "R_X86_64_GOTPCREL"; 882 case 10: return "R_X86_64_32"; 883 case 11: return "R_X86_64_32S"; 884 case 12: return "R_X86_64_16"; 885 case 13: return "R_X86_64_PC16"; 886 case 14: return "R_X86_64_8"; 887 case 15: return "R_X86_64_PC8"; --- 822 unchanged lines hidden (view full) --- 1710 PRT("\nSection Header[%d]:", i); 1711 PRT(" sh_name: %s\n", s->name); 1712 PRT(" sh_addr: %#-14jx", (uintmax_t)s->addr); 1713 if (s->flags != 0) 1714 PRT(" sh_flags: [ %s ]\n", sh_flags(s->flags)); 1715 else 1716 PRT(" sh_flags: 0\n"); 1717 PRT(" sh_size: %#-14jx", (uintmax_t)s->sz); |
1611 PRT(" sh_type: [ %s ]\n", sh_types(s->type)); | 1718 PRT(" sh_type: [ %s ]\n", 1719 sh_types(ed->ehdr.e_machine, s->type)); |
1612 PRT(" sh_offset: %#-14jx", (uintmax_t)s->off); 1613 PRT(" sh_entsize: %#jx\n", (uintmax_t)s->entsize); 1614 PRT(" sh_link: %-14u", s->link); 1615 PRT(" sh_info: %u\n", s->info); 1616 PRT(" sh_addralign: %#jx\n", (uintmax_t)s->align); 1617 } else { 1618 PRT("\n"); 1619 PRT("entry: %ju\n", (uintmax_t)i); 1620 PRT("\tsh_name: %s\n", s->name); | 1720 PRT(" sh_offset: %#-14jx", (uintmax_t)s->off); 1721 PRT(" sh_entsize: %#jx\n", (uintmax_t)s->entsize); 1722 PRT(" sh_link: %-14u", s->link); 1723 PRT(" sh_info: %u\n", s->info); 1724 PRT(" sh_addralign: %#jx\n", (uintmax_t)s->align); 1725 } else { 1726 PRT("\n"); 1727 PRT("entry: %ju\n", (uintmax_t)i); 1728 PRT("\tsh_name: %s\n", s->name); |
1621 PRT("\tsh_type: %s\n", sh_types(s->type)); | 1729 PRT("\tsh_type: %s\n", 1730 sh_types(ed->ehdr.e_machine, s->type)); |
1622 PRT("\tsh_flags: %s\n", sh_flags(s->flags)); 1623 PRT("\tsh_addr: %#jx\n", (uintmax_t)s->addr); 1624 PRT("\tsh_offset: %ju\n", (uintmax_t)s->off); 1625 PRT("\tsh_size: %ju\n", (uintmax_t)s->sz); 1626 PRT("\tsh_link: %u\n", s->link); 1627 PRT("\tsh_info: %u\n", s->info); 1628 PRT("\tsh_addralign: %ju\n", (uintmax_t)s->align); 1629 PRT("\tsh_entsize: %ju\n", (uintmax_t)s->entsize); --- 110 unchanged lines hidden (view full) --- 1740 PRT("%10s ", idx); 1741 else 1742 PRT("%10s ", idx); 1743 PRT("0x%8.8jx ", (uintmax_t)sym.st_value); 1744 if (ed->ec == ELFCLASS32) 1745 PRT("0x%8.8jx ", (uintmax_t)sym.st_size); 1746 else 1747 PRT("0x%12.12jx ", (uintmax_t)sym.st_size); | 1731 PRT("\tsh_flags: %s\n", sh_flags(s->flags)); 1732 PRT("\tsh_addr: %#jx\n", (uintmax_t)s->addr); 1733 PRT("\tsh_offset: %ju\n", (uintmax_t)s->off); 1734 PRT("\tsh_size: %ju\n", (uintmax_t)s->sz); 1735 PRT("\tsh_link: %u\n", s->link); 1736 PRT("\tsh_info: %u\n", s->info); 1737 PRT("\tsh_addralign: %ju\n", (uintmax_t)s->align); 1738 PRT("\tsh_entsize: %ju\n", (uintmax_t)s->entsize); --- 110 unchanged lines hidden (view full) --- 1849 PRT("%10s ", idx); 1850 else 1851 PRT("%10s ", idx); 1852 PRT("0x%8.8jx ", (uintmax_t)sym.st_value); 1853 if (ed->ec == ELFCLASS32) 1854 PRT("0x%8.8jx ", (uintmax_t)sym.st_size); 1855 else 1856 PRT("0x%12.12jx ", (uintmax_t)sym.st_size); |
1748 PRT("%s ", st_types_S[GELF_ST_TYPE(sym.st_info)]); 1749 PRT("%s ", st_bindings_S[GELF_ST_BIND(sym.st_info)]); | 1857 PRT("%s ", st_type_S(GELF_ST_TYPE(sym.st_info))); 1858 PRT("%s ", st_bindings_S(GELF_ST_BIND(sym.st_info))); |
1750 PRT("%c ", st_others[sym.st_other]); 1751 PRT("%3u ", (vs == NULL ? 0 : vs[j])); 1752 PRT("%-11.11s ", sh_name(ed, sym.st_shndx)); 1753 PRT("%s\n", name); 1754 } else { 1755 PRT("\nentry: %d\n", j); 1756 PRT("\tst_name: %s\n", name); 1757 PRT("\tst_value: %#jx\n", (uintmax_t)sym.st_value); 1758 PRT("\tst_size: %ju\n", (uintmax_t)sym.st_size); 1759 PRT("\tst_info: %s %s\n", | 1859 PRT("%c ", st_others[sym.st_other]); 1860 PRT("%3u ", (vs == NULL ? 0 : vs[j])); 1861 PRT("%-11.11s ", sh_name(ed, sym.st_shndx)); 1862 PRT("%s\n", name); 1863 } else { 1864 PRT("\nentry: %d\n", j); 1865 PRT("\tst_name: %s\n", name); 1866 PRT("\tst_value: %#jx\n", (uintmax_t)sym.st_value); 1867 PRT("\tst_size: %ju\n", (uintmax_t)sym.st_size); 1868 PRT("\tst_info: %s %s\n", |
1760 st_types[GELF_ST_TYPE(sym.st_info)], 1761 st_bindings[GELF_ST_BIND(sym.st_info)]); | 1869 st_type(ed->ehdr.e_machine, 1870 GELF_ST_TYPE(sym.st_info)), 1871 st_bindings(GELF_ST_BIND(sym.st_info))); |
1762 PRT("\tst_shndx: %ju\n", (uintmax_t)sym.st_shndx); 1763 } 1764 } 1765} 1766 1767/* 1768 * Dump the symbol tables. (.dynsym and .symtab) 1769 */ --- 398 unchanged lines hidden (view full) --- 2168 PRT("addend symbol\n"); 2169 } else { 2170 PRT(" ndx addr value "); 2171 PRT("reloc addend symbol\n"); 2172 } 2173 for(i = 0; i < len; i++) { 2174 PRT("[%5.5d] ", i); 2175 if (ed->ec == ELFCLASS32) { | 1872 PRT("\tst_shndx: %ju\n", (uintmax_t)sym.st_shndx); 1873 } 1874 } 1875} 1876 1877/* 1878 * Dump the symbol tables. (.dynsym and .symtab) 1879 */ --- 398 unchanged lines hidden (view full) --- 2278 PRT("addend symbol\n"); 2279 } else { 2280 PRT(" ndx addr value "); 2281 PRT("reloc addend symbol\n"); 2282 } 2283 for(i = 0; i < len; i++) { 2284 PRT("[%5.5d] ", i); 2285 if (ed->ec == ELFCLASS32) { |
2176 PRT("%-8.8jx ", s->addr + i * s->entsize); | 2286 PRT("%-8.8jx ", 2287 (uintmax_t) (s->addr + i * s->entsize)); |
2177 PRT("%-8.8x ", *((uint32_t *)dst.d_buf + i)); 2178 } else { | 2288 PRT("%-8.8x ", *((uint32_t *)dst.d_buf + i)); 2289 } else { |
2179 PRT("%-16.16jx ", s->addr + i * s->entsize); 2180 PRT("%-16.16jx ", *((uint64_t *)dst.d_buf + i)); | 2290 PRT("%-16.16jx ", 2291 (uintmax_t) (s->addr + i * s->entsize)); 2292 PRT("%-16.16jx ", 2293 (uintmax_t) *((uint64_t *)dst.d_buf + i)); |
2181 } 2182 PRT("%-18s ", r_type(ed->ehdr.e_machine, 2183 GELF_R_TYPE(got[i].u_r.rel.r_info))); 2184 if (ed->ec == ELFCLASS32) 2185 PRT("%-8.8jd ", 2186 (intmax_t)got[i].u_r.rela.r_addend); 2187 else 2188 PRT("%-12.12jd ", --- 4 unchanged lines hidden (view full) --- 2193 } 2194 free(got); 2195 } else { 2196 for(i = 0; i < len; i++) { 2197 PRT("\nentry: %d\n", i); 2198 if (ed->ec == ELFCLASS32) 2199 PRT("\t%#x\n", *((uint32_t *)dst.d_buf + i)); 2200 else | 2294 } 2295 PRT("%-18s ", r_type(ed->ehdr.e_machine, 2296 GELF_R_TYPE(got[i].u_r.rel.r_info))); 2297 if (ed->ec == ELFCLASS32) 2298 PRT("%-8.8jd ", 2299 (intmax_t)got[i].u_r.rela.r_addend); 2300 else 2301 PRT("%-12.12jd ", --- 4 unchanged lines hidden (view full) --- 2306 } 2307 free(got); 2308 } else { 2309 for(i = 0; i < len; i++) { 2310 PRT("\nentry: %d\n", i); 2311 if (ed->ec == ELFCLASS32) 2312 PRT("\t%#x\n", *((uint32_t *)dst.d_buf + i)); 2313 else |
2201 PRT("\t%#jx\n", *((uint64_t *)dst.d_buf + i)); | 2314 PRT("\t%#jx\n", 2315 (uintmax_t) *((uint64_t *)dst.d_buf + i)); |
2202 } 2203 } 2204} 2205 2206/* 2207 * Dump the content of Global Offset Table section. 2208 */ 2209static void --- 649 unchanged lines hidden --- | 2316 } 2317 } 2318} 2319 2320/* 2321 * Dump the content of Global Offset Table section. 2322 */ 2323static void --- 649 unchanged lines hidden --- |