From 758448675f7ac4357d1935204c9b14b8af53226c Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Thu, 21 May 2020 11:18:08 -0400 Subject: [PATCH 1/2] Fix #32, Apply standard code style --- ELF_Structures.h | 717 +++++++++++++------------- SampleTblImg.c | 14 +- elf2cfetbl.c | 1254 +++++++++++++++++++++++++--------------------- 3 files changed, 1056 insertions(+), 929 deletions(-) diff --git a/ELF_Structures.h b/ELF_Structures.h index 3d7966f..a1d05f8 100644 --- a/ELF_Structures.h +++ b/ELF_Structures.h @@ -21,274 +21,276 @@ */ #include -typedef uint32_t Elf32_Addr; -typedef uint16_t Elf32_Half; -typedef uint32_t Elf32_Off; -typedef int32_t Elf32_Sword; -typedef uint32_t Elf32_Word; - -typedef uint64_t Elf64_Addr; -typedef uint64_t Elf64_Off; -typedef uint16_t Elf64_Half; -typedef uint32_t Elf64_Word; -typedef int32_t Elf64_Sword; -typedef uint64_t Elf64_Xword; -typedef int64_t Elf64_Sxword; +typedef uint32_t Elf32_Addr; +typedef uint16_t Elf32_Half; +typedef uint32_t Elf32_Off; +typedef int32_t Elf32_Sword; +typedef uint32_t Elf32_Word; + +typedef uint64_t Elf64_Addr; +typedef uint64_t Elf64_Off; +typedef uint16_t Elf64_Half; +typedef uint32_t Elf64_Word; +typedef int32_t Elf64_Sword; +typedef uint64_t Elf64_Xword; +typedef int64_t Elf64_Sxword; #define EI_NIDENT 16 /**< \brief Size of e_ident[] */ /** -* Elf 32 bit Header Format -*/ -typedef struct { - unsigned char e_ident [EI_NIDENT] ; /**< \brief Machine independent data to allow decoding of file */ - Elf32_Half e_type; /**< \brief Identifies object file type */ - Elf32_Half e_machine; /**< \brief Specifies required architecture for file */ - Elf32_Word e_version; /**< \brief Object file version */ - Elf32_Addr e_entry; /**< \brief Virtual start address for process */ - Elf32_Off e_phoff; /**< \brief File offset to beginning of Program Header Table */ - Elf32_Off e_shoff; /**< \brief File offset to beginning of Section Header Table */ - Elf32_Word e_flags; /**< \brief Processor specific flags */ - Elf32_Half e_ehsize; /**< \brief ELF Header's size, in bytes */ - Elf32_Half e_phentsize; /**< \brief Size, in bytes, of each Program Header Table Entry */ - Elf32_Half e_phnum; /**< \brief Number of entries the Program Header Table contains */ - Elf32_Half e_shentsize; /**< \brief Size, in bytes, of each Section Header Table Entry */ - Elf32_Half e_shnum; /**< \brief Number of entries the Section Header Table contains */ - Elf32_Half e_shstrndx; /**< \brief Section Header Table index for the Section Name String Table */ + * Elf 32 bit Header Format + */ +typedef struct +{ + unsigned char e_ident[EI_NIDENT]; /**< \brief Machine independent data to allow decoding of file */ + Elf32_Half e_type; /**< \brief Identifies object file type */ + Elf32_Half e_machine; /**< \brief Specifies required architecture for file */ + Elf32_Word e_version; /**< \brief Object file version */ + Elf32_Addr e_entry; /**< \brief Virtual start address for process */ + Elf32_Off e_phoff; /**< \brief File offset to beginning of Program Header Table */ + Elf32_Off e_shoff; /**< \brief File offset to beginning of Section Header Table */ + Elf32_Word e_flags; /**< \brief Processor specific flags */ + Elf32_Half e_ehsize; /**< \brief ELF Header's size, in bytes */ + Elf32_Half e_phentsize; /**< \brief Size, in bytes, of each Program Header Table Entry */ + Elf32_Half e_phnum; /**< \brief Number of entries the Program Header Table contains */ + Elf32_Half e_shentsize; /**< \brief Size, in bytes, of each Section Header Table Entry */ + Elf32_Half e_shnum; /**< \brief Number of entries the Section Header Table contains */ + Elf32_Half e_shstrndx; /**< \brief Section Header Table index for the Section Name String Table */ } Elf32_Ehdr; /** -* Elf 64 bit Header Format -*/ -typedef struct { - unsigned char e_ident[EI_NIDENT]; /**< \brief Machine independent data to allow decoding of file */ - Elf64_Half e_type; /**< \brief Identifies object file type */ - Elf64_Half e_machine; /**< \brief Specifies required architecture for file */ - Elf64_Word e_version; /**< \brief Object file version */ - Elf64_Addr e_entry; /**< \brief Virtual start address for process */ - Elf64_Off e_phoff; /**< \brief File offset to beginning of Program Header Table */ - Elf64_Off e_shoff; /**< \brief File offset to beginning of Section Header Table */ - Elf64_Word e_flags; /**< \brief Processor specific flags */ - Elf64_Half e_ehsize; /**< \brief ELF Header's size, in bytes */ - Elf64_Half e_phentsize; /**< \brief Size, in bytes, of each Program Header Table Entry */ - Elf64_Half e_phnum; /**< \brief Number of entries the Program Header Table contains */ - Elf64_Half e_shentsize; /**< \brief Size, in bytes, of each Section Header Table Entry */ - Elf64_Half e_shnum; /**< \brief Number of entries the Section Header Table contains */ - Elf64_Half e_shstrndx; /**< \brief Section Header Table index for the Section Name String Table */ + * Elf 64 bit Header Format + */ +typedef struct +{ + unsigned char e_ident[EI_NIDENT]; /**< \brief Machine independent data to allow decoding of file */ + Elf64_Half e_type; /**< \brief Identifies object file type */ + Elf64_Half e_machine; /**< \brief Specifies required architecture for file */ + Elf64_Word e_version; /**< \brief Object file version */ + Elf64_Addr e_entry; /**< \brief Virtual start address for process */ + Elf64_Off e_phoff; /**< \brief File offset to beginning of Program Header Table */ + Elf64_Off e_shoff; /**< \brief File offset to beginning of Section Header Table */ + Elf64_Word e_flags; /**< \brief Processor specific flags */ + Elf64_Half e_ehsize; /**< \brief ELF Header's size, in bytes */ + Elf64_Half e_phentsize; /**< \brief Size, in bytes, of each Program Header Table Entry */ + Elf64_Half e_phnum; /**< \brief Number of entries the Program Header Table contains */ + Elf64_Half e_shentsize; /**< \brief Size, in bytes, of each Section Header Table Entry */ + Elf64_Half e_shnum; /**< \brief Number of entries the Section Header Table contains */ + Elf64_Half e_shstrndx; /**< \brief Section Header Table index for the Section Name String Table */ } Elf64_Ehdr; -union Elf_Ehdr { +union Elf_Ehdr +{ Elf32_Ehdr Ehdr32; Elf64_Ehdr Ehdr64; }; /** -* e_type values are as follows: -*/ + * e_type values are as follows: + */ -#define ET_NONE 0 /**< \brief No file type */ -#define ET_REL 1 /**< \brief Relocatable file */ -#define ET_EXEC 2 /**< \brief Executable file */ -#define ET_DYN 3 /**< \brief Shared object file */ -#define ET_CORE 4 /**< \brief Core file */ -#define ET_LOPROC 0xff00 /**< \brief Processor-specific */ -#define ET_HIPROC 0xffff /**< \brief Processor-specific */ +#define ET_NONE 0 /**< \brief No file type */ +#define ET_REL 1 /**< \brief Relocatable file */ +#define ET_EXEC 2 /**< \brief Executable file */ +#define ET_DYN 3 /**< \brief Shared object file */ +#define ET_CORE 4 /**< \brief Core file */ +#define ET_LOPROC 0xff00 /**< \brief Processor-specific */ +#define ET_HIPROC 0xffff /**< \brief Processor-specific */ /** -* e_machine values are as follows: -*/ -#define EM_NONE 0 /**< \brief No machine */ -#define EM_M32 1 /**< \brief AT&T WE 32100 */ -#define EM_SPARC 2 /**< \brief SPARC */ -#define EM_386 3 /**< \brief Intel 80386 */ -#define EM_68K 4 /**< \brief Motorola 68000 */ -#define EM_88K 5 /**< \brief Motorola 88000 */ -#define EM_860 7 /**< \brief Intel 80860 */ -#define EM_MIPS 8 /**< \brief MIPS RS3000 */ -#define EM_S370 9 /**< \brief IBM System/370 Processor */ -#define EM_MIPS_RS3_LE 10 /**< \brief MIPS RS3000 Little-endian */ -#define EM_PARISC 15 /**< \brief Hewlett-Packard PA-RISC */ -#define EM_VPP500 17 /**< \brief Fujitsu VPP500 */ -#define EM_SPARC32PLUS 18 /**< \brief Enhanced instruction set SPARC */ -#define EM_960 19 /**< \brief Intel 80960 */ -#define EM_PPC 20 /**< \brief PowerPC */ -#define EM_PPC64 21 /**< \brief 64-bit PowerPC */ -#define EM_S390 22 /**< \brief IBM System/390 Processor */ -#define EM_SPU 23 /**< \brief IBM SPU/SPC */ -#define EM_V800 36 /**< \brief NEC V800 */ -#define EM_FR20 37 /**< \brief Fujitsu FR20 */ -#define EM_RH32 38 /**< \brief TRW RH-32 */ -#define EM_RCE 39 /**< \brief Motorola RCE */ -#define EM_ARM 40 /**< \brief Advanced RISC Machines ARM */ -#define EM_ALPHA 41 /**< \brief Digital Alpha */ -#define EM_SH 42 /**< \brief Hitachi SH */ -#define EM_SPARCV9 43 /**< \brief SPARC Version 9 */ -#define EM_TRICORE 44 /**< \brief Siemens Tricore embedded processor */ -#define EM_ARC 45 /**< \brief Argonaut RISC Core, Argonaut Technologies Inc. */ -#define EM_H8_300 46 /**< \brief Hitachi H8/300 */ -#define EM_H8_300H 47 /**< \brief Hitachi H8/300H */ -#define EM_H8S 48 /**< \brief Hitachi H8S */ -#define EM_H8_500 49 /**< \brief Hitachi H8/500 */ -#define EM_IA_64 50 /**< \brief Intel IA-64 processor architecture */ -#define EM_MIPS_X 51 /**< \brief Stanford MIPS-X */ -#define EM_COLDFIRE 52 /**< \brief Motorola ColdFire */ -#define EM_68HC12 53 /**< \brief Motorola M68HC12 */ -#define EM_MMA 54 /**< \brief Fujitsu MMA Multimedia Accelerator */ -#define EM_PCP 55 /**< \brief Siemens PCP */ -#define EM_NCPU 56 /**< \brief Sony nCPU embedded RISC processor */ -#define EM_NDR1 57 /**< \brief Denso NDR1 microprocessor */ -#define EM_STARCORE 58 /**< \brief Motorola Star*Core processor */ -#define EM_ME16 59 /**< \brief Toyota ME16 processor */ -#define EM_ST100 60 /**< \brief STMicroelectronics ST100 processor */ -#define EM_TINYJ 61 /**< \brief Advanced Logic Corp. TinyJ embedded processor family */ -#define EM_X86_64 62 /**< \brief AMD x86-64 architecture */ -#define EM_PDSP 63 /**< \brief Sony DSP Processor */ -#define EM_PDP10 64 /**< \brief Digital Equipment Corp. PDP-10 */ -#define EM_PDP11 65 /**< \brief Digital Equipment Corp. PDP-11 */ -#define EM_FX66 66 /**< \brief Siemens FX66 microcontroller */ -#define EM_ST9PLUS 67 /**< \brief STMicroelectronics ST9+ 8/16 bit microcontroller */ -#define EM_ST7 68 /**< \brief STMicroelectronics ST7 8-bit microcontroller */ -#define EM_68HC16 69 /**< \brief Motorola MC68HC16 Microcontroller */ -#define EM_68HC11 70 /**< \brief Motorola MC68HC11 Microcontroller */ -#define EM_68HC08 71 /**< \brief Motorola MC68HC08 Microcontroller */ -#define EM_68HC05 72 /**< \brief Motorola MC68HC05 Microcontroller */ -#define EM_SVX 73 /**< \brief Silicon Graphics SVx */ -#define EM_ST19 74 /**< \brief STMicroelectronics ST19 8-bit microcontroller */ -#define EM_VAX 75 /**< \brief Digital VAX */ -#define EM_CRIS 76 /**< \brief Axis Communications 32-bit embedded processor */ -#define EM_JAVELIN 77 /**< \brief Infineon Technologies 32-bit embedded processor */ -#define EM_FIREPATH 78 /**< \brief Element 14 64-bit DSP Processor */ -#define EM_ZSP 79 /**< \brief LSI Logic 16-bit DSP Processor */ -#define EM_MMIX 80 /**< \brief Donald Knuth's educational 64-bit processor */ -#define EM_HUANY 81 /**< \brief Harvard University machine-independent object files */ -#define EM_PRISM 82 /**< \brief SiTera Prism */ -#define EM_AVR 83 /**< \brief Atmel AVR 8-bit microcontroller */ -#define EM_FR30 84 /**< \brief Fujitsu FR30 */ -#define EM_D10V 85 /**< \brief Mitsubishi D10V */ -#define EM_D30V 86 /**< \brief Mitsubishi D30V */ -#define EM_V850 87 /**< \brief NEC v850 */ -#define EM_M32R 88 /**< \brief Mitsubishi M32R */ -#define EM_MN10300 89 /**< \brief Matsushita MN10300 */ -#define EM_MN10200 90 /**< \brief Matsushita MN10200 */ -#define EM_PJ 91 /**< \brief picoJava */ -#define EM_OPENRISC 92 /**< \brief OpenRISC 32-bit embedded processor */ -#define EM_ARC_COMPACT 93 /**< \brief ARC International ARCompact processor (old spelling/synonym: EM_ARC_A5) */ -#define EM_XTENSA 94 /**< \brief Tensilica Xtensa Architecture */ -#define EM_VIDEOCORE 95 /**< \brief Alphamosaic VideoCore processor */ -#define EM_TMM_GPP 96 /**< \brief Thompson Multimedia General Purpose Processor */ -#define EM_NS32K 97 /**< \brief National Semiconductor 32000 series */ -#define EM_TPC 98 /**< \brief Tenor Network TPC processor */ -#define EM_SNP1K 99 /**< \brief Trebia SNP 1000 processor */ -#define EM_ST200 100 /**< \brief STMicroelectronics (www.st.com) ST200 microcontroller */ -#define EM_IP2K 101 /**< \brief Ubicom IP2xxx microcontroller family */ -#define EM_MAX 102 /**< \brief MAX Processor */ -#define EM_CR 103 /**< \brief National Semiconductor CompactRISC microprocessor */ -#define EM_F2MC16 104 /**< \brief Fujitsu F2MC16 */ -#define EM_MSP430 105 /**< \brief Texas Instruments embedded microcontroller msp430 */ -#define EM_BLACKFIN 106 /**< \brief Analog Devices Blackfin (DSP) processor */ -#define EM_SE_C33 107 /**< \brief S1C33 Family of Seiko Epson processors */ -#define EM_SEP 108 /**< \brief Sharp embedded microprocessor */ -#define EM_ARCA 109 /**< \brief Arca RISC Microprocessor */ -#define EM_UNICORE 110 /**< \brief Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University */ -#define EM_EXCESS 111 /**< \brief eXcess: 16/32/64-bit configurable embedded CPU */ -#define EM_DXP 112 /**< \brief Icera Semiconductor Inc. Deep Execution Processor */ -#define EM_ALTERA_NIOS2 113 /**< \brief Altera Nios II soft-core processor */ -#define EM_CRX 114 /**< \brief National Semiconductor CompactRISC CRX microprocessor */ -#define EM_XGATE 115 /**< \brief Motorola XGATE embedded processor */ -#define EM_C166 116 /**< \brief Infineon C16x/XC16x processor */ -#define EM_M16C 117 /**< \brief Renesas M16C series microprocessors */ -#define EM_DSPIC30F 118 /**< \brief Microchip Technology dsPIC30F Digital Signal Controller */ -#define EM_CE 119 /**< \brief Freescale Communication Engine RISC core */ -#define EM_M32C 120 /**< \brief Renesas M32C series microprocessors */ -#define EM_TSK3000 131 /**< \brief Altium TSK3000 core */ -#define EM_RS08 132 /**< \brief Freescale RS08 embedded processor */ -#define EM_SHARC 133 /**< \brief Analog Devices SHARC family of 32-bit DSP processors */ -#define EM_ECOG2 134 /**< \brief Cyan Technology eCOG2 microprocessor */ -#define EM_SCORE7 135 /**< \brief Sunplus S+core7 RISC processor */ -#define EM_DSP24 136 /**< \brief New Japan Radio (NJR) 24-bit DSP Processor */ -#define EM_VIDEOCORE3 137 /**< \brief Broadcom VideoCore III processor */ + * e_machine values are as follows: + */ +#define EM_NONE 0 /**< \brief No machine */ +#define EM_M32 1 /**< \brief AT&T WE 32100 */ +#define EM_SPARC 2 /**< \brief SPARC */ +#define EM_386 3 /**< \brief Intel 80386 */ +#define EM_68K 4 /**< \brief Motorola 68000 */ +#define EM_88K 5 /**< \brief Motorola 88000 */ +#define EM_860 7 /**< \brief Intel 80860 */ +#define EM_MIPS 8 /**< \brief MIPS RS3000 */ +#define EM_S370 9 /**< \brief IBM System/370 Processor */ +#define EM_MIPS_RS3_LE 10 /**< \brief MIPS RS3000 Little-endian */ +#define EM_PARISC 15 /**< \brief Hewlett-Packard PA-RISC */ +#define EM_VPP500 17 /**< \brief Fujitsu VPP500 */ +#define EM_SPARC32PLUS 18 /**< \brief Enhanced instruction set SPARC */ +#define EM_960 19 /**< \brief Intel 80960 */ +#define EM_PPC 20 /**< \brief PowerPC */ +#define EM_PPC64 21 /**< \brief 64-bit PowerPC */ +#define EM_S390 22 /**< \brief IBM System/390 Processor */ +#define EM_SPU 23 /**< \brief IBM SPU/SPC */ +#define EM_V800 36 /**< \brief NEC V800 */ +#define EM_FR20 37 /**< \brief Fujitsu FR20 */ +#define EM_RH32 38 /**< \brief TRW RH-32 */ +#define EM_RCE 39 /**< \brief Motorola RCE */ +#define EM_ARM 40 /**< \brief Advanced RISC Machines ARM */ +#define EM_ALPHA 41 /**< \brief Digital Alpha */ +#define EM_SH 42 /**< \brief Hitachi SH */ +#define EM_SPARCV9 43 /**< \brief SPARC Version 9 */ +#define EM_TRICORE 44 /**< \brief Siemens Tricore embedded processor */ +#define EM_ARC 45 /**< \brief Argonaut RISC Core, Argonaut Technologies Inc. */ +#define EM_H8_300 46 /**< \brief Hitachi H8/300 */ +#define EM_H8_300H 47 /**< \brief Hitachi H8/300H */ +#define EM_H8S 48 /**< \brief Hitachi H8S */ +#define EM_H8_500 49 /**< \brief Hitachi H8/500 */ +#define EM_IA_64 50 /**< \brief Intel IA-64 processor architecture */ +#define EM_MIPS_X 51 /**< \brief Stanford MIPS-X */ +#define EM_COLDFIRE 52 /**< \brief Motorola ColdFire */ +#define EM_68HC12 53 /**< \brief Motorola M68HC12 */ +#define EM_MMA 54 /**< \brief Fujitsu MMA Multimedia Accelerator */ +#define EM_PCP 55 /**< \brief Siemens PCP */ +#define EM_NCPU 56 /**< \brief Sony nCPU embedded RISC processor */ +#define EM_NDR1 57 /**< \brief Denso NDR1 microprocessor */ +#define EM_STARCORE 58 /**< \brief Motorola Star*Core processor */ +#define EM_ME16 59 /**< \brief Toyota ME16 processor */ +#define EM_ST100 60 /**< \brief STMicroelectronics ST100 processor */ +#define EM_TINYJ 61 /**< \brief Advanced Logic Corp. TinyJ embedded processor family */ +#define EM_X86_64 62 /**< \brief AMD x86-64 architecture */ +#define EM_PDSP 63 /**< \brief Sony DSP Processor */ +#define EM_PDP10 64 /**< \brief Digital Equipment Corp. PDP-10 */ +#define EM_PDP11 65 /**< \brief Digital Equipment Corp. PDP-11 */ +#define EM_FX66 66 /**< \brief Siemens FX66 microcontroller */ +#define EM_ST9PLUS 67 /**< \brief STMicroelectronics ST9+ 8/16 bit microcontroller */ +#define EM_ST7 68 /**< \brief STMicroelectronics ST7 8-bit microcontroller */ +#define EM_68HC16 69 /**< \brief Motorola MC68HC16 Microcontroller */ +#define EM_68HC11 70 /**< \brief Motorola MC68HC11 Microcontroller */ +#define EM_68HC08 71 /**< \brief Motorola MC68HC08 Microcontroller */ +#define EM_68HC05 72 /**< \brief Motorola MC68HC05 Microcontroller */ +#define EM_SVX 73 /**< \brief Silicon Graphics SVx */ +#define EM_ST19 74 /**< \brief STMicroelectronics ST19 8-bit microcontroller */ +#define EM_VAX 75 /**< \brief Digital VAX */ +#define EM_CRIS 76 /**< \brief Axis Communications 32-bit embedded processor */ +#define EM_JAVELIN 77 /**< \brief Infineon Technologies 32-bit embedded processor */ +#define EM_FIREPATH 78 /**< \brief Element 14 64-bit DSP Processor */ +#define EM_ZSP 79 /**< \brief LSI Logic 16-bit DSP Processor */ +#define EM_MMIX 80 /**< \brief Donald Knuth's educational 64-bit processor */ +#define EM_HUANY 81 /**< \brief Harvard University machine-independent object files */ +#define EM_PRISM 82 /**< \brief SiTera Prism */ +#define EM_AVR 83 /**< \brief Atmel AVR 8-bit microcontroller */ +#define EM_FR30 84 /**< \brief Fujitsu FR30 */ +#define EM_D10V 85 /**< \brief Mitsubishi D10V */ +#define EM_D30V 86 /**< \brief Mitsubishi D30V */ +#define EM_V850 87 /**< \brief NEC v850 */ +#define EM_M32R 88 /**< \brief Mitsubishi M32R */ +#define EM_MN10300 89 /**< \brief Matsushita MN10300 */ +#define EM_MN10200 90 /**< \brief Matsushita MN10200 */ +#define EM_PJ 91 /**< \brief picoJava */ +#define EM_OPENRISC 92 /**< \brief OpenRISC 32-bit embedded processor */ +#define EM_ARC_COMPACT 93 /**< \brief ARC International ARCompact processor (old spelling/synonym: EM_ARC_A5) */ +#define EM_XTENSA 94 /**< \brief Tensilica Xtensa Architecture */ +#define EM_VIDEOCORE 95 /**< \brief Alphamosaic VideoCore processor */ +#define EM_TMM_GPP 96 /**< \brief Thompson Multimedia General Purpose Processor */ +#define EM_NS32K 97 /**< \brief National Semiconductor 32000 series */ +#define EM_TPC 98 /**< \brief Tenor Network TPC processor */ +#define EM_SNP1K 99 /**< \brief Trebia SNP 1000 processor */ +#define EM_ST200 100 /**< \brief STMicroelectronics (www.st.com) ST200 microcontroller */ +#define EM_IP2K 101 /**< \brief Ubicom IP2xxx microcontroller family */ +#define EM_MAX 102 /**< \brief MAX Processor */ +#define EM_CR 103 /**< \brief National Semiconductor CompactRISC microprocessor */ +#define EM_F2MC16 104 /**< \brief Fujitsu F2MC16 */ +#define EM_MSP430 105 /**< \brief Texas Instruments embedded microcontroller msp430 */ +#define EM_BLACKFIN 106 /**< \brief Analog Devices Blackfin (DSP) processor */ +#define EM_SE_C33 107 /**< \brief S1C33 Family of Seiko Epson processors */ +#define EM_SEP 108 /**< \brief Sharp embedded microprocessor */ +#define EM_ARCA 109 /**< \brief Arca RISC Microprocessor */ +#define EM_UNICORE 110 /**< \brief Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University */ +#define EM_EXCESS 111 /**< \brief eXcess: 16/32/64-bit configurable embedded CPU */ +#define EM_DXP 112 /**< \brief Icera Semiconductor Inc. Deep Execution Processor */ +#define EM_ALTERA_NIOS2 113 /**< \brief Altera Nios II soft-core processor */ +#define EM_CRX 114 /**< \brief National Semiconductor CompactRISC CRX microprocessor */ +#define EM_XGATE 115 /**< \brief Motorola XGATE embedded processor */ +#define EM_C166 116 /**< \brief Infineon C16x/XC16x processor */ +#define EM_M16C 117 /**< \brief Renesas M16C series microprocessors */ +#define EM_DSPIC30F 118 /**< \brief Microchip Technology dsPIC30F Digital Signal Controller */ +#define EM_CE 119 /**< \brief Freescale Communication Engine RISC core */ +#define EM_M32C 120 /**< \brief Renesas M32C series microprocessors */ +#define EM_TSK3000 131 /**< \brief Altium TSK3000 core */ +#define EM_RS08 132 /**< \brief Freescale RS08 embedded processor */ +#define EM_SHARC 133 /**< \brief Analog Devices SHARC family of 32-bit DSP processors */ +#define EM_ECOG2 134 /**< \brief Cyan Technology eCOG2 microprocessor */ +#define EM_SCORE7 135 /**< \brief Sunplus S+core7 RISC processor */ +#define EM_DSP24 136 /**< \brief New Japan Radio (NJR) 24-bit DSP Processor */ +#define EM_VIDEOCORE3 137 /**< \brief Broadcom VideoCore III processor */ #define EM_LATTICEMICO32 138 /**< \brief RISC processor for Lattice FPGA architecture */ -#define EM_SE_C17 139 /**< \brief Seiko Epson C17 family */ -#define EM_TI_C6000 140 /**< \brief The Texas Instruments TMS320C6000 DSP family */ -#define EM_TI_C2000 141 /**< \brief The Texas Instruments TMS320C2000 DSP family */ -#define EM_TI_C5500 142 /**< \brief The Texas Instruments TMS320C55x DSP family */ -#define EM_TI_ARP32 143 /**< \brief Texas Instruments Application Specific RISC Processor, 32bit fetch */ -#define EM_TI_PRU 144 /**< \brief Texas Instruments Programmable Realtime Unit */ -#define EM_MMDSP_PLUS 160 /**< \brief EM_MMDSP_PLUS 160 STMicroelectronics 64bit VLIW Data Signal Processor */ -#define EM_CYPRESS_M8C 161 /**< \brief Cypress M8C microprocessor */ -#define EM_R32C 162 /**< \brief Renesas R32C series microprocessors */ -#define EM_TRIMEDIA 163 /**< \brief NXP Semiconductors TriMedia architecture family */ -#define EM_QDSP6 164 /**< \brief QUALCOMM DSP6 Processor */ -#define EM_8051 165 /**< \brief Intel 8051 and variants */ -#define EM_STXP7X 166 /**< \brief STMicroelectronics STxP7x family of configurable and extensible RISC processors */ -#define EM_NDS32 167 /**< \brief Andes Technology compact code size embedded RISC processor family */ -#define EM_ECOG1 168 /**< \brief Cyan Technology eCOG1X family */ -#define EM_ECOG1X 168 /**< \brief Cyan Technology eCOG1X family */ -#define EM_MAXQ30 169 /**< \brief Dallas Semiconductor MAXQ30 Core Micro-controllers */ -#define EM_XIMO16 170 /**< \brief New Japan Radio (NJR) 16-bit DSP Processor */ -#define EM_MANIK 171 /**< \brief M2000 Reconfigurable RISC Microprocessor */ -#define EM_RX 173 /**< \brief Renesas RX family */ -#define EM_METAG 174 /**< \brief Imagination Technologies META processor architecture */ -#define EM_MCST_ELBRUS 175 /**< \brief MCST Elbrus general purpose hardware architecture */ -#define EM_ECOG16 176 /**< \brief Cyan Technology eCOG16 family */ -#define EM_CR16 177 /**< \brief National Semiconductor CompactRISC CR16 16-bit microprocessor */ -#define EM_ETPU 178 /**< \brief Freescale Extended Time Processing Unit */ -#define EM_SLE9X 179 /**< \brief Infineon Technologies SLE9X core */ -#define EM_L10M 180 /**< \brief Intel L10M */ -#define EM_K10M 181 /**< \brief Intel K10M */ -#define EM_AARCH64 183 /**< \brief ARM 64-bit architecture (AARCH64) */ -#define EM_AVR32 185 /**< \brief Atmel Corporation 32-bit microprocessor family */ -#define EM_STM8 186 /**< \brief STMicroeletronics STM8 8-bit microcontroller */ -#define EM_TILE64 187 /**< \brief Tilera TILE64 multicore architecture family */ -#define EM_TILEPRO 188 /**< \brief Tilera TILEPro multicore architecture family */ -#define EM_MICROBLAZE 189 /**< \brief Xilinx MicroBlaze 32-bit RISC soft processor core */ -#define EM_CUDA 190 /**< \brief NVIDIA CUDA architecture */ -#define EM_TILEGX 191 /**< \brief Tilera TILE-Gx multicore architecture family */ -#define EM_CLOUDSHIELD 192 /**< \brief CloudShield architecture family */ -#define EM_COREA_1ST 193 /**< \brief KIPO-KAIST Core-A 1st generation processor family */ -#define EM_COREA_2ND 194 /**< \brief KIPO-KAIST Core-A 2nd generation processor family */ -#define EM_ARC_COMPACT2 195 /**< \brief Synopsis ARCompact V2 */ -#define EM_OPEN8 196 /**< \brief Open8 8-bit RISC soft processor core */ -#define EM_RL78 197 /**< \brief Renesas RL78 family */ -#define EM_VIDEOCORE5 198 /**< \brief Broadcom VideoCore V processor */ -#define EM_78KOR 199 /**< \brief Renesas 78KOR family */ -#define EM_56800EX 200 /**< \brief Freescale 56800EX Digital Signal Controller (DSC) */ -#define EM_BA1 201 /**< \brief Beyond BA1 CPU architecture */ -#define EM_BA2 202 /**< \brief Beyond BA2 CPU architecture */ -#define EM_XCORE 203 /**< \brief XMOS xCORE processor family */ -#define EM_MCHP_PIC 204 /**< \brief Microchip 8-bit PIC(r) family */ -#define EM_INTEL205 205 /**< \brief Reserved by Intel */ -#define EM_INTEL206 206 /**< \brief Reserved by Intel */ -#define EM_INTEL207 207 /**< \brief Reserved by Intel */ -#define EM_INTEL208 208 /**< \brief Reserved by Intel */ -#define EM_INTEL209 209 /**< \brief Reserved by Intel */ -#define EM_KM32 210 /**< \brief KM211 KM32 32-bit processor */ -#define EM_KMX32 211 /**< \brief KM211 KMX32 32-bit processor */ -#define EM_KMX16 212 /**< \brief KM211 KMX16 16-bit processor */ -#define EM_KMX8 213 /**< \brief KM211 KMX8 8-bit processor */ -#define EM_KVARC 214 /**< \brief KM211 KVARC processor */ -#define EM_CDP 215 /**< \brief Paneve CDP architecture family */ -#define EM_COGE 216 /**< \brief Cognitive Smart Memory Processor */ -#define EM_COOL 217 /**< \brief Bluechip Systems CoolEngine */ -#define EM_NORC 218 /**< \brief Nanoradio Optimized RISC */ -#define EM_CSR_KALIMBA 219 /**< \brief CSR Kalimba architecture family */ -#define EM_Z80 220 /**< \brief Zilog Z80 */ -#define EM_VISIUM 221 /**< \brief Controls and Data Services VISIUMcore processor */ -#define EM_FT32 222 /**< \brief FTDI Chip FT32 high performance 32-bit RISC architecture */ -#define EM_MOXIE 223 /**< \brief Moxie processor family */ -#define EM_AMDGPU 224 /**< \brief AMD GPU architecture */ -#define EM_RISCV 243 /**< \brief RISC-VEM_FR30 84 Fujitsu FR30 */ - +#define EM_SE_C17 139 /**< \brief Seiko Epson C17 family */ +#define EM_TI_C6000 140 /**< \brief The Texas Instruments TMS320C6000 DSP family */ +#define EM_TI_C2000 141 /**< \brief The Texas Instruments TMS320C2000 DSP family */ +#define EM_TI_C5500 142 /**< \brief The Texas Instruments TMS320C55x DSP family */ +#define EM_TI_ARP32 143 /**< \brief Texas Instruments Application Specific RISC Processor, 32bit fetch */ +#define EM_TI_PRU 144 /**< \brief Texas Instruments Programmable Realtime Unit */ +#define EM_MMDSP_PLUS 160 /**< \brief EM_MMDSP_PLUS 160 STMicroelectronics 64bit VLIW Data Signal Processor */ +#define EM_CYPRESS_M8C 161 /**< \brief Cypress M8C microprocessor */ +#define EM_R32C 162 /**< \brief Renesas R32C series microprocessors */ +#define EM_TRIMEDIA 163 /**< \brief NXP Semiconductors TriMedia architecture family */ +#define EM_QDSP6 164 /**< \brief QUALCOMM DSP6 Processor */ +#define EM_8051 165 /**< \brief Intel 8051 and variants */ +#define EM_STXP7X 166 /**< \brief STMicroelectronics STxP7x family of configurable and extensible RISC processors */ +#define EM_NDS32 167 /**< \brief Andes Technology compact code size embedded RISC processor family */ +#define EM_ECOG1 168 /**< \brief Cyan Technology eCOG1X family */ +#define EM_ECOG1X 168 /**< \brief Cyan Technology eCOG1X family */ +#define EM_MAXQ30 169 /**< \brief Dallas Semiconductor MAXQ30 Core Micro-controllers */ +#define EM_XIMO16 170 /**< \brief New Japan Radio (NJR) 16-bit DSP Processor */ +#define EM_MANIK 171 /**< \brief M2000 Reconfigurable RISC Microprocessor */ +#define EM_RX 173 /**< \brief Renesas RX family */ +#define EM_METAG 174 /**< \brief Imagination Technologies META processor architecture */ +#define EM_MCST_ELBRUS 175 /**< \brief MCST Elbrus general purpose hardware architecture */ +#define EM_ECOG16 176 /**< \brief Cyan Technology eCOG16 family */ +#define EM_CR16 177 /**< \brief National Semiconductor CompactRISC CR16 16-bit microprocessor */ +#define EM_ETPU 178 /**< \brief Freescale Extended Time Processing Unit */ +#define EM_SLE9X 179 /**< \brief Infineon Technologies SLE9X core */ +#define EM_L10M 180 /**< \brief Intel L10M */ +#define EM_K10M 181 /**< \brief Intel K10M */ +#define EM_AARCH64 183 /**< \brief ARM 64-bit architecture (AARCH64) */ +#define EM_AVR32 185 /**< \brief Atmel Corporation 32-bit microprocessor family */ +#define EM_STM8 186 /**< \brief STMicroeletronics STM8 8-bit microcontroller */ +#define EM_TILE64 187 /**< \brief Tilera TILE64 multicore architecture family */ +#define EM_TILEPRO 188 /**< \brief Tilera TILEPro multicore architecture family */ +#define EM_MICROBLAZE 189 /**< \brief Xilinx MicroBlaze 32-bit RISC soft processor core */ +#define EM_CUDA 190 /**< \brief NVIDIA CUDA architecture */ +#define EM_TILEGX 191 /**< \brief Tilera TILE-Gx multicore architecture family */ +#define EM_CLOUDSHIELD 192 /**< \brief CloudShield architecture family */ +#define EM_COREA_1ST 193 /**< \brief KIPO-KAIST Core-A 1st generation processor family */ +#define EM_COREA_2ND 194 /**< \brief KIPO-KAIST Core-A 2nd generation processor family */ +#define EM_ARC_COMPACT2 195 /**< \brief Synopsis ARCompact V2 */ +#define EM_OPEN8 196 /**< \brief Open8 8-bit RISC soft processor core */ +#define EM_RL78 197 /**< \brief Renesas RL78 family */ +#define EM_VIDEOCORE5 198 /**< \brief Broadcom VideoCore V processor */ +#define EM_78KOR 199 /**< \brief Renesas 78KOR family */ +#define EM_56800EX 200 /**< \brief Freescale 56800EX Digital Signal Controller (DSC) */ +#define EM_BA1 201 /**< \brief Beyond BA1 CPU architecture */ +#define EM_BA2 202 /**< \brief Beyond BA2 CPU architecture */ +#define EM_XCORE 203 /**< \brief XMOS xCORE processor family */ +#define EM_MCHP_PIC 204 /**< \brief Microchip 8-bit PIC(r) family */ +#define EM_INTEL205 205 /**< \brief Reserved by Intel */ +#define EM_INTEL206 206 /**< \brief Reserved by Intel */ +#define EM_INTEL207 207 /**< \brief Reserved by Intel */ +#define EM_INTEL208 208 /**< \brief Reserved by Intel */ +#define EM_INTEL209 209 /**< \brief Reserved by Intel */ +#define EM_KM32 210 /**< \brief KM211 KM32 32-bit processor */ +#define EM_KMX32 211 /**< \brief KM211 KMX32 32-bit processor */ +#define EM_KMX16 212 /**< \brief KM211 KMX16 16-bit processor */ +#define EM_KMX8 213 /**< \brief KM211 KMX8 8-bit processor */ +#define EM_KVARC 214 /**< \brief KM211 KVARC processor */ +#define EM_CDP 215 /**< \brief Paneve CDP architecture family */ +#define EM_COGE 216 /**< \brief Cognitive Smart Memory Processor */ +#define EM_COOL 217 /**< \brief Bluechip Systems CoolEngine */ +#define EM_NORC 218 /**< \brief Nanoradio Optimized RISC */ +#define EM_CSR_KALIMBA 219 /**< \brief CSR Kalimba architecture family */ +#define EM_Z80 220 /**< \brief Zilog Z80 */ +#define EM_VISIUM 221 /**< \brief Controls and Data Services VISIUMcore processor */ +#define EM_FT32 222 /**< \brief FTDI Chip FT32 high performance 32-bit RISC architecture */ +#define EM_MOXIE 223 /**< \brief Moxie processor family */ +#define EM_AMDGPU 224 /**< \brief AMD GPU architecture */ +#define EM_RISCV 243 /**< \brief RISC-VEM_FR30 84 Fujitsu FR30 */ /** -* e_version values are as follows: -*/ + * e_version values are as follows: + */ #define EV_NONE 0 /**< \brief version */ #define EV_CURRENT 1 /**< \brief Current version */ /** -* e_ident[] index values are as follows: -*/ + * e_ident[] index values are as follows: + */ #define EI_MAG0 0 /**< \brief File identification */ #define EI_MAG1 1 /**< \brief File identification */ #define EI_MAG2 2 /**< \brief File identification */ @@ -299,73 +301,71 @@ union Elf_Ehdr { #define EI_PAD 7 /**< \brief Start of padding bytes */ /** -* e_ident[ELFMAG0...ELFMAG3] values are as follows: -*/ + * e_ident[ELFMAG0...ELFMAG3] values are as follows: + */ #define ELFMAG0 0x7f /**< \brief e_ident[EI_MAG0] */ #define ELFMAG1 'E' /**< \brief e_ident[EI_MAG1] */ #define ELFMAG2 'L' /**< \brief e_ident[EI_MAG2] */ #define ELFMAG3 'F' /**< \brief e_ident[EI_MAG3] */ /** -* e_ident[EI_CLASS] values are as follows: -*/ + * e_ident[EI_CLASS] values are as follows: + */ #define ELFCLASSNONE 0 /**< \brief Invalid class */ #define ELFCLASS32 1 /**< \brief 32-bit objects */ #define ELFCLASS64 2 /**< \brief 64-bit objects */ /** -* e_ident[EI_DATA] values are as follows: -*/ + * e_ident[EI_DATA] values are as follows: + */ #define ELFDATANONE 0 /**< \brief Invalid data encoding */ #define ELFDATA2LSB 1 /**< \brief Little-Endian storage */ #define ELFDATA2MSB 2 /**< \brief Big-Endian storage */ /** -* Special Section Indexes: -*/ - -#define SHN_UNDEF 0 /**< \brief Marks an undefined, missing, irrelevant, or otherwise meaningless section */ -#define SHN_LORESERVE 0xff00 /**< \brief Specifies the lower bound of the range of reserved indexes */ -#define SHN_LOPROC 0xff00 /**< \brief Values >= than this are reserved for processor-specific semantics */ -#define SHN_HIPROC 0xff1f /**< \brief Values <= than this are reserved for processor-specific semantics */ -#define SHN_ABS 0xfff1 /**< \brief Specifies absolute values for the corresponding reference */ -#define SHN_COMMON 0xfff2 /**< \brief Symbols defined relative to this section are common symbols */ -#define SHN_HIRESERVE 0xffff /**< \brief Specifies the upper bound of the range of reserved indexes */ - + * Special Section Indexes: + */ +#define SHN_UNDEF 0 /**< \brief Marks an undefined, missing, irrelevant, or otherwise meaningless section */ +#define SHN_LORESERVE 0xff00 /**< \brief Specifies the lower bound of the range of reserved indexes */ +#define SHN_LOPROC 0xff00 /**< \brief Values >= than this are reserved for processor-specific semantics */ +#define SHN_HIPROC 0xff1f /**< \brief Values <= than this are reserved for processor-specific semantics */ +#define SHN_ABS 0xfff1 /**< \brief Specifies absolute values for the corresponding reference */ +#define SHN_COMMON 0xfff2 /**< \brief Symbols defined relative to this section are common symbols */ +#define SHN_HIRESERVE 0xffff /**< \brief Specifies the upper bound of the range of reserved indexes */ /** -* 32 bit Section Header Format -*/ + * 32 bit Section Header Format + */ typedef struct { - Elf32_Word sh_name; /**< \brief Index into Section Header String Table giving location of section name */ - Elf32_Word sh_type; /**< \brief Section type */ - Elf32_Word sh_flags; /**< \brief Section attributes */ - Elf32_Addr sh_addr; /**< \brief Address at which first byte of section should reside */ - Elf32_Off sh_offset; /**< \brief File offset to first byte of Section */ - Elf32_Word sh_size; /**< \brief Section size, in bytes */ - Elf32_Word sh_link; /**< \brief Section Header Table index link (interpretation depends upon Section Type) */ - Elf32_Word sh_info; /**< \brief Extra information (interpretation depends upon Section Type) */ - Elf32_Word sh_addralign; /**< \brief Section memory address alignment constraints */ - Elf32_Word sh_entsize; /**< \brief Size of an entry for a Section containing a table of fixed size entries */ + Elf32_Word sh_name; /**< \brief Index into Section Header String Table giving location of section name */ + Elf32_Word sh_type; /**< \brief Section type */ + Elf32_Word sh_flags; /**< \brief Section attributes */ + Elf32_Addr sh_addr; /**< \brief Address at which first byte of section should reside */ + Elf32_Off sh_offset; /**< \brief File offset to first byte of Section */ + Elf32_Word sh_size; /**< \brief Section size, in bytes */ + Elf32_Word sh_link; /**< \brief Section Header Table index link (interpretation depends upon Section Type) */ + Elf32_Word sh_info; /**< \brief Extra information (interpretation depends upon Section Type) */ + Elf32_Word sh_addralign; /**< \brief Section memory address alignment constraints */ + Elf32_Word sh_entsize; /**< \brief Size of an entry for a Section containing a table of fixed size entries */ } Elf32_Shdr; /** -* 64 bit Section Header Format -*/ + * 64 bit Section Header Format + */ typedef struct { - Elf64_Word sh_name; /**< \brief Index into Section Header String Table giving location of section name */ - Elf64_Word sh_type; /**< \brief Section type */ - Elf64_Xword sh_flags; /**< \brief Section attributes */ - Elf64_Addr sh_addr; /**< \brief Address at which first byte of section should reside */ - Elf64_Off sh_offset; /**< \brief File offset to first byte of Section */ - Elf64_Xword sh_size; /**< \brief Section size, in bytes */ - Elf64_Word sh_link; /**< \brief Section Header Table index link (interpretation depends upon Section Type) */ - Elf64_Word sh_info; /**< \brief Extra information (interpretation depends upon Section Type) */ - Elf64_Xword sh_addralign; /**< \brief Section memory address alignment constraints */ - Elf64_Xword sh_entsize; /**< \brief Size of an entry for a Section containing a table of fixed size entries */ + Elf64_Word sh_name; /**< \brief Index into Section Header String Table giving location of section name */ + Elf64_Word sh_type; /**< \brief Section type */ + Elf64_Xword sh_flags; /**< \brief Section attributes */ + Elf64_Addr sh_addr; /**< \brief Address at which first byte of section should reside */ + Elf64_Off sh_offset; /**< \brief File offset to first byte of Section */ + Elf64_Xword sh_size; /**< \brief Section size, in bytes */ + Elf64_Word sh_link; /**< \brief Section Header Table index link (interpretation depends upon Section Type) */ + Elf64_Word sh_info; /**< \brief Extra information (interpretation depends upon Section Type) */ + Elf64_Xword sh_addralign; /**< \brief Section memory address alignment constraints */ + Elf64_Xword sh_entsize; /**< \brief Size of an entry for a Section containing a table of fixed size entries */ } Elf64_Shdr; union Elf_Shdr @@ -375,70 +375,70 @@ union Elf_Shdr }; /** -* sh_type values are as follows: -*/ -#define SHT_NULL 0 /**< \brief Marks Section Header as inactive */ -#define SHT_PROGBITS 1 /**< \brief Section contains information defined by program */ -#define SHT_SYMTAB 2 /**< \brief Section contains symbols for link editing */ -#define SHT_STRTAB 3 /**< \brief Section contains a string table */ -#define SHT_RELA 4 /**< \brief Section contains relocation entries with explicit addends */ -#define SHT_HASH 5 /**< \brief Section contains a symbol hash table */ -#define SHT_DYNAMIC 6 /**< \brief Section contains information for dynamic linking */ -#define SHT_NOTE 7 /**< \brief Section contains information for marking the file */ -#define SHT_NOBITS 8 /**< \brief Section occupies no file space but otherwise resembles #SHT_PROGBITS */ -#define SHT_REL 9 /**< \brief Section contains relocation entries without explicit addends */ -#define SHT_SHLIB 10 /**< \brief Reserved Section type */ -#define SHT_DYNSYM 11 /**< \brief Section contains minimal set of dynamic linking symbols */ -#define SHT_INIT_ARRAY 14 /**< \brief Array of pointers to initialization functions */ -#define SHT_FINI_ARRAY 15 /**< \brief Array of pointers to termination functions */ -#define SHT_PREINIT_ARRAY 16 /**< \brief Array of pointers to functions invoked prior to all initialization functions */ -#define SHT_GROUP 17 /**< \brief A set of sections that are related and must be treated specially by the linker */ -#define SHT_SYMTAB_SHNDX 18 /**< \brief An array of values corresponding (one-to-one) with symbol table entries */ - -#define SHT_LOPROC 0x70000000 /**< \brief Values >= are reserved for Processor specific semantics */ -#define SHT_HIPROC 0x7fffffff /**< \brief Values <= are reserved for Processor specific semantics */ -#define SHT_LOUSER 0x80000000 /**< \brief Values >= are reserved for application programs */ -#define SHT_HIUSER 0xffffffff /**< \brief Values <= are reserved for application programs */ + * sh_type values are as follows: + */ +#define SHT_NULL 0 /**< \brief Marks Section Header as inactive */ +#define SHT_PROGBITS 1 /**< \brief Section contains information defined by program */ +#define SHT_SYMTAB 2 /**< \brief Section contains symbols for link editing */ +#define SHT_STRTAB 3 /**< \brief Section contains a string table */ +#define SHT_RELA 4 /**< \brief Section contains relocation entries with explicit addends */ +#define SHT_HASH 5 /**< \brief Section contains a symbol hash table */ +#define SHT_DYNAMIC 6 /**< \brief Section contains information for dynamic linking */ +#define SHT_NOTE 7 /**< \brief Section contains information for marking the file */ +#define SHT_NOBITS 8 /**< \brief Section occupies no file space but otherwise resembles #SHT_PROGBITS */ +#define SHT_REL 9 /**< \brief Section contains relocation entries without explicit addends */ +#define SHT_SHLIB 10 /**< \brief Reserved Section type */ +#define SHT_DYNSYM 11 /**< \brief Section contains minimal set of dynamic linking symbols */ +#define SHT_INIT_ARRAY 14 /**< \brief Array of pointers to initialization functions */ +#define SHT_FINI_ARRAY 15 /**< \brief Array of pointers to termination functions */ +#define SHT_PREINIT_ARRAY 16 /**< \brief Array of pointers to functions invoked prior to all init functions */ +#define SHT_GROUP 17 /**< \brief A set of sections that are related and must be treated specially by the linker */ +#define SHT_SYMTAB_SHNDX 18 /**< \brief An array of values corresponding (one-to-one) with symbol table entries */ + +#define SHT_LOPROC 0x70000000 /**< \brief Values >= are reserved for Processor specific semantics */ +#define SHT_HIPROC 0x7fffffff /**< \brief Values <= are reserved for Processor specific semantics */ +#define SHT_LOUSER 0x80000000 /**< \brief Values >= are reserved for application programs */ +#define SHT_HIUSER 0xffffffff /**< \brief Values <= are reserved for application programs */ /** -* sh_flags values are as follows: -*/ -#define SHF_WRITE 0x1 /**< \brief Section contains data that should be writable during execution */ -#define SHF_ALLOC 0x2 /**< \brief Section occupies memory during process execution */ -#define SHF_EXECINSTR 0x4 /**< \brief Section contains executable machine instructions */ -#define SHF_MERGE 0x10 /**< \brief Section contains data that can be merged to eliminate duplication */ -#define SHF_STRINGS 0x20 /**< \brief Section consists of null-terminated character strings */ -#define SHF_INFO_LINK 0x40 /**< \brief sh_info field of this section contains section header table index */ -#define SHF_LINK_ORDER 0x80 /**< \brief Section requires special ordering requirements for link editors */ + * sh_flags values are as follows: + */ +#define SHF_WRITE 0x1 /**< \brief Section contains data that should be writable during execution */ +#define SHF_ALLOC 0x2 /**< \brief Section occupies memory during process execution */ +#define SHF_EXECINSTR 0x4 /**< \brief Section contains executable machine instructions */ +#define SHF_MERGE 0x10 /**< \brief Section contains data that can be merged to eliminate duplication */ +#define SHF_STRINGS 0x20 /**< \brief Section consists of null-terminated character strings */ +#define SHF_INFO_LINK 0x40 /**< \brief sh_info field of this section contains section header table index */ +#define SHF_LINK_ORDER 0x80 /**< \brief Section requires special ordering requirements for link editors */ #define SHF_OS_NONCONFORMING 0x100 /**< \brief Section requires special OS-specific processing */ -#define SHF_GROUP 0x200 /**< \brief Section is a member of a section group */ +#define SHF_GROUP 0x200 /**< \brief Section is a member of a section group */ -#define SHF_MASKPROC 0xf0000000 /**< \brief Bits in this mask are reserved for processor specific semantics */ +#define SHF_MASKPROC 0xf0000000 /**< \brief Bits in this mask are reserved for processor specific semantics */ /** -* 32 bit Symbol Table Entry -*/ + * 32 bit Symbol Table Entry + */ typedef struct { - Elf32_Word st_name; /**< \brief String Table Index that gives the symbol name */ - Elf32_Addr st_value; /**< \brief Value of associated symbol */ - Elf32_Word st_size; /**< \brief Size, in bytes, of symbol */ - unsigned char st_info; /**< \brief Symbol's type and binding attributes */ - unsigned char st_other; /**< \brief */ - Elf32_Half st_shndx; /**< \brief */ + Elf32_Word st_name; /**< \brief String Table Index that gives the symbol name */ + Elf32_Addr st_value; /**< \brief Value of associated symbol */ + Elf32_Word st_size; /**< \brief Size, in bytes, of symbol */ + unsigned char st_info; /**< \brief Symbol's type and binding attributes */ + unsigned char st_other; /**< \brief */ + Elf32_Half st_shndx; /**< \brief */ } Elf32_Sym; /** -* 64 bit Symbol Table Entry -*/ + * 64 bit Symbol Table Entry + */ typedef struct { - Elf64_Word st_name; /**< \brief String Table Index that gives the symbol name */ - unsigned char st_info; /**< \brief Symbol's type and binding attributes */ - unsigned char st_other; /**< \brief */ - Elf64_Half st_shndx; /**< \brief */ - Elf64_Addr st_value; /**< \brief Value of associated symbol */ - Elf64_Xword st_size; /**< \brief Size, in bytes, of symbol */ + Elf64_Word st_name; /**< \brief String Table Index that gives the symbol name */ + unsigned char st_info; /**< \brief Symbol's type and binding attributes */ + unsigned char st_other; /**< \brief */ + Elf64_Half st_shndx; /**< \brief */ + Elf64_Addr st_value; /**< \brief Value of associated symbol */ + Elf64_Xword st_size; /**< \brief Size, in bytes, of symbol */ } Elf64_Sym; union Elf_Sym @@ -447,32 +447,31 @@ union Elf_Sym Elf64_Sym Sym64; }; - -#define ELF32_ST_INFO (b,t) (((b) << 4 ) + ((t) & 0xf)) +#define ELF32_ST_INFO (b, t)(((b) << 4) + ((t)&0xf)) /** -* Extraction and possible values of symbol table entry binding attributes in st_info -*/ -#define ELF32_ST_BIND (i) ((i) >> 4) + * Extraction and possible values of symbol table entry binding attributes in st_info + */ +#define ELF32_ST_BIND (i)((i) >> 4) -#define STB_LOCAL 0 /**< \brief Local symbols are not visible outside the object file */ -#define STB_GLOBAL 1 /**< \brief Global symbols are visible to all object files being combined */ -#define STB_WEAK 2 /**< \brief Same as Global but with lower precedence */ +#define STB_LOCAL 0 /**< \brief Local symbols are not visible outside the object file */ +#define STB_GLOBAL 1 /**< \brief Global symbols are visible to all object files being combined */ +#define STB_WEAK 2 /**< \brief Same as Global but with lower precedence */ -#define STB_LOPROC 13 /**< \brief Values >= are reserved for processor specific semantics */ -#define STB_HIPROC 15 /**< \brief Values <= are reserved for processor specific semantics */ +#define STB_LOPROC 13 /**< \brief Values >= are reserved for processor specific semantics */ +#define STB_HIPROC 15 /**< \brief Values <= are reserved for processor specific semantics */ /** -* Extraction and possible values of symbol table entry type attributes in st_info -*/ -#define ELF32_ST_TYPE (i) ((i) & 0xf) - -#define STT_NOTYPE 0 /**< \brief The symbol's type is unspecified */ -#define STT_OBJECT 1 /**< \brief Symbol associated with a data object (variable, array, etc) */ -#define STT_FUNC 2 /**< \brief Symbol associated with a function or other executable code */ -#define STT_SECTION 3 /**< \brief Symbol associated with a section */ -#define STT_FILE 4 /**< \brief Symbol's name gives the source file */ -#define STT_COMMON 5 /**< \brief Symbol labels an uninitialized common block */ - -#define STT_LOPROC 13 /**< \brief Values >= are reserved for processor specific semantics */ -#define STT_HIPROC 15 /**< \brief Values <= are reserved for processor specific semantics */ + * Extraction and possible values of symbol table entry type attributes in st_info + */ +#define ELF32_ST_TYPE (i)((i)&0xf) + +#define STT_NOTYPE 0 /**< \brief The symbol's type is unspecified */ +#define STT_OBJECT 1 /**< \brief Symbol associated with a data object (variable, array, etc) */ +#define STT_FUNC 2 /**< \brief Symbol associated with a function or other executable code */ +#define STT_SECTION 3 /**< \brief Symbol associated with a section */ +#define STT_FILE 4 /**< \brief Symbol's name gives the source file */ +#define STT_COMMON 5 /**< \brief Symbol labels an uninitialized common block */ + +#define STT_LOPROC 13 /**< \brief Values >= are reserved for processor specific semantics */ +#define STT_HIPROC 15 /**< \brief Values <= are reserved for processor specific semantics */ diff --git a/SampleTblImg.c b/SampleTblImg.c index cbf745a..eaa2e7c 100644 --- a/SampleTblImg.c +++ b/SampleTblImg.c @@ -20,7 +20,7 @@ ** */ -#include "cfe_tbl_filedef.h" /* Required to obtain the CFE_TBL_FILEDEF macro definition */ +#include "cfe_tbl_filedef.h" /* Required to obtain the CFE_TBL_FILEDEF macro definition */ /* ** The following is an example of a data structure the application may have declared @@ -28,17 +28,17 @@ */ typedef struct { - int Int1; - int Int2; - int Int3; - char Char1; + int Int1; + int Int2; + int Int3; + char Char1; } MyTblStruct_t; /* ** The following is an example of the declaration statement that defines the desired ** contents of the table image. */ -MyTblStruct_t MyTblStruct = { 0x01020304, 0x05060708, 0x090A0B0C, 0x0D }; +MyTblStruct_t MyTblStruct = {0x01020304, 0x05060708, 0x090A0B0C, 0x0D}; /* ** The macro below identifies: @@ -47,4 +47,4 @@ MyTblStruct_t MyTblStruct = { 0x01020304, 0x05060708, 0x090A0B0C, 0x0D }; ** 3) a brief description of the contents of the file image ** 4) the desired name of the table image binary file that is cFE compatible */ -CFE_TBL_FILEDEF(MyTblStruct, MyApp.TableName, Table Utility Test Table, MyTblDefault.bin ) +CFE_TBL_FILEDEF(MyTblStruct, MyApp.TableName, Table Utility Test Table, MyTblDefault.bin) diff --git a/elf2cfetbl.c b/elf2cfetbl.c index b201624..a4a6d7b 100644 --- a/elf2cfetbl.c +++ b/elf2cfetbl.c @@ -41,27 +41,24 @@ #include "ELF_Structures.h" #include "cfe_tbl_filedef.h" -#define MAX_SECTION_HDR_NAME_LEN (128) -#define TBL_DEF_SYMBOL_NAME "CFE_TBL_FileDef" -#define SUCCESS (0) -#define FAILED (1) +#define MAX_SECTION_HDR_NAME_LEN (128) +#define TBL_DEF_SYMBOL_NAME "CFE_TBL_FileDef" +#define SUCCESS (0) +#define FAILED (1) /* macro to construct 32 bit value from 4 chars */ -#define U32FROM4CHARS( _C1, _C2, _C3, _C4 ) \ - ( (uint32)(_C1) << 24 | \ - (uint32)(_C2) << 16 | \ - (uint32)(_C3) << 8 | \ - (uint32)(_C4) ) +#define U32FROM4CHARS(_C1, _C2, _C3, _C4) \ + ((uint32)(_C1) << 24 | (uint32)(_C2) << 16 | (uint32)(_C3) << 8 | (uint32)(_C4)) typedef struct { - int32 Value; - char String[50]; + int32 Value; + char String[50]; } ElfStrMap; /** -* Function Prototypes -*/ + * Function Prototypes + */ int32 ProcessCmdLineOptions(int argc, char *argv[]); int32 GetSrcFilename(void); int32 GetDstFilename(void); @@ -96,59 +93,59 @@ void PrintElfHeader32(union Elf_Ehdr ElfHeader); void PrintElfHeader64(union Elf_Ehdr ElfHeader); /** -* Global Variables -*/ -char SrcFilename[PATH_MAX]={""}; -char DstFilename[PATH_MAX]={""}; -char TableName[38]={""}; -char Description[32]={""}; -char LineOfText[300]={""}; - -bool Verbose=false; -bool ReportVersion=false; -bool OutputHelp=false; -bool ByteSwapRequired=false; -bool ScIDSpecified=false; -bool ProcIDSpecified=false; -bool AppIDSpecified=false; -bool ScEpochSpecified=false; -bool FileEpochSpecified=false; -bool TableNameOverride=false; -bool DescriptionOverride=false; -bool ThisMachineIsLittleEndian=true; -bool TargetMachineIsLittleEndian=true; -bool EnableTimeTagInHeader=false; -bool TargetWordsizeIs32Bit=true; - -bool TableDataIsAllZeros=false; + * Global Variables + */ +char SrcFilename[PATH_MAX] = {""}; +char DstFilename[PATH_MAX] = {""}; +char TableName[38] = {""}; +char Description[32] = {""}; +char LineOfText[300] = {""}; + +bool Verbose = false; +bool ReportVersion = false; +bool OutputHelp = false; +bool ByteSwapRequired = false; +bool ScIDSpecified = false; +bool ProcIDSpecified = false; +bool AppIDSpecified = false; +bool ScEpochSpecified = false; +bool FileEpochSpecified = false; +bool TableNameOverride = false; +bool DescriptionOverride = false; +bool ThisMachineIsLittleEndian = true; +bool TargetMachineIsLittleEndian = true; +bool EnableTimeTagInHeader = false; +bool TargetWordsizeIs32Bit = true; + +bool TableDataIsAllZeros = false; FILE *SrcFileDesc = NULL; FILE *DstFileDesc = NULL; -CFE_FS_Header_t FileHeader; -CFE_TBL_File_Hdr_t TableHeader; +CFE_FS_Header_t FileHeader; +CFE_TBL_File_Hdr_t TableHeader; -union Elf_Ehdr ElfHeader; -union Elf_Shdr **SectionHeaderPtrs = NULL; -union Elf_Shdr SectionHeaderStringTable = {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}; -int64 SectionHeaderStringTableDataOffset = 0; -char **SectionNamePtrs = NULL; +union Elf_Ehdr ElfHeader; +union Elf_Shdr **SectionHeaderPtrs = NULL; +union Elf_Shdr SectionHeaderStringTable = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; +int64 SectionHeaderStringTableDataOffset = 0; +char ** SectionNamePtrs = NULL; struct stat SrcFileStats; -uint64_t StringTableDataOffset = 0; -int32 SymbolTableDataOffset = 0; -uint64_t NumSymbols = 0; -uint64_t SymbolTableEntrySize = 0; -union Elf_Sym **SymbolPtrs = NULL; -char **SymbolNames; -int32 TblDefSymbolIndex = -1; +uint64_t StringTableDataOffset = 0; +int32 SymbolTableDataOffset = 0; +uint64_t NumSymbols = 0; +uint64_t SymbolTableEntrySize = 0; +union Elf_Sym ** SymbolPtrs = NULL; +char ** SymbolNames; +int32 TblDefSymbolIndex = -1; CFE_TBL_FileDef_t TblFileDef; -int32 UserObjSymbolIndex = -1; -uint32 SpacecraftID=0; -uint32 ProcessorID=0; -uint32 ApplicationID=0; -time_t EpochTime=0; +int32 UserObjSymbolIndex = -1; +uint32 SpacecraftID = 0; +uint32 ProcessorID = 0; +uint32 ApplicationID = 0; +time_t EpochTime = 0; typedef struct { @@ -160,208 +157,202 @@ typedef struct uint32 Second; } SpecifiedEpoch_t; -SpecifiedEpoch_t ScEpoch = {1970,1,1,0,0,0}; -SpecifiedEpoch_t FileEpoch = {1970,1,1,0,0,0}; -time_t EpochDelta; -time_t SrcFileTimeInScEpoch; +SpecifiedEpoch_t ScEpoch = {1970, 1, 1, 0, 0, 0}; +SpecifiedEpoch_t FileEpoch = {1970, 1, 1, 0, 0, 0}; +time_t EpochDelta; +time_t SrcFileTimeInScEpoch; /** -* ELF Characteristic Maps -*/ -ElfStrMap e_type_Map[] = -{ - { ET_NONE, "ET_NONE (0)" }, - { ET_REL, "ET_REL (1)" }, - { ET_EXEC, "ET_EXEC (2)" }, - { ET_DYN, "ET_DYN (3)" }, - { ET_CORE, "ET_CORE (4)" }, - { 0, "* Unknown Elf File Type (%d) *" }, + * ELF Characteristic Maps + */ +ElfStrMap e_type_Map[] = { + {ET_NONE, "ET_NONE (0)"}, {ET_REL, "ET_REL (1)"}, {ET_EXEC, "ET_EXEC (2)"}, + {ET_DYN, "ET_DYN (3)"}, {ET_CORE, "ET_CORE (4)"}, {0, "* Unknown Elf File Type (%d) *"}, }; -ElfStrMap e_machine_Map[] = -{ - { EM_NONE , "EM_NONE ( 0)" }, - { EM_M32 , "EM_M32 ( 1)" }, - { EM_SPARC , "EM_SPARC ( 2)" }, - { EM_386 , "EM_386 ( 3)" }, - { EM_68K , "EM_68K ( 4)" }, - { EM_88K , "EM_88K ( 5)" }, - { EM_860 , "EM_860 ( 7)" }, - { EM_MIPS , "EM_MIPS ( 8)" }, - { EM_S370 , "EM_S370 ( 9)" }, - { EM_MIPS_RS3_LE , "EM_MIPS_RS3_LE (10)" }, - { EM_PARISC , "EM_PARISC (15)" }, - { EM_VPP500 , "EM_VPP500 (17)" }, - { EM_SPARC32PLUS , "EM_SPARC32PLUS (18)" }, - { EM_960 , "EM_960 (19)" }, - { EM_PPC , "EM_PPC (20)" }, - { EM_PPC64 , "EM_PPC64 (21)" }, - { EM_S390 , "EM_S390 (22)" }, - { EM_SPU , "EM_SPU (23)" }, - { EM_V800 , "EM_V800 (36)" }, - { EM_FR20 , "EM_FR20 (37)" }, - { EM_RH32 , "EM_RH32 (38)" }, - { EM_RCE , "EM_RCE (39)" }, - { EM_ARM , "EM_ARM (40)" }, - { EM_ALPHA , "EM_ALPHA (41)" }, - { EM_SH , "EM_SH (42)" }, - { EM_SPARCV9 , "EM_SPARCV9 (43)" }, - { EM_TRICORE , "EM_TRICORE (44)" }, - { EM_ARC , "EM_ARC (45)" }, - { EM_H8_300 , "EM_H8_300 (46)" }, - { EM_H8_300H , "EM_H8_300H (47)" }, - { EM_H8S , "EM_H8S (48)" }, - { EM_H8_500 , "EM_H8_500 (49)" }, - { EM_IA_64 , "EM_IA_64 (50)" }, - { EM_MIPS_X , "EM_MIPS_X (51)" }, - { EM_COLDFIRE , "EM_COLDFIRE (52)" }, - { EM_68HC12 , "EM_68HC12 (53)" }, - { EM_MMA , "EM_MMA (54)" }, - { EM_PCP , "EM_PCP (55)" }, - { EM_NCPU , "EM_NCPU (56)" }, - { EM_NDR1 , "EM_NDR1 (57)" }, - { EM_STARCORE , "EM_STARCORE (58)" }, - { EM_ME16 , "EM_ME16 (59)" }, - { EM_ST100 , "EM_ST100 (60)" }, - { EM_TINYJ , "EM_TINYJ (61)" }, - { EM_X86_64 , "EM_X86_64 (62)" }, - { EM_PDSP , "EM_PDSP (63)" }, - { EM_PDP10 , "EM_PDP10 (64)" }, - { EM_PDP11 , "EM_PDP11 (65)" }, - { EM_FX66 , "EM_FX66 (66)" }, - { EM_ST9PLUS , "EM_ST9PLUS (67)" }, - { EM_ST7 , "EM_ST7 (68)" }, - { EM_68HC16 , "EM_68HC16 (69)" }, - { EM_68HC11 , "EM_68HC11 (70)" }, - { EM_68HC08 , "EM_68HC08 (71)" }, - { EM_68HC05 , "EM_68HC05 (72)" }, - { EM_SVX , "EM_SVX (73)" }, - { EM_ST19 , "EM_ST19 (74)" }, - { EM_VAX , "EM_VAX (75)" }, - { EM_CRIS , "EM_CRIS (76)" }, - { EM_JAVELIN , "EM_JAVELIN (77)" }, - { EM_FIREPATH , "EM_FIREPATH (78)" }, - { EM_ZSP , "EM_ZSP (79)" }, - { EM_MMIX , "EM_MMIX (80)" }, - { EM_HUANY , "EM_HUANY (81)" }, - { EM_PRISM , "EM_PRISM (82)" }, - { EM_AVR , "EM_AVR (83)" }, - { EM_FR30 , "EM_FR30 (84)" }, - { EM_D10V , "EM_D10V (85)" }, - { EM_D30V , "EM_D30V (86)" }, - { EM_V850 , "EM_V850 (87)" }, - { EM_M32R , "EM_M32R (88)" }, - { EM_MN10300 , "EM_MN10300 (89)" }, - { EM_MN10200 , "EM_MN10200 (90)" }, - { EM_PJ , "EM_PJ (91)" }, - { EM_OPENRISC , "EM_OPENRISC (92)" }, - { EM_ARC_COMPACT , "EM_ARC_COMPACT (93)" }, - { EM_XTENSA , "EM_XTENSA (94)" }, - { EM_VIDEOCORE , "EM_VIDEOCORE (95)" }, - { EM_TMM_GPP , "EM_TMM_GPP (96)" }, - { EM_NS32K , "EM_NS32K (97)" }, - { EM_TPC , "EM_TPC (98)" }, - { EM_SNP1K , "EM_SNP1K (99)" }, - { EM_ST200 , "EM_ST200 (100)" }, - { EM_IP2K , "EM_IP2K (101)" }, - { EM_MAX , "EM_MAX (102)" }, - { EM_CR , "EM_CR (103)" }, - { EM_F2MC16 , "EM_F2MC16 (104)" }, - { EM_MSP430 , "EM_MSP430 (105)" }, - { EM_BLACKFIN , "EM_BLACKFIN (106)" }, - { EM_SE_C33 , "EM_SE_C33 (107)" }, - { EM_SEP , "EM_SEP (108)" }, - { EM_ARCA , "EM_ARCA (109)" }, - { EM_UNICORE , "EM_UNICORE (110)" }, - { EM_EXCESS , "EM_EXCESS (111)" }, - { EM_DXP , "EM_DXP (112)" }, - { EM_ALTERA_NIOS2, "EM_ALTERA_NIOS2 (113)"}, - { EM_CRX , "EM_CRX (114)" }, - { EM_XGATE , "EM_XGATE (115)" }, - { EM_C166 , "EM_C166 (116)" }, - { EM_M16C , "EM_M16C (117)" }, - { EM_DSPIC30F , "EM_DSPIC30F (118)" }, - { EM_CE , "EM_CE (119)" }, - { EM_M32C , "EM_M32C (120)" }, - { EM_TSK3000 , "EM_TSK3000 (131)" }, - { EM_RS08 , "EM_RS08 (132)" }, - { EM_SHARC , "EM_SHARC (133)" }, - { EM_ECOG2 , "EM_ECOG2 (134)" }, - { EM_SCORE7 , "EM_SCORE7 (135)" }, - { EM_DSP24 , "EM_DSP24 (136)" }, - { EM_VIDEOCORE3 , "EM_VIDEOCORE3 (137)" }, - { EM_LATTICEMICO32,"EM_LATTICEMICO32(138)"}, - { EM_SE_C17 , "EM_SE_C17 (139)" }, - { EM_TI_C6000 , "EM_TI_C6000 (140)" }, - { EM_TI_C2000 , "EM_TI_C2000 (141)" }, - { EM_TI_C5500 , "EM_TI_C5500 (142)" }, - { EM_TI_ARP32 , "EM_TI_ARP32 (143)" }, - { EM_TI_PRU , "EM_TI_PRU (144)" }, - { EM_MMDSP_PLUS , "EM_MMDSP_PLUS (160)" }, - { EM_CYPRESS_M8C , "EM_CYPRESS_M8C (161)" }, - { EM_R32C , "EM_R32C (162)" }, - { EM_TRIMEDIA , "EM_TRIMEDIA (163)" }, - { EM_QDSP6 , "EM_QDSP6 (164)" }, - { EM_8051 , "EM_8051 (165)" }, - { EM_STXP7X , "EM_STXP7X (166)" }, - { EM_NDS32 , "EM_NDS32 (167)" }, - { EM_ECOG1 , "EM_ECOG1 (168)" }, - { EM_ECOG1X , "EM_ECOG1X (168)" }, - { EM_MAXQ30 , "EM_MAXQ30 (169)" }, - { EM_XIMO16 , "EM_XIMO16 (170)" }, - { EM_MANIK , "EM_MANIK (171)" }, - { EM_RX , "EM_RX (173)" }, - { EM_METAG , "EM_METAG (174)" }, - { EM_MCST_ELBRUS , "EM_MCST_ELBRUS (175)" }, - { EM_ECOG16 , "EM_ECOG16 (176)" }, - { EM_CR16 , "EM_CR16 (177)" }, - { EM_ETPU , "EM_ETPU (178)" }, - { EM_SLE9X , "EM_SLE9X (179)" }, - { EM_L10M , "EM_L10M (180)" }, - { EM_K10M , "EM_K10M (181)" }, - { EM_AARCH64 , "EM_AARCH64 (183)" }, - { EM_AVR32 , "EM_AVR32 (185)" }, - { EM_STM8 , "EM_STM8 (186)" }, - { EM_TILE64 , "EM_TILE64 (187)" }, - { EM_TILEPRO , "EM_TILEPRO (188)" }, - { EM_MICROBLAZE , "EM_MICROBLAZE (189)" }, - { EM_CUDA , "EM_CUDA (190)" }, - { EM_TILEGX , "EM_TILEGX (191)" }, - { EM_CLOUDSHIELD , "EM_CLOUDSHIELD (192)" }, - { EM_COREA_1ST , "EM_COREA_1ST (193)" }, - { EM_COREA_2ND , "EM_COREA_2ND (194)" }, - { EM_ARC_COMPACT2, "EM_ARC_COMPACT2 (195)"}, - { EM_OPEN8 , "EM_OPEN8 (196)" }, - { EM_RL78 , "EM_RL78 (197)" }, - { EM_VIDEOCORE5 , "EM_VIDEOCORE5 (198)" }, - { EM_78KOR , "EM_78KOR (199)" }, - { EM_56800EX , "EM_56800EX (200)" }, - { EM_BA1 , "EM_BA1 (201)" }, - { EM_BA2 , "EM_BA2 (202)" }, - { EM_XCORE , "EM_XCORE (203)" }, - { EM_MCHP_PIC , "EM_MCHP_PIC (204)" }, - { EM_INTEL205 , "EM_INTEL205 (205)" }, - { EM_INTEL206 , "EM_INTEL206 (206)" }, - { EM_INTEL207 , "EM_INTEL207 (207)" }, - { EM_INTEL208 , "EM_INTEL208 (208)" }, - { EM_INTEL209 , "EM_INTEL209 (209)" }, - { EM_KM32 , "EM_KM32 (210)" }, - { EM_KMX32 , "EM_KMX32 (211)" }, - { EM_KMX16 , "EM_KMX16 (212)" }, - { EM_KMX8 , "EM_KMX8 (213)" }, - { EM_KVARC , "EM_KVARC (214)" }, - { EM_CDP , "EM_CDP (215)" }, - { EM_COGE , "EM_COGE (216)" }, - { EM_COOL , "EM_COOL (217)" }, - { EM_NORC , "EM_NORC (218)" }, - { EM_CSR_KALIMBA , "EM_CSR_KALIMBA (219)" }, - { EM_Z80 , "EM_Z80 (220)" }, - { EM_VISIUM , "EM_VISIUM (221)" }, - { EM_FT32 , "EM_FT32 (222)" }, - { EM_MOXIE , "EM_MOXIE (223)" }, - { EM_AMDGPU , "EM_AMDGPU (224)" }, - { EM_RISCV , "EM_RISCV (243)" }, - { 0 , "* Unknown Machine Type (%d) *" }, +ElfStrMap e_machine_Map[] = { + {EM_NONE, "EM_NONE ( 0)"}, + {EM_M32, "EM_M32 ( 1)"}, + {EM_SPARC, "EM_SPARC ( 2)"}, + {EM_386, "EM_386 ( 3)"}, + {EM_68K, "EM_68K ( 4)"}, + {EM_88K, "EM_88K ( 5)"}, + {EM_860, "EM_860 ( 7)"}, + {EM_MIPS, "EM_MIPS ( 8)"}, + {EM_S370, "EM_S370 ( 9)"}, + {EM_MIPS_RS3_LE, "EM_MIPS_RS3_LE (10)"}, + {EM_PARISC, "EM_PARISC (15)"}, + {EM_VPP500, "EM_VPP500 (17)"}, + {EM_SPARC32PLUS, "EM_SPARC32PLUS (18)"}, + {EM_960, "EM_960 (19)"}, + {EM_PPC, "EM_PPC (20)"}, + {EM_PPC64, "EM_PPC64 (21)"}, + {EM_S390, "EM_S390 (22)"}, + {EM_SPU, "EM_SPU (23)"}, + {EM_V800, "EM_V800 (36)"}, + {EM_FR20, "EM_FR20 (37)"}, + {EM_RH32, "EM_RH32 (38)"}, + {EM_RCE, "EM_RCE (39)"}, + {EM_ARM, "EM_ARM (40)"}, + {EM_ALPHA, "EM_ALPHA (41)"}, + {EM_SH, "EM_SH (42)"}, + {EM_SPARCV9, "EM_SPARCV9 (43)"}, + {EM_TRICORE, "EM_TRICORE (44)"}, + {EM_ARC, "EM_ARC (45)"}, + {EM_H8_300, "EM_H8_300 (46)"}, + {EM_H8_300H, "EM_H8_300H (47)"}, + {EM_H8S, "EM_H8S (48)"}, + {EM_H8_500, "EM_H8_500 (49)"}, + {EM_IA_64, "EM_IA_64 (50)"}, + {EM_MIPS_X, "EM_MIPS_X (51)"}, + {EM_COLDFIRE, "EM_COLDFIRE (52)"}, + {EM_68HC12, "EM_68HC12 (53)"}, + {EM_MMA, "EM_MMA (54)"}, + {EM_PCP, "EM_PCP (55)"}, + {EM_NCPU, "EM_NCPU (56)"}, + {EM_NDR1, "EM_NDR1 (57)"}, + {EM_STARCORE, "EM_STARCORE (58)"}, + {EM_ME16, "EM_ME16 (59)"}, + {EM_ST100, "EM_ST100 (60)"}, + {EM_TINYJ, "EM_TINYJ (61)"}, + {EM_X86_64, "EM_X86_64 (62)"}, + {EM_PDSP, "EM_PDSP (63)"}, + {EM_PDP10, "EM_PDP10 (64)"}, + {EM_PDP11, "EM_PDP11 (65)"}, + {EM_FX66, "EM_FX66 (66)"}, + {EM_ST9PLUS, "EM_ST9PLUS (67)"}, + {EM_ST7, "EM_ST7 (68)"}, + {EM_68HC16, "EM_68HC16 (69)"}, + {EM_68HC11, "EM_68HC11 (70)"}, + {EM_68HC08, "EM_68HC08 (71)"}, + {EM_68HC05, "EM_68HC05 (72)"}, + {EM_SVX, "EM_SVX (73)"}, + {EM_ST19, "EM_ST19 (74)"}, + {EM_VAX, "EM_VAX (75)"}, + {EM_CRIS, "EM_CRIS (76)"}, + {EM_JAVELIN, "EM_JAVELIN (77)"}, + {EM_FIREPATH, "EM_FIREPATH (78)"}, + {EM_ZSP, "EM_ZSP (79)"}, + {EM_MMIX, "EM_MMIX (80)"}, + {EM_HUANY, "EM_HUANY (81)"}, + {EM_PRISM, "EM_PRISM (82)"}, + {EM_AVR, "EM_AVR (83)"}, + {EM_FR30, "EM_FR30 (84)"}, + {EM_D10V, "EM_D10V (85)"}, + {EM_D30V, "EM_D30V (86)"}, + {EM_V850, "EM_V850 (87)"}, + {EM_M32R, "EM_M32R (88)"}, + {EM_MN10300, "EM_MN10300 (89)"}, + {EM_MN10200, "EM_MN10200 (90)"}, + {EM_PJ, "EM_PJ (91)"}, + {EM_OPENRISC, "EM_OPENRISC (92)"}, + {EM_ARC_COMPACT, "EM_ARC_COMPACT (93)"}, + {EM_XTENSA, "EM_XTENSA (94)"}, + {EM_VIDEOCORE, "EM_VIDEOCORE (95)"}, + {EM_TMM_GPP, "EM_TMM_GPP (96)"}, + {EM_NS32K, "EM_NS32K (97)"}, + {EM_TPC, "EM_TPC (98)"}, + {EM_SNP1K, "EM_SNP1K (99)"}, + {EM_ST200, "EM_ST200 (100)"}, + {EM_IP2K, "EM_IP2K (101)"}, + {EM_MAX, "EM_MAX (102)"}, + {EM_CR, "EM_CR (103)"}, + {EM_F2MC16, "EM_F2MC16 (104)"}, + {EM_MSP430, "EM_MSP430 (105)"}, + {EM_BLACKFIN, "EM_BLACKFIN (106)"}, + {EM_SE_C33, "EM_SE_C33 (107)"}, + {EM_SEP, "EM_SEP (108)"}, + {EM_ARCA, "EM_ARCA (109)"}, + {EM_UNICORE, "EM_UNICORE (110)"}, + {EM_EXCESS, "EM_EXCESS (111)"}, + {EM_DXP, "EM_DXP (112)"}, + {EM_ALTERA_NIOS2, "EM_ALTERA_NIOS2 (113)"}, + {EM_CRX, "EM_CRX (114)"}, + {EM_XGATE, "EM_XGATE (115)"}, + {EM_C166, "EM_C166 (116)"}, + {EM_M16C, "EM_M16C (117)"}, + {EM_DSPIC30F, "EM_DSPIC30F (118)"}, + {EM_CE, "EM_CE (119)"}, + {EM_M32C, "EM_M32C (120)"}, + {EM_TSK3000, "EM_TSK3000 (131)"}, + {EM_RS08, "EM_RS08 (132)"}, + {EM_SHARC, "EM_SHARC (133)"}, + {EM_ECOG2, "EM_ECOG2 (134)"}, + {EM_SCORE7, "EM_SCORE7 (135)"}, + {EM_DSP24, "EM_DSP24 (136)"}, + {EM_VIDEOCORE3, "EM_VIDEOCORE3 (137)"}, + {EM_LATTICEMICO32, "EM_LATTICEMICO32(138)"}, + {EM_SE_C17, "EM_SE_C17 (139)"}, + {EM_TI_C6000, "EM_TI_C6000 (140)"}, + {EM_TI_C2000, "EM_TI_C2000 (141)"}, + {EM_TI_C5500, "EM_TI_C5500 (142)"}, + {EM_TI_ARP32, "EM_TI_ARP32 (143)"}, + {EM_TI_PRU, "EM_TI_PRU (144)"}, + {EM_MMDSP_PLUS, "EM_MMDSP_PLUS (160)"}, + {EM_CYPRESS_M8C, "EM_CYPRESS_M8C (161)"}, + {EM_R32C, "EM_R32C (162)"}, + {EM_TRIMEDIA, "EM_TRIMEDIA (163)"}, + {EM_QDSP6, "EM_QDSP6 (164)"}, + {EM_8051, "EM_8051 (165)"}, + {EM_STXP7X, "EM_STXP7X (166)"}, + {EM_NDS32, "EM_NDS32 (167)"}, + {EM_ECOG1, "EM_ECOG1 (168)"}, + {EM_ECOG1X, "EM_ECOG1X (168)"}, + {EM_MAXQ30, "EM_MAXQ30 (169)"}, + {EM_XIMO16, "EM_XIMO16 (170)"}, + {EM_MANIK, "EM_MANIK (171)"}, + {EM_RX, "EM_RX (173)"}, + {EM_METAG, "EM_METAG (174)"}, + {EM_MCST_ELBRUS, "EM_MCST_ELBRUS (175)"}, + {EM_ECOG16, "EM_ECOG16 (176)"}, + {EM_CR16, "EM_CR16 (177)"}, + {EM_ETPU, "EM_ETPU (178)"}, + {EM_SLE9X, "EM_SLE9X (179)"}, + {EM_L10M, "EM_L10M (180)"}, + {EM_K10M, "EM_K10M (181)"}, + {EM_AARCH64, "EM_AARCH64 (183)"}, + {EM_AVR32, "EM_AVR32 (185)"}, + {EM_STM8, "EM_STM8 (186)"}, + {EM_TILE64, "EM_TILE64 (187)"}, + {EM_TILEPRO, "EM_TILEPRO (188)"}, + {EM_MICROBLAZE, "EM_MICROBLAZE (189)"}, + {EM_CUDA, "EM_CUDA (190)"}, + {EM_TILEGX, "EM_TILEGX (191)"}, + {EM_CLOUDSHIELD, "EM_CLOUDSHIELD (192)"}, + {EM_COREA_1ST, "EM_COREA_1ST (193)"}, + {EM_COREA_2ND, "EM_COREA_2ND (194)"}, + {EM_ARC_COMPACT2, "EM_ARC_COMPACT2 (195)"}, + {EM_OPEN8, "EM_OPEN8 (196)"}, + {EM_RL78, "EM_RL78 (197)"}, + {EM_VIDEOCORE5, "EM_VIDEOCORE5 (198)"}, + {EM_78KOR, "EM_78KOR (199)"}, + {EM_56800EX, "EM_56800EX (200)"}, + {EM_BA1, "EM_BA1 (201)"}, + {EM_BA2, "EM_BA2 (202)"}, + {EM_XCORE, "EM_XCORE (203)"}, + {EM_MCHP_PIC, "EM_MCHP_PIC (204)"}, + {EM_INTEL205, "EM_INTEL205 (205)"}, + {EM_INTEL206, "EM_INTEL206 (206)"}, + {EM_INTEL207, "EM_INTEL207 (207)"}, + {EM_INTEL208, "EM_INTEL208 (208)"}, + {EM_INTEL209, "EM_INTEL209 (209)"}, + {EM_KM32, "EM_KM32 (210)"}, + {EM_KMX32, "EM_KMX32 (211)"}, + {EM_KMX16, "EM_KMX16 (212)"}, + {EM_KMX8, "EM_KMX8 (213)"}, + {EM_KVARC, "EM_KVARC (214)"}, + {EM_CDP, "EM_CDP (215)"}, + {EM_COGE, "EM_COGE (216)"}, + {EM_COOL, "EM_COOL (217)"}, + {EM_NORC, "EM_NORC (218)"}, + {EM_CSR_KALIMBA, "EM_CSR_KALIMBA (219)"}, + {EM_Z80, "EM_Z80 (220)"}, + {EM_VISIUM, "EM_VISIUM (221)"}, + {EM_FT32, "EM_FT32 (222)"}, + {EM_MOXIE, "EM_MOXIE (223)"}, + {EM_AMDGPU, "EM_AMDGPU (224)"}, + {EM_RISCV, "EM_RISCV (243)"}, + {0, "* Unknown Machine Type (%d) *"}, }; // Elf Header helper functions @@ -544,7 +535,6 @@ uint64_t get_sh_entsize(const union Elf_Shdr *SectionHeader) } } - // Elf_Sym helper functions uint32_t get_st_name(const union Elf_Sym *Symbol) @@ -587,8 +577,9 @@ void set_st_size(union Elf_Sym *Symbol, uint64_t new_value) { if (TargetWordsizeIs32Bit) { - Symbol->Sym32.st_size = (uint32_t) new_value; - if (Symbol->Sym32.st_size != new_value) { + Symbol->Sym32.st_size = (uint32_t)new_value; + if (Symbol->Sym32.st_size != new_value) + { printf("ERROR: Sym32.st_size can not hold %lu\n", (long unsigned int)new_value); } } @@ -611,32 +602,39 @@ uint16_t get_st_shndx(const union Elf_Sym *Symbol) } /** -* -*/ + * + */ int main(int argc, char *argv[]) { - int32 Status = SUCCESS; - int32 i=0; + int32 Status = SUCCESS; + int32 i = 0; Status = ProcessCmdLineOptions(argc, argv); - if (Status != SUCCESS) return Status; + if (Status != SUCCESS) + return Status; - if (ReportVersion) OutputVersionInfo(); + if (ReportVersion) + OutputVersionInfo(); Status = GetSrcFilename(); - if (OutputHelp) OutputHelpInfo(); - if (Status != SUCCESS) return Status; + if (OutputHelp) + OutputHelpInfo(); + if (Status != SUCCESS) + return Status; Status = OpenSrcFile(); - if (Status != SUCCESS) return Status; + if (Status != SUCCESS) + return Status; Status = GetElfHeader(); - if (Status != SUCCESS) return Status; + if (Status != SUCCESS) + return Status; /* Get the string section header first */ Status = GetSectionHeader(get_e_shstrndx(&ElfHeader), &SectionHeaderStringTable); - if (Status != SUCCESS) return Status; + if (Status != SUCCESS) + return Status; if (TargetWordsizeIs32Bit) { @@ -656,7 +654,7 @@ int main(int argc, char *argv[]) } /* Read in each section header from input file */ - for (i=0; i< get_e_shnum(&ElfHeader); i++) + for (i = 0; i < get_e_shnum(&ElfHeader); i++) { Status = GetSectionHeader(i, SectionHeaderPtrs[i]); if (Status != SUCCESS) @@ -675,7 +673,7 @@ int main(int argc, char *argv[]) } /* Read in each symbol table entry */ - for (i=0; i 12)) { - fprintf(stderr, "Error! Spacecraft Epoch Month is not of the form 'MM:' where MM is in the range of 1-12\n"); + fprintf( + stderr, + "Error! Spacecraft Epoch Month is not of the form 'MM:' where MM is in the range of 1-12\n"); Status = false; } else @@ -1084,10 +1083,12 @@ int32 ProcessCmdLineOptions(int ArgumentCount, char *Arguments[]) } } ScEpoch.Day = strtoul(&Arguments[i][10], &EndPtr, 0); - if ((EndPtr != &Arguments[i][12]) || - (ScEpoch.Day == 0) || (ScEpoch.Day > MaxDay)) + if ((EndPtr != &Arguments[i][12]) || (ScEpoch.Day == 0) || (ScEpoch.Day > MaxDay)) { - fprintf(stderr, "Error! Spacecraft Epoch Day is not of the form 'DD:' where DD is in the range of 1-%d\n", MaxDay); + fprintf( + stderr, + "Error! Spacecraft Epoch Day is not of the form 'DD:' where DD is in the range of 1-%d\n", + MaxDay); Status = false; } else @@ -1095,7 +1096,8 @@ int32 ProcessCmdLineOptions(int ArgumentCount, char *Arguments[]) ScEpoch.Hour = strtoul(&Arguments[i][13], &EndPtr, 0); if ((EndPtr != &Arguments[i][15]) || (ScEpoch.Hour > 23)) { - fprintf(stderr, "Error! Spacecraft Epoch Hour is not of the form 'hh:' where hh is in the range of 0-23\n"); + fprintf(stderr, "Error! Spacecraft Epoch Hour is not of the form 'hh:' where hh is in the " + "range of 0-23\n"); Status = false; } else @@ -1103,7 +1105,8 @@ int32 ProcessCmdLineOptions(int ArgumentCount, char *Arguments[]) ScEpoch.Minute = strtoul(&Arguments[i][16], &EndPtr, 0); if ((EndPtr != &Arguments[i][18]) || (ScEpoch.Minute > 59)) { - fprintf(stderr, "Error! Spacecraft Epoch Minute is not of the form 'mm:' where mm is in the range of 0-59\n"); + fprintf(stderr, "Error! Spacecraft Epoch Minute is not of the form 'mm:' where mm is " + "in the range of 0-59\n"); Status = false; } else @@ -1111,7 +1114,8 @@ int32 ProcessCmdLineOptions(int ArgumentCount, char *Arguments[]) ScEpoch.Second = strtoul(&Arguments[i][19], &EndPtr, 0); if ((EndPtr != &Arguments[i][21]) || (ScEpoch.Second > 59)) { - fprintf(stderr, "Error! Spacecraft Epoch Second is not of the form 'ss' where ss is in the range of 0-59\n"); + fprintf(stderr, "Error! Spacecraft Epoch Second is not of the form 'ss' where ss " + "is in the range of 0-59\n"); Status = false; } else @@ -1137,13 +1141,15 @@ int32 ProcessCmdLineOptions(int ArgumentCount, char *Arguments[]) FileEpoch.Month = strtoul(&Arguments[i][7], &EndPtr, 0); if ((EndPtr != &Arguments[i][9]) || (FileEpoch.Month == 0) || (FileEpoch.Month > 12)) { - fprintf(stderr, "Error! File Epoch Month is not of the form 'MM:' where MM is in the range of 1-12\n"); + fprintf(stderr, + "Error! File Epoch Month is not of the form 'MM:' where MM is in the range of 1-12\n"); Status = false; } else { MaxDay = 31; - if ((FileEpoch.Month == 4) || (FileEpoch.Month == 6) || (FileEpoch.Month == 9) || (FileEpoch.Month == 11)) + if ((FileEpoch.Month == 4) || (FileEpoch.Month == 6) || (FileEpoch.Month == 9) || + (FileEpoch.Month == 11)) { MaxDay = 30; } @@ -1175,7 +1181,9 @@ int32 ProcessCmdLineOptions(int ArgumentCount, char *Arguments[]) FileEpoch.Day = strtoul(&Arguments[i][10], &EndPtr, 0); if ((EndPtr != &Arguments[i][12]) || (FileEpoch.Day == 0) || (FileEpoch.Day > MaxDay)) { - fprintf(stderr, "Error! File Epoch Day is not of the form 'DD:' where DD is in the range of 1-%d\n", MaxDay); + fprintf(stderr, + "Error! File Epoch Day is not of the form 'DD:' where DD is in the range of 1-%d\n", + MaxDay); Status = false; } else @@ -1183,7 +1191,9 @@ int32 ProcessCmdLineOptions(int ArgumentCount, char *Arguments[]) FileEpoch.Hour = strtoul(&Arguments[i][13], &EndPtr, 0); if ((EndPtr != &Arguments[i][15]) || (FileEpoch.Hour > 23)) { - fprintf(stderr, "Error! File Epoch Hour is not of the form 'hh:' where hh is in the range of 0-23\n"); + fprintf( + stderr, + "Error! File Epoch Hour is not of the form 'hh:' where hh is in the range of 0-23\n"); Status = false; } else @@ -1191,7 +1201,8 @@ int32 ProcessCmdLineOptions(int ArgumentCount, char *Arguments[]) FileEpoch.Minute = strtoul(&Arguments[i][16], &EndPtr, 0); if ((EndPtr != &Arguments[i][18]) || (FileEpoch.Minute > 59)) { - fprintf(stderr, "Error! File Epoch Minute is not of the form 'mm:' where mm is in the range of 0-59\n"); + fprintf(stderr, "Error! File Epoch Minute is not of the form 'mm:' where mm is in the " + "range of 0-59\n"); Status = false; } else @@ -1199,7 +1210,8 @@ int32 ProcessCmdLineOptions(int ArgumentCount, char *Arguments[]) FileEpoch.Second = strtoul(&Arguments[i][19], &EndPtr, 0); if ((EndPtr != &Arguments[i][21]) || (FileEpoch.Second > 59)) { - fprintf(stderr, "Error! File Epoch Second is not of the form 'ss' where ss is in the range of 0-59\n"); + fprintf(stderr, "Error! File Epoch Second is not of the form 'ss' where ss is in " + "the range of 0-59\n"); Status = false; } else @@ -1229,22 +1241,22 @@ int32 ProcessCmdLineOptions(int ArgumentCount, char *Arguments[]) } i++; } - FileEpochTm.tm_sec = FileEpoch.Second; - FileEpochTm.tm_min = FileEpoch.Minute; - FileEpochTm.tm_hour = FileEpoch.Hour; - FileEpochTm.tm_mday = FileEpoch.Day; - FileEpochTm.tm_mon = FileEpoch.Month - 1; - FileEpochTm.tm_year = FileEpoch.Year - 1900; + FileEpochTm.tm_sec = FileEpoch.Second; + FileEpochTm.tm_min = FileEpoch.Minute; + FileEpochTm.tm_hour = FileEpoch.Hour; + FileEpochTm.tm_mday = FileEpoch.Day; + FileEpochTm.tm_mon = FileEpoch.Month - 1; + FileEpochTm.tm_year = FileEpoch.Year - 1900; FileEpochTm.tm_isdst = -1; FileEpochInSecs = mktime(&FileEpochTm); - ScEpochTm.tm_sec = ScEpoch.Second; - ScEpochTm.tm_min = ScEpoch.Minute; - ScEpochTm.tm_hour = ScEpoch.Hour; - ScEpochTm.tm_mday = ScEpoch.Day; - ScEpochTm.tm_mon = ScEpoch.Month - 1; - ScEpochTm.tm_year = ScEpoch.Year - 1900; + ScEpochTm.tm_sec = ScEpoch.Second; + ScEpochTm.tm_min = ScEpoch.Minute; + ScEpochTm.tm_hour = ScEpoch.Hour; + ScEpochTm.tm_mday = ScEpoch.Day; + ScEpochTm.tm_mon = ScEpoch.Month - 1; + ScEpochTm.tm_year = ScEpoch.Year - 1900; ScEpochTm.tm_isdst = -1; ScEpochInSecs = mktime(&ScEpochTm); @@ -1255,8 +1267,8 @@ int32 ProcessCmdLineOptions(int ArgumentCount, char *Arguments[]) } /** -* -*/ + * + */ void OutputVersionInfo(void) { @@ -1266,8 +1278,8 @@ void OutputVersionInfo(void) } /** -* -*/ + * + */ void OutputHelpInfo(void) { @@ -1280,35 +1292,52 @@ void OutputHelpInfo(void) printf(" -v produces verbose output showing the breakdown of the object file in detail\n"); printf(" -V shows the version of this utility\n"); printf(" -s# specifies a Spacecraft ID to be put into file header.\n"); - printf(" # can be specified as decimal, octal (starting with a zero), or hex (starting with '0x')\n"); - printf(" -Scccc specifies a Spacecraft ID as a 4 byte string to be put into the table file file header.\n"); - printf(" cccc represents the 4 ASCII characters that will be encoded into the 32 bit Spacecaft ID field.\n"); + printf(" # can be specified as decimal, octal (starting with a zero), or hex (starting " + "with '0x')\n"); + printf(" -Scccc specifies a Spacecraft ID as a 4 byte string to be put into the table file file " + "header.\n"); + printf(" cccc represents the 4 ASCII characters that will be encoded into the 32 bit " + "Spacecaft ID field.\n"); printf(" examples: -SMMS1 or -SQQ#2\n"); printf(" -p# specifies a Processor ID to be put into file header.\n"); - printf(" # can be specified as decimal, octal (starting with a zero), or hex (starting with '0x')\n"); - printf(" -Pcccc specifies a Processor ID as a 4 byte string to be put into the table file header.\n"); - printf(" cccc represents the 4 ASCII characters that will be encoded into the 32 bit Processor ID field.\n"); + printf(" # can be specified as decimal, octal (starting with a zero), or hex (starting " + "with '0x')\n"); + printf( + " -Pcccc specifies a Processor ID as a 4 byte string to be put into the table file header.\n"); + printf(" cccc represents the 4 ASCII characters that will be encoded into the 32 bit " + "Processor ID field.\n"); printf(" examples: -PMMS1 or -PQQ#2\n"); printf(" -a# specifies an Application ID to be put into file header.\n"); - printf(" # can be specified as decimal, octal (starting with a zero), or hex (starting with '0x')\n"); - printf(" -T enables insertion of the SrcFilename's file creation time into the standard cFE File Header.\n"); - printf(" This option must be specified for either the '-e' and/or '-f' options below to have any effect.\n"); + printf(" # can be specified as decimal, octal (starting with a zero), or hex (starting " + "with '0x')\n"); + printf(" -T enables insertion of the SrcFilename's file creation time into the standard cFE " + "File Header.\n"); + printf(" This option must be specified for either the '-e' and/or '-f' options below to " + "have any effect.\n"); printf(" By default, the time tag fields are set to zero.\n"); - printf(" -eYYYY:MM:DD:hh:mm:ss specifies the spacecraft epoch time. The SrcFilename's file creation time will be converted to\n"); - printf(" seconds since the specified epoch time and stored in the standard cFE File Header.\n"); + printf(" -eYYYY:MM:DD:hh:mm:ss specifies the spacecraft epoch time. The SrcFilename's file creation time will " + "be converted to\n"); + printf(" seconds since the specified epoch time and stored in the standard cFE File " + "Header.\n"); printf(" where: YYYY=year, MM=month (01-12), DD=day (01-31), \n"); printf(" hh=hour (00-23), mm=minute (00-59), ss=seconds (00-59)\n"); - printf(" If no epoch is specified, the default epoch is either 1970:01:01:00:00:00 or the epoch specified\n"); + printf(" If no epoch is specified, the default epoch is either 1970:01:01:00:00:00 or the " + "epoch specified\n"); printf(" by the user using the '-f' option described below\n"); - printf(" This option requires the '-T' option, defined above, to be specified to have any effect\n"); - printf(" -fYYYY:MM:DD:hh:mm:ss specifies the file system epoch time. The SrcFilename's file creation time is obtained from the\n"); - printf(" file system as seconds since an epoch. On most systems the file system epoch is defined as\n"); - printf(" 1970:01:01:00:00:00. If the user is running this application on a machine with a different epoch,\n"); + printf(" This option requires the '-T' option, defined above, to be specified to have any " + "effect\n"); + printf(" -fYYYY:MM:DD:hh:mm:ss specifies the file system epoch time. The SrcFilename's file creation time is " + "obtained from the\n"); + printf(" file system as seconds since an epoch. On most systems the file system epoch is " + "defined as\n"); + printf(" 1970:01:01:00:00:00. If the user is running this application on a machine with a " + "different epoch,\n"); printf(" then the file system epoch should be defined with this option.\n"); printf(" where: YYYY=year, MM=month (01-12), DD=day (01-31), \n"); printf(" hh=hour (00-23), mm=minute (00-59), ss=seconds (00-59)\n"); printf(" If no epoch is specified, the default epoch is 1970:01:01:00:00:00\n"); - printf(" This option requires the '-T' option, defined above, to be specified to have any effect\n"); + printf(" This option requires the '-T' option, defined above, to be specified to have any " + "effect\n"); printf(" SrcFilename specifies the object file to be converted\n"); printf(" DestDirectory specifies the directory in which the cFE Table Image file is to be created.\n"); printf(" If a directory is not specified './' is assumed.\n"); @@ -1317,13 +1346,15 @@ void OutputHelpInfo(void) printf(" elf2cfetbl MyObjectFile ../../TblDefaultImgDir/\n"); printf(" elf2cfetbl -s12 -p0x0D -a016 -e2000:01:01:00:00:00 MyObjectFile ../../TblDefaultImgDir/\n"); printf("\n"); - printf("NOTE: The name of the target file is specified within the source file as part of the CFE_TBL_FILEDEF macro.\n"); - printf(" If the macro has not been included in the source file, the utility will fail to convert the object file.\n"); + printf("NOTE: The name of the target file is specified within the source file as part of the CFE_TBL_FILEDEF " + "macro.\n"); + printf(" If the macro has not been included in the source file, the utility will fail to convert the object " + "file.\n"); } /** -* -*/ + * + */ int32 GetSrcFilename(void) { @@ -1332,15 +1363,15 @@ int32 GetSrcFilename(void) if (strlen(SrcFilename) == 0) { OutputHelp = true; - Status = FAILED; + Status = FAILED; } return Status; } /** -* -*/ + * + */ int32 GetDstFilename(void) { @@ -1353,14 +1384,15 @@ int32 GetDstFilename(void) strcat(DstFilename, TblFileDef.TgtFilename); - if (Verbose) printf("Target Filename: %s\n", DstFilename); + if (Verbose) + printf("Target Filename: %s\n", DstFilename); return Status; } /** -* -*/ + * + */ int32 OpenSrcFile(void) { @@ -1381,12 +1413,16 @@ int32 OpenSrcFile(void) { SrcFileTimeInScEpoch = SrcFileStats.st_mtime + EpochDelta; - if (Verbose) printf("Original Source File Modification Time: %s\n", ctime(&SrcFileStats.st_mtime)); - if (Verbose) printf("Source File Modification Time in Seconds since S/C Epoch: %ld (0x%08lX)\n", SrcFileTimeInScEpoch, SrcFileTimeInScEpoch); + if (Verbose) + printf("Original Source File Modification Time: %s\n", ctime(&SrcFileStats.st_mtime)); + if (Verbose) + printf("Source File Modification Time in Seconds since S/C Epoch: %ld (0x%08lX)\n", SrcFileTimeInScEpoch, + SrcFileTimeInScEpoch); } - else + else { - if (Verbose) printf("Unable to get modification time from %s", SrcFilename); + if (Verbose) + printf("Unable to get modification time from %s", SrcFilename); SrcFileTimeInScEpoch = 0; } @@ -1408,15 +1444,15 @@ int32 OpenDstFile(void) } /** -* -*/ + * + */ int32 GetElfHeader(void) { - int32 Status = SUCCESS; - size_t NumHdrsRead = 0; - char VerboseStr[60]; - int32 EndiannessCheck=0x01020304; + int32 Status = SUCCESS; + size_t NumHdrsRead = 0; + char VerboseStr[60]; + int32 EndiannessCheck = 0x01020304; if (((char *)&EndiannessCheck)[0] == 0x01) { @@ -1425,7 +1461,8 @@ int32 GetElfHeader(void) else if (((char *)&EndiannessCheck)[0] != 0x04) { printf("Unable to determine endianness of this machine! (0x%02x, 0x%02x, 0x%02x, 0x%02x)\n", - ((char *)&EndiannessCheck)[0], ((char *)&EndiannessCheck)[1], ((char *)&EndiannessCheck)[2], ((char *)&EndiannessCheck)[3]); + ((char *)&EndiannessCheck)[0], ((char *)&EndiannessCheck)[1], ((char *)&EndiannessCheck)[2], + ((char *)&EndiannessCheck)[3]); return FAILED; } @@ -1438,16 +1475,21 @@ int32 GetElfHeader(void) return FAILED; } - if (Verbose) printf("ELF Header:\n"); - if (Verbose) printf(" e_ident[EI_MAG0..3] = 0x%02x,%c%c%c\n", - get_e_ident(&ElfHeader, EI_MAG0), get_e_ident(&ElfHeader, EI_MAG1), - get_e_ident(&ElfHeader, EI_MAG2), get_e_ident(&ElfHeader, EI_MAG3)); + if (Verbose) + printf("ELF Header:\n"); + if (Verbose) + printf(" e_ident[EI_MAG0..3] = 0x%02x,%c%c%c\n", get_e_ident(&ElfHeader, EI_MAG0), + get_e_ident(&ElfHeader, EI_MAG1), get_e_ident(&ElfHeader, EI_MAG2), get_e_ident(&ElfHeader, EI_MAG3)); /* Verify the ELF file magic number */ - if (get_e_ident(&ElfHeader, EI_MAG0) != ELFMAG0) Status = FAILED; - if (get_e_ident(&ElfHeader, EI_MAG1) != ELFMAG1) Status = FAILED; - if (get_e_ident(&ElfHeader, EI_MAG2) != ELFMAG2) Status = FAILED; - if (get_e_ident(&ElfHeader, EI_MAG3) != ELFMAG3) Status = FAILED; + if (get_e_ident(&ElfHeader, EI_MAG0) != ELFMAG0) + Status = FAILED; + if (get_e_ident(&ElfHeader, EI_MAG1) != ELFMAG1) + Status = FAILED; + if (get_e_ident(&ElfHeader, EI_MAG2) != ELFMAG2) + Status = FAILED; + if (get_e_ident(&ElfHeader, EI_MAG3) != ELFMAG3) + Status = FAILED; if (Status == FAILED) { @@ -1469,13 +1511,15 @@ int32 GetElfHeader(void) case ELFCLASS32: sprintf(VerboseStr, "ELFCLASS32 (1)"); - if (Verbose) printf("Target table is 32 bit\n"); + if (Verbose) + printf("Target table is 32 bit\n"); TargetWordsizeIs32Bit = true; break; case ELFCLASS64: sprintf(VerboseStr, "ELFCLASS64 (2)"); - if (Verbose) printf("Target table is 64 bit\n"); + if (Verbose) + printf("Target table is 64 bit\n"); TargetWordsizeIs32Bit = false; break; @@ -1492,7 +1536,8 @@ int32 GetElfHeader(void) return Status; } - if (Verbose) printf(" e_ident[EI_CLASS] = %s\n", VerboseStr); + if (Verbose) + printf(" e_ident[EI_CLASS] = %s\n", VerboseStr); /* Verify Data Encoding type */ switch (get_e_ident(&ElfHeader, EI_DATA)) @@ -1532,16 +1577,19 @@ int32 GetElfHeader(void) return Status; } - if (Verbose) printf(" e_ident[EI_DATA] = %s\n", VerboseStr); + if (Verbose) + printf(" e_ident[EI_DATA] = %s\n", VerboseStr); /* Verify ELF Header Version */ if (get_e_ident(&ElfHeader, EI_VERSION) != EV_CURRENT) { - printf("Source file '%s' is improper ELF header version (%d)\n", SrcFilename, get_e_ident(&ElfHeader, EI_VERSION)); + printf("Source file '%s' is improper ELF header version (%d)\n", SrcFilename, + get_e_ident(&ElfHeader, EI_VERSION)); return FAILED; } - if (Verbose) printf(" e_ident[EI_VERSION] = %d\n", get_e_ident(&ElfHeader, EI_VERSION)); + if (Verbose) + printf(" e_ident[EI_VERSION] = %d\n", get_e_ident(&ElfHeader, EI_VERSION)); // Now that e_ident is processed (with word size), read rest of the header if (TargetWordsizeIs32Bit) @@ -1573,7 +1621,8 @@ int32 GetElfHeader(void) return FAILED; } - if (Verbose) printf(" e_type = %s\n", VerboseStr); + if (Verbose) + printf(" e_type = %s\n", VerboseStr); /* Verify machine type */ Status = GetStringFromMap(&VerboseStr[0], e_machine_Map, (int32)get_e_machine(&ElfHeader)); @@ -1584,12 +1633,14 @@ int32 GetElfHeader(void) return FAILED; } - if (Verbose) printf(" e_machine = %s\n", VerboseStr); + if (Verbose) + printf(" e_machine = %s\n", VerboseStr); /* Verify ELF Object File Version */ if (get_e_version(&ElfHeader) != EV_CURRENT) { - printf("Error in source file '%s' - Improper ELF object version (%d)\n", SrcFilename, get_e_version(&ElfHeader)); + printf("Error in source file '%s' - Improper ELF object version (%d)\n", SrcFilename, + get_e_version(&ElfHeader)); return FAILED; } @@ -1605,27 +1656,27 @@ int32 GetElfHeader(void) } /** -* -*/ + * + */ int32 GetSectionHeader(int32 SectionIndex, union Elf_Shdr *SectionHeader) { - int32 Status = SUCCESS; + int32 Status = SUCCESS; size_t NumHdrsRead = 0; - char VerboseStr[60]; - int64 SeekOffset; - int32 Shentsize; - int32 i=0; + char VerboseStr[60]; + int64 SeekOffset; + int32 Shentsize; + int32 i = 0; if (TargetWordsizeIs32Bit) { SeekOffset = ElfHeader.Ehdr32.e_shoff; - Shentsize = ElfHeader.Ehdr32.e_shentsize; + Shentsize = ElfHeader.Ehdr32.e_shentsize; } else { SeekOffset = ElfHeader.Ehdr64.e_shoff; - Shentsize = ElfHeader.Ehdr64.e_shentsize; + Shentsize = ElfHeader.Ehdr64.e_shentsize; } if (SectionIndex > 0) @@ -1656,25 +1707,29 @@ int32 GetSectionHeader(int32 SectionIndex, union Elf_Shdr *SectionHeader) return FAILED; } - if (ByteSwapRequired == true) SwapSectionHeader(SectionHeader); + if (ByteSwapRequired == true) + SwapSectionHeader(SectionHeader); if ((SectionHeaderStringTableDataOffset != 0) && (get_sh_name(SectionHeader) != 0)) { - if (Verbose) printf("Section Header #%d:\n", SectionIndex); + if (Verbose) + printf("Section Header #%d:\n", SectionIndex); SeekOffset = SectionHeaderStringTableDataOffset + get_sh_name(SectionHeader); - if (Verbose) printf(" sh_name = 0x%08x - ", get_sh_name(SectionHeader)); + if (Verbose) + printf(" sh_name = 0x%08x - ", get_sh_name(SectionHeader)); fseek(SrcFileDesc, SeekOffset, SEEK_SET); while ((VerboseStr[i] = fgetc(SrcFileDesc)) != '\0') { i++; } - if (Verbose) printf("%s\n", VerboseStr); + if (Verbose) + printf("%s\n", VerboseStr); /* Save the name for later reference */ - strncpy(SectionNamePtrs[SectionIndex], VerboseStr, (MAX_SECTION_HDR_NAME_LEN-1)); - SectionNamePtrs[SectionIndex][(MAX_SECTION_HDR_NAME_LEN-1)] = '\0'; + strncpy(SectionNamePtrs[SectionIndex], VerboseStr, (MAX_SECTION_HDR_NAME_LEN - 1)); + SectionNamePtrs[SectionIndex][(MAX_SECTION_HDR_NAME_LEN - 1)] = '\0'; switch (get_sh_type(SectionHeader)) { @@ -1696,7 +1751,7 @@ int32 GetSectionHeader(int32 SectionIndex, union Elf_Shdr *SectionHeader) SymbolTableDataOffset = SectionHeader->Shdr64.sh_offset + sizeof(Elf64_Sym); } SymbolTableEntrySize = get_sh_entsize(SectionHeader); - NumSymbols = (get_sh_size(SectionHeader) / get_sh_entsize(SectionHeader)) - 1; + NumSymbols = (get_sh_size(SectionHeader) / get_sh_entsize(SectionHeader)) - 1; sprintf(VerboseStr, "SHT_SYMTAB (2) - # Symbols = %lu", (long unsigned int)NumSymbols); break; @@ -1765,9 +1820,11 @@ int32 GetSectionHeader(int32 SectionIndex, union Elf_Shdr *SectionHeader) break; } - if (Verbose) printf(" sh_type = %s\n", VerboseStr); + if (Verbose) + printf(" sh_type = %s\n", VerboseStr); - if (Verbose) print_sh_flags(SectionHeader); + if (Verbose) + print_sh_flags(SectionHeader); if (TargetWordsizeIs32Bit) { @@ -1783,17 +1840,17 @@ int32 GetSectionHeader(int32 SectionIndex, union Elf_Shdr *SectionHeader) } /** -* -*/ + * + */ int32 GetSymbol(int32 SymbolIndex, union Elf_Sym *Symbol) { - int32 Status = SUCCESS; - int32 NumSymRead = 0; + int32 Status = SUCCESS; + int32 NumSymRead = 0; uint64_t calculated_offset = SymbolTableDataOffset + (SymbolIndex * SymbolTableEntrySize); - int32_t SeekOffset = (int32_t) calculated_offset; - char VerboseStr[60]; - int32 i=0; + int32_t SeekOffset = (int32_t)calculated_offset; + char VerboseStr[60]; + int32 i = 0; if (SeekOffset != calculated_offset) { printf("Error: SeekOffset may not be %lu\n", (long unsigned int)calculated_offset); @@ -1825,33 +1882,37 @@ int32 GetSymbol(int32 SymbolIndex, union Elf_Sym *Symbol) return FAILED; } - if (ByteSwapRequired) SwapSymbol(Symbol); + if (ByteSwapRequired) + SwapSymbol(Symbol); - if (Verbose) printf("Symbol #%d:\n", (SymbolIndex+1)); + if (Verbose) + printf("Symbol #%d:\n", (SymbolIndex + 1)); SeekOffset = StringTableDataOffset + get_st_name(Symbol); - if (Verbose) printf(" st_name = 0x%08x - ", get_st_name(Symbol)); + if (Verbose) + printf(" st_name = 0x%08x - ", get_st_name(Symbol)); fseek(SrcFileDesc, SeekOffset, SEEK_SET); - while ((iSym32.st_value); - if (Verbose) printf(" st_size = 0x%08x\n", Symbol->Sym32.st_size); - if (Verbose) printf(" st_info = 0x%02x\n", Symbol->Sym32.st_info); - if (Verbose) printf(" st_other = 0x%02x\n", Symbol->Sym32.st_other); - if (Verbose) printf(" st_shndx = 0x%04x\n", Symbol->Sym32.st_shndx); + if (Verbose) + printf(" st_value = 0x%x\n", Symbol->Sym32.st_value); + if (Verbose) + printf(" st_size = 0x%08x\n", Symbol->Sym32.st_size); + if (Verbose) + printf(" st_info = 0x%02x\n", Symbol->Sym32.st_info); + if (Verbose) + printf(" st_other = 0x%02x\n", Symbol->Sym32.st_other); + if (Verbose) + printf(" st_shndx = 0x%04x\n", Symbol->Sym32.st_shndx); } void PrintSymbol64(union Elf_Sym *Symbol) { - if (Verbose) printf(" st_value = 0x%lx\n", (long unsigned int)Symbol->Sym64.st_value); - if (Verbose) printf(" st_size = 0x%08lx\n", (long unsigned int)Symbol->Sym64.st_size); - if (Verbose) printf(" st_info = 0x%02x\n", Symbol->Sym64.st_info); - if (Verbose) printf(" st_other = 0x%02x\n", Symbol->Sym64.st_other); - if (Verbose) printf(" st_shndx = 0x%04x\n", Symbol->Sym64.st_shndx); + if (Verbose) + printf(" st_value = 0x%lx\n", (long unsigned int)Symbol->Sym64.st_value); + if (Verbose) + printf(" st_size = 0x%08lx\n", (long unsigned int)Symbol->Sym64.st_size); + if (Verbose) + printf(" st_info = 0x%02x\n", Symbol->Sym64.st_info); + if (Verbose) + printf(" st_other = 0x%02x\n", Symbol->Sym64.st_other); + if (Verbose) + printf(" st_shndx = 0x%04x\n", Symbol->Sym64.st_shndx); } void PrintSectionHeader32(union Elf_Shdr *SectionHeader) { - if (Verbose) printf(" sh_addr = 0x%x\n", SectionHeader->Shdr32.sh_addr); - if (Verbose) printf(" sh_offset = 0x%08x\n", SectionHeader->Shdr32.sh_offset); - if (Verbose) printf(" sh_size = 0x%08x\n", SectionHeader->Shdr32.sh_size); - if (Verbose) printf(" sh_link = 0x%08x\n", SectionHeader->Shdr32.sh_link); - if (Verbose) printf(" sh_info = 0x%08x\n", SectionHeader->Shdr32.sh_info); - if (Verbose) printf(" sh_addralign = 0x%08x\n", SectionHeader->Shdr32.sh_addralign); - if (Verbose) printf(" sh_entsize = 0x%08x\n", SectionHeader->Shdr32.sh_entsize); + if (Verbose) + printf(" sh_addr = 0x%x\n", SectionHeader->Shdr32.sh_addr); + if (Verbose) + printf(" sh_offset = 0x%08x\n", SectionHeader->Shdr32.sh_offset); + if (Verbose) + printf(" sh_size = 0x%08x\n", SectionHeader->Shdr32.sh_size); + if (Verbose) + printf(" sh_link = 0x%08x\n", SectionHeader->Shdr32.sh_link); + if (Verbose) + printf(" sh_info = 0x%08x\n", SectionHeader->Shdr32.sh_info); + if (Verbose) + printf(" sh_addralign = 0x%08x\n", SectionHeader->Shdr32.sh_addralign); + if (Verbose) + printf(" sh_entsize = 0x%08x\n", SectionHeader->Shdr32.sh_entsize); } void PrintSectionHeader64(union Elf_Shdr *SectionHeader) { - if (Verbose) printf(" sh_addr = 0x%lx\n", (long unsigned int)SectionHeader->Shdr64.sh_addr); - if (Verbose) printf(" sh_offset = 0x%08lx\n", (long unsigned int)SectionHeader->Shdr64.sh_offset); - if (Verbose) printf(" sh_size = 0x%08lx\n", (long unsigned int)SectionHeader->Shdr64.sh_size); - if (Verbose) printf(" sh_link = 0x%08x\n", SectionHeader->Shdr64.sh_link); - if (Verbose) printf(" sh_info = 0x%08x\n", SectionHeader->Shdr64.sh_info); - if (Verbose) printf(" sh_addralign = 0x%08lx\n", (long unsigned int)SectionHeader->Shdr64.sh_addralign); - if (Verbose) printf(" sh_entsize = 0x%08lx\n", (long unsigned int)SectionHeader->Shdr64.sh_entsize); + if (Verbose) + printf(" sh_addr = 0x%lx\n", (long unsigned int)SectionHeader->Shdr64.sh_addr); + if (Verbose) + printf(" sh_offset = 0x%08lx\n", (long unsigned int)SectionHeader->Shdr64.sh_offset); + if (Verbose) + printf(" sh_size = 0x%08lx\n", (long unsigned int)SectionHeader->Shdr64.sh_size); + if (Verbose) + printf(" sh_link = 0x%08x\n", SectionHeader->Shdr64.sh_link); + if (Verbose) + printf(" sh_info = 0x%08x\n", SectionHeader->Shdr64.sh_info); + if (Verbose) + printf(" sh_addralign = 0x%08lx\n", (long unsigned int)SectionHeader->Shdr64.sh_addralign); + if (Verbose) + printf(" sh_entsize = 0x%08lx\n", (long unsigned int)SectionHeader->Shdr64.sh_entsize); } void PrintElfHeader32(union Elf_Ehdr ElfHeader) { - if (Verbose) printf(" e_version = %d\n", get_e_version(&ElfHeader)); - if (Verbose) printf(" e_entry = 0x%x\n", ElfHeader.Ehdr32.e_entry); - if (Verbose) printf(" e_phoff = 0x%08x (%u)\n", ElfHeader.Ehdr32.e_phoff, ElfHeader.Ehdr32.e_phoff); - if (Verbose) printf(" e_shoff = 0x%08x (%u)\n", ElfHeader.Ehdr32.e_shoff, ElfHeader.Ehdr32.e_shoff); - if (Verbose) printf(" e_flags = 0x%08x\n", ElfHeader.Ehdr32.e_flags); - if (Verbose) printf(" e_ehsize = %d\n", ElfHeader.Ehdr32.e_ehsize); - if (Verbose) printf(" e_phentsize = %d\n", ElfHeader.Ehdr32.e_phentsize); - if (Verbose) printf(" e_phnum = %d\n", ElfHeader.Ehdr32.e_phnum); - if (Verbose) printf(" e_shentsize = %d\n", ElfHeader.Ehdr32.e_shentsize); - if (Verbose) printf(" e_shnum = %d\n", get_e_shnum(&ElfHeader)); - if (Verbose) printf(" e_shstrndx = %d\n", get_e_shstrndx(&ElfHeader)); + if (Verbose) + printf(" e_version = %d\n", get_e_version(&ElfHeader)); + if (Verbose) + printf(" e_entry = 0x%x\n", ElfHeader.Ehdr32.e_entry); + if (Verbose) + printf(" e_phoff = 0x%08x (%u)\n", ElfHeader.Ehdr32.e_phoff, ElfHeader.Ehdr32.e_phoff); + if (Verbose) + printf(" e_shoff = 0x%08x (%u)\n", ElfHeader.Ehdr32.e_shoff, ElfHeader.Ehdr32.e_shoff); + if (Verbose) + printf(" e_flags = 0x%08x\n", ElfHeader.Ehdr32.e_flags); + if (Verbose) + printf(" e_ehsize = %d\n", ElfHeader.Ehdr32.e_ehsize); + if (Verbose) + printf(" e_phentsize = %d\n", ElfHeader.Ehdr32.e_phentsize); + if (Verbose) + printf(" e_phnum = %d\n", ElfHeader.Ehdr32.e_phnum); + if (Verbose) + printf(" e_shentsize = %d\n", ElfHeader.Ehdr32.e_shentsize); + if (Verbose) + printf(" e_shnum = %d\n", get_e_shnum(&ElfHeader)); + if (Verbose) + printf(" e_shstrndx = %d\n", get_e_shstrndx(&ElfHeader)); } void PrintElfHeader64(union Elf_Ehdr ElfHeader) { - if (Verbose) printf(" e_version = %d\n", get_e_version(&ElfHeader)); - if (Verbose) printf(" e_entry = 0x%lx\n", (long unsigned int)ElfHeader.Ehdr64.e_entry); - if (Verbose) printf(" e_phoff = 0x%08lx (%lu)\n", (long unsigned int)ElfHeader.Ehdr64.e_phoff, (long unsigned int)ElfHeader.Ehdr64.e_phoff); - if (Verbose) printf(" e_shoff = 0x%08lx (%lu)\n", (long unsigned int)ElfHeader.Ehdr64.e_shoff, (long unsigned int)ElfHeader.Ehdr64.e_shoff); - if (Verbose) printf(" e_flags = 0x%08x\n", ElfHeader.Ehdr64.e_flags); - if (Verbose) printf(" e_ehsize = %d\n", ElfHeader.Ehdr64.e_ehsize); - if (Verbose) printf(" e_phentsize = %d\n", ElfHeader.Ehdr64.e_phentsize); - if (Verbose) printf(" e_phnum = %d\n", ElfHeader.Ehdr64.e_phnum); - if (Verbose) printf(" e_shentsize = %d\n", ElfHeader.Ehdr64.e_shentsize); - if (Verbose) printf(" e_shnum = %d\n", get_e_shnum(&ElfHeader)); - if (Verbose) printf(" e_shstrndx = %d\n", get_e_shstrndx(&ElfHeader)); + if (Verbose) + printf(" e_version = %d\n", get_e_version(&ElfHeader)); + if (Verbose) + printf(" e_entry = 0x%lx\n", (long unsigned int)ElfHeader.Ehdr64.e_entry); + if (Verbose) + printf(" e_phoff = 0x%08lx (%lu)\n", (long unsigned int)ElfHeader.Ehdr64.e_phoff, + (long unsigned int)ElfHeader.Ehdr64.e_phoff); + if (Verbose) + printf(" e_shoff = 0x%08lx (%lu)\n", (long unsigned int)ElfHeader.Ehdr64.e_shoff, + (long unsigned int)ElfHeader.Ehdr64.e_shoff); + if (Verbose) + printf(" e_flags = 0x%08x\n", ElfHeader.Ehdr64.e_flags); + if (Verbose) + printf(" e_ehsize = %d\n", ElfHeader.Ehdr64.e_ehsize); + if (Verbose) + printf(" e_phentsize = %d\n", ElfHeader.Ehdr64.e_phentsize); + if (Verbose) + printf(" e_phnum = %d\n", ElfHeader.Ehdr64.e_phnum); + if (Verbose) + printf(" e_shentsize = %d\n", ElfHeader.Ehdr64.e_shentsize); + if (Verbose) + printf(" e_shnum = %d\n", get_e_shnum(&ElfHeader)); + if (Verbose) + printf(" e_shstrndx = %d\n", get_e_shstrndx(&ElfHeader)); } void SwapElfHeader(void) @@ -1973,10 +2082,10 @@ void SwapElfHeader(void) } /** -* -*/ + * + */ -void SwapSectionHeader(union Elf_Shdr *SectionHeader) +void SwapSectionHeader(union Elf_Shdr *SectionHeader) { if (TargetWordsizeIs32Bit) { @@ -2007,10 +2116,10 @@ void SwapSectionHeader(union Elf_Shdr *SectionHeader) } /** -* -*/ + * + */ -void SwapSymbol(union Elf_Sym *Symbol) +void SwapSymbol(union Elf_Sym *Symbol) { if (TargetWordsizeIs32Bit) { @@ -2029,30 +2138,30 @@ void SwapSymbol(union Elf_Sym *Symbol) } /** -* -*/ + * + */ void SwapUInt16(uint16 *ValueToSwap) { - uint8 *BytePtr = (uint8 *)ValueToSwap; + uint8 *BytePtr = (uint8 *)ValueToSwap; uint8 TempByte = BytePtr[1]; - BytePtr[1] = BytePtr[0]; - BytePtr[0] = TempByte; + BytePtr[1] = BytePtr[0]; + BytePtr[0] = TempByte; } /** -* -*/ + * + */ void SwapUInt32(uint32 *ValueToSwap) { - uint8 *BytePtr = (uint8 *)ValueToSwap; + uint8 *BytePtr = (uint8 *)ValueToSwap; uint8 TempByte = BytePtr[3]; - BytePtr[3] = BytePtr[0]; - BytePtr[0] = TempByte; - TempByte = BytePtr[2]; - BytePtr[2] = BytePtr[1]; - BytePtr[1] = TempByte; + BytePtr[3] = BytePtr[0]; + BytePtr[0] = TempByte; + TempByte = BytePtr[2]; + BytePtr[2] = BytePtr[1]; + BytePtr[1] = TempByte; } void SwapUInt64(uint64 *ValueToSwap) @@ -2060,7 +2169,7 @@ void SwapUInt64(uint64 *ValueToSwap) uint8 *BytePtr = (uint8 *)ValueToSwap; uint8 TempByte; - TempByte = BytePtr[7]; + TempByte = BytePtr[7]; BytePtr[7] = BytePtr[0]; BytePtr[0] = TempByte; @@ -2078,8 +2187,8 @@ void SwapUInt64(uint64 *ValueToSwap) } /** -* -*/ + * + */ int32 GetStringFromMap(char *Result, ElfStrMap *Map, int32 Key) { @@ -2107,17 +2216,18 @@ int32 GetStringFromMap(char *Result, ElfStrMap *Map, int32 Key) } /** -* -*/ + * + */ int32 GetTblDefInfo(void) { - int32 Status = SUCCESS; - uint32 SeekOffset = 0; - int32 NumDefsRead = 0; + int32 Status = SUCCESS; + uint32 SeekOffset = 0; + int32 NumDefsRead = 0; /* Read the data to be used to format the CFE File and Table Headers */ - if ((get_st_size(SymbolPtrs[TblDefSymbolIndex]) != sizeof(CFE_TBL_FileDef_t)) && (get_st_size(SymbolPtrs[TblDefSymbolIndex]) != 0)) + if ((get_st_size(SymbolPtrs[TblDefSymbolIndex]) != sizeof(CFE_TBL_FileDef_t)) && + (get_st_size(SymbolPtrs[TblDefSymbolIndex]) != 0)) { printf("Error! '%s' is not properly defined in '%s'. Size of object is incorrect (%lu).\n", TBL_DEF_SYMBOL_NAME, SrcFilename, (long unsigned int)get_st_size(SymbolPtrs[TblDefSymbolIndex])); @@ -2126,8 +2236,9 @@ int32 GetTblDefInfo(void) else { // fseek expects a long int, sh_offset and st_value are uint64 for elf64 - uint64_t calculated_offset = get_sh_offset(SectionHeaderPtrs[get_st_shndx(SymbolPtrs[TblDefSymbolIndex])]) + get_st_value(SymbolPtrs[TblDefSymbolIndex]); - SeekOffset = (uint32_t) (calculated_offset); + uint64_t calculated_offset = get_sh_offset(SectionHeaderPtrs[get_st_shndx(SymbolPtrs[TblDefSymbolIndex])]) + + get_st_value(SymbolPtrs[TblDefSymbolIndex]); + SeekOffset = (uint32_t)(calculated_offset); if (SeekOffset != calculated_offset) { printf("Error: SeekOffset may not be %lu\n", (long unsigned int)calculated_offset); @@ -2142,7 +2253,8 @@ int32 GetTblDefInfo(void) Status = FAILED; } - if (ByteSwapRequired) SwapUInt32(&TblFileDef.ObjectSize); + if (ByteSwapRequired) + SwapUInt32(&TblFileDef.ObjectSize); if (Verbose) { @@ -2169,50 +2281,57 @@ int32 GetTblDefInfo(void) } /** -* -*/ + * + */ int32 LocateAndReadUserObject(void) { - int32 Status = SUCCESS; - int32 i=0; - int32 j=0; + int32 Status = SUCCESS; + int32 i = 0; + int32 j = 0; uint32 SeekOffset = 0; uint8 AByte; /* Search the symbol table for the user defined object */ - if (Verbose) printf("\nTrying to match ObjectName '%s'... (length %lu)",TblFileDef.ObjectName,(long unsigned int)strlen(TblFileDef.ObjectName)); - while (i Date: Fri, 29 May 2020 18:18:03 -0400 Subject: [PATCH 2/2] Increase version to 3.1.5 and update Readme --- README.md | 5 +++++ elf2cfetbl.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0232650..4a67ade 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,11 @@ See README.txt for more information. ## Version History +### Development Build: 3.1.5 + +- Apply code style +- See + ### Development Build: 3.1.4 - Fix string termination warnings in GCC9 diff --git a/elf2cfetbl.c b/elf2cfetbl.c index a4a6d7b..737f338 100644 --- a/elf2cfetbl.c +++ b/elf2cfetbl.c @@ -1273,7 +1273,7 @@ int32 ProcessCmdLineOptions(int ArgumentCount, char *Arguments[]) void OutputVersionInfo(void) { printf("\nElf Object File to cFE Table Image File Conversion Tool\n"); - printf(" Version v3.1.4\n"); + printf(" Version v3.1.5\n"); printf(" Built - %s %s\n\n", __DATE__, __TIME__); }