]> git.pld-linux.org Git - packages/mold.git/commitdiff
upstream fixes for x86 32bit non-PIC failures; rel 2 auto/th/mold-1.6.0-2
authorJan Palus <atler@pld-linux.org>
Wed, 19 Oct 2022 12:21:44 +0000 (14:21 +0200)
committerJan Palus <atler@pld-linux.org>
Wed, 19 Oct 2022 12:21:44 +0000 (14:21 +0200)
see https://github.com/rui314/mold/issues/794

mold.spec
x86-nonpic.patch [new file with mode: 0644]

index 0ac1b75fa4b6961a89113150fcc5deebce2f4177..f2a812b72babff81d22738348ba5fe8e7fcac9d0 100644 (file)
--- a/mold.spec
+++ b/mold.spec
@@ -5,11 +5,12 @@
 Summary:       mold: A Modern Linker
 Name:          mold
 Version:       1.6.0
 Summary:       mold: A Modern Linker
 Name:          mold
 Version:       1.6.0
-Release:       1
+Release:       2
 License:       GPL v3+
 Group:         Development/Libraries
 Source0:       https://github.com/rui314/mold/archive/v%{version}/%{name}-%{version}.tar.gz
 # Source0-md5: f6eb0adbc0ebd5dc75aed698bddd1a0e
 License:       GPL v3+
 Group:         Development/Libraries
 Source0:       https://github.com/rui314/mold/archive/v%{version}/%{name}-%{version}.tar.gz
 # Source0-md5: f6eb0adbc0ebd5dc75aed698bddd1a0e
+Patch0:                x86-nonpic.patch
 URL:           https://github.com/rui314/mold
 BuildRequires: cmake >= 3.13
 %{?with_tests:BuildRequires:   glibc-static}
 URL:           https://github.com/rui314/mold
 BuildRequires: cmake >= 3.13
 %{?with_tests:BuildRequires:   glibc-static}
@@ -38,6 +39,7 @@ especially in rapid debug-edit-rebuild cycles.
 
 %prep
 %setup -q
 
 %prep
 %setup -q
+%patch0 -p1
 
 %{__rm} -r third-party/{mimalloc,tbb}
 
 
 %{__rm} -r third-party/{mimalloc,tbb}
 
diff --git a/x86-nonpic.patch b/x86-nonpic.patch
new file mode 100644 (file)
index 0000000..615b112
--- /dev/null
@@ -0,0 +1,72 @@
+From 2aa24949c7214c20cfc943a4862b5ff63470112f Mon Sep 17 00:00:00 2001
+From: Rui Ueyama <ruiu@bluewhale.systems>
+Date: Wed, 19 Oct 2022 19:33:18 +0800
+Subject: [PATCH] [ELF][i386] Allow R_386_PC32 after R_386_TLS_{GD,LDM}
+
+I don't know why GCC sometimes creates a PC32 relocation instead of
+PLT32 after a TLS_GD/TLS_LDM. I believe it's strictly speaking a
+violation of the psABI. But we need to handle such input.
+
+Fixes https://github.com/rui314/mold/issues/794
+---
+ elf/arch-i386.cc | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/elf/arch-i386.cc b/elf/arch-i386.cc
+index 46391844..20563faa 100644
+--- a/elf/arch-i386.cc
++++ b/elf/arch-i386.cc
+@@ -485,7 +485,8 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
+         Fatal(ctx) << *this << ": TLS_GD reloc must be followed by PLT or GOT32";
+       if (u32 ty = rels[i + 1].r_type;
+-          ty != R_386_PLT32 && ty != R_386_GOT32 && ty != R_386_GOT32X)
++          ty != R_386_PLT32 && ty != R_386_PC32 &&
++          ty != R_386_GOT32 && ty != R_386_GOT32X)
+         Fatal(ctx) << *this << ": TLS_GD reloc must be followed by PLT or GOT32";
+       if (relax_tlsgd(ctx, sym))
+@@ -498,7 +499,8 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
+         Fatal(ctx) << *this << ": TLS_LDM reloc must be followed by PLT or GOT32";
+       if (u32 ty = rels[i + 1].r_type;
+-          ty != R_386_PLT32 && ty != R_386_GOT32 && ty != R_386_GOT32X)
++          ty != R_386_PLT32 && ty != R_386_PC32 &&
++          ty != R_386_GOT32 && ty != R_386_GOT32X)
+         Fatal(ctx) << *this << ": TLS_LDM reloc must be followed by PLT or GOT32";
+       if (relax_tlsld(ctx))
+From 288cd5b4007a0a20da9aab52ab56067ad46866e8 Mon Sep 17 00:00:00 2001
+From: Rui Ueyama <ruiu@bluewhale.systems>
+Date: Wed, 19 Oct 2022 20:14:53 +0800
+Subject: [PATCH] [ELF][i386] Fix assertion failure
+
+https://github.com/rui314/mold/issues/794
+---
+ elf/arch-i386.cc | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/elf/arch-i386.cc b/elf/arch-i386.cc
+index 20563faa..87524fd1 100644
+--- a/elf/arch-i386.cc
++++ b/elf/arch-i386.cc
+@@ -234,7 +234,8 @@ void InputSection<E>::apply_reloc_alloc(Context<E> &ctx, u8 *base) {
+       } else {
+         // Relax GD to LE
+         switch (rels[i + 1].r_type) {
+-        case R_386_PLT32: {
++        case R_386_PLT32:
++        case R_386_PC32: {
+           static const u8 insn[] = {
+             0x65, 0xa1, 0, 0, 0, 0, // mov %gs:0, %eax
+             0x81, 0xe8, 0, 0, 0, 0, // add $val, %eax
+@@ -266,7 +267,8 @@ void InputSection<E>::apply_reloc_alloc(Context<E> &ctx, u8 *base) {
+       } else {
+         // Relax LD to LE
+         switch (rels[i + 1].r_type) {
+-        case R_386_PLT32: {
++        case R_386_PLT32:
++        case R_386_PC32: {
+           static const u8 insn[] = {
+             0x31, 0xc0,             // xor %eax, %eax
+             0x65, 0x8b, 0x00,       // mov %gs:(%eax), %eax
This page took 0.41068 seconds and 4 git commands to generate.