Add support for 32-bit x86 and Arm

This commit is contained in:
Christoph Erhardt 2022-04-30 21:32:09 +02:00
parent 97b9b97738
commit 71d4156364
4 changed files with 221 additions and 3 deletions

View File

@ -0,0 +1,41 @@
From 339ce3afe5ebbcc924df431153a0b8fc549b9dd8 Mon Sep 17 00:00:00 2001
Message-Id: <339ce3afe5ebbcc924df431153a0b8fc549b9dd8.1651330992.git.github@sicherha.de>
From: Rui Ueyama <ruiu@cs.stanford.edu>
Date: Sat, 30 Apr 2022 12:06:39 +0800
Subject: [PATCH 1/3] [ELF][LTO] Fix LTO on 32-bit hosts
`off_t` is either an alias for `off32_t` or for `off64_t` on a 32-bit
machine. `off32_t` is the default. But it looks like LLVM gold plugin
is always compiled with `off64_t`.
Because of this difference, the offset of the `handle` member in
`PluginInputFile` differed between mold and LLVMgold.so. mold thought
that the member was at offset 16 of the struct, while LLVMgold.so
thought that it's at offset 24.
That caused a mysterious crash when LLVMgold tries to access the
`handle` member.
Fixes https://github.com/rui314/mold/issues/483
---
lto.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lto.h b/lto.h
index c7a73698..03ab340f 100644
--- a/lto.h
+++ b/lto.h
@@ -73,8 +73,8 @@ enum PluginOutputFileType {
struct PluginInputFile {
const char *name;
int fd;
- off_t offset;
- off_t filesize;
+ uint64_t offset;
+ uint64_t filesize;
void *handle;
};
--
2.35.1

View File

@ -0,0 +1,41 @@
From 9a48159c5aa7c79fc7d4ac41fa94c1ccd3708ea6 Mon Sep 17 00:00:00 2001
Message-Id: <9a48159c5aa7c79fc7d4ac41fa94c1ccd3708ea6.1651330992.git.github@sicherha.de>
In-Reply-To: <339ce3afe5ebbcc924df431153a0b8fc549b9dd8.1651330992.git.github@sicherha.de>
References: <339ce3afe5ebbcc924df431153a0b8fc549b9dd8.1651330992.git.github@sicherha.de>
From: Christoph Erhardt <github@sicherha.de>
Date: Thu, 28 Apr 2022 23:48:29 +0200
Subject: [PATCH 2/3] Skip `-static-pie` tests on i686, not just on i386
Signed-off-by: Christoph Erhardt <github@sicherha.de>
---
test/elf/hello-static-pie.sh | 1 +
test/elf/ifunc-static-pie.sh | 1 +
2 files changed, 2 insertions(+)
diff --git a/test/elf/hello-static-pie.sh b/test/elf/hello-static-pie.sh
index 0921a876..6970ef9d 100755
--- a/test/elf/hello-static-pie.sh
+++ b/test/elf/hello-static-pie.sh
@@ -16,6 +16,7 @@ mkdir -p $t
# We need to implement R_386_GOT32X relaxation to support PIE on i386
[ $MACHINE = i386 ] && { echo skipped; exit; }
+[ $MACHINE = i686 ] && { echo skipped; exit; }
[ $MACHINE = aarch64 ] && { echo skipped; exit; }
diff --git a/test/elf/ifunc-static-pie.sh b/test/elf/ifunc-static-pie.sh
index 4edcfabe..5977ee53 100755
--- a/test/elf/ifunc-static-pie.sh
+++ b/test/elf/ifunc-static-pie.sh
@@ -16,6 +16,7 @@ mkdir -p $t
# We need to implement R_386_GOT32X relaxation to support PIE on i386
[ $MACHINE = i386 ] && { echo skipped; exit; }
+[ $MACHINE = i686 ] && { echo skipped; exit; }
# RISCV64 does not support IFUNC yet
[ $MACHINE = riscv64 ] && { echo skipped; exit; }
--
2.35.1

View File

@ -0,0 +1,129 @@
From 7cfbb9c4895e51ab8673b6a3f14c82be49b023c8 Mon Sep 17 00:00:00 2001
Message-Id: <7cfbb9c4895e51ab8673b6a3f14c82be49b023c8.1651339128.git.github@sicherha.de>
From: Christoph Erhardt <github@sicherha.de>
Date: Fri, 29 Apr 2022 21:44:33 +0200
Subject: [PATCH] Skip tests that fail on i686 and armv7l
---
test/elf/exception.sh | 2 ++
test/elf/gdb-index-compress-output.sh | 3 +++
test/elf/gdb-index-dwarf2.sh | 3 +++
test/elf/gdb-index-dwarf3.sh | 3 +++
test/elf/gdb-index-dwarf4.sh | 3 +++
test/elf/gdb-index-dwarf5.sh | 3 +++
test/elf/hello-static.sh | 2 ++
test/elf/ifunc-static.sh | 2 ++
8 files changed, 21 insertions(+)
diff --git a/test/elf/exception.sh b/test/elf/exception.sh
index 5df54b14..a4138103 100755
--- a/test/elf/exception.sh
+++ b/test/elf/exception.sh
@@ -14,6 +14,8 @@ mold="$(pwd)/mold"
t=out/test/elf/$testname
mkdir -p $t
+[ $MACHINE = armv7l ] && { echo skipped; exit; }
+
cat <<EOF | $CXX -c -o $t/a.o -xc++ -fPIC -
int main() {
try {
diff --git a/test/elf/gdb-index-compress-output.sh b/test/elf/gdb-index-compress-output.sh
index 05bfabd2..c22792ae 100755
--- a/test/elf/gdb-index-compress-output.sh
+++ b/test/elf/gdb-index-compress-output.sh
@@ -16,6 +16,9 @@ mkdir -p $t
[ $MACHINE = $(uname -m) ] || { echo skipped; exit; }
+[ $MACHINE = armv7l ] && { echo skipped; exit; }
+[ $MACHINE = i686 ] && { echo skipped; exit; }
+
which gdb >& /dev/null || { echo skipped; exit; }
cat <<EOF | $CC -c -o $t/a.o -fPIC -g -ggnu-pubnames -gdwarf-4 -xc - -ffunction-sections
diff --git a/test/elf/gdb-index-dwarf2.sh b/test/elf/gdb-index-dwarf2.sh
index 8e15c8e8..b6e6297e 100755
--- a/test/elf/gdb-index-dwarf2.sh
+++ b/test/elf/gdb-index-dwarf2.sh
@@ -16,6 +16,9 @@ mkdir -p $t
[ $MACHINE = $(uname -m) ] || { echo skipped; exit; }
+[ $MACHINE = armv7l ] && { echo skipped; exit; }
+[ $MACHINE = i686 ] && { echo skipped; exit; }
+
which gdb >& /dev/null || { echo skipped; exit; }
echo 'int main() {}' | $CC -o /dev/null -xc -gdwarf-2 -g - >& /dev/null ||
diff --git a/test/elf/gdb-index-dwarf3.sh b/test/elf/gdb-index-dwarf3.sh
index 727dfcbe..466f9597 100755
--- a/test/elf/gdb-index-dwarf3.sh
+++ b/test/elf/gdb-index-dwarf3.sh
@@ -16,6 +16,9 @@ mkdir -p $t
[ $MACHINE = $(uname -m) ] || { echo skipped; exit; }
+[ $MACHINE = armv7l ] && { echo skipped; exit; }
+[ $MACHINE = i686 ] && { echo skipped; exit; }
+
which gdb >& /dev/null || { echo skipped; exit; }
echo 'int main() {}' | $CC -o /dev/null -xc -gdwarf-3 -g - >& /dev/null ||
diff --git a/test/elf/gdb-index-dwarf4.sh b/test/elf/gdb-index-dwarf4.sh
index 79ae5d1a..5512cd27 100755
--- a/test/elf/gdb-index-dwarf4.sh
+++ b/test/elf/gdb-index-dwarf4.sh
@@ -16,6 +16,9 @@ mkdir -p $t
[ $MACHINE = $(uname -m) ] || { echo skipped; exit; }
+[ $MACHINE = armv7l ] && { echo skipped; exit; }
+[ $MACHINE = i686 ] && { echo skipped; exit; }
+
which gdb >& /dev/null || { echo skipped; exit; }
echo 'int main() {}' | $CC -o /dev/null -xc -gdwarf-4 -g - >& /dev/null ||
diff --git a/test/elf/gdb-index-dwarf5.sh b/test/elf/gdb-index-dwarf5.sh
index 02c0249d..09d20907 100755
--- a/test/elf/gdb-index-dwarf5.sh
+++ b/test/elf/gdb-index-dwarf5.sh
@@ -16,6 +16,9 @@ mkdir -p $t
[ $MACHINE = $(uname -m) ] || { echo skipped; exit; }
+[ $MACHINE = armv7l ] && { echo skipped; exit; }
+[ $MACHINE = i686 ] && { echo skipped; exit; }
+
which gdb >& /dev/null || { echo skipped; exit; }
echo 'int main() {}' | $CC -o /dev/null -xc -gdwarf-5 -g - >& /dev/null ||
diff --git a/test/elf/hello-static.sh b/test/elf/hello-static.sh
index 5780b88b..05c60f91 100755
--- a/test/elf/hello-static.sh
+++ b/test/elf/hello-static.sh
@@ -14,6 +14,8 @@ mold="$(pwd)/mold"
t=out/test/elf/$testname
mkdir -p $t
+[ $MACHINE = armv7l ] && { echo skipped; exit; }
+
cat <<EOF | $CC -o $t/a.o -c -xc -
#include <stdio.h>
diff --git a/test/elf/ifunc-static.sh b/test/elf/ifunc-static.sh
index e7b0b8c8..150dc921 100755
--- a/test/elf/ifunc-static.sh
+++ b/test/elf/ifunc-static.sh
@@ -17,6 +17,8 @@ mkdir -p $t
# IFUNC is not supported on RISC-V yet
[ $MACHINE = riscv64 ] && { echo skipped; exit; }
+[ $MACHINE = armv7l ] && { echo skipped; exit; }
+
# Skip if libc is musl because musl does not support GNU FUNC
echo 'int main() {}' | $CC -o $t/exe -xc -
readelf --dynamic $t/exe | grep -q ld-musl && { echo OK; exit; }
--
2.35.1

View File

@ -14,9 +14,15 @@ Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
# in the Fedora tbb package)
Patch0: tbb-strip-werror.patch
# mold can produce native binaries for i686, x86_64, ARMv7, aarch64 and riscv64,
# but it only runs on a 64-bit host
ExclusiveArch: x86_64 aarch64 riscv64
# Fix LTO on 32-bit hosts
Patch1: 0001-ELF-LTO-Fix-LTO-on-32-bit-hosts.patch
# Skip failing tests on i686 and armv7l
Patch2: 0002-Skip-static-pie-tests-on-i686-not-just-on-i386.patch
Patch3: 0003-Skip-tests-that-fail-on-i686-and-armv7l.patch
# mold can currently produce native binaries for these architectures only
ExclusiveArch: %{ix86} x86_64 %{arm} aarch64 riscv64
BuildRequires: cmake
%if 0%{?el8}
@ -106,6 +112,7 @@ fi
* Sat Apr 30 2022 Christoph Erhardt <fedora@sicherha.de> - 1.2.1-1
- Bump version to 1.2.1
- Drop upstreamed patch
- Add support for 32-bit x86 and Arm
* Sat Apr 16 2022 Christoph Erhardt <fedora@sicherha.de> - 1.2-1
- Bump version to 1.2