#include "ft_nm.h" char *get_section_type(int type) { switch (type) { case SHT_NULL: return "NULL"; case SHT_PROGBITS: return "PROGBITS"; case SHT_SYMTAB: return "SYMTAB"; case SHT_STRTAB: return "STRTAB"; case SHT_RELA: return "RELA"; case SHT_HASH: return "HASH"; case SHT_DYNAMIC: return "DYNAMIC"; case SHT_NOTE: return "NOTE"; case SHT_NOBITS: return "NOBITS"; case SHT_REL: return "REL"; case SHT_SHLIB: return "SHLIB"; case SHT_DYNSYM: return "DYNSYM"; case SHT_INIT_ARRAY: return "INIT_ARRAY"; case SHT_FINI_ARRAY: return "FINI_ARRAY"; default: return "UNKNOWN"; } } char *get_section_flags(int flags) { char *str = malloc(4); int i = 0; if (flags & SHF_WRITE) str[i++] = 'W'; if (flags & SHF_ALLOC) str[i++] = 'A'; if (flags & SHF_EXECINSTR) str[i++] = 'X'; str[i] = '\0'; return (str); } char *get_sym_type(int type) { switch (type) { case STT_NOTYPE: return "NOTYPE"; case STT_OBJECT: return "OBJECT"; case STT_FUNC: return "FUNC"; case STT_SECTION: return "SECTION"; case STT_FILE: return "FILE"; case STT_COMMON: return "COMMON"; case STT_TLS: return "TLS"; default: return "UNKNOWN"; } } char *get_sym_bind(int bind) { switch (bind) { case STB_LOCAL: return "LOCAL"; case STB_GLOBAL: return "GLOBAL"; case STB_WEAK: return "WEAK"; case STB_GNU_UNIQUE: return "UNIQUE"; default: return "UNKNOWN"; } } char *get_sym_vis(int vis) { switch (vis) { case STV_DEFAULT: return "DEFAULT"; case STV_INTERNAL: return "INTERNAL"; case STV_HIDDEN: return "HIDDEN"; case STV_PROTECTED: return "PROTECTED"; default: return "UNKNOWN"; } } char *get_sym_shndx(int shndx) { switch (shndx) { case SHN_UNDEF: return "UND"; case SHN_ABS: return "ABS"; case SHN_COMMON: return "COM"; case SHN_XINDEX: return "XID"; case SHN_LOPROC: return "LOP"; case SHN_HIPROC: return "HIP"; case SHN_LOOS: return "LOOS"; case SHN_HIOS: return "HIOS"; case SHN_MIPS_TEXT: return "MIPS_T"; case SHN_MIPS_DATA: return "MIPS_D"; case SHN_MIPS_SCOMMON: return "SCOM"; case SHN_MIPS_SUNDEFINED: return "SUND"; default: return "SEC"; } } char *get_sh_type(int type) { switch (type) { case SHT_NULL: return "NULL"; case SHT_PROGBITS: return "PROGBITS"; case SHT_SYMTAB: return "SYMTAB"; case SHT_STRTAB: return "STRTAB"; case SHT_RELA: return "RELA"; case SHT_HASH: return "HASH"; case SHT_DYNAMIC: return "DYNAMIC"; case SHT_NOTE: return "NOTE"; case SHT_NOBITS: return "NOBITS"; case SHT_REL: return "REL"; case SHT_SHLIB: return "SHLIB"; case SHT_DYNSYM: return "DYNSYM"; case SHT_INIT_ARRAY: return "INIT_ARRAY"; case SHT_FINI_ARRAY: return "FINI_ARRAY"; case SHT_PREINIT_ARRAY: return "PREINIT_ARRAY"; case SHT_GROUP: return "GROUP"; case SHT_SYMTAB_SHNDX: return "SYMTAB_SHNDX"; case SHT_NUM: return "NUM"; case SHT_LOOS: return "LOOS"; case SHT_GNU_ATTRIBUTES: return "GNU_ATTRIBUTES"; case SHT_GNU_HASH: return "GNU_HASH"; case SHT_GNU_LIBLIST: return "GNU_LIBLIST"; case SHT_CHECKSUM: return "CHECKSUM"; case SHT_LOSUNW: return "LOSUNW"; case SHT_SUNW_COMDAT: return "SUNW_COMDAT"; case SHT_SUNW_syminfo: return "SUNW_syminfo"; case SHT_GNU_verdef: return "GNU_verdef"; case SHT_GNU_verneed: return "GNU_verneed"; case SHT_GNU_versym: return "GNU_versym"; case SHT_LOPROC: return "LOPROC"; case SHT_HIPROC: return "HIPROC"; case SHT_LOUSER: return "LOUSER"; case SHT_HIUSER: return "HIUSER"; default: return "UNKNOWN"; } } char *get_sh_flag(int flag) { switch (flag) { case SHF_WRITE: return "W"; case SHF_ALLOC: return "A"; case SHF_EXECINSTR: return "X"; case SHF_MERGE: return "M"; case SHF_STRINGS: return "S"; case SHF_INFO_LINK: return "I"; case SHF_LINK_ORDER: return "L"; case SHF_OS_NONCONFORMING: return "O"; case SHF_GROUP: return "G"; case SHF_TLS: return "T"; case SHF_COMPRESSED: return "C"; case SHF_MASKOS: return "o"; case SHF_MASKPROC: return "p"; case SHF_ORDERED: return "r"; case SHF_EXCLUDE: return "e"; default: return "UNKNOWN"; } }