diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Kconfig | 59 | ||||
-rw-r--r-- | tools/imx8image.c | 79 | ||||
-rw-r--r-- | tools/imx8mimage.c | 89 | ||||
-rw-r--r-- | tools/relocate-rela.c | 151 |
4 files changed, 296 insertions, 82 deletions
diff --git a/tools/Kconfig b/tools/Kconfig index 117c921da3..539708f277 100644 --- a/tools/Kconfig +++ b/tools/Kconfig @@ -98,4 +98,63 @@ config TOOLS_MKEFICAPSULE optionally sign that file. If you want to enable UEFI capsule update feature on your target, you certainly need this. +menuconfig FSPI_CONF_HEADER + bool "FlexSPI Header Configuration" + help + FSPI Header Configuration + +config FSPI_CONF_FILE + string "FlexSPI Header File" + depends on FSPI_CONF_HEADER + help + FlexSPI Header File name + +config READ_CLK_SOURCE + hex "Sampling Clock Source" + default 0x00 + depends on FSPI_CONF_HEADER + help + Sample Clock source for Flash, default is internal loopback clock + +config DEVICE_TYPE + hex "Flash Type" + default 0x01 + depends on FSPI_CONF_HEADER + help + Flash type: Serial NOR (0X01) and Serial NAND (0x02) + +config FLASH_PAD_TYPE + hex "Flash Pad Type" + default 0x01 + depends on FSPI_CONF_HEADER + help + Flash Pad type : + Single Pad 0x01 + Dual Pads 0x02 + Quad Pad 0x04 + Octal Pad 0x08 + +config SERIAL_CLK_FREQUENCY + hex "Serial Clock Frequency" + default 0x02 + depends on FSPI_CONF_HEADER + help + Chip specific frequency: other value 30MHz + 1-30MHz 2-50MHz 3-60MHz 4-75MHz 5-80MHz 6-100MHz 7-133MHz 8-166MHz + +config LUT_CUSTOM_SEQUENCE + hex "Enable Custom Look Up Table(LUT) Sequence" + default 0x00 + depends on FSPI_CONF_HEADER + help + 0 - Use predefined LUT Sequence + 1 - Use LUT Sequence provided + +config LUT_SEQUENCE + string "Look Up Table Sequence" + default "0x0b, 0x04, 0x18, 0x08, 0x08, 0x30, 0x04, 0x24" + depends on FSPI_CONF_HEADER + help + Look Up Table Sequence + endmenu diff --git a/tools/imx8image.c b/tools/imx8image.c index fa8f227487..01e1486911 100644 --- a/tools/imx8image.c +++ b/tools/imx8image.c @@ -60,6 +60,7 @@ static table_entry_t imx8image_core_entries[] = { {CFG_M40, "M40", "M4 core 0", }, {CFG_M41, "M41", "M4 core 1", }, {CFG_A35, "A35", "A35 core", }, + {CFG_A55, "A55", "A55 core", }, {CFG_A53, "A53", "A53 core", }, {CFG_A72, "A72", "A72 core", }, {-1, "", "", }, @@ -117,6 +118,10 @@ static void parse_cfg_cmd(image_t *param_stack, int32_t cmd, char *token, soc = QX; } else if (!strncmp(token, "IMX8QM", 6)) { soc = QM; + } else if (!strncmp(token, "ULP", 3)) { + soc = IMX9; + } else if (!strncmp(token, "IMX9", 4)) { + soc = IMX9; } else { fprintf(stderr, "Unknown CMD_SOC_TYPE"); exit(EXIT_FAILURE); @@ -187,6 +192,7 @@ static void parse_cfg_fld(image_t *param_stack, int32_t *cmd, char *token, param_stack[p_idx].filename = token; break; case CFG_A35: + case CFG_A55: param_stack[p_idx].ext = CORE_CA35; param_stack[p_idx].option = (*cmd == CMD_DATA) ? DATA : AP; @@ -219,6 +225,7 @@ static void parse_cfg_fld(image_t *param_stack, int32_t *cmd, char *token, case CFG_M41: case CFG_A35: case CFG_A53: + case CFG_A55: case CFG_A72: param_stack[p_idx++].entry = (uint32_t)strtoll(token, NULL, 0); @@ -548,6 +555,18 @@ static void set_image_array_entry(flash_header_v3_t *container, img->dst = 0x20C00000; img->entry = 0x20000000; break; + case SENTINEL: + if (container->num_images > 0) { + fprintf(stderr, "Error: SENTINEL container only allows 1 image\n"); + return; + } + + img->hab_flags |= IMG_TYPE_SENTINEL; + img->hab_flags |= CORE_ULP_SENTINEL << BOOT_IMG_FLAGS_CORE_SHIFT; + tmp_name = "SENTINEL"; + img->dst = 0xe4000000; /* S400 IRAM base */ + img->entry = 0xe4000000; + break; case AP: if (soc == QX && core == CORE_CA35) { meta = IMAGE_A35_DEFAULT_META(custom_partition); @@ -555,6 +574,8 @@ static void set_image_array_entry(flash_header_v3_t *container, meta = IMAGE_A53_DEFAULT_META(custom_partition); } else if (soc == QM && core == CORE_CA72) { meta = IMAGE_A72_DEFAULT_META(custom_partition); + } else if (((soc == ULP) || (soc == IMX9)) && core == CORE_CA35) { + meta = 0; } else { fprintf(stderr, "Error: invalid AP core id: %" PRIu64 "\n", @@ -562,8 +583,10 @@ static void set_image_array_entry(flash_header_v3_t *container, exit(EXIT_FAILURE); } img->hab_flags |= IMG_TYPE_EXEC; - /* On B0, only core id = 4 is valid */ - img->hab_flags |= CORE_CA53 << BOOT_IMG_FLAGS_CORE_SHIFT; + if ((soc == ULP) || (soc == IMX9)) + img->hab_flags |= CORE_ULP_CA35 << BOOT_IMG_FLAGS_CORE_SHIFT; + else + img->hab_flags |= CORE_CA53 << BOOT_IMG_FLAGS_CORE_SHIFT; /* On B0, only core id = 4 is valid */ tmp_name = "AP"; img->dst = entry; img->entry = entry; @@ -572,17 +595,22 @@ static void set_image_array_entry(flash_header_v3_t *container, break; case M40: case M41: - if (core == 0) { - core = CORE_CM4_0; - meta = IMAGE_M4_0_DEFAULT_META(custom_partition); - } else if (core == 1) { - core = CORE_CM4_1; - meta = IMAGE_M4_1_DEFAULT_META(custom_partition); + if ((soc == ULP) || (soc == IMX9)) { + core = CORE_ULP_CM33; + meta = 0; } else { - fprintf(stderr, - "Error: invalid m4 core id: %" PRIu64 "\n", - core); - exit(EXIT_FAILURE); + if (core == 0) { + core = CORE_CM4_0; + meta = IMAGE_M4_0_DEFAULT_META(custom_partition); + } else if (core == 1) { + core = CORE_CM4_1; + meta = IMAGE_M4_1_DEFAULT_META(custom_partition); + } else { + fprintf(stderr, + "Error: invalid m4 core id: %" PRIu64 "\n", + core); + exit(EXIT_FAILURE); + } } img->hab_flags |= IMG_TYPE_EXEC; img->hab_flags |= core << BOOT_IMG_FLAGS_CORE_SHIFT; @@ -598,7 +626,14 @@ static void set_image_array_entry(flash_header_v3_t *container, break; case DATA: img->hab_flags |= IMG_TYPE_DATA; - img->hab_flags |= CORE_CA35 << BOOT_IMG_FLAGS_CORE_SHIFT; + if ((soc == ULP) || (soc == IMX9)) { + if (core == CORE_CM4_0) + img->hab_flags |= CORE_ULP_CM33 << BOOT_IMG_FLAGS_CORE_SHIFT; + else + img->hab_flags |= CORE_ULP_CA35 << BOOT_IMG_FLAGS_CORE_SHIFT; + } else { + img->hab_flags |= CORE_CA35 << BOOT_IMG_FLAGS_CORE_SHIFT; + } tmp_name = "DATA"; img->dst = entry; break; @@ -630,6 +665,15 @@ static void set_image_array_entry(flash_header_v3_t *container, img->dst = img->entry - 1; } break; + case UPOWER: + if (soc == ULP) { + img->hab_flags |= IMG_TYPE_EXEC; + img->hab_flags |= CORE_ULP_UPOWER << BOOT_IMG_FLAGS_CORE_SHIFT; + tmp_name = "UPOWER"; + img->dst = 0x28300200; /* UPOWER code RAM */ + img->entry = 0x28300200; + } + break; default: fprintf(stderr, "unrecognized image type (%d)\n", type); exit(EXIT_FAILURE); @@ -797,6 +841,10 @@ static int build_container(soc_type_t soc, uint32_t sector_size, fprintf(stdout, "Platform:\ti.MX8QXP B0\n"); else if (soc == QM) fprintf(stdout, "Platform:\ti.MX8QM B0\n"); + else if (soc == ULP) + fprintf(stdout, "Platform:\ti.MX8ULP A0\n"); + else if (soc == IMX9) + fprintf(stdout, "Platform:\ti.MX9\n"); set_imx_hdr_v3(&imx_header, 0); set_imx_hdr_v3(&imx_header, 1); @@ -815,6 +863,7 @@ static int build_container(soc_type_t soc, uint32_t sector_size, case M41: case SCFW: case DATA: + case UPOWER: case MSG_BLOCK: if (container < 0) { fprintf(stderr, "No container found\n"); @@ -833,6 +882,7 @@ static int build_container(soc_type_t soc, uint32_t sector_size, break; case SECO: + case SENTINEL: if (container < 0) { fprintf(stderr, "No container found\n"); exit(EXIT_FAILURE); @@ -941,7 +991,8 @@ static int build_container(soc_type_t soc, uint32_t sector_size, if (img_sp->option == M40 || img_sp->option == M41 || img_sp->option == AP || img_sp->option == DATA || img_sp->option == SCD || img_sp->option == SCFW || - img_sp->option == SECO || img_sp->option == MSG_BLOCK) { + img_sp->option == SECO || img_sp->option == MSG_BLOCK || + img_sp->option == UPOWER || img_sp->option == SENTINEL) { copy_file_aligned(ofd, img_sp->filename, img_sp->src, sector_size); } diff --git a/tools/imx8mimage.c b/tools/imx8mimage.c index 4eed683396..a4699decf9 100644 --- a/tools/imx8mimage.c +++ b/tools/imx8mimage.c @@ -120,7 +120,6 @@ static void parse_cfg_cmd(int32_t cmd, char *token, char *name, int lineno) rom_version = ROM_V1; } break; - } } @@ -412,9 +411,75 @@ static void dump_header_v2(imx_header_v3_t *imx_header, int index) imx_header[index].boot_data.plugin); } +#ifdef CONFIG_FSPI_CONF_HEADER +static int generate_fspi_header (int ifd) +{ + int ret, i = 0; + char *val; + char lut_str[] = CONFIG_LUT_SEQUENCE; + + fspi_conf fspi_conf_data = { + .tag = {0x46, 0x43, 0x46, 0x42}, + .version = {0x00, 0x00, 0x01, 0x56}, + .reserved_1 = {0x00, 0x00, 0x00, 0x00}, + .read_sample = CONFIG_READ_CLK_SOURCE, + .datahold = 0x03, + .datasetup = 0x03, + .coladdrwidth = 0x00, + .devcfgenable = 0x00, + .reserved_2 = {0x00, 0x00, 0x00}, + .devmodeseq = {0x00, 0x00, 0x00, 0x00}, + .devmodearg = {0x00, 0x00, 0x00, 0x00}, + .cmd_enable = 0x00, + .reserved_3 = {0x00}, + .cmd_seq = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + .cmd_arg = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + .controllermisc = {0x00, 0x00, 0x00, 0x00}, + .dev_type = CONFIG_DEVICE_TYPE, + .sflash_pad = CONFIG_FLASH_PAD_TYPE, + .serial_clk = CONFIG_SERIAL_CLK_FREQUENCY, + .lut_custom = CONFIG_LUT_CUSTOM_SEQUENCE, + .reserved_4 = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + .sflashA1 = {0x00, 0x00, 0x00, 0x10}, + .sflashA2 = {0x00, 0x00, 0x00, 0x00}, + .sflashB1 = {0x00, 0x00, 0x00, 0x00}, + .sflashB2 = {0x00, 0x00, 0x00, 0x00}, + .cspadover = {0x00, 0x00, 0x00, 0x00}, + .sclkpadover = {0x00, 0x00, 0x00, 0x00}, + .datapadover = {0x00, 0x00, 0x00, 0x00}, + .dqspadover = {0x00, 0x00, 0x00, 0x00}, + .timeout = {0x00, 0x00, 0x00, 0x00}, + .commandInt = {0x00, 0x00, 0x00, 0x00}, + .datavalid = {0x00, 0x00, 0x00, 0x00}, + .busyoffset = {0x00, 0x00}, + .busybitpolarity = {0x00, 0x00}, + }; + + for (val = strtok(lut_str, ","); val; val = strtok(NULL, ",")) { + fspi_conf_data.lut[i++] = strtoul(val, NULL, 16); + } + + ret = lseek(ifd, 0, SEEK_CUR); + if (write(ifd, &fspi_conf_data, sizeof(fspi_conf_data)) == -1) + exit(EXIT_FAILURE); + + ret = lseek(ifd, sizeof(fspi_conf_data), SEEK_CUR); + + return ret; +} +#endif + void build_image(int ofd) { int file_off, header_hdmi_off = 0, header_image_off; + +#ifdef CONFIG_FSPI_CONF_HEADER + int fspi_off, fspi_fd; + char *fspi; +#endif + int hdmi_fd, ap_fd, sld_fd; uint32_t sld_load_addr = 0; uint32_t csf_off, sld_csf_off = 0; @@ -455,6 +520,20 @@ void build_image(int ofd) header_image_off = file_off + ivt_offset; +#ifdef CONFIG_FSPI_CONF_HEADER + fspi = CONFIG_FSPI_CONF_FILE; + fspi_fd = open(fspi, O_RDWR | O_CREAT, S_IRWXU); + if (fspi_fd < 0) { + fprintf(stderr, "Can't open %s: %s\n", + fspi, strerror(errno)); + exit(EXIT_FAILURE); + } + + fspi_off = generate_fspi_header(fspi_fd); + file_off = header_image_off + fspi_off; + close(fspi_fd); + +#endif ap_fd = open(ap_img, O_RDONLY | O_BINARY); if (ap_fd < 0) { fprintf(stderr, "%s: Can't open: %s\n", @@ -505,14 +584,6 @@ void build_image(int ofd) exit(EXIT_FAILURE); } else { sld_header_off = sld_src_off - rom_image_offset; - /* - * Record the second bootloader relative offset in - * image's IVT reserved1 - */ - if (rom_version == ROM_V1) { - imx_header[IMAGE_IVT_ID].fhdr.reserved1 = - sld_header_off - header_image_off; - } sld_fd = open(sld_img, O_RDONLY | O_BINARY); if (sld_fd < 0) { fprintf(stderr, "%s: Can't open: %s\n", diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c index 090fb1acb2..2d2a2ed277 100644 --- a/tools/relocate-rela.c +++ b/tools/relocate-rela.c @@ -16,10 +16,34 @@ #include <string.h> #include "compiler.h" +#ifndef EM_AARCH64 +#define EM_AARCH64 183 +#endif + #ifndef R_AARCH64_RELATIVE #define R_AARCH64_RELATIVE 1027 #endif +#ifndef EM_MICROBLAZE +#define EM_MICROBLAZE 189 +#endif + +#ifndef R_MICROBLAZE_NONE +#define R_MICROBLAZE_NONE 0 +#endif + +#ifndef R_MICROBLAZE_32 +#define R_MICROBLAZE_32 1 +#endif + +#ifndef R_MICROBLAZE_REL +#define R_MICROBLAZE_REL 16 +#endif + +#ifndef R_MICROBLAZE_GLOB_DAT +#define R_MICROBLAZE_GLOB_DAT 18 +#endif + static int ei_class; static uint64_t rela_start, rela_end, text_base, dyn_start; @@ -43,10 +67,8 @@ static bool supported_rela(Elf64_Rela *rela) uint32_t type = rela->r_info & mask; switch (type) { -#ifdef R_AARCH64_RELATIVE case R_AARCH64_RELATIVE: return true; -#endif default: fprintf(stderr, "warning: unsupported relocation type %" PRIu32 " at %" PRIx64 "\n", @@ -60,7 +82,9 @@ static int decode_elf64(FILE *felf, char **argv) { size_t size; Elf64_Ehdr header; - uint64_t section_header_base, section_header_size, sh_offset, sh_size; + uint64_t section_header_base, section_header_size; + uint64_t sh_addr, sh_offset, sh_size; + Elf64_Half sh_index, sh_num; Elf64_Shdr *sh_table; /* Elf symbol table */ int ret, i, machine; char *sh_str; @@ -76,7 +100,7 @@ static int decode_elf64(FILE *felf, char **argv) return 25; } - machine = header.e_machine; + machine = le16_to_cpu(header.e_machine); debug("Machine\t%d\n", machine); if (machine != EM_AARCH64) { @@ -84,9 +108,10 @@ static int decode_elf64(FILE *felf, char **argv) return 30; } - text_base = header.e_entry; - section_header_base = header.e_shoff; - section_header_size = header.e_shentsize * header.e_shnum; + text_base = le64_to_cpu(header.e_entry); + section_header_base = le64_to_cpu(header.e_shoff); + section_header_size = le16_to_cpu(header.e_shentsize) * + le16_to_cpu(header.e_shnum); sh_table = malloc(section_header_size); if (!sh_table) { @@ -114,9 +139,9 @@ static int decode_elf64(FILE *felf, char **argv) return 27; } - sh_size = sh_table[header.e_shstrndx].sh_size; - debug("e_shstrndx\t0x%08x\n", header.e_shstrndx); - debug("sh_size\t\t0x%08lx\n", sh_size); + sh_index = le16_to_cpu(header.e_shstrndx); + sh_size = le64_to_cpu(sh_table[sh_index].sh_size); + debug("e_shstrndx %x, sh_size %lx\n", sh_index, sh_size); sh_str = malloc(sh_size); if (!sh_str) { @@ -130,9 +155,8 @@ static int decode_elf64(FILE *felf, char **argv) * Specifies the byte offset from the beginning of the file * to the first byte in the section. */ - sh_offset = sh_table[header.e_shstrndx].sh_offset; - - debug("sh_offset\t0x%08x\n", header.e_shnum); + sh_offset = le64_to_cpu(sh_table[sh_index].sh_offset); + sh_num = le16_to_cpu(header.e_shnum); ret = fseek(felf, sh_offset, SEEK_SET); if (ret) { @@ -153,18 +177,22 @@ static int decode_elf64(FILE *felf, char **argv) return 30; } - for (i = 0; i < header.e_shnum; i++) { - /* fprintf(stderr, "%s\n", sh_str + sh_table[i].sh_name); Debug only */ - if (!strcmp(".rela.dyn", (sh_str + sh_table[i].sh_name))) { + for (i = 0; i < sh_num; i++) { + char *sh_name = sh_str + le32_to_cpu(sh_table[i].sh_name); + + debug("%s\n", sh_name); + + sh_addr = le64_to_cpu(sh_table[i].sh_addr); + sh_offset = le64_to_cpu(sh_table[i].sh_offset); + sh_size = le64_to_cpu(sh_table[i].sh_size); + + if (!strcmp(".rela.dyn", sh_name)) { debug("Found section\t\".rela_dyn\"\n"); - debug(" at addr\t0x%08x\n", - (unsigned int)sh_table[i].sh_addr); - debug(" at offset\t0x%08x\n", - (unsigned int)sh_table[i].sh_offset); - debug(" of size\t0x%08x\n", - (unsigned int)sh_table[i].sh_size); - rela_start = sh_table[i].sh_addr; - rela_end = rela_start + sh_table[i].sh_size; + debug(" at addr\t0x%08x\n", sh_addr); + debug(" at offset\t0x%08x\n", sh_offset); + debug(" of size\t0x%08x\n", sh_size); + rela_start = sh_addr; + rela_end = rela_start + sh_size; break; } } @@ -188,7 +216,9 @@ static int decode_elf32(FILE *felf, char **argv) { size_t size; Elf32_Ehdr header; - uint64_t section_header_base, section_header_size, sh_offset, sh_size; + uint64_t section_header_base, section_header_size; + uint32_t sh_addr, sh_offset, sh_size; + Elf32_Half sh_index, sh_num; Elf32_Shdr *sh_table; /* Elf symbol table */ int ret, i, machine; char *sh_str; @@ -204,7 +234,7 @@ static int decode_elf32(FILE *felf, char **argv) return 25; } - machine = header.e_machine; + machine = le16_to_cpu(header.e_machine); debug("Machine %d\n", machine); if (machine != EM_MICROBLAZE) { @@ -212,14 +242,10 @@ static int decode_elf32(FILE *felf, char **argv) return 30; } - text_base = header.e_entry; - section_header_base = header.e_shoff; - - debug("Section header base %x\n", section_header_base); - - section_header_size = header.e_shentsize * header.e_shnum; - - debug("Section header size %d\n", section_header_size); + text_base = le32_to_cpu(header.e_entry); + section_header_base = le32_to_cpu(header.e_shoff); + section_header_size = le16_to_cpu(header.e_shentsize) * + le16_to_cpu(header.e_shnum); sh_table = malloc(section_header_size); if (!sh_table) { @@ -247,8 +273,9 @@ static int decode_elf32(FILE *felf, char **argv) return 27; } - sh_size = sh_table[header.e_shstrndx].sh_size; - debug("e_shstrndx %x, sh_size %lx\n", header.e_shstrndx, sh_size); + sh_index = le16_to_cpu(header.e_shstrndx); + sh_size = le32_to_cpu(sh_table[sh_index].sh_size); + debug("e_shstrndx %x, sh_size %lx\n", sh_index, sh_size); sh_str = malloc(sh_size); if (!sh_str) { @@ -262,9 +289,8 @@ static int decode_elf32(FILE *felf, char **argv) * Specifies the byte offset from the beginning of the file * to the first byte in the section. */ - sh_offset = sh_table[header.e_shstrndx].sh_offset; - - debug("sh_offset %x\n", header.e_shnum); + sh_offset = le32_to_cpu(sh_table[sh_index].sh_offset); + sh_num = le16_to_cpu(header.e_shnum); ret = fseek(felf, sh_offset, SEEK_SET); if (ret) { @@ -277,7 +303,7 @@ static int decode_elf32(FILE *felf, char **argv) size = fread(sh_str, 1, sh_size, felf); if (size != sh_size) { - fprintf(stderr, "%s: Can't read section: %lx/%lx\n", + fprintf(stderr, "%s: Can't read section: %lx/%x\n", argv[0], size, sh_size); free(sh_str); free(sh_table); @@ -285,22 +311,29 @@ static int decode_elf32(FILE *felf, char **argv) return 30; } - for (i = 0; i < header.e_shnum; i++) { - debug("%s\n", sh_str + sh_table[i].sh_name); - if (!strcmp(".rela.dyn", (sh_str + sh_table[i].sh_name))) { + for (i = 0; i < sh_num; i++) { + char *sh_name = sh_str + le32_to_cpu(sh_table[i].sh_name); + + debug("%s\n", sh_name); + + sh_addr = le64_to_cpu(sh_table[i].sh_addr); + sh_offset = le64_to_cpu(sh_table[i].sh_offset); + sh_size = le64_to_cpu(sh_table[i].sh_size); + + if (!strcmp(".rela.dyn", sh_name)) { debug("Found section\t\".rela_dyn\"\n"); - debug(" at addr\t0x%08x\n", (unsigned int)sh_table[i].sh_addr); - debug(" at offset\t0x%08x\n", (unsigned int)sh_table[i].sh_offset); - debug(" of size\t0x%08x\n", (unsigned int)sh_table[i].sh_size); - rela_start = sh_table[i].sh_addr; - rela_end = rela_start + sh_table[i].sh_size; + debug(" at addr\t0x%08x\n", sh_addr); + debug(" at offset\t0x%08x\n", sh_offset); + debug(" of size\t0x%08x\n", sh_size); + rela_start = sh_addr; + rela_end = rela_start + sh_size; } - if (!strcmp(".dynsym", (sh_str + sh_table[i].sh_name))) { + if (!strcmp(".dynsym", sh_name)) { debug("Found section\t\".dynsym\"\n"); - debug(" at addr\t0x%08x\n", (unsigned int)sh_table[i].sh_addr); - debug(" at offset\t0x%08x\n", (unsigned int)sh_table[i].sh_offset); - debug(" of size\t0x%08x\n", (unsigned int)sh_table[i].sh_size); - dyn_start = sh_table[i].sh_addr; + debug(" at addr\t0x%08x\n", sh_addr); + debug(" at offset\t0x%08x\n", sh_offset); + debug(" of size\t0x%08x\n", sh_size); + dyn_start = sh_addr; } } @@ -386,9 +419,9 @@ static int rela_elf64(char **argv, FILE *f) return 4; } - swrela.r_offset = cpu_to_le64(rela.r_offset); - swrela.r_info = cpu_to_le64(rela.r_info); - swrela.r_addend = cpu_to_le64(rela.r_addend); + swrela.r_offset = le64_to_cpu(rela.r_offset); + swrela.r_info = le64_to_cpu(rela.r_info); + swrela.r_addend = le64_to_cpu(rela.r_addend); if (!supported_rela(&swrela)) continue; @@ -487,9 +520,9 @@ static int rela_elf32(char **argv, FILE *f) PRIu32 " r_addend:\t%" PRIx32 "\n", rela.r_offset, rela.r_info, rela.r_addend); - swrela.r_offset = cpu_to_le32(rela.r_offset); - swrela.r_info = cpu_to_le32(rela.r_info); - swrela.r_addend = cpu_to_le32(rela.r_addend); + swrela.r_offset = le32_to_cpu(rela.r_offset); + swrela.r_info = le32_to_cpu(rela.r_info); + swrela.r_addend = le32_to_cpu(rela.r_addend); debug("SWRela:\toffset:\t%" PRIx32 " r_info:\t%" PRIu32 " r_addend:\t%" PRIx32 "\n", |