[PATCH 01/10] tilo: convert data to big endian

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make sure that data in TILO image is big endian.

Signed-off-by: Aaro Koskinen <aaro.koskinen@xxxxxx>
---
 tilo/maketilo.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tilo/maketilo.c b/tilo/maketilo.c
index b89a4f161769..0a14a96149dc 100644
--- a/tilo/maketilo.c
+++ b/tilo/maketilo.c
@@ -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);
-- 
1.8.4.4

--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Development]     [DCCP]     [Linux ARM Development]     [Linux]     [Photo]     [Yosemite Help]     [Linux ARM Kernel]     [Linux SCSI]     [Linux x86_64]     [Linux Hams]

  Powered by Linux