]> git.draconx.ca Git - gentoo-draconx.git/blob - dev-util/elftoaout/files/elftoaout-lp64-fixes.patch
dev-util/elftoaout: New package.
[gentoo-draconx.git] / dev-util / elftoaout / files / elftoaout-lp64-fixes.patch
1 diff --git a/elftoaout-2.3/elftoaout.c b/elftoaout-2.3/elftoaout.c
2 index 943c9ef..1f9b4c0 100644
3 --- a/elftoaout-2.3/elftoaout.c
4 +++ b/elftoaout-2.3/elftoaout.c
5 @@ -20,6 +20,7 @@
6   */
7  #include <stdio.h>
8  #include <stdlib.h>
9 +#include <stdint.h>
10  #ifdef linux
11  #include <linux/elf.h>
12  #define ELFDATA2MSB   2
13 @@ -27,9 +28,20 @@
14  #include <sys/elf.h>
15  #endif
16  
17 -#define swab16(x)  (((x)<<8&0xFF00)|((x)>>8&0x00FF))
18 -#define swab32(x)  (((x)<<24&0xFF000000)|((x)<<8&0x00FF0000)|((x)>>24&0x000000FF)|((x)>>8&0x0000FF00))
19 -#define swab64(x)  ((((unsigned long long)(swab32((unsigned int)x))) << 32) | (swab32(((unsigned long long)x)>>32)))
20 +static uint16_t swab16(uint16_t x)
21 +{
22 +       return (((x)<<8&0xFF00)|((x)>>8&0x00FF));
23 +}
24 +
25 +static uint32_t swab32(uint32_t x)
26 +{
27 +       return (((x)<<24&0xFF000000)|((x)<<8&0x00FF0000)|((x)>>24&0x000000FF)|((x)>>8&0x0000FF00));
28 +}
29 +
30 +static uint64_t swab64(uint64_t x)
31 +{
32 +       return ((((unsigned long long)(swab32(x))) << 32) | (swab32(x>>32)));
33 +}
34  
35  /* We carry a.out header here in order to compile the thing on Solaris */
36  
37 @@ -37,14 +49,14 @@
38  #define        CMAGIC      0x01030108
39  
40  typedef struct {
41 -       unsigned long   a_magic;        /* magic number */
42 -       unsigned long   a_text;         /* size of text segment */
43 -       unsigned long   a_data;         /* size of initialized data */
44 -       unsigned long   a_bss;          /* size of uninitialized data */
45 -       unsigned long   a_syms;         /* size of symbol table || checksum */
46 -       unsigned long   a_entry;        /* entry point */
47 -       unsigned long   a_trsize;       /* size of text relocation */
48 -       unsigned long   a_drsize;       /* size of data relocation */
49 +       uint32_t        a_magic;        /* magic number */
50 +       uint32_t        a_text;         /* size of text segment */
51 +       uint32_t        a_data;         /* size of initialized data */
52 +       uint32_t        a_bss;          /* size of uninitialized data */
53 +       uint32_t        a_syms;         /* size of symbol table || checksum */
54 +       uint32_t        a_entry;        /* entry point */
55 +       uint32_t        a_trsize;       /* size of text relocation */
56 +       uint32_t        a_drsize;       /* size of data relocation */
57  } Exec;
58  
59  
60 @@ -75,7 +87,7 @@ void print_ptab(ProgTable *t);
61  void print_ptab64(ProgTable64 *t);
62  
63  typedef struct {
64 -       char *buf;                /* Image data */
65 +       unsigned char *buf;       /* Image data */
66         unsigned len;             /* Length of buffer */
67         unsigned bss;             /* Length of extra data */
68  } Segment;
69 @@ -386,9 +398,9 @@ void print_ptab64(ProgTable64 *t) {
70                         printf("NULL");
71                         break;
72                 case PT_LOAD:
73 -                       printf("Loadable to 0x%Lx[0x%Lx] from 0x%Lx[0x%Lx] align 0x%Lx",
74 -                               p->p_vaddr, p->p_memsz, p->p_offset, p->p_filesz,
75 -                               p->p_align);
76 +                       printf("Loadable to 0x%jx[0x%jx] from 0x%jx[0x%jx] align 0x%jx",
77 +                               (uintmax_t)p->p_vaddr, (uintmax_t)p->p_memsz, (uintmax_t)p->p_offset, (uintmax_t)p->p_filesz,
78 +                               (uintmax_t)p->p_align);
79                         break;
80                 case PT_DYNAMIC:
81                         printf("Dynamic");