#include <stdlib.h>
#include <errno.h>
#include <string.h>
+#include <stdint.h>
#define ELF_FORMAT 0x464c457f
-typedef unsigned short uint16_t;
-typedef unsigned int uint32_t;
-typedef int int32_t;
-
typedef uint16_t Elf32_Half;
typedef uint32_t Elf32_Word;
typedef int32_t Elf32_Sword;
}
/* Memory Allocation for Segment and Section entries */
- pSegmentEntries = (Elf32_Phdr *)malloc(elfHeader.e_phentsize * elfHeader.e_phnum);
+ pSegmentEntries = (Elf32_Phdr *)malloc((uint64_t)elfHeader.e_phentsize * (uint64_t)elfHeader.e_phnum);
if (pSegmentEntries == NULL) {
printf("error[%s] : memory allocation <pSegmentEntries>\n", fileName);
exit_status = EXIT_FAILURE;
goto finalize;
}
- if (!fread(pSegmentEntries, elfHeader.e_phentsize * elfHeader.e_phnum, 1, fp)) {
+ if (!fread(pSegmentEntries, (uint64_t)elfHeader.e_phentsize * (uint64_t)elfHeader.e_phnum, 1, fp)) {
printf("error[%s] : file read <pSegmentEntries>\n", fileName);
exit_status = EXIT_FAILURE;
goto finalize;
#include <errno.h>
#include <string.h>
#include <elf.h>
+#include <stdint.h>
#define ELF_FORMAT 0x464c457f
#define DT_GARBAGE 0xffffffff /* End of processor-specific */
}
/* Memory Allocation for Segment and Section entries */
- pSegmentEntries = (Elf64_Phdr *)malloc(elfHeader.e_phentsize * elfHeader.e_phnum);
+ pSegmentEntries = (Elf64_Phdr *)malloc((uint64_t)elfHeader.e_phentsize * (uint64_t)elfHeader.e_phnum);
if (pSegmentEntries == NULL) {
printf("error[%s] : memory allocation <pSegmentEntries>\n", fileName);
exit_status = EXIT_FAILURE;
goto finalize;
}
- if (!fread(pSegmentEntries, elfHeader.e_phentsize * elfHeader.e_phnum, 1, fp)) {
+ if (!fread(pSegmentEntries, (uint64_t)elfHeader.e_phentsize * (uint64_t)elfHeader.e_phnum, 1, fp)) {
printf("error[%s] : file read <pSegmentEntries>\n", fileName);
exit_status = EXIT_FAILURE;
goto finalize;