Skip to contentSkip to conversation

tilo: convert data to big endian

PATCH Superseded Aaro Koskinen 1 participant 1 message Dec 7, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/10 tilo: convert data to big endian

Make sure that data in TILO image is big endian.

---
 tilo/maketilo.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
tilo/maketilo.c +9 -1
index b89a4f161769..0a14a96149dc 100644
@@ -28,6 +28,7 @@
 
 #include <stdio.h>
 #include <sys/stat.h>
+#include <arpa/inet.h>
 #include <stdlib.h>
 #include <string.h>
 #include "b.h"
@@ -220,7 +221,7 @@ int main (int argc, char **argv)
 	output_end = root_image_start + rootlen;
 
 	/* patch code, data and BSS size in the .out header */
-	*(unsigned*)(output_buffer+4) = output_end - output_buffer;
+	*(unsigned*)(output_buffer+4) = htonl(output_end - output_buffer);
 	*(unsigned*)(output_buffer+8) = 0;
 	*(unsigned*)(output_buffer+12) = 0;
 
@@ -268,6 +269,13 @@ int main (int argc, char **argv)
 	ii[3].unpacked_len = 0;
 	ii[3].root_start = 0;
 
+	for (i = 0; i < 4; i++) {
+		ii[i].packed_start = htonl(ii[i].packed_start);
+		ii[i].packed_len   = htonl(ii[i].packed_len);
+		ii[i].unpacked_len = htonl(ii[i].unpacked_len);
+		ii[i].root_start   = htonl(ii[i].root_start);
+	}
+
 	f = fopen (output_file, "wb");
 	if (!f) {
 		fprintf (stderr, "Can't open %s for writing\n", output_file);
Signature · 1 line
1.8.4.4