My program dumps an a bunch of bytes in a long array which is big endian, my goal is to split up the bytes into double words (groups of 4 bytes) and put them in little endian format. Here is the code that I have gotten thus far:
int print_got_bytes(struct _section *got_section, Elf_Data *data) {
size_t size = data->d_size;
off_t offset = data->d_off;
unsigned char *buf = (unsigned char *) data->d_buf;
unsigned char *data_bytes;
printf("%ld\n", size);
//for(int cnt = 0; cnt < size; cnt += 4) {
for(int i = 3; i >= 0; i--) {
data_bytes[3 - i] = buf[i];
printf("%02x", data_bytes[3 - i]);
}
//}
puts("");
return 0;
}
So far this works for the first set of bytes, but I cannot figure out how to increment the pointer data_bytes
and repeat the process for the next set of bytes. Is this the wrong method of going about solving this problem?