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
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Bertalan <dani@danielbertalan.dev>
Date: Mon, 27 Mar 2023 19:24:04 +1100
Subject: [PATCH] Add support for SerenityOS
Teaches the assembler, BFD, and the linker about the SerenityOS target
triple.
---
bfd/config.bfd | 15 +++++++++++++++
gas/config/tc-i386.c | 3 ++-
gas/config/te-serenity.h | 3 +++
gas/configure.tgt | 2 ++
ld/Makefile.am | 1 +
ld/Makefile.in | 1 +
ld/configure.tgt | 9 +++++++++
7 files changed, 33 insertions(+), 1 deletion(-)
create mode 100644 gas/config/te-serenity.h
diff --git a/bfd/config.bfd b/bfd/config.bfd
index cdd4a2b..b943f2e 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -285,6 +285,11 @@ case "${targ}" in
targ_selvecs="aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec"
want64=true
;;
+ aarch64-*-serenity*)
+ targ_defvec=aarch64_elf64_le_vec
+ targ_selvecs=
+ want64=true
+ ;;
aarch64-*-linux* | aarch64-*-netbsd*)
targ_defvec=aarch64_elf64_le_vec
targ_selvecs="aarch64_elf64_be_vec aarch64_elf32_le_vec aarch64_elf32_be_vec arm_elf32_le_vec arm_elf32_be_vec aarch64_pei_le_vec aarch64_pe_le_vec"
@@ -666,6 +671,11 @@ case "${targ}" in
targ_selvecs=
targ64_selvecs=x86_64_elf64_vec
;;
+ i[3-7]86-*-serenity*)
+ targ_defvec=i386_elf32_vec
+ targ_selvecs=
+ targ64_selvecs=x86_64_elf64_vec
+ ;;
#ifdef BFD64
x86_64-*-cloudabi*)
targ_defvec=x86_64_elf64_cloudabi_vec
@@ -736,6 +746,11 @@ case "${targ}" in
targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec"
want64=true
;;
+ x86_64-*-serenity*)
+ targ_defvec=x86_64_elf64_vec
+ targ_selvecs=i386_elf32_vec
+ want64=true
+ ;;
#endif
i[3-7]86-*-lynxos*)
targ_defvec=i386_elf32_vec
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index c5f124d..3b969dc 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -492,7 +492,8 @@ const char extra_symbol_chars[] = "*%-([{}"
&& !defined (TE_Haiku) \
&& !defined (TE_FreeBSD) \
&& !defined (TE_DragonFly) \
- && !defined (TE_NetBSD))
+ && !defined (TE_NetBSD) \
+ && !defined (TE_SerenityOS))
/* This array holds the chars that always start a comment. If the
pre-processor is disabled, these aren't very useful. The option
--divide will remove '/' from this list. */
diff --git a/gas/config/te-serenity.h b/gas/config/te-serenity.h
new file mode 100644
index 0000000000000000000000000000000000000000..f38faf598cba7f561ed9528ee37328228ee55bdc
--- /dev/null
+++ b/gas/config/te-serenity.h
@@ -0,0 +1,3 @@
+#include "te-generic.h"
+
+#define TE_SerenityOS 1
diff --git a/gas/configure.tgt b/gas/configure.tgt
index 98205c3..4961fde 100644
--- a/gas/configure.tgt
+++ b/gas/configure.tgt
@@ -134,6 +134,7 @@ case ${generic_target} in
aarch64*-linux-gnu_ilp32) arch=aarch64:32 ;;
esac ;;
aarch64*-*-netbsd*) fmt=elf em=nbsd;;
+ aarch64*-*-serenity*) fmt=elf em=serenity ;;
aarch64*-*-openbsd*) fmt=elf;;
aarch64*-*-pe*) fmt=coff em=pepaarch64 ;;
alpha-*-*vms*) fmt=evax ;;
@@ -264,6 +265,7 @@ case ${generic_target} in
i386-*-*nt*) fmt=coff em=pe ;;
i386-*-rdos*) fmt=elf ;;
i386-*-darwin*) fmt=macho ;;
+ i386-*-serenity) fmt=elf em=serenity ;;
ia16-*-elf*) fmt=elf ;;
diff --git a/ld/Makefile.am b/ld/Makefile.am
index 001483f..dad8105 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -457,6 +457,7 @@ ALL_64_EMULATION_SOURCES = \
eelf_x86_64_cloudabi.c \
eelf_x86_64_fbsd.c \
eelf_x86_64_haiku.c \
+ eelf_x86_64_serenity.c \
eelf_x86_64_sol2.c \
ehppa64linux.c \
ei386pep.c \
diff --git a/ld/Makefile.in b/ld/Makefile.in
index eaba463..b51922c 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -957,6 +957,7 @@ ALL_64_EMULATION_SOURCES = \
eelf_x86_64_cloudabi.c \
eelf_x86_64_fbsd.c \
eelf_x86_64_haiku.c \
+ eelf_x86_64_serenity.c \
eelf_x86_64_sol2.c \
ehppa64linux.c \
ei386pep.c \
diff --git a/ld/configure.tgt b/ld/configure.tgt
index 41e95f2..ca99409 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -97,6 +97,9 @@ aarch64-*-freebsd*) targ_emul=aarch64fbsd
aarch64-*-fuchsia*) targ_emul=aarch64elf
targ_extra_emuls="aarch64elfb armelf armelfb"
;;
+aarch64-*-serenity*) targ_emul=aarch64elf
+ targ_extra_emuls=
+ ;;
aarch64_be-*-linux-gnu_ilp32)
targ_emul=aarch64linux32b
targ_extra_libpath="aarch64linuxb aarch64linux aarch64linux32 armelfb_linux_eabi armelf_linux_eabi"
@@ -374,6 +377,9 @@ i[3-7]86-*-linux-*) targ_emul=elf_i386
i[3-7]86-*-redox*) targ_emul=elf_i386
targ_extra_emuls=elf_x86_64
;;
+i[3-7]86-*-serenity*) targ_emul=elf_i386
+ targ64_extra_emuls="elf_x86_64"
+ ;;
i[3-7]86-*-sysv[45]*) targ_emul=elf_i386
targ_extra_emuls=elf_iamcu
;;
@@ -1012,6 +1018,9 @@ x86_64-*-linux-*) targ_emul=elf_x86_64
x86_64-*-redox*) targ_emul=elf_x86_64
targ_extra_emuls=elf_i386
;;
+x86_64-*-serenity*) targ_emul=elf_x86_64
+ targ_extra_emuls="elf_i386"
+ ;;
x86_64-*-solaris2*) targ_emul=elf_x86_64_sol2
targ_extra_emuls="elf_x86_64 elf_i386_sol2 elf_i386_ldso elf_i386 elf_iamcu"
targ_extra_libpath=$targ_extra_emuls
|