#include "elf_machine_type.h" #include #include #include char* ELF_MACHINE_TYPE_TEXT[] = { "No ISA Set", "\x00\x01""AT&T WE 32100", "\x00\x3E""Advanced Micro Devices x86_64" }; void GetELFMachineTypeText(ELFMachine type, char buffer[256]) { if (!buffer) return; memset(buffer, '\0', 256); if (type == 0) { strncpy(buffer, ELF_MACHINE_TYPE_TEXT[0], strlen(ELF_MACHINE_TYPE_TEXT[0])); return; } for(unsigned int i = 1; i < sizeof(ELF_MACHINE_TYPE_TEXT) / sizeof(char*); i++) { char* text = ELF_MACHINE_TYPE_TEXT[i]; if (type == (unsigned int) text[0] + text[1]) { strncpy(buffer, &text[2], strlen(&text[2])); return; } } }