Gentoo Archives: gentoo-commits

From: Matt Turner <mattst88@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-apps/sparc-utils/, sys-apps/sparc-utils/files/
Date: Wed, 01 Apr 2020 05:08:11
Message-Id: 1585717670.e63b7c35c2c49b7ae4cce57ca167035737480e53.mattst88@gentoo
1 commit: e63b7c35c2c49b7ae4cce57ca167035737480e53
2 Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
3 AuthorDate: Wed Apr 1 05:01:01 2020 +0000
4 Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
5 CommitDate: Wed Apr 1 05:07:50 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e63b7c35
7
8 sys-apps/sparc-utils: Add patch to fix on 64-bit userland
9
10 Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
11
12 .../files/elftoaout-2.3-64bit_fixes-1.patch | 261 +++++++++++++++++++++
13 ...ils-1.9-r5.ebuild => sparc-utils-1.9-r6.ebuild} | 1 +
14 2 files changed, 262 insertions(+)
15
16 diff --git a/sys-apps/sparc-utils/files/elftoaout-2.3-64bit_fixes-1.patch b/sys-apps/sparc-utils/files/elftoaout-2.3-64bit_fixes-1.patch
17 new file mode 100644
18 index 00000000000..2be0e67184f
19 --- /dev/null
20 +++ b/sys-apps/sparc-utils/files/elftoaout-2.3-64bit_fixes-1.patch
21 @@ -0,0 +1,261 @@
22 +Submitted By: Jim Gifford (patches at jg555 dot com)
23 +Date: 2006-01-03
24 +Initial Package Version: 2.3
25 +Origin: Dave Miller
26 +Upstream Status: Unknown
27 +Description: Fixes 64 Bit Issues with Elftoaout
28 +
29 + https://marc.info/?l=linux-sparc&m=113617505627794&w=2
30 +
31 +diff -Naur elftoaout-2.3/elftoaout.c elftoaout-2.3/elftoaout.c
32 +--- a/elftoaout-2.3/elftoaout.c 2000-06-03 20:20:12.000000000 +0000
33 ++++ b/elftoaout-2.3/elftoaout.c 2006-01-03 22:33:28.000000000 +0000
34 +@@ -20,16 +20,36 @@
35 + */
36 + #include <stdio.h>
37 + #include <stdlib.h>
38 +-#ifdef linux
39 + #include <linux/elf.h>
40 +-#define ELFDATA2MSB 2
41 +-#else
42 +-#include <sys/elf.h>
43 +-#endif
44 +-
45 +-#define swab16(x) (((x)<<8&0xFF00)|((x)>>8&0x00FF))
46 +-#define swab32(x) (((x)<<24&0xFF000000)|((x)<<8&0x00FF0000)|((x)>>24&0x000000FF)|((x)>>8&0x0000FF00))
47 +-#define swab64(x) ((((unsigned long long)(swab32((unsigned int)x))) << 32) | (swab32(((unsigned long long)x)>>32)))
48 ++#include <sys/types.h>
49 ++
50 ++static inline u_int16_t swab16(u_int16_t x)
51 ++{
52 ++ return (((x << 8) & 0xFF00) |
53 ++ ((x >> 8) & 0x00FF));
54 ++}
55 ++
56 ++static inline u_int32_t swab32(u_int32_t x)
57 ++{
58 ++ return (((x << 24) & 0xFF000000) |
59 ++ ((x << 8) & 0x00FF0000) |
60 ++ ((x >> 24) & 0x000000FF) |
61 ++ ((x >> 8) & 0x0000FF00));
62 ++}
63 ++
64 ++static inline u_int64_t swab64(u_int64_t x)
65 ++{
66 ++ return ((u_int64_t)
67 ++ ((u_int64_t)(((u_int64_t)x & (u_int64_t)0x00000000000000ffULL) << 56) |
68 ++ (u_int64_t)(((u_int64_t)x & (u_int64_t)0x000000000000ff00ULL) << 40) |
69 ++ (u_int64_t)(((u_int64_t)x & (u_int64_t)0x0000000000ff0000ULL) << 24) |
70 ++ (u_int64_t)(((u_int64_t)x & (u_int64_t)0x00000000ff000000ULL) << 8) |
71 ++ (u_int64_t)(((u_int64_t)x & (u_int64_t)0x000000ff00000000ULL) >> 8) |
72 ++ (u_int64_t)(((u_int64_t)x & (u_int64_t)0x0000ff0000000000ULL) >> 24) |
73 ++ (u_int64_t)(((u_int64_t)x & (u_int64_t)0x00ff000000000000ULL) >> 40) |
74 ++ (u_int64_t)(((u_int64_t)x & (u_int64_t)0xff00000000000000ULL) >> 56)));
75 ++}
76 ++
77 +
78 + /* We carry a.out header here in order to compile the thing on Solaris */
79 +
80 +@@ -37,14 +57,14 @@
81 + #define CMAGIC 0x01030108
82 +
83 + typedef struct {
84 +- unsigned long a_magic; /* magic number */
85 +- unsigned long a_text; /* size of text segment */
86 +- unsigned long a_data; /* size of initialized data */
87 +- unsigned long a_bss; /* size of uninitialized data */
88 +- unsigned long a_syms; /* size of symbol table || checksum */
89 +- unsigned long a_entry; /* entry point */
90 +- unsigned long a_trsize; /* size of text relocation */
91 +- unsigned long a_drsize; /* size of data relocation */
92 ++ u_int32_t a_magic; /* magic number */
93 ++ u_int32_t a_text; /* size of text segment */
94 ++ u_int32_t a_data; /* size of initialized data */
95 ++ u_int32_t a_bss; /* size of uninitialized data */
96 ++ u_int32_t a_syms; /* size of symbol table || checksum */
97 ++ u_int32_t a_entry; /* entry point */
98 ++ u_int32_t a_trsize; /* size of text relocation */
99 ++ u_int32_t a_drsize; /* size of data relocation */
100 + } Exec;
101 +
102 +
103 +@@ -56,17 +76,16 @@
104 + int swab;
105 + int sparc64;
106 + int csum;
107 +- /* friend void Usage(void); */
108 + } Application;
109 +
110 + typedef struct {
111 + Elf32_Phdr *tab;
112 +- unsigned len;
113 ++ unsigned int len;
114 + } ProgTable;
115 +
116 + typedef struct {
117 + Elf64_Phdr *tab;
118 +- unsigned len;
119 ++ unsigned int len;
120 + } ProgTable64;
121 +
122 + void get_ptab(ProgTable *t, FILE *inp, const Elf32_Ehdr *h);
123 +@@ -75,9 +94,9 @@
124 + void print_ptab64(ProgTable64 *t);
125 +
126 + typedef struct {
127 +- char *buf; /* Image data */
128 +- unsigned len; /* Length of buffer */
129 +- unsigned bss; /* Length of extra data */
130 ++ unsigned char *buf; /* Image data */
131 ++ unsigned int len; /* Length of buffer */
132 ++ unsigned int bss; /* Length of extra data */
133 + } Segment;
134 +
135 + void load_image(Segment *t, const ProgTable *h, FILE *inp);
136 +@@ -105,7 +124,8 @@
137 +
138 + parse_args(&prog, argc, argv);
139 +
140 +- if (prog.version) Version();
141 ++ if (prog.version)
142 ++ Version();
143 +
144 + if (freopen(prog.iname, "r", stdin) == NULL) {
145 + fprintf(stderr, "Cannot open \"%s\"\n", prog.iname);
146 +@@ -141,7 +161,8 @@
147 + exit(0);
148 + }
149 +
150 +-void parse_args( Application *t, unsigned argc, const char **argv ){
151 ++void parse_args( Application *t, unsigned argc, const char **argv )
152 ++{
153 + const char *arg;
154 + union {
155 + char c[4];
156 +@@ -185,8 +206,8 @@
157 + if (t->csum && t->sun4_mode) Usage (); /* Checksum lives in header. */
158 + }
159 +
160 +-void get_header(Elf32_Ehdr *t, FILE *inp) {
161 +-
162 ++void get_header(Elf32_Ehdr *t, FILE *inp)
163 ++{
164 + if (fread((void*) t, sizeof(Elf64_Ehdr), 1, inp) != 1) {
165 + fprintf(stderr, "Read error on header\n");
166 + exit(1);
167 +@@ -249,8 +270,9 @@
168 + }
169 + }
170 +
171 +-void get_ptab(ProgTable *t, FILE *inp, const Elf32_Ehdr *h) {
172 +- unsigned x;
173 ++void get_ptab(ProgTable *t, FILE *inp, const Elf32_Ehdr *h)
174 ++{
175 ++ unsigned int x;
176 +
177 + /** fprintf(stderr, "Program header table off = 0x%x\n",
178 + (unsigned) h->e_phoff); **/
179 +@@ -294,8 +316,9 @@
180 + }
181 + }
182 +
183 +-void get_ptab64(ProgTable64 *t, FILE *inp, const Elf64_Ehdr *h) {
184 +- unsigned x;
185 ++void get_ptab64(ProgTable64 *t, FILE *inp, const Elf64_Ehdr *h)
186 ++{
187 ++ unsigned int x;
188 +
189 + if (h->e_phoff == 0) {
190 + fprintf(stderr, "No Program Header Table\n");
191 +@@ -332,8 +355,9 @@
192 + }
193 + }
194 +
195 +-void print_ptab(ProgTable *t) {
196 +- unsigned x;
197 ++void print_ptab(ProgTable *t)
198 ++{
199 ++ unsigned int x;
200 + const Elf32_Phdr *p;
201 +
202 + for (x = 0; x < t->len; x++) {
203 +@@ -374,8 +398,9 @@
204 + }
205 + }
206 +
207 +-void print_ptab64(ProgTable64 *t) {
208 +- unsigned x;
209 ++void print_ptab64(ProgTable64 *t)
210 ++{
211 ++ unsigned int x;
212 + const Elf64_Phdr *p;
213 +
214 + for (x = 0; x < t->len; x++) {
215 +@@ -387,8 +412,11 @@
216 + break;
217 + case PT_LOAD:
218 + printf("Loadable to 0x%Lx[0x%Lx] from 0x%Lx[0x%Lx] align 0x%Lx",
219 +- p->p_vaddr, p->p_memsz, p->p_offset, p->p_filesz,
220 +- p->p_align);
221 ++ (unsigned long long) p->p_vaddr,
222 ++ (unsigned long long) p->p_memsz,
223 ++ (unsigned long long) p->p_offset,
224 ++ (unsigned long long) p->p_filesz,
225 ++ (unsigned long long) p->p_align);
226 + break;
227 + case PT_DYNAMIC:
228 + printf("Dynamic");
229 +@@ -416,9 +444,10 @@
230 + }
231 + }
232 +
233 +-void load_image(Segment *t, const ProgTable *tp, FILE *inp) {
234 ++void load_image(Segment *t, const ProgTable *tp, FILE *inp)
235 ++{
236 + Elf32_Phdr *p, *q;
237 +- unsigned x;
238 ++ unsigned int x;
239 + unsigned long off, len;
240 +
241 + p = 0;
242 +@@ -484,9 +513,10 @@
243 + }
244 + }
245 +
246 +-void load_image64(Segment *t, const ProgTable64 *tp, FILE *inp) {
247 ++void load_image64(Segment *t, const ProgTable64 *tp, FILE *inp)
248 ++{
249 + Elf64_Phdr *p, *q;
250 +- unsigned x;
251 ++ unsigned int x;
252 + unsigned long long off, len;
253 +
254 + p = 0;
255 +@@ -547,7 +577,8 @@
256 + }
257 + }
258 +
259 +-void store_image(Segment *t, FILE *out) {
260 ++void store_image(Segment *t, FILE *out)
261 ++{
262 + Exec ohdb;
263 +
264 + if (prog.swab) {
265 +@@ -585,13 +616,15 @@
266 + return;
267 + }
268 +
269 +-void Usage(){
270 ++void Usage()
271 ++{
272 + if (prog.version) Version();
273 + fprintf(stderr, "Usage: elftoaout [-o output] [-c|-b] [-V] input\n");
274 + exit(1);
275 + }
276 +
277 +-void Version(){
278 ++void Version()
279 ++{
280 + printf("elftoaout 2.3: ELF to a.out convertor for SPARC and SPARC64 bootstraps\n");
281 + }
282 +
283
284 diff --git a/sys-apps/sparc-utils/sparc-utils-1.9-r5.ebuild b/sys-apps/sparc-utils/sparc-utils-1.9-r6.ebuild
285 similarity index 96%
286 rename from sys-apps/sparc-utils/sparc-utils-1.9-r5.ebuild
287 rename to sys-apps/sparc-utils/sparc-utils-1.9-r6.ebuild
288 index 3f13a6d64e5..3aec8e00f8e 100644
289 --- a/sys-apps/sparc-utils/sparc-utils-1.9-r5.ebuild
290 +++ b/sys-apps/sparc-utils/sparc-utils-1.9-r6.ebuild
291 @@ -23,6 +23,7 @@ S=${WORKDIR}/${P}.orig
292 PATCHES=(
293 "${WORKDIR}/${PN}_${PV}-4.diff"
294 "${FILESDIR}"/${P}-no-implicit.patch
295 + "${FILESDIR}"/elftoaout-2.3-64bit_fixes-1.patch
296 )
297
298 src_compile() {