]> git.draconx.ca Git - gentoo-draconx.git/blobdiff - dev-util/elftoaout/files/elftoaout-lp64-fixes.patch
dev-util/elftoaout: New package.
[gentoo-draconx.git] / dev-util / elftoaout / files / elftoaout-lp64-fixes.patch
diff --git a/dev-util/elftoaout/files/elftoaout-lp64-fixes.patch b/dev-util/elftoaout/files/elftoaout-lp64-fixes.patch
new file mode 100644 (file)
index 0000000..57fd11d
--- /dev/null
@@ -0,0 +1,81 @@
+diff --git a/elftoaout-2.3/elftoaout.c b/elftoaout-2.3/elftoaout.c
+index 943c9ef..1f9b4c0 100644
+--- a/elftoaout-2.3/elftoaout.c
++++ b/elftoaout-2.3/elftoaout.c
+@@ -20,6 +20,7 @@
+  */
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <stdint.h>
+ #ifdef linux
+ #include <linux/elf.h>
+ #define ELFDATA2MSB   2
+@@ -27,9 +28,20 @@
+ #include <sys/elf.h>
+ #endif
+-#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)))
++static uint16_t swab16(uint16_t x)
++{
++      return (((x)<<8&0xFF00)|((x)>>8&0x00FF));
++}
++
++static uint32_t swab32(uint32_t x)
++{
++      return (((x)<<24&0xFF000000)|((x)<<8&0x00FF0000)|((x)>>24&0x000000FF)|((x)>>8&0x0000FF00));
++}
++
++static uint64_t swab64(uint64_t x)
++{
++      return ((((unsigned long long)(swab32(x))) << 32) | (swab32(x>>32)));
++}
+ /* We carry a.out header here in order to compile the thing on Solaris */
+@@ -37,14 +49,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;
+@@ -75,7 +87,7 @@ void print_ptab(ProgTable *t);
+ void print_ptab64(ProgTable64 *t);
+ typedef struct {
+-      char *buf;                /* Image data */
++      unsigned char *buf;       /* Image data */
+       unsigned len;             /* Length of buffer */
+       unsigned bss;             /* Length of extra data */
+ } Segment;
+@@ -386,9 +398,9 @@ void print_ptab64(ProgTable64 *t) {
+                       printf("NULL");
+                       break;
+               case PT_LOAD:
+-                      printf("Loadable to 0x%Lx[0x%Lx] from 0x%Lx[0x%Lx] align 0x%Lx",
+-                              p->p_vaddr, p->p_memsz, p->p_offset, p->p_filesz,
+-                              p->p_align);
++                      printf("Loadable to 0x%jx[0x%jx] from 0x%jx[0x%jx] align 0x%jx",
++                              (uintmax_t)p->p_vaddr, (uintmax_t)p->p_memsz, (uintmax_t)p->p_offset, (uintmax_t)p->p_filesz,
++                              (uintmax_t)p->p_align);
+                       break;
+               case PT_DYNAMIC:
+                       printf("Dynamic");