Dash:
[t2.git] / package / sparc / elftoaout / endianness-64bit.patch
blob996af1b51f48dfeb285e1429a7b6ac9d917f9456
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/.../elftoaout/endianness-64bit.patch
5 # Copyright (C) 2009 The T2 SDE Project
6 #
7 # More information can be found in the files COPYING and README.
8 #
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 # --- T2-COPYRIGHT-NOTE-END ---
17 This fixes elftoaout for little-endian machines (e.g. during cross
18 compiling) as well as "long long" > 64bit.
20 - Rene Rebe <rene@exactcode.de>
22 --- elftoaout-2.3/elftoaout.c 2000-06-03 22:20:12.000000000 +0200
23 +++ elftoaout-2.3-fixed/elftoaout.c 2009-10-20 15:02:57.000000000 +0200
24 @@ -3,6 +3,7 @@
26 * Copyright (C) 1995,1996 Pete A. Zaitcev (zaitcev@vger.rutgers.edu)
27 * Copyright (C) 1997 Jakub Jelinek (jj@ultra.linux.cz)
28 + * Copyright (C) 2009 Rene Rebe (rene@exactcode.de)
30 * This program is free software; you can redistribute it and/or modify it
31 * under the terms of the GNU General Public License as published by the
32 @@ -20,6 +21,7 @@
34 #include <stdio.h>
35 #include <stdlib.h>
36 +#include <inttypes.h>
37 #ifdef linux
38 #include <linux/elf.h>
39 #define ELFDATA2MSB 2
40 @@ -29,7 +31,7 @@
42 #define swab16(x) (((x)<<8&0xFF00)|((x)>>8&0x00FF))
43 #define swab32(x) (((x)<<24&0xFF000000)|((x)<<8&0x00FF0000)|((x)>>24&0x000000FF)|((x)>>8&0x0000FF00))
44 -#define swab64(x) ((((unsigned long long)(swab32((unsigned int)x))) << 32) | (swab32(((unsigned long long)x)>>32)))
45 +#define swab64(x) ((((uint64_t)(swab32((unsigned int)x))) << 32) | (swab32(((uint64_t)x)>>32)))
47 /* We carry a.out header here in order to compile the thing on Solaris */
49 @@ -37,14 +39,14 @@
50 #define CMAGIC 0x01030108
52 typedef struct {
53 - unsigned long a_magic; /* magic number */
54 - unsigned long a_text; /* size of text segment */
55 - unsigned long a_data; /* size of initialized data */
56 - unsigned long a_bss; /* size of uninitialized data */
57 - unsigned long a_syms; /* size of symbol table || checksum */
58 - unsigned long a_entry; /* entry point */
59 - unsigned long a_trsize; /* size of text relocation */
60 - unsigned long a_drsize; /* size of data relocation */
61 + uint32_t a_magic; /* magic number */
62 + uint32_t a_text; /* size of text segment */
63 + uint32_t a_data; /* size of initialized data */
64 + uint32_t a_bss; /* size of uninitialized data */
65 + uint32_t a_syms; /* size of symbol table || checksum */
66 + uint32_t a_entry; /* entry point */
67 + uint32_t a_trsize; /* size of text relocation */
68 + uint32_t a_drsize; /* size of data relocation */
69 } Exec;
72 @@ -94,6 +96,7 @@
74 int main(int argc, const char **argv)
76 + const int x = 1; /* endianness check canary */
77 FILE *inp = stdin;
78 FILE *out;
79 union {
80 @@ -104,6 +107,7 @@
81 Segment image;
83 parse_args(&prog, argc, argv);
84 + prog.swab = *(char*)&x;
86 if (prog.version) Version();