# --- T2-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # T2 SDE: package/.../elftoaout/endianness-64bit.patch # Copyright (C) 2009 The T2 SDE Project # # More information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # --- T2-COPYRIGHT-NOTE-END --- This fixes elftoaout for little-endian machines (e.g. during cross compiling) as well as "long long" > 64bit. - Rene Rebe --- elftoaout-2.3/elftoaout.c 2000-06-03 22:20:12.000000000 +0200 +++ elftoaout-2.3-fixed/elftoaout.c 2009-10-20 15:02:57.000000000 +0200 @@ -3,6 +3,7 @@ * * Copyright (C) 1995,1996 Pete A. Zaitcev (zaitcev@vger.rutgers.edu) * Copyright (C) 1997 Jakub Jelinek (jj@ultra.linux.cz) + * Copyright (C) 2009 Rene Rebe (rene@exactcode.de) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -20,6 +21,7 @@ */ #include #include +#include #ifdef linux #include #define ELFDATA2MSB 2 @@ -29,7 +31,7 @@ #define swab16(x) (((x)<<8&0xFF00)|((x)>>8&0x00FF)) #define swab32(x) (((x)<<24&0xFF000000)|((x)<<8&0x00FF0000)|((x)>>24&0x000000FF)|((x)>>8&0x0000FF00)) -#define swab64(x) ((((unsigned long long)(swab32((unsigned int)x))) << 32) | (swab32(((unsigned long long)x)>>32))) +#define swab64(x) ((((uint64_t)(swab32((unsigned int)x))) << 32) | (swab32(((uint64_t)x)>>32))) /* We carry a.out header here in order to compile the thing on Solaris */ @@ -37,14 +39,14 @@ #define CMAGIC 0x01030108 typedef struct { - unsigned long a_magic; /* magic number */ - unsigned long a_text; /* size of text segment */ - unsigned long a_data; /* size of initialized data */ - unsigned long a_bss; /* size of uninitialized data */ - unsigned long a_syms; /* size of symbol table || checksum */ - unsigned long a_entry; /* entry point */ - unsigned long a_trsize; /* size of text relocation */ - unsigned long a_drsize; /* size of data relocation */ + uint32_t a_magic; /* magic number */ + uint32_t a_text; /* size of text segment */ + uint32_t a_data; /* size of initialized data */ + uint32_t a_bss; /* size of uninitialized data */ + uint32_t a_syms; /* size of symbol table || checksum */ + uint32_t a_entry; /* entry point */ + uint32_t a_trsize; /* size of text relocation */ + uint32_t a_drsize; /* size of data relocation */ } Exec; @@ -94,6 +96,7 @@ int main(int argc, const char **argv) { + const int x = 1; /* endianness check canary */ FILE *inp = stdin; FILE *out; union { @@ -104,6 +107,7 @@ Segment image; parse_args(&prog, argc, argv); + prog.swab = *(char*)&x; if (prog.version) Version();