-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathx32.patch
209 lines (187 loc) · 6.45 KB
/
x32.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
--- rpm-4.18.1/build/rpmfc.c.orig 2023-09-28 20:44:47.296539499 +0200
+++ rpm-4.18.1/build/rpmfc.c 2023-09-28 20:56:50.552621285 +0200
@@ -648,6 +648,7 @@ static const struct rpmfcTokens_s rpmfcT
{ "ELF 32-bit", RPMFC_ELF32|RPMFC_INCLUDE },
{ "ELF 64-bit", RPMFC_ELF64|RPMFC_INCLUDE },
+// { "ELF 32-bit", RPMFC_ELFX32|RPMFC_INCLUDE },
{ "troff or preprocessor input", RPMFC_INCLUDE },
{ "GNU Info", RPMFC_INCLUDE },
@@ -753,7 +754,11 @@ static rpm_color_t rpmfcColor(const char
if (strstr(fmstr, fct->token) == NULL)
continue;
- fcolor |= fct->colors;
+ // This is a nasty hack, but will have to do for now
+ if ((fct->colors & RPMFC_ELF32) && (strstr(fmstr, "x86-64") != NULL))
+ fcolor |= RPMFC_ELFX32|RPMFC_INCLUDE;
+ else
+ fcolor |= fct->colors;
if (fcolor & RPMFC_INCLUDE)
break;
}
@@ -1149,7 +1154,10 @@ static uint32_t getElfColor(const char *
color = RPMFC_ELF64;
break;
case ELFCLASS32:
- color = RPMFC_ELF32;
+ if (ehdr.e_machine == EM_X86_64)
+ color = RPMFC_ELFX32;
+ else
+ color = RPMFC_ELF32;
break;
}
diff -ur rpm-4.16.1.2/include/rpm/rpmfc.h rpm-4.16.1.2.x32/include/rpm/rpmfc.h
--- rpm-4.16.1.2/include/rpm/rpmfc.h 2020-05-28 12:04:25.011136544 +0200
+++ rpm-4.16.1.2.x32/include/rpm/rpmfc.h 2021-03-21 21:50:04.127398387 +0100
@@ -26,8 +26,9 @@
RPMFC_BLACK = 0,
RPMFC_ELF32 = (1 << 0),
RPMFC_ELF64 = (1 << 1),
+ RPMFC_ELFX32 = (1 << 2),
RPMFC_ELFMIPSN32 = (1 << 2),
-#define RPMFC_ELF (RPMFC_ELF32|RPMFC_ELF64|RPMFC_ELFMIPSN32)
+#define RPMFC_ELF (RPMFC_ELF32|RPMFC_ELF64|RPMFC_ELFX32|RPMFC_ELFMIPSN32)
/*!< (1 << 3) leaks into package headers, reserved */
RPMFC_WHITE = (1 << 29),
diff -ur rpm-4.16.1.2/installplatform rpm-4.16.1.2.x32/installplatform
--- rpm-4.16.1.2/installplatform 2020-05-28 12:04:25.027136631 +0200
+++ rpm-4.16.1.2.x32/installplatform 2021-03-21 21:51:47.671145954 +0100
@@ -21,6 +21,9 @@
ARCH_INSTALL_POST='%{nil}'
LIB=lib
+ TARGETCPU="%{_target_cpu}"
+ APPEND_TARGET_ABI=
+ PREFERCOLOR=
# XXX FIXME: incomplete and quite likely wrong too in places,
# consult various arch folks for correct names etc.
@@ -82,7 +84,17 @@
ISANAME=x86
ISABITS=64
CANONARCH=x86_64
- CANONCOLOR=3
+ CANONCOLOR=7
+ ;;
+ x32)
+ ISANAME=x86
+ ISABITS=x32
+ CANONARCH=x32
+ CANONCOLOR=7
+ APPEND_TARGET_ABI=1
+ TARGETCPU="x86_64"
+ PREFERCOLOR=4
+ RPMRC_GNU="-gnux32"
;;
ia64)
ISANAME=ia
@@ -190,10 +200,14 @@
# skip architectures for which we dont have full config parameters
[ -z "$CANONARCH" ] && continue
- if [ "$OS" = "linux" ] && [ "$CANONCOLOR" = 3 ]; then
+ if [ "$OS" = "linux" ] && ( [ "$CANONCOLOR" = 3 ] || [ "$CANONARCH" = "x86_64" ] ); then
LIB=${LIB}64
fi
+ if [ "$OS" = "linux" ] && [ "$CANONARCH" = "x32" ]; then
+ LIB=${LIB}x32
+ fi
+
if [ "$OS" = "linux" ] && [ "$CANONARCH" != "noarch" ]; then
DEBUGINFO=1
fi
@@ -202,8 +216,11 @@
| sed -e "s,=RPMRC_OPTFLAGS=,$RPMRC_OPTFLAGS," \
-e "s,=RPMCANONARCH=,$CANONARCH,g" \
-e "s,=RPMCANONCOLOR=,$CANONCOLOR," \
+ -e "s,=RPMPREFERCOLOR=,${PREFERCOLOR:+%_prefer_color\\t$PREFERCOLOR}," \
-e "s,=RPMRC_GNU=,$RPMRC_GNU," \
-e "s,=RPMDEBUGINFO=,$DEBUGINFO," \
+ -e "s,=TARGET_ABI=,${APPEND_TARGET_ABI:+%{?_gnu\}}," \
+ -e "s,=TARGETCPU=,$TARGETCPU," \
-e "s,=LIB=,$LIB," \
-e "s,=ARCH_INSTALL_POST=,$ARCH_INSTALL_POST," \
-e '/\${\w*:-/!s,\${,%{_,' \
diff -ur rpm-4.16.1.2/platform.in rpm-4.16.1.2.x32/platform.in
--- rpm-4.16.1.2/platform.in 2020-05-28 12:04:25.047136741 +0200
+++ rpm-4.16.1.2.x32/platform.in 2021-03-21 21:51:47.671145954 +0100
@@ -8,7 +8,7 @@
%_vendor @RPMCANONVENDOR@
%_os @RPMCANONOS@
%_gnu =RPMRC_GNU=
-%_target_platform %{_target_cpu}-%{_vendor}-%{_target_os}
+%_target_platform =TARGETCPU=-%{_vendor}-%{_target_os}=TARGET_ABI=
%optflags =RPMRC_OPTFLAGS=
%__isa_name =ISANAME=
@@ -21,6 +21,7 @@
# 1 Elf32 permitted
# 2 Elf64 permitted
%_transaction_color =RPMCANONCOLOR=
+=RPMPREFERCOLOR=
#==============================================================================
# ---- configure macros.
diff -ur rpm-4.16.1.2/rpmrc.in rpm-4.16.1.2.x32/rpmrc.in
--- rpm-4.16.1.2/rpmrc.in 2020-05-28 12:04:25.075136894 +0200
+++ rpm-4.16.1.2.x32/rpmrc.in 2021-03-21 21:50:04.127398387 +0100
@@ -24,6 +24,7 @@
optflags: x86_64_v4 -O2 -g -march=x86-64-v4
optflags: amd64 -O2 -g
optflags: ia32e -O2 -g
+optflags: x32 -O2 -g -mtune=generic -march=x86-64
optflags: alpha -O2 -g -mieee
optflags: alphaev5 -O2 -g -mieee -mtune=ev5
@@ -155,6 +156,8 @@
archcolor: loongarch64 2
+archcolor: x32 4
+
#############################################################
# Canonical arch names and numbers
@@ -170,6 +173,7 @@
arch_canon: amd64: amd64 1
arch_canon: ia32e: ia32e 1
arch_canon: em64t: em64t 1
+arch_canon: x32: x32 1
arch_canon: alpha: alpha 2
arch_canon: alphaev5: alphaev5 2
@@ -379,6 +383,8 @@
buildarchtranslate: amd64: x86_64
buildarchtranslate: ia32e: x86_64
+buildarchtranslate: x32: x32
+
buildarchtranslate: sh3: sh3
buildarchtranslate: sh4: sh4
buildarchtranslate: sh4a: sh4
@@ -486,13 +492,15 @@
arch_compat: ia64: noarch
-arch_compat: x86_64: amd64 em64t athlon noarch
-arch_compat: amd64: x86_64 em64t athlon noarch
+arch_compat: x86_64: amd64 em64t athlon x32 noarch
+arch_compat: amd64: x86_64 em64t athlon x32 noarch
arch_compat: ia32e: x86_64 em64t athlon noarch
-arch_compat: x86_64_v2: x86_64 amd64 em64t athlon noarch
-arch_compat: x86_64_v3: x86_64_v2 x86_64 amd64 em64t athlon noarch
-arch_compat: x86_64_v4: x86_64_v3 x86_64_v2 x86_64 amd64 em64t athlon noarch
+arch_compat: x86_64_v2: x86_64 amd64 em64t athlon x32 noarch
+arch_compat: x86_64_v3: x86_64_v2 x86_64 amd64 em64t athlon x32 noarch
+arch_compat: x86_64_v4: x86_64_v3 x86_64_v2 x86_64 amd64 em64t athlon x32 noarch
+arch_compat: x32: x32 x86_64 noarch
+
arch_compat: sh3: noarch
arch_compat: sh4: noarch
arch_compat: sh4a: sh4
@@ -628,6 +636,8 @@
buildarch_compat: amd64: x86_64
buildarch_compat: ia32e: x86_64
+buildarch_compat: x32: noarch
+
buildarch_compat: sh3: noarch
buildarch_compat: sh4: noarch
buildarch_compat: sh4a: sh4
diff -ur rpm-4.16.1.2/tools/elfdeps.c rpm-4.16.1.2.x32/tools/elfdeps.c
--- rpm-4.16.1.2/tools/elfdeps.c 2020-05-28 12:04:25.084136944 +0200
+++ rpm-4.16.1.2.x32/tools/elfdeps.c 2021-03-21 21:50:04.127398387 +0100
@@ -94,6 +94,9 @@
break;
}
}
+ if ((ehdr->e_ident[EI_CLASS] == ELFCLASS32) && (ehdr->e_machine == EM_X86_64)) {
+ marker = "(x32bit)";
+ }
return marker;
}