Source: binutils Version: 2.27-2 Tags: patch User: debian-sp...@lists.debian.org Usertags: sparc64 X-Debbugs-Cc: glaub...@physik.fu-berlin.de
Hi Matthias, Here is a debdiff with the three proposed fixes for gold on sparc64 as discussed. Regards, James
diff -u binutils-2.27/debian/changelog binutils-2.27/debian/changelog --- binutils-2.27/debian/changelog +++ binutils-2.27/debian/changelog @@ -1,3 +1,9 @@ +binutils (2.27-3) UNRELEASED; urgency=medium + + * Added patches to fix gold on sparc64. + + -- James Clarke <jrt...@jrtc27.com> Sun, 07 Aug 2016 21:54:56 +0100 + binutils (2.27-2) unstable; urgency=medium * Disable gold for all mips cross targets too. diff -u binutils-2.27/debian/patches/series binutils-2.27/debian/patches/series --- binutils-2.27/debian/patches/series +++ binutils-2.27/debian/patches/series @@ -26,2 +26,6 @@ +sparc64-gold-allow-R_SPARC_32.patch +sparc64-gold-fix-R_SPARC_GOTDATA_OP_LOX10.patch +sparc64-gold-fix-gc-sections.patch + # patches taken from the trunk only in patch2: unchanged: --- binutils-2.27.orig/debian/patches/sparc64-gold-allow-R_SPARC_32.patch +++ binutils-2.27/debian/patches/sparc64-gold-allow-R_SPARC_32.patch @@ -0,0 +1,29 @@ +From 4da566d6d858ba1d05f495240eaae4500c97fc77 Mon Sep 17 00:00:00 2001 +From: James Clarke <jrt...@jrtc27.com> +Date: Wed, 13 Jul 2016 19:49:08 +0100 +Subject: [PATCH] Allow R_SPARC_32 on sparc64 +To: binut...@sourceware.org +Cc: Cary Coutant <ccout...@gmail.com> + +gold/ + * sparc.cc (Target_sparc::Scan::check_non_pic): Allow R_SPARC_32 on + sparc64. +--- + gold/sparc.cc | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/gold/sparc.cc b/gold/sparc.cc +index dc4612d..d9a8ef4 100644 +--- a/gold/sparc.cc ++++ b/gold/sparc.cc +@@ -2150,6 +2150,7 @@ Target_sparc<size, big_endian>::Scan::check_non_pic(Relobj* object, unsigned int + case elfcpp::R_SPARC_RELATIVE: + case elfcpp::R_SPARC_IRELATIVE: + case elfcpp::R_SPARC_COPY: ++ case elfcpp::R_SPARC_32: + case elfcpp::R_SPARC_64: + case elfcpp::R_SPARC_GLOB_DAT: + case elfcpp::R_SPARC_JMP_SLOT: +-- +2.9.1 + only in patch2: unchanged: --- binutils-2.27.orig/debian/patches/sparc64-gold-fix-R_SPARC_GOTDATA_OP_LOX10.patch +++ binutils-2.27/debian/patches/sparc64-gold-fix-R_SPARC_GOTDATA_OP_LOX10.patch @@ -0,0 +1,49 @@ +From fe9ea8c5fc9b612e315848cb75ffbbe2227f8299 Mon Sep 17 00:00:00 2001 +From: James Clarke <jrt...@jrtc27.com> +Date: Wed, 13 Jul 2016 19:58:14 +0100 +Subject: [PATCH] R_SPARC_GOTDATA_OP_LOX10 should fall back on GOT10 not GOT13 +To: binut...@sourceware.org +Cc: Cary Coutant <ccout...@gmail.com> + +gold/ + * sparc.cc (Target_sparc::Relocate::relocate): R_SPARC_GOTDATA_OP_LOX10 + should fall back on R_SPARC_GOT10, not R_SPARC_GOT13. +--- + gold/sparc.cc | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/gold/sparc.cc b/gold/sparc.cc +index dc4612d..de16f4b 100644 +--- a/gold/sparc.cc ++++ b/gold/sparc.cc +@@ -3469,6 +3469,13 @@ Target_sparc<size, big_endian>::Relocate::relocate( + Reloc::lo10(view, object, psymval, addend); + break; + ++ case elfcpp::R_SPARC_GOTDATA_OP_LOX10: ++ if (gdop_valid) ++ { ++ Reloc::gdop_lox10(view, got_offset); ++ break; ++ } ++ /* Fall through. */ + case elfcpp::R_SPARC_GOT10: + Reloc::lo10(view, got_offset, addend); + break; +@@ -3487,13 +3494,6 @@ Target_sparc<size, big_endian>::Relocate::relocate( + } + break; + +- case elfcpp::R_SPARC_GOTDATA_OP_LOX10: +- if (gdop_valid) +- { +- Reloc::gdop_lox10(view, got_offset); +- break; +- } +- /* Fall through. */ + case elfcpp::R_SPARC_GOT13: + Reloc::rela32_13(view, got_offset, addend); + break; +-- +2.9.1 + only in patch2: unchanged: --- binutils-2.27.orig/debian/patches/sparc64-gold-fix-gc-sections.patch +++ binutils-2.27/debian/patches/sparc64-gold-fix-gc-sections.patch @@ -0,0 +1,92 @@ +From d4d7f65bb1d5aad78bd9650c4efd7d4592ba2796 Mon Sep 17 00:00:00 2001 +From: James Clarke <jrt...@jrtc27.com> +Date: Sun, 24 Jul 2016 18:30:13 +0100 +Subject: [PATCH] gold: Fix segfault on sparc with STT_SPARC_REGISTER and + --gc-sections +To: binut...@sourceware.org +Cc: Cary Coutant <ccout...@gmail.com> + +gold/ + * symtab.cc (Symbol_table::add_from_relobj): Handle NULL symbols, + which will be present for STT_SPARC_REGISTER. + (Symbol_table::add_from_pluginobj): Likewise. + (Symbol_table::add_from_dynobj): Likewise. + (Symbol_table::add_from_incrobj): Removed dead code. +--- + +Easy reproduction: + + $ cat main.c + int main() { + return 0; + } + $ gcc -o main -Wl,--gc-sections main.c + $ gcc -fuse-ld=gold -o main -Wl,--gc-sections main.c + collect2: fatal error: ld terminated with signal 11 [Segmentation fault] + compilation terminated. + +This is because res->is_externally_visible inside Symbol_table::add_from_relobj +when res is NULL (since this is an STT_SPARC_REGISTER dummy symbol). + +With this patch I've done the obvious bare minimum to get this to work, but +given these NULLs are floating around now I highly suspect there will be other +places where they crop up. + + gold/symtab.cc | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +diff --git a/gold/symtab.cc b/gold/symtab.cc +index 5ce5c31..b31794a 100644 +--- a/gold/symtab.cc ++++ b/gold/symtab.cc +@@ -1325,6 +1325,9 @@ Symbol_table::add_from_relobj( + res = this->add_from_object(relobj, name, name_key, ver, ver_key, + is_default_version, *psym, st_shndx, + is_ordinary, orig_st_shndx); ++ ++ if (res == NULL) ++ continue; + + if (is_forced_local) + this->force_local(res); +@@ -1406,6 +1409,9 @@ Symbol_table::add_from_pluginobj( + is_default_version, *sym, st_shndx, + is_ordinary, st_shndx); + ++ if (res == NULL) ++ return NULL; ++ + if (is_forced_local) + this->force_local(res); + +@@ -1602,6 +1608,9 @@ Symbol_table::add_from_dynobj( + } + } + ++ if (res == NULL) ++ continue; ++ + // Note that it is possible that RES was overridden by an + // earlier object, in which case it can't be aliased here. + if (st_shndx != elfcpp::SHN_UNDEF +@@ -1640,7 +1649,6 @@ Symbol_table::add_from_incrobj( + + Stringpool::Key ver_key = 0; + bool is_default_version = false; +- bool is_forced_local = false; + + Stringpool::Key name_key; + name = this->namepool_.add(name, true, &name_key); +@@ -1650,9 +1658,6 @@ Symbol_table::add_from_incrobj( + is_default_version, *sym, st_shndx, + is_ordinary, st_shndx); + +- if (is_forced_local) +- this->force_local(res); +- + return res; + } + +-- +2.9.1 +
signature.asc
Description: PGP signature