From 52527c462f255065bcb053f14a13b747a8a30005 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Tue, 19 Nov 2019 08:50:58 -0500 Subject: [PATCH] add patch fixing copy relocs issue on riscv this is binutils issue 23825, but it's caused by gcc using local-exec model rather than initial-exec model with the intent of making binutils generate copy relocations. this is harmful, unnecessary, and not presently supported by musl (and probably should never be). patch taken from https://github.com/riscv/riscv-gcc/pull/118. --- .../gcc-7.2.0/0016-riscv-tls-copy-relocs.diff | 16 ++++++++++++++++ .../gcc-7.3.0/0018-riscv-tls-copy-relocs.diff | 16 ++++++++++++++++ .../gcc-8.3.0/0015-riscv-tls-copy-relocs.diff | 16 ++++++++++++++++ .../gcc-9.2.0/0015-riscv-tls-copy-relocs.diff | 16 ++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 patches/gcc-7.2.0/0016-riscv-tls-copy-relocs.diff create mode 100644 patches/gcc-7.3.0/0018-riscv-tls-copy-relocs.diff create mode 100644 patches/gcc-8.3.0/0015-riscv-tls-copy-relocs.diff create mode 100644 patches/gcc-9.2.0/0015-riscv-tls-copy-relocs.diff diff --git a/patches/gcc-7.2.0/0016-riscv-tls-copy-relocs.diff b/patches/gcc-7.2.0/0016-riscv-tls-copy-relocs.diff new file mode 100644 index 0000000..566be71 --- /dev/null +++ b/patches/gcc-7.2.0/0016-riscv-tls-copy-relocs.diff @@ -0,0 +1,16 @@ +diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c +index 677728e77ed..444d01e87ec 100644 +--- a/gcc/config/riscv/riscv.c ++++ b/gcc/config/riscv/riscv.c +@@ -1209,9 +1209,11 @@ riscv_legitimize_tls_address (rtx loc) + rtx dest, tp, tmp; + enum tls_model model = SYMBOL_REF_TLS_MODEL (loc); + ++#if 0 + /* Since we support TLS copy relocs, non-PIC TLS accesses may all use LE. */ + if (!flag_pic) + model = TLS_MODEL_LOCAL_EXEC; ++#endif + + switch (model) + { diff --git a/patches/gcc-7.3.0/0018-riscv-tls-copy-relocs.diff b/patches/gcc-7.3.0/0018-riscv-tls-copy-relocs.diff new file mode 100644 index 0000000..566be71 --- /dev/null +++ b/patches/gcc-7.3.0/0018-riscv-tls-copy-relocs.diff @@ -0,0 +1,16 @@ +diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c +index 677728e77ed..444d01e87ec 100644 +--- a/gcc/config/riscv/riscv.c ++++ b/gcc/config/riscv/riscv.c +@@ -1209,9 +1209,11 @@ riscv_legitimize_tls_address (rtx loc) + rtx dest, tp, tmp; + enum tls_model model = SYMBOL_REF_TLS_MODEL (loc); + ++#if 0 + /* Since we support TLS copy relocs, non-PIC TLS accesses may all use LE. */ + if (!flag_pic) + model = TLS_MODEL_LOCAL_EXEC; ++#endif + + switch (model) + { diff --git a/patches/gcc-8.3.0/0015-riscv-tls-copy-relocs.diff b/patches/gcc-8.3.0/0015-riscv-tls-copy-relocs.diff new file mode 100644 index 0000000..566be71 --- /dev/null +++ b/patches/gcc-8.3.0/0015-riscv-tls-copy-relocs.diff @@ -0,0 +1,16 @@ +diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c +index 677728e77ed..444d01e87ec 100644 +--- a/gcc/config/riscv/riscv.c ++++ b/gcc/config/riscv/riscv.c +@@ -1209,9 +1209,11 @@ riscv_legitimize_tls_address (rtx loc) + rtx dest, tp, tmp; + enum tls_model model = SYMBOL_REF_TLS_MODEL (loc); + ++#if 0 + /* Since we support TLS copy relocs, non-PIC TLS accesses may all use LE. */ + if (!flag_pic) + model = TLS_MODEL_LOCAL_EXEC; ++#endif + + switch (model) + { diff --git a/patches/gcc-9.2.0/0015-riscv-tls-copy-relocs.diff b/patches/gcc-9.2.0/0015-riscv-tls-copy-relocs.diff new file mode 100644 index 0000000..566be71 --- /dev/null +++ b/patches/gcc-9.2.0/0015-riscv-tls-copy-relocs.diff @@ -0,0 +1,16 @@ +diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c +index 677728e77ed..444d01e87ec 100644 +--- a/gcc/config/riscv/riscv.c ++++ b/gcc/config/riscv/riscv.c +@@ -1209,9 +1209,11 @@ riscv_legitimize_tls_address (rtx loc) + rtx dest, tp, tmp; + enum tls_model model = SYMBOL_REF_TLS_MODEL (loc); + ++#if 0 + /* Since we support TLS copy relocs, non-PIC TLS accesses may all use LE. */ + if (!flag_pic) + model = TLS_MODEL_LOCAL_EXEC; ++#endif + + switch (model) + {