From 8eff4703e522bd023a611881fd20d3dda6e75f59 Mon Sep 17 00:00:00 2001 From: Christoph Erhardt Date: Sat, 22 Oct 2022 17:26:09 +0200 Subject: [PATCH] Bump version to 1.6.0 --- 0002-ELF-Fix-test-for-PPC64LE.patch | 40 ----------------- ...w-R_386_PC32-after-R_386_TLS_-GD-LDM.patch | 44 +++++++++++++++++++ 0003-ELF-i386-Fix-assertion-failure.patch | 40 +++++++++++++++++ ...for-section-symbols-when-st_shndx-SH.patch | 40 +++++++++++++++++ mold.spec | 20 +++++++-- sources | 2 +- 6 files changed, 141 insertions(+), 45 deletions(-) delete mode 100644 0002-ELF-Fix-test-for-PPC64LE.patch create mode 100644 0002-ELF-i386-Allow-R_386_PC32-after-R_386_TLS_-GD-LDM.patch create mode 100644 0003-ELF-i386-Fix-assertion-failure.patch create mode 100644 0004-Fix-name-lookup-for-section-symbols-when-st_shndx-SH.patch diff --git a/0002-ELF-Fix-test-for-PPC64LE.patch b/0002-ELF-Fix-test-for-PPC64LE.patch deleted file mode 100644 index 09f0b5a..0000000 --- a/0002-ELF-Fix-test-for-PPC64LE.patch +++ /dev/null @@ -1,40 +0,0 @@ -From f6f03510d6c19e6009c903fed00294813126db3b Mon Sep 17 00:00:00 2001 -Message-Id: -In-Reply-To: -References: -From: Rui Ueyama -Date: Thu, 29 Sep 2022 15:41:28 +0800 -Subject: [PATCH 2/2] [ELF] Fix test for PPC64LE - -`readelf --symbols` print out auxiliary information after a symbol name -for PPC64, so something like `foo$` didn't match. - - 7: 0000000000000000 80 FUNC GLOBAL DEFAULT 3 main [: 8] - 8: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND .TOC. - 9: 0000000000000000 72 FUNC GLOBAL DEFAULT 11 foo [: 8] - 10: 0000000000000000 40 FUNC GLOBAL DEFAULT 19 bar - -Fixes https://github.com/rui314/mold/issues/739 ---- - test/elf/relocatable-archive.sh | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/test/elf/relocatable-archive.sh b/test/elf/relocatable-archive.sh -index e5544bb8..759cd871 100755 ---- a/test/elf/relocatable-archive.sh -+++ b/test/elf/relocatable-archive.sh -@@ -38,8 +38,8 @@ ar crs $t/e.a $t/a.o $t/b.o $t/c.o - ./mold -r -o $t/f.o $t/d.o $t/e.a - - readelf --symbols $t/f.o > $t/log --grep -q 'foo$' $t/log --grep -q 'bar$' $t/log --! grep -q 'baz$' $t/log || false -+grep -q 'foo\b' $t/log -+grep -q 'bar\b' $t/log -+! grep -q 'baz\b' $t/log || false - - echo OK --- -2.37.3 - diff --git a/0002-ELF-i386-Allow-R_386_PC32-after-R_386_TLS_-GD-LDM.patch b/0002-ELF-i386-Allow-R_386_PC32-after-R_386_TLS_-GD-LDM.patch new file mode 100644 index 0000000..8ff0bde --- /dev/null +++ b/0002-ELF-i386-Allow-R_386_PC32-after-R_386_TLS_-GD-LDM.patch @@ -0,0 +1,44 @@ +From 2f5b3be6214d8157736e60f68693352a3ffd5a47 Mon Sep 17 00:00:00 2001 +Message-Id: <2f5b3be6214d8157736e60f68693352a3ffd5a47.1666197268.git.github@sicherha.de> +In-Reply-To: <6c0c571d629d924e3f59d8710de6589848204e17.1666197268.git.github@sicherha.de> +References: <6c0c571d629d924e3f59d8710de6589848204e17.1666197268.git.github@sicherha.de> +From: Rui Ueyama +Date: Wed, 19 Oct 2022 19:33:18 +0800 +Subject: [PATCH 2/3] [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::scan_relocations(Context &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::scan_relocations(Context &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)) +-- +2.37.3 + diff --git a/0003-ELF-i386-Fix-assertion-failure.patch b/0003-ELF-i386-Fix-assertion-failure.patch new file mode 100644 index 0000000..2ce9d75 --- /dev/null +++ b/0003-ELF-i386-Fix-assertion-failure.patch @@ -0,0 +1,40 @@ +From b6d3255e1a498d5a966bd303eb09390aa24ef596 Mon Sep 17 00:00:00 2001 +Message-Id: +In-Reply-To: <6c0c571d629d924e3f59d8710de6589848204e17.1666197268.git.github@sicherha.de> +References: <6c0c571d629d924e3f59d8710de6589848204e17.1666197268.git.github@sicherha.de> +From: Rui Ueyama +Date: Wed, 19 Oct 2022 20:14:53 +0800 +Subject: [PATCH 3/3] [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::apply_reloc_alloc(Context &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::apply_reloc_alloc(Context &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 +-- +2.37.3 + diff --git a/0004-Fix-name-lookup-for-section-symbols-when-st_shndx-SH.patch b/0004-Fix-name-lookup-for-section-symbols-when-st_shndx-SH.patch new file mode 100644 index 0000000..54d5859 --- /dev/null +++ b/0004-Fix-name-lookup-for-section-symbols-when-st_shndx-SH.patch @@ -0,0 +1,40 @@ +From 8bfdf07e71706162ab98159bf1a412d31ff31e0e Mon Sep 17 00:00:00 2001 +Message-Id: <8bfdf07e71706162ab98159bf1a412d31ff31e0e.1666443387.git.github@sicherha.de> +In-Reply-To: <6c0c571d629d924e3f59d8710de6589848204e17.1666443387.git.github@sicherha.de> +References: <6c0c571d629d924e3f59d8710de6589848204e17.1666443387.git.github@sicherha.de> +From: Christoph Erhardt +Date: Sat, 22 Oct 2022 14:41:42 +0200 +Subject: [PATCH 4/4] Fix name lookup for section symbols when `st_shndx == + SHN_XINDEX` + +When the section-header index has the escape value `SHN_XINDEX`, the +actual index must be looked up in the separate `SHT_SYMTAB_SHNDX` table. +Trying to use `SHN_XINDEX` (= 0xffff) as an index results in an +out-of-bounds read. The error can be observed when running the +`x86_64_many-sections.sh` test on RHEL 8 or 9 (but not on Fedora, +because there the assembler doesn't emit section symbols). + +Instead of using `st_shndx` directly, call the pre-existing helper +method `get_shndx()` to get the correct behaviour. + +Signed-off-by: Christoph Erhardt +--- + elf/input-files.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/elf/input-files.cc b/elf/input-files.cc +index 15ccd634..3c5ca619 100644 +--- a/elf/input-files.cc ++++ b/elf/input-files.cc +@@ -439,7 +439,7 @@ void ObjectFile::initialize_symbols(Context &ctx) { + + std::string_view name; + if (esym.st_type == STT_SECTION) +- name = this->shstrtab.data() + this->elf_sections[esym.st_shndx].sh_name; ++ name = this->shstrtab.data() + this->elf_sections[get_shndx(esym)].sh_name; + else + name = this->symbol_strtab.data() + esym.st_name; + +-- +2.37.3 + diff --git a/mold.spec b/mold.spec index 1a4366c..c8e6959 100644 --- a/mold.spec +++ b/mold.spec @@ -1,5 +1,5 @@ Name: mold -Version: 1.5.1 +Version: 1.6.0 Release: 1%{?dist} Summary: A Modern Linker @@ -17,11 +17,15 @@ Patch0: tbb-strip-werror.patch # Allow building against the system-provided `xxhash.h` Patch2: 0001-Use-system-compatible-include-path-for-xxhash.h.patch -# Fix unit test failing on ppc64 -Patch3: 0002-ELF-Fix-test-for-PPC64LE.patch +# Fix test failure on i386 (https://github.com/rui314/mold/issues/794) +Patch3: 0002-ELF-i386-Allow-R_386_PC32-after-R_386_TLS_-GD-LDM.patch +Patch4: 0003-ELF-i386-Fix-assertion-failure.patch + +# Fix test failure on epel8/epel9 (https://github.com/rui314/mold/pull/809) +Patch5: 0004-Fix-name-lookup-for-section-symbols-when-st_shndx-SH.patch # mold can currently produce native binaries for these architectures only -ExclusiveArch: %{ix86} x86_64 %{arm32} aarch64 ppc64le %{riscv32} %{riscv64} sparc64 sparc64v +ExclusiveArch: %{ix86} x86_64 %{arm32} aarch64 %{power64} %{riscv32} %{riscv64} s390x sparc64 sparc64v BuildRequires: cmake %if 0%{?el8} @@ -36,6 +40,9 @@ BuildRequires: openssl-devel BuildRequires: xxhash-devel BuildRequires: zlib-devel +# Required by bundled oneTBB +BuildRequires: hwloc-devel + # The following packages are only required for executing the tests BuildRequires: clang BuildRequires: gdb @@ -104,6 +111,11 @@ fi %{_mandir}/man1/mold.1* %changelog +* Sat Oct 22 2022 Christoph Erhardt - 1.6.0-1 +- Bump version to 1.6.0 +- Add new supported architectures +- Drop upstreamed patch + * Thu Sep 29 2022 Christoph Erhardt - 1.5.1-1 - Bump version to 1.5.1 (#2130132) - Switch to CMake build diff --git a/sources b/sources index ce2f44f..99d30c6 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (mold-1.5.1.tar.gz) = 340a45c5190ce5ba87eaa05238da7c70400bf4a2788a095935b9675593078ad76bbd95e67aa36b3ec683428724a3c6bc27c7e0a69569afce461682dc4bd16b10 +SHA512 (mold-1.6.0.tar.gz) = dcb498da95ee02a08b175861ae24f3793705671670f6f3487eebd3aab2487fd2163fc1747c9ca2fd1c3570a5f1f0bcfd7d4d91bf6a904a1ba098be6cbbe8c857