Initial commit on c9s

Resolves: RHELMISC-34713
This commit is contained in:
Nick Clifton 2026-06-09 09:22:21 +01:00
parent c631df82f5
commit d38e615157
40 changed files with 6467 additions and 0 deletions

2
.gitignore vendored
View File

@ -0,0 +1,2 @@
/binutils-with-gold-2.46.tar.xz
/binutils-2.19.50.0.1-output-format.sed

View File

@ -0,0 +1,11 @@
diff -rup binutils.orig/bfd/elfnn-aarch64.c binutils-2.27/bfd/elfnn-aarch64.c
--- binutils.orig/bfd/elfnn-aarch64.c 2017-02-21 10:45:19.311956006 +0000
+++ binutils-2.27/bfd/elfnn-aarch64.c 2017-02-21 11:55:07.517922655 +0000
@@ -4947,6 +4947,7 @@ elfNN_aarch64_final_link_relocate (reloc
it here if it is defined in a non-shared object. */
if (h != NULL
&& h->type == STT_GNU_IFUNC
+ && (input_section->flags & SEC_ALLOC)
&& h->def_regular)
{
asection *plt;

View File

@ -0,0 +1,154 @@
From 3221c470f0765886a49a1a3d2ec602e4104a377b Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 2 Aug 2024 19:52:00 -0700
Subject: [PATCH] LTO: Restore the wrapper symbol check for standard function
Call unwrap_hash_lookup to restore the wrapper symbol check for standard
function since reference to standard function may not show up in LTO
symbol table:
[hjl@gnu-tgl-3 pr31956-3]$ nm foo.o
00000000 T main
U __real_malloc
00000000 T __wrap_malloc
[hjl@gnu-tgl-3 pr31956-3]$ lto-dump -list foo.o
Type Visibility Size Name
function default 0 malloc
function default 0 __real_malloc
function default 3 main
function default 5 __wrap_malloc
[hjl@gnu-tgl-3 pr31956-3]$ make
gcc -O2 -flto -Wall -c -o foo.o foo.c
gcc -Wl,--wrap=malloc -O2 -flto -Wall -o x foo.o
/usr/local/bin/ld: /tmp/ccsPW0a9.ltrans0.ltrans.o: in function `main':
<artificial>:(.text.startup+0xa): undefined reference to `__wrap_malloc'
collect2: error: ld returned 1 exit status
make: *** [Makefile:22: x] Error 1
[hjl@gnu-tgl-3 pr31956-3]$
Also add a test to verify that the unused wrapper is removed.
PR ld/31956
* plugin.c (get_symbols): Restore the wrapper symbol check for
standard function.
* testsuite/ld-plugin/lto.exp: Run the malloc test and the
unused test.
* testsuite/ld-plugin/pr31956c.c: New file.
* testsuite/ld-plugin/pr31956d.c: New file.
* testsuite/ld-plugin/pr31956d.d: New file.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
ld/plugin.c | 14 ++++++++++++--
ld/testsuite/ld-plugin/lto.exp | 16 ++++++++++++++++
ld/testsuite/ld-plugin/pr31956c.c | 19 +++++++++++++++++++
ld/testsuite/ld-plugin/pr31956d.c | 7 +++++++
ld/testsuite/ld-plugin/pr31956d.d | 4 ++++
5 files changed, 58 insertions(+), 2 deletions(-)
create mode 100644 ld/testsuite/ld-plugin/pr31956c.c
create mode 100644 ld/testsuite/ld-plugin/pr31956d.c
create mode 100644 ld/testsuite/ld-plugin/pr31956d.d
diff --git a/ld/plugin.c b/ld/plugin.c
index 03ee9880d10..51c4765cc5b 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -778,8 +778,18 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms,
{
blhe = h;
/* Check if a symbol is a wrapper symbol. */
- if (blhe && blhe->wrapper_symbol)
- wrap_status = wrapper;
+ if (blhe)
+ {
+ if (blhe->wrapper_symbol)
+ wrap_status = wrapper;
+ else if (link_info.wrap_hash != NULL)
+ {
+ struct bfd_link_hash_entry *unwrap
+ = unwrap_hash_lookup (&link_info, (bfd *) abfd, blhe);
+ if (unwrap != NULL && unwrap != h)
+ wrap_status = wrapper;
+ }
+ }
}
else
{
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index ad59e2abd61..1a8c3736307 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -546,6 +546,22 @@ set lto_link_elf_tests [list \
{} \
"pr31956b" \
] \
+ [list \
+ "PR ld/31956 (malloc)" \
+ "-Wl,--wrap=malloc" \
+ "-O2 -flto" \
+ {pr31956c.c} \
+ {} \
+ "pr31956c" \
+ ] \
+ [list \
+ "PR ld/31956 (unused)" \
+ "-Wl,--wrap=parse_line" \
+ "-O2 -flto" \
+ {pr31956d.c} \
+ {{"nm" {} "pr31956d.d"}} \
+ "pr31956d" \
+ ] \
[list \
"Build pr30281.so" \
"-shared -Wl,--version-script,pr30281.t \
diff --git a/ld/testsuite/ld-plugin/pr31956c.c b/ld/testsuite/ld-plugin/pr31956c.c
new file mode 100644
index 00000000000..4a46b2b49a8
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr31956c.c
@@ -0,0 +1,19 @@
+#include <stdlib.h>
+
+extern void *__real_malloc (size_t);
+
+void *
+__wrap_malloc (size_t n)
+{
+ if (n == 0)
+ return NULL;
+ else
+ return __real_malloc (n);
+};
+
+int
+main (void)
+{
+ void *ptr = malloc (30);
+ return ptr == NULL ? 1 : 0;
+}
diff --git a/ld/testsuite/ld-plugin/pr31956d.c b/ld/testsuite/ld-plugin/pr31956d.c
new file mode 100644
index 00000000000..cb7f2d50643
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr31956d.c
@@ -0,0 +1,7 @@
+void __wrap_parse_line(void) {};
+
+int
+main (void)
+{
+ return 0;
+}
diff --git a/ld/testsuite/ld-plugin/pr31956d.d b/ld/testsuite/ld-plugin/pr31956d.d
new file mode 100644
index 00000000000..b579cdc7353
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr31956d.d
@@ -0,0 +1,4 @@
+#failif
+#...
+[0-9a-f]+ T .*parse_line
+#...
--
2.45.2

View File

@ -0,0 +1,167 @@
diff -rup binutils-with-gold-2.45.90/bfd/elf-attrs.c /work/sources/binutils/upstream/2.46/bfd/elf-attrs.c
--- binutils-with-gold-2.45.90/bfd/elf-attrs.c 2026-01-25 09:30:41.000000000 +0000
+++ /work/sources/binutils/upstream/2.46/bfd/elf-attrs.c 2026-01-27 08:04:23.387789745 +0000
@@ -3192,7 +3192,7 @@ _bfd_elf_obj_attr_v2_cmp (const obj_attr
This allows an early return if we find a higher numbered tag. */
obj_attr_v2_t *
-_bfd_obj_attr_v2_find_by_tag (const obj_attr_subsection_v2_t *subsec,
+bfd_obj_attr_v2_find_by_tag (const obj_attr_subsection_v2_t *subsec,
obj_attr_tag_t tag,
bool sorted)
{
@@ -3218,6 +3218,14 @@ LINKED_LIST_MUTATIVE_OPS_DECL (obj_attr_
LINKED_LIST_MERGE_SORT_DECL (obj_attr_subsection_v2_t,
obj_attr_v2_t, /* extern */)
+/* Public API wrapper for LINKED_LIST_APPEND (obj_attr_v2_t). */
+
+void bfd_obj_attr_subsection_v2_append (obj_attr_subsection_v2_t *subsec,
+ obj_attr_v2_t *attr)
+{
+ LINKED_LIST_APPEND (obj_attr_v2_t) (subsec, attr);
+}
+
/* Create a new object attribute subsection with the following properties:
- NAME: the name of the subsection. Note: this parameter never holds a
string literal, so the value has to be freeable.
@@ -3364,6 +3372,24 @@ LINKED_LIST_MUTATIVE_OPS_DECL (obj_attr_
LINKED_LIST_MERGE_SORT_DECL (obj_attr_subsection_list_t,
obj_attr_subsection_v2_t, /* extern */)
+/* Public API wrapper for LINKED_LIST_APPEND (obj_attr_subsection_v2_t). */
+
+void
+bfd_obj_attr_subsection_v2_list_append (obj_attr_subsection_list_t *l,
+ obj_attr_subsection_v2_t *subsec)
+{
+ LINKED_LIST_APPEND (obj_attr_subsection_v2_t) (l, subsec);
+}
+
+/* Public API wrapper for LINKED_LIST_REMOVE (obj_attr_subsection_v2_t). */
+
+obj_attr_subsection_v2_t *
+bfd_obj_attr_subsection_v2_list_remove (obj_attr_subsection_list_t *l,
+ obj_attr_subsection_v2_t *subsec)
+{
+ return LINKED_LIST_REMOVE (obj_attr_subsection_v2_t) (l, subsec);
+}
+
/* Serialize the object attributes in ABFD into the vendor section of
OUTPUT_BFD. */
diff -rup binutils-with-gold-2.45.90/bfd/elf-bfd.h /work/sources/binutils/upstream/2.46/bfd/elf-bfd.h
--- binutils-with-gold-2.45.90/bfd/elf-bfd.h 2026-01-25 09:30:41.000000000 +0000
+++ /work/sources/binutils/upstream/2.46/bfd/elf-bfd.h 2026-01-27 08:04:23.387789745 +0000
@@ -3216,15 +3216,17 @@ extern bool _bfd_elf_read_notes
(bfd *, file_ptr, bfd_size_type, size_t) ATTRIBUTE_HIDDEN;
extern obj_attr_v2_t *bfd_elf_obj_attr_v2_init (obj_attr_tag_t,
- union obj_attr_value_v2) ATTRIBUTE_HIDDEN;
+ union obj_attr_value_v2);
extern void _bfd_elf_obj_attr_v2_free (obj_attr_v2_t *, obj_attr_encoding_v2_t)
ATTRIBUTE_HIDDEN;
extern obj_attr_v2_t *_bfd_elf_obj_attr_v2_copy (const obj_attr_v2_t *,
obj_attr_encoding_v2_t) ATTRIBUTE_HIDDEN;
extern int _bfd_elf_obj_attr_v2_cmp (const obj_attr_v2_t *,
const obj_attr_v2_t *) ATTRIBUTE_HIDDEN;
-extern obj_attr_v2_t * _bfd_obj_attr_v2_find_by_tag
- (const obj_attr_subsection_v2_t *, obj_attr_tag_t, bool) ATTRIBUTE_HIDDEN;
+extern obj_attr_v2_t *bfd_obj_attr_v2_find_by_tag
+ (const obj_attr_subsection_v2_t *, obj_attr_tag_t, bool);
+extern void bfd_obj_attr_subsection_v2_append
+ (obj_attr_subsection_v2_t *, obj_attr_v2_t *);
LINKED_LIST_MUTATIVE_OPS_PROTOTYPE (obj_attr_subsection_v2_t,
obj_attr_v2_t, ATTRIBUTE_HIDDEN);
LINKED_LIST_MERGE_SORT_PROTOTYPE_ (obj_attr_v2_t, ATTRIBUTE_HIDDEN);
@@ -3241,6 +3243,10 @@ extern obj_attr_subsection_v2_t *bfd_obj
(obj_attr_subsection_v2_t *, const char *, bool);
extern obj_attr_subsection_scope_v2_t bfd_elf_obj_attr_subsection_v2_scope
(const bfd *, const char *);
+extern void bfd_obj_attr_subsection_v2_list_append
+ (obj_attr_subsection_list_t *, obj_attr_subsection_v2_t *);
+extern obj_attr_subsection_v2_t *bfd_obj_attr_subsection_v2_list_remove
+ (obj_attr_subsection_list_t *, obj_attr_subsection_v2_t *);
LINKED_LIST_MUTATIVE_OPS_PROTOTYPE (obj_attr_subsection_list_t,
obj_attr_subsection_v2_t,
ATTRIBUTE_HIDDEN);
diff -rup binutils-with-gold-2.45.90/bfd/elfnn-aarch64.c /work/sources/binutils/upstream/2.46/bfd/elfnn-aarch64.c
--- binutils-with-gold-2.45.90/bfd/elfnn-aarch64.c 2026-01-25 09:30:41.000000000 +0000
+++ /work/sources/binutils/upstream/2.46/bfd/elfnn-aarch64.c 2026-01-27 08:04:23.388789835 +0000
@@ -10632,7 +10632,7 @@ elfNN_aarch64_link_setup_object_attribut
if (aeabi_feature_and_bits_subsec != NULL)
{
const obj_attr_v2_t *attr_bti
- = _bfd_obj_attr_v2_find_by_tag (aeabi_feature_and_bits_subsec,
+ = bfd_obj_attr_v2_find_by_tag (aeabi_feature_and_bits_subsec,
Tag_Feature_BTI, true);
if (attr_bti && attr_bti->val.uint == 1)
tdata->sw_protections.plt_type |= PLT_BTI;
diff -rup binutils-with-gold-2.45.90/bfd/elfxx-aarch64.c /work/sources/binutils/upstream/2.46/bfd/elfxx-aarch64.c
--- binutils-with-gold-2.45.90/bfd/elfxx-aarch64.c 2026-01-25 09:30:41.000000000 +0000
+++ /work/sources/binutils/upstream/2.46/bfd/elfxx-aarch64.c 2026-01-27 08:04:23.388789835 +0000
@@ -956,7 +956,7 @@ obj_attr_v2_record_tag_value (obj_attr_s
bool value)
{
obj_attr_v2_t *attr;
- attr = _bfd_obj_attr_v2_find_by_tag (subsec, tag, false);
+ attr = bfd_obj_attr_v2_find_by_tag (subsec, tag, false);
if (attr != NULL)
{
if (attr->val.uint != value)
@@ -1175,11 +1175,11 @@ aarch64_check_pauthabi_attributes (const
int version_id = 0;
const obj_attr_v2_t *attr
- = _bfd_obj_attr_v2_find_by_tag (subsec, Tag_PAuth_Platform, true);
+ = bfd_obj_attr_v2_find_by_tag (subsec, Tag_PAuth_Platform, true);
if (attr != NULL)
platform_id = attr->val.uint;
- attr = _bfd_obj_attr_v2_find_by_tag (subsec, Tag_PAuth_Schema, true);
+ attr = bfd_obj_attr_v2_find_by_tag (subsec, Tag_PAuth_Schema, true);
if (attr != NULL)
version_id = attr->val.uint;
diff -rup binutils-with-gold-2.45.90/gas/config/obj-elf-attr.c /work/sources/binutils/upstream/2.46/gas/config/obj-elf-attr.c
--- binutils-with-gold-2.45.90/gas/config/obj-elf-attr.c 2026-01-25 09:30:41.000000000 +0000
+++ /work/sources/binutils/upstream/2.46/gas/config/obj-elf-attr.c 2026-01-27 08:04:23.388789835 +0000
@@ -1063,7 +1063,7 @@ obj_attr_v2_record (obj_attr_tag_t key,
/* Go over the list of already recorded attributes and check for
redefinitions (which are forbidden). */
bool skip_recording = false;
- obj_attr_v2_t *recorded_attr = _bfd_obj_attr_v2_find_by_tag
+ obj_attr_v2_t *recorded_attr = bfd_obj_attr_v2_find_by_tag
(elf_obj_attr_subsections (stdoutput).last, obj_attr->tag, false);
if (recorded_attr != NULL)
{
@@ -1084,7 +1084,7 @@ obj_attr_v2_record (obj_attr_tag_t key,
return;
}
- LINKED_LIST_APPEND (obj_attr_v2_t)
+ bfd_obj_attr_subsection_v2_append
(elf_obj_attr_subsections (stdoutput).last, obj_attr);
}
@@ -1133,9 +1133,9 @@ obj_attr_v2_subsection_record (const cha
}
/* Move the existing subsection to the last position. */
- LINKED_LIST_REMOVE (obj_attr_subsection_v2_t)
+ bfd_obj_attr_subsection_v2_list_remove
(&elf_obj_attr_subsections (stdoutput), already_recorded_subsec);
- LINKED_LIST_APPEND (obj_attr_subsection_v2_t)
+ bfd_obj_attr_subsection_v2_list_append
(&elf_obj_attr_subsections (stdoutput), already_recorded_subsec);
/* Note: 'name' was unused, and will be freed on exit. */
}
@@ -1158,7 +1158,7 @@ obj_attr_v2_subsection_record (const cha
= bfd_elf_obj_attr_subsection_v2_init (name, scope,
comprehension_optional,
encoding);
- LINKED_LIST_APPEND (obj_attr_subsection_v2_t)
+ bfd_obj_attr_subsection_v2_list_append
(&elf_obj_attr_subsections (stdoutput), new_subsection);
return;
}

View File

@ -0,0 +1,12 @@
--- binutils.orig/bfd/elfnn-aarch64.c 2025-02-07 13:42:20.961333141 +0000
+++ binutils-with-gold-2.44/bfd/elfnn-aarch64.c 2025-02-07 13:42:29.781353740 +0000
@@ -10162,7 +10162,8 @@ elfNN_aarch64_init_small_plt0_entry (bfd
/* PR 26312: Explicitly set the sh_entsize to 0 so that
consumers do not think that the section contains fixed
sized objects. */
- elf_section_data (htab->root.splt->output_section)->this_hdr.sh_entsize = 0;
+ if (elf_section_data (htab->root.splt->output_section) != NULL)
+ elf_section_data (htab->root.splt->output_section)->this_hdr.sh_entsize = 0;
plt_got_2nd_ent = (htab->root.sgotplt->output_section->vma
+ htab->root.sgotplt->output_offset

View File

@ -0,0 +1,11 @@
--- binutils.orig/config/override.m4 2021-08-31 14:20:17.275574804 +0100
+++ binutils-2.37/config/override.m4 2021-08-31 14:36:37.793954247 +0100
@@ -41,7 +41,7 @@ dnl Or for updating the whole tree at on
AC_DEFUN([_GCC_AUTOCONF_VERSION_CHECK],
[m4_if(m4_defn([_GCC_AUTOCONF_VERSION]),
m4_defn([m4_PACKAGE_VERSION]), [],
- [m4_fatal([Please use exactly Autoconf ]_GCC_AUTOCONF_VERSION[ instead of ]m4_defn([m4_PACKAGE_VERSION])[.])])
+ [])
])
m4_define([AC_INIT], m4_defn([AC_INIT])[
_GCC_AUTOCONF_VERSION_CHECK

View File

@ -0,0 +1,413 @@
From 9e7085f2700d698dfbb37aef24c0489c2d09a978 Mon Sep 17 00:00:00 2001
From: Siddhesh Poyarekar <siddhesh@gotplt.org>
Date: Thu, 6 Feb 2025 12:06:27 -0500
Subject: [PATCH] Revert "aarch64: GCS tests for linking issues with dynamic
objects"
This reverts commit 1c136b8ee9b9fb402b66957bd51e89e47b94a0f6.
---
.../protections/aarch64-protections.exp | 15 ----------
.../ld-aarch64/protections/gcs-dynamic-1-a.d | 12 --------
.../ld-aarch64/protections/gcs-dynamic-1-b.d | 12 --------
.../protections/gcs-dynamic-2-a-i.d | 15 ----------
.../protections/gcs-dynamic-2-a-ii.d | 8 ------
.../protections/gcs-dynamic-2-a-iii.d | 15 ----------
.../protections/gcs-dynamic-2-a-iv.d | 12 --------
.../ld-aarch64/protections/gcs-dynamic-2-b.d | 14 ----------
.../ld-aarch64/protections/gcs-dynamic-2-c.d | 12 --------
.../ld-aarch64/protections/gcs-dynamic-2-d.d | 14 ----------
.../ld-aarch64/protections/gcs-dynamic-3-a.d | 15 ----------
.../ld-aarch64/protections/gcs-dynamic-3-b.d | 14 ----------
.../ld-aarch64/protections/gcs-dynamic-3-c.d | 12 --------
.../ld-aarch64/protections/gcs-dynamic-4-a.d | 7 -----
.../ld-aarch64/protections/gcs-dynamic-4-b.d | 7 -----
.../ld-aarch64/protections/gcs-dynamic-4-c.d | 7 -----
ld/testsuite/ld-aarch64/protections/gcs-so.s | 28 -------------------
ld/testsuite/ld-aarch64/protections/gcs-so2.s | 28 -------------------
18 files changed, 247 deletions(-)
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-dynamic-1-a.d
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-dynamic-1-b.d
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-i.d
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-ii.d
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-iii.d
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-iv.d
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-b.d
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-c.d
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-d.d
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-a.d
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-b.d
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-c.d
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-a.d
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-b.d
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-c.d
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-so.s
delete mode 100644 ld/testsuite/ld-aarch64/protections/gcs-so2.s
diff --git a/ld/testsuite/ld-aarch64/protections/aarch64-protections.exp b/ld/testsuite/ld-aarch64/protections/aarch64-protections.exp
index cf0f03daee6..b49428d1039 100644
--- a/ld/testsuite/ld-aarch64/protections/aarch64-protections.exp
+++ b/ld/testsuite/ld-aarch64/protections/aarch64-protections.exp
@@ -42,21 +42,6 @@ set aarch64elflinktests {
"-shared" ""
"-I$srcdir/$subdir -defsym __property_bti__=1"
{bti-plt-so.s} {} "libbti-plt-so.so"}
-
- {"Build gcs-so for GCS tests"
- "-shared" ""
- "-I$srcdir/$subdir -defsym __property_gcs__=1"
- {gcs-so.s} {} "libgcs-so.so"}
-
- {"Build nogcs-so for GCS tests"
- "-shared" ""
- "-I$srcdir/$subdir"
- {gcs-so.s} {} "libnogcs-so.so"}
-
- {"Build gcs-so2 for GCS tests"
- "-shared" ""
- "-I$srcdir/$subdir -defsym __property_gcs__=1"
- {gcs-so2.s} {} "libgcs-so2.so"}
}
if [check_shared_lib_support] {
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-1-a.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-1-a.d
deleted file mode 100644
index be8a301f6c0..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-1-a.d
+++ /dev/null
@@ -1,12 +0,0 @@
-#name: '-z gcs=always -z gcs-report=error' and shared library with GCS feature reports no error.
-#source: gcs.s
-#source: gcs2.s
-#alltargets: [check_shared_lib_support] *linux*
-#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
-#ld: -z gcs=always -z gcs-report=error -L./tmpdir -lgcs-so
-#readelf: -n
-
-Displaying notes found in: .note.gnu.property
-[ ]+Owner[ ]+Data size[ ]+Description
- GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
- Properties: AArch64 feature: GCS
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-1-b.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-1-b.d
deleted file mode 100644
index d53d45ae598..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-1-b.d
+++ /dev/null
@@ -1,12 +0,0 @@
-#name: '-z gcs=always -z gcs-report=error -z gcs-report-dynamic=error' and shared library with GCS feature reports no error.
-#source: gcs.s
-#source: gcs2.s
-#alltargets: [check_shared_lib_support] *linux*
-#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
-#ld: -z gcs=always -z gcs-report=error -z gcs-report-dynamic=error -L./tmpdir -lgcs-so
-#readelf: -n
-
-Displaying notes found in: .note.gnu.property
-[ ]+Owner[ ]+Data size[ ]+Description
- GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
- Properties: AArch64 feature: GCS
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-i.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-i.d
deleted file mode 100644
index 903d14099be..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-i.d
+++ /dev/null
@@ -1,15 +0,0 @@
-#name: '-z gcs=always -z gcs-report=error' and shared libraries without GCS feature reports warnings.
-#source: gcs.s
-#source: gcs2.s
-#alltargets: [check_shared_lib_support] *linux*
-#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
-#ld: -z gcs=always -z gcs-report=error -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
-#warning: \A[^\n]*libnogcs-so\.so: warning: GCS is required by -z gcs[^\n]*\n
-#warning: [^\n]*libbti-plt-so\.so: warning: GCS is required by -z gcs[^\n]*
-
-#readelf: -n
-
-Displaying notes found in: .note.gnu.property
-[ ]+Owner[ ]+Data size[ ]+Description
- GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
- Properties: AArch64 feature: GCS
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-ii.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-ii.d
deleted file mode 100644
index 7adb481bc30..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-ii.d
+++ /dev/null
@@ -1,8 +0,0 @@
-#name: '-z gcs=always -z gcs-report=error -z gcs-report-dynamic=error' and shared libraries without GCS feature reports errors.
-#source: gcs.s
-#source: gcs2.s
-#alltargets: [check_shared_lib_support] *linux*
-#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
-#ld: -z gcs=always -z gcs-report=error -z gcs-report-dynamic=error -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
-#error: \A[^\n]*libnogcs-so\.so: error: GCS is required by -z gcs[^\n]*\n
-#error: [^\n]*libbti-plt-so\.so: error: GCS is required by -z gcs[^\n]*
\ No newline at end of file
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-iii.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-iii.d
deleted file mode 100644
index 76a7c461347..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-iii.d
+++ /dev/null
@@ -1,15 +0,0 @@
-#name: '-z gcs=always -z gcs-report=error -z gcs-report-dynamic=warning' and shared libraries without GCS feature reports warnings.
-#source: gcs.s
-#source: gcs2.s
-#alltargets: [check_shared_lib_support] *linux*
-#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
-#ld: -z gcs=always -z gcs-report=error -z gcs-report-dynamic=warning -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
-#warning: \A[^\n]*libnogcs-so\.so: warning: GCS is required by -z gcs[^\n]*\n
-#warning: [^\n]*libbti-plt-so\.so: warning: GCS is required by -z gcs[^\n]*
-
-#readelf: -n
-
-Displaying notes found in: .note.gnu.property
-[ ]+Owner[ ]+Data size[ ]+Description
- GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
- Properties: AArch64 feature: GCS
\ No newline at end of file
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-iv.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-iv.d
deleted file mode 100644
index 554ca1186ef..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-a-iv.d
+++ /dev/null
@@ -1,12 +0,0 @@
-#name: '-z gcs=always -z gcs-report=error -z gcs-report-dynamic=none' and shared libraries without GCS feature reports nothing.
-#source: gcs.s
-#source: gcs2.s
-#alltargets: [check_shared_lib_support] *linux*
-#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
-#ld: -z gcs=always -z gcs-report=error -z gcs-report-dynamic=none -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
-#readelf: -n
-
-Displaying notes found in: .note.gnu.property
-[ ]+Owner[ ]+Data size[ ]+Description
- GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
- Properties: AArch64 feature: GCS
\ No newline at end of file
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-b.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-b.d
deleted file mode 100644
index 36262bbc087..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-b.d
+++ /dev/null
@@ -1,14 +0,0 @@
-#name: '-z gcs=always -z gcs-report=warning' and shared libraries without GCS feature reports warnings.
-#source: gcs.s
-#source: gcs2.s
-#alltargets: [check_shared_lib_support] *linux*
-#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
-#ld: -z gcs=always -z gcs-report=warning -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
-#warning: \A[^\n]*libnogcs-so\.so: warning: GCS is required by -z gcs[^\n]*\n
-#warning: [^\n]*libbti-plt-so\.so: warning: GCS is required by -z gcs[^\n]*
-#readelf: -n
-
-Displaying notes found in: .note.gnu.property
-[ ]+Owner[ ]+Data size[ ]+Description
- GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
- Properties: AArch64 feature: GCS
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-c.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-c.d
deleted file mode 100644
index 6c7f5da8be7..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-c.d
+++ /dev/null
@@ -1,12 +0,0 @@
-#name: '-z gcs=always -z gcs-report=none' and shared libraries without GCS feature reports nothing.
-#source: gcs.s
-#source: gcs2.s
-#alltargets: [check_shared_lib_support] *linux*
-#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
-#ld: -z gcs=always -z gcs-report=none -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
-#readelf: -n
-
-Displaying notes found in: .note.gnu.property
-[ ]+Owner[ ]+Data size[ ]+Description
- GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
- Properties: AArch64 feature: GCS
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-d.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-d.d
deleted file mode 100644
index 58498e6c00b..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-2-d.d
+++ /dev/null
@@ -1,14 +0,0 @@
-#name: '-z gcs=always -z gcs-report' and shared libraries without GCS feature reports warnings.
-#source: gcs.s
-#source: gcs2.s
-#alltargets: [check_shared_lib_support] *linux*
-#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
-#ld: -z gcs=always -z gcs-report -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
-#warning: \A[^\n]*libnogcs-so\.so: warning: GCS is required by -z gcs[^\n]*\n
-#warning: [^\n]*libbti-plt-so\.so: warning: GCS is required by -z gcs[^\n]*
-#readelf: -n
-
-Displaying notes found in: .note.gnu.property
-[ ]+Owner[ ]+Data size[ ]+Description
- GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
- Properties: AArch64 feature: GCS
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-a.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-a.d
deleted file mode 100644
index ecdaf526779..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-a.d
+++ /dev/null
@@ -1,15 +0,0 @@
-#name: '-z gcs=implicit -z gcs-report=error' and shared libraries without GCS feature reports warnings.
-#source: gcs.s
-#source: gcs2.s
-#alltargets: [check_shared_lib_support] *linux*
-#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
-#ld: -z gcs=implicit -z gcs-report=error -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
-#warning: \A[^\n]*libnogcs-so\.so: warning: GCS is required by -z gcs[^\n]*\n
-#warning: [^\n]*libbti-plt-so\.so: warning: GCS is required by -z gcs[^\n]*
-
-#readelf: -n
-
-Displaying notes found in: .note.gnu.property
-[ ]+Owner[ ]+Data size[ ]+Description
- GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
- Properties: AArch64 feature: GCS
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-b.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-b.d
deleted file mode 100644
index 4d32fb6aa54..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-b.d
+++ /dev/null
@@ -1,14 +0,0 @@
-#name: '-z gcs=implicit -z gcs-report=warning' and shared libraries without GCS feature reports warnings.
-#source: gcs.s
-#source: gcs2.s
-#alltargets: [check_shared_lib_support] *linux*
-#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
-#ld: -z gcs=implicit -z gcs-report=warning -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
-#warning: \A[^\n]*libnogcs-so\.so: warning: GCS is required by -z gcs[^\n]*\n
-#warning: [^\n]*libbti-plt-so\.so: warning: GCS is required by -z gcs[^\n]*
-#readelf: -n
-
-Displaying notes found in: .note.gnu.property
-[ ]+Owner[ ]+Data size[ ]+Description
- GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
- Properties: AArch64 feature: GCS
\ No newline at end of file
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-c.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-c.d
deleted file mode 100644
index c0da6c1d9c6..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-3-c.d
+++ /dev/null
@@ -1,12 +0,0 @@
-#name: '-z gcs=implicit -z gcs-report=none' and shared libraries without GCS feature reports no warning.
-#source: gcs.s
-#source: gcs2.s
-#alltargets: [check_shared_lib_support] *linux*
-#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
-#ld: -z gcs=implicit -z gcs-report=none -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
-#readelf: -n
-
-Displaying notes found in: .note.gnu.property
-[ ]+Owner[ ]+Data size[ ]+Description
- GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
- Properties: AArch64 feature: GCS
\ No newline at end of file
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-a.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-a.d
deleted file mode 100644
index ae324bbba1e..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-a.d
+++ /dev/null
@@ -1,7 +0,0 @@
-#name: '-z gcs=never -z gcs-report=error' and shared libraries without GCS feature reports no warning/error.
-#source: gcs.s
-#source: gcs2.s
-#alltargets: [check_shared_lib_support] *linux*
-#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
-#ld: -z gcs=never -z gcs-report=error -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
-#readelf: -n
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-b.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-b.d
deleted file mode 100644
index 6b65898b924..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-b.d
+++ /dev/null
@@ -1,7 +0,0 @@
-#name: '-z gcs=never -z gcs-report=warning' and shared libraries without GCS feature reports no warning/error.
-#source: gcs.s
-#source: gcs2.s
-#alltargets: [check_shared_lib_support] *linux*
-#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
-#ld: -z gcs=never -z gcs-report=warning -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
-#readelf: -n
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-c.d b/ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-c.d
deleted file mode 100644
index 35b011f6a8e..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-dynamic-4-c.d
+++ /dev/null
@@ -1,7 +0,0 @@
-#name: '-z gcs=never -z gcs-report=none' and shared libraries without GCS feature reports no warning/error.
-#source: gcs.s
-#source: gcs2.s
-#alltargets: [check_shared_lib_support] *linux*
-#as: -march=armv9.4-a+gcs -defsym __property_gcs__=1
-#ld: -z gcs=never -z gcs-report=none -L./tmpdir -lnogcs-so -lbti-plt-so -lgcs-so2
-#readelf: -n
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-so.s b/ld/testsuite/ld-aarch64/protections/gcs-so.s
deleted file mode 100644
index aa6485b9dde..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-so.s
+++ /dev/null
@@ -1,28 +0,0 @@
- .global foo2
- .type foo2, %function
-foo2:
- sub sp, sp, #16
- mov w0, 9
- str w0, [sp, 12]
- ldr w0, [sp, 12]
- add w0, w0, 4
- str w0, [sp, 12]
- nop
- add sp, sp, 16
- ret
- .size foo2, .-foo2
- .global bar2
- .type bar2, %function
-bar2:
- sub sp, sp, #16
- mov w0, 9
- str w0, [sp, 12]
- ldr w0, [sp, 12]
- add w0, w0, 4
- str w0, [sp, 12]
- nop
- add sp, sp, 16
- ret
- .size bar2, .-bar2
-
-.include "gnu-note-properties-selectable-merged.inc"
diff --git a/ld/testsuite/ld-aarch64/protections/gcs-so2.s b/ld/testsuite/ld-aarch64/protections/gcs-so2.s
deleted file mode 100644
index 938ba43c69c..00000000000
--- a/ld/testsuite/ld-aarch64/protections/gcs-so2.s
+++ /dev/null
@@ -1,28 +0,0 @@
- .global foo3
- .type foo3, %function
-foo3:
- sub sp, sp, #16
- mov w0, 9
- str w0, [sp, 12]
- ldr w0, [sp, 12]
- add w0, w0, 4
- str w0, [sp, 12]
- nop
- add sp, sp, 16
- ret
- .size foo3, .-foo3
- .global bar3
- .type bar3, %function
-bar3:
- sub sp, sp, #16
- mov w0, 9
- str w0, [sp, 12]
- ldr w0, [sp, 12]
- add w0, w0, 4
- str w0, [sp, 12]
- nop
- add sp, sp, 16
- ret
- .size bar3, .-bar3
-
-.include "gnu-note-properties-selectable-merged.inc"
--
2.48.1

View File

@ -0,0 +1,17 @@
diff -pruN a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
--- a/bfd/elfnn-aarch64.c 2025-02-06 10:39:49.722259921 -0500
+++ b/bfd/elfnn-aarch64.c 2025-02-06 10:47:28.604658973 -0500
@@ -5051,11 +5051,10 @@ bfd_elfNN_aarch64_set_options (struct bf
libraries. If a user also wants to error GCS issues in the shared
libraries, '-z gcs-report-dynamic=error' will have to be specified
explicitly. */
+ /* XXX Fedora override: default to NONE. */
if (sw_protections->gcs_report_dynamic == MARKING_UNSET)
elf_aarch64_tdata (output_bfd)->sw_protections.gcs_report_dynamic
- = (sw_protections->gcs_report == MARKING_ERROR)
- ? MARKING_WARN
- : sw_protections->gcs_report;
+ = MARKING_NONE;
elf_aarch64_tdata (output_bfd)->n_bti_issues = 0;
elf_aarch64_tdata (output_bfd)->n_gcs_issues = 0;

View File

@ -0,0 +1,82 @@
diff -rup binutils.orig/configure binutils-2.40/configure
--- binutils.orig/configure 2023-02-13 14:43:00.728877170 +0000
+++ binutils-2.40/configure 2023-02-13 14:43:13.671864892 +0000
@@ -5442,49 +5442,6 @@ if test -z "$LD"; then
fi
fi
-# Check whether -static-libstdc++ -static-libgcc is supported.
-have_static_libs=no
-if test "$GCC" = yes; then
- saved_LDFLAGS="$LDFLAGS"
-
- LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc"
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether g++ accepts -static-libstdc++ -static-libgcc" >&5
-$as_echo_n "checking whether g++ accepts -static-libstdc++ -static-libgcc... " >&6; }
- ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-#if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
-#error -static-libstdc++ not implemented
-#endif
-int main() {}
-_ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }; have_static_libs=yes
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
- LDFLAGS="$saved_LDFLAGS"
-fi
-
-
if test -n "$ac_tool_prefix"; then
--- binutils.orig/configure.ac 2024-11-26 15:08:50.162328683 +0000
+++ binutils-2.43.50-1686dc7079f/configure.ac 2024-11-26 15:08:56.929374527 +0000
@@ -1410,26 +1410,6 @@ if test -z "$LD"; then
fi
fi
-# Check whether -static-libstdc++ -static-libgcc is supported.
-have_static_libs=no
-if test "$GCC" = yes; then
- saved_LDFLAGS="$LDFLAGS"
-
- LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc"
- AC_MSG_CHECKING([whether g++ accepts -static-libstdc++ -static-libgcc])
- AC_LANG_PUSH(C++)
- AC_LINK_IFELSE([AC_LANG_SOURCE([
-#if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
-#error -static-libstdc++ not implemented
-#endif
-int main() {}])],
- [AC_MSG_RESULT([yes]); have_static_libs=yes],
- [AC_MSG_RESULT([no])])
- AC_LANG_POP(C++)
-
- LDFLAGS="$saved_LDFLAGS"
-fi
-
ACX_PROG_GNAT
ACX_PROG_GDC
ACX_PROG_CARGO

View File

@ -0,0 +1,33 @@
diff -rup binutils.orig/bfd/Makefile.am binutils-2.32/bfd/Makefile.am
--- binutils.orig/bfd/Makefile.am 2019-02-08 12:22:51.395684251 +0000
+++ binutils-2.32/bfd/Makefile.am 2019-02-08 12:22:53.970664973 +0000
@@ -33,7 +33,7 @@ bfdlibdir = @bfdlibdir@
bfdincludedir = @bfdincludedir@
bfdlib_LTLIBRARIES = libbfd.la
bfdinclude_HEADERS = $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \
- $(INCDIR)/diagnostics.h $(INCDIR)/bfdlink.h
+ $(INCDIR)/diagnostics.h $(INCDIR)/bfdlink.h $(INCDIR)/demangle.h
else !INSTALL_LIBBFD
# Empty these so that the respective installation directories will not be created.
bfdlibdir =
diff -rup binutils.orig/bfd/Makefile.in binutils-2.32/bfd/Makefile.in
--- binutils.orig/bfd/Makefile.in 2019-02-08 12:21:35.291254044 +0000
+++ binutils-2.32/bfd/Makefile.in 2019-02-08 12:22:10.163992947 +0000
@@ -249,7 +249,7 @@ am__can_run_installinfo = \
esac
am__bfdinclude_HEADERS_DIST = $(INCDIR)/plugin-api.h bfd.h \
$(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \
- $(INCDIR)/diagnostics.h $(INCDIR)/bfdlink.h
+ $(INCDIR)/diagnostics.h $(INCDIR)/bfdlink.h $(INCDIR)/demangle.h
HEADERS = $(bfdinclude_HEADERS)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
@@ -468,7 +468,7 @@ libbfd_la_LDFLAGS = $(am__append_1) -rel
@INSTALL_LIBBFD_FALSE@bfdinclude_HEADERS = $(am__append_2)
@INSTALL_LIBBFD_TRUE@bfdinclude_HEADERS = $(BFD_H) \
@INSTALL_LIBBFD_TRUE@ $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \
-@INSTALL_LIBBFD_TRUE@ $(INCDIR)/diagnostics.h \
+@INSTALL_LIBBFD_TRUE@ $(INCDIR)/diagnostics.h $(INCDIR)/demangle.h \
@INSTALL_LIBBFD_TRUE@ $(INCDIR)/bfdlink.h $(am__append_2)
@INSTALL_LIBBFD_FALSE@rpath_bfdlibdir = @bfdlibdir@
@INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libbfd.la

View File

@ -0,0 +1,11 @@
--- binutils.orig/binutils/testsuite/binutils-all/ar.exp 2024-02-07 13:02:23.490031197 +0000
+++ binutils-2.42/binutils/testsuite/binutils-all/ar.exp 2024-02-07 13:03:10.285034069 +0000
@@ -1017,7 +1017,7 @@ symbol_table
argument_parsing
deterministic_archive
replacing_deterministic_member
-replacing_non_deterministic_member
+# replacing_non_deterministic_member
replacing_sde_deterministic_member
delete_an_element
move_an_element

180
binutils-gcc-10-fixes.patch Normal file
View File

@ -0,0 +1,180 @@
diff -rup binutils.orig/gold/gdb-index.cc binutils-2.34.0/gold/gdb-index.cc
--- binutils.orig/gold/gdb-index.cc 2020-07-24 09:12:29.241306445 +0100
+++ binutils-2.34.0/gold/gdb-index.cc 2020-07-24 09:15:48.332095898 +0100
@@ -817,7 +817,7 @@ Gdb_index_info_reader::get_qualified_nam
void
Gdb_index_info_reader::record_cu_ranges(Dwarf_die* die)
{
- unsigned int shndx;
+ unsigned int shndx = 0;
unsigned int shndx2;
off_t ranges_offset = die->ref_attribute(elfcpp::DW_AT_ranges, &shndx);
diff -rup binutils.orig/gold/layout.cc binutils-2.34.0/gold/layout.cc
--- binutils.orig/gold/layout.cc 2020-07-24 09:12:29.243306433 +0100
+++ binutils-2.34.0/gold/layout.cc 2020-07-24 09:15:11.464320064 +0100
@@ -1986,7 +1986,7 @@ Layout::attach_allocated_section_to_segm
seg_flags |= os->extra_segment_flags();
// Check for --section-start.
- uint64_t addr;
+ uint64_t addr = 0;
bool is_address_set = parameters->options().section_start(os->name(), &addr);
// In general the only thing we really care about for PT_LOAD
diff -rup binutils.orig/binutils/dlltool.c binutils-2.34.0/binutils/dlltool.c
--- binutils.orig/binutils/dlltool.c 2020-07-24 09:12:28.974308069 +0100
+++ binutils-2.34.0/binutils/dlltool.c 2020-07-24 12:09:37.527121295 +0100
@@ -1305,7 +1305,7 @@ run (const char *what, char *args)
int pid, wait_status;
int i;
const char **argv;
- char *errmsg_fmt, *errmsg_arg;
+ char *errmsg_fmt = "", *errmsg_arg = "";
char *temp_base = choose_temp_base ();
inform (_("run: %s %s"), what, args);
diff -rup binutils.orig/gas/config/tc-arm.c binutils-2.34.0/gas/config/tc-arm.c
--- binutils.orig/gas/config/tc-arm.c 2020-07-24 09:12:32.368287432 +0100
+++ binutils-2.34.0/gas/config/tc-arm.c 2020-07-24 12:14:19.842360634 +0100
@@ -28416,9 +28416,12 @@ md_apply_fix (fixS * fixP,
perform relaxation. */
if (value == -2)
{
- newval = md_chars_to_number (buf, THUMB_SIZE);
- newval = 0xbf00; /* NOP encoding T1 */
- md_number_to_chars (buf, newval, THUMB_SIZE);
+ if (fixP->fx_done || !seg->use_rela_p)
+ {
+ newval = md_chars_to_number (buf, THUMB_SIZE);
+ newval = 0xbf00; /* NOP encoding T1 */
+ md_number_to_chars (buf, newval, THUMB_SIZE);
+ }
}
else
{
@@ -28631,17 +28634,14 @@ md_apply_fix (fixS * fixP,
case BFD_RELOC_ARM_GOTFUNCDESC:
case BFD_RELOC_ARM_GOTOFFFUNCDESC:
case BFD_RELOC_ARM_FUNCDESC:
- if (arm_fdpic)
- {
- if (fixP->fx_done || !seg->use_rela_p)
- md_number_to_chars (buf, 0, 4);
- }
- else
+ if (!arm_fdpic)
{
as_bad_where (fixP->fx_file, fixP->fx_line,
_("Relocation supported only in FDPIC mode"));
- }
- break;
+ break;
+ }
+ value = 0;
+ /* Fall through. */
#endif
case BFD_RELOC_RVA:
diff -rup binutils.orig/gas/config/tc-arm.c binutils-2.34.0/gas/config/tc-arm.c
--- binutils.orig/gas/config/tc-arm.c 2020-07-24 12:16:02.099719884 +0100
+++ binutils-2.34.0/gas/config/tc-arm.c 2020-07-24 12:34:17.690858328 +0100
@@ -28641,7 +28641,7 @@ md_apply_fix (fixS * fixP,
break;
}
value = 0;
- /* Fall through. */
+ goto fred;
#endif
case BFD_RELOC_RVA:
@@ -28653,6 +28653,7 @@ md_apply_fix (fixS * fixP,
#ifdef TE_PE
case BFD_RELOC_32_SECREL:
#endif
+ fred:
if (fixP->fx_done || !seg->use_rela_p)
#ifdef TE_WINCE
/* For WinCE we only do this for pcrel fixups. */
diff -rup binutils.orig/gas/config/tc-arm.c binutils-2.34.0/gas/config/tc-arm.c
--- binutils.orig/gas/config/tc-arm.c 2020-07-24 13:28:26.926553452 +0100
+++ binutils-2.34.0/gas/config/tc-arm.c 2020-07-24 13:31:57.835215763 +0100
@@ -28416,12 +28416,8 @@ md_apply_fix (fixS * fixP,
perform relaxation. */
if (value == -2)
{
- if (fixP->fx_done || !seg->use_rela_p)
- {
- newval = md_chars_to_number (buf, THUMB_SIZE);
- newval = 0xbf00; /* NOP encoding T1 */
- md_number_to_chars (buf, newval, THUMB_SIZE);
- }
+ newval = 0xbf00; /* NOP encoding T1 */
+ goto jim;
}
else
{
@@ -28432,6 +28428,7 @@ md_apply_fix (fixS * fixP,
{
newval = md_chars_to_number (buf, THUMB_SIZE);
newval |= ((value & 0x3e) << 2) | ((value & 0x40) << 3);
+ jim:
md_number_to_chars (buf, newval, THUMB_SIZE);
}
}
diff -rup binutils.orig/binutils/mclex.c binutils-2.34.0/binutils/mclex.c
--- binutils.orig/binutils/mclex.c 2020-07-24 13:28:26.297557441 +0100
+++ binutils-2.34.0/binutils/mclex.c 2020-07-24 14:46:53.587940149 +0100
@@ -207,7 +207,7 @@ enum_severity (int e)
static void
mc_add_keyword_ascii (const char *sz, int rid, const char *grp, rc_uint_type nv, const char *sv)
{
- unichar *usz, *usv = NULL;
+ unichar *usz = NULL, *usv = NULL;
rc_uint_type usz_len;
unicode_from_codepage (&usz_len, &usz, sz, CP_ACP);
diff -rup binutils.orig/binutils/windmc.c binutils-2.34.0/binutils/windmc.c
--- binutils.orig/binutils/windmc.c 2020-07-24 13:28:26.279557556 +0100
+++ binutils-2.34.0/binutils/windmc.c 2020-07-24 14:48:05.460477478 +0100
@@ -338,7 +338,7 @@ mc_add_node_lang (mc_node *root, const m
static char *
convert_unicode_to_ACP (const unichar *usz)
{
- char *s;
+ char *s = NULL;
rc_uint_type l;
if (! usz)
@@ -607,10 +607,10 @@ mc_generate_bin_item (mc_node_lang *n, r
else
{
rc_uint_type txt_len, l;
- char *cvt_txt;
+ char *cvt_txt = NULL;
codepage_from_unicode( &l, n->message, &cvt_txt, n->lang->lang_info.wincp);
- if (! cvt_txt)
+ if (cvt_txt == NULL)
fatal ("Failed to convert message to language codepage.\n");
txt_len = strlen (cvt_txt);
if (mcset_automatic_null_termination && txt_len > 0)
@@ -1107,7 +1107,7 @@ main (int argc, char **argv)
/* Load the input file and do code page transformations to UTF16. */
{
- unichar *u;
+ unichar *u = NULL;
rc_uint_type ul;
char *buff;
bfd_size_type flen;
--- binutils.orig/binutils/srconv.c 2020-07-24 15:37:25.847459208 +0100
+++ binutils-2.34.0/binutils/srconv.c 2020-07-24 15:39:12.853773423 +0100
@@ -316,6 +316,7 @@ wr_hd (struct coff_ofile *p)
struct IT_hd hd;
hd.spare1 = 0;
+ hd.spare2 = 0;
if (bfd_get_file_flags (abfd) & EXEC_P)
hd.mt = MTYPE_ABS_LM;
else

View File

@ -0,0 +1,11 @@
--- binutils.orig/gold/dwp.cc 2023-05-02 13:26:44.075148082 +0100
+++ binutils-2.40/gold/dwp.cc 2023-05-02 13:27:16.189130127 +0100
@@ -2418,6 +2418,8 @@ main(int argc, char** argv)
{
Dwo_file exe_file(exe_filename);
exe_file.read_executable(&files);
+ if (files.empty())
+ gold_fatal(_("Could not find any dwo links in specified EXE"));
}
// Add any additional files listed on command line.

View File

@ -0,0 +1,193 @@
diff --git a/gold/i386.cc b/gold/i386.cc
index bf209fe9a86..31161ff091c 100644
--- a/gold/i386.cc
+++ b/gold/i386.cc
@@ -360,7 +360,11 @@ class Target_i386 : public Sized_target<32, false>
got_(NULL), plt_(NULL), got_plt_(NULL), got_irelative_(NULL),
got_tlsdesc_(NULL), global_offset_table_(NULL), rel_dyn_(NULL),
rel_irelative_(NULL), copy_relocs_(elfcpp::R_386_COPY),
- got_mod_index_offset_(-1U), tls_base_symbol_defined_(false)
+ got_mod_index_offset_(-1U), tls_base_symbol_defined_(false),
+ isa_1_used_(0), isa_1_needed_(0),
+ feature_1_(0), feature_2_used_(0), feature_2_needed_(0),
+ object_isa_1_used_(0), object_feature_1_(0),
+ object_feature_2_used_(0), seen_first_object_(false)
{ }
// Process the relocations to determine unreferenced sections for
@@ -859,6 +863,21 @@ class Target_i386 : public Sized_target<32, false>
this->rel_dyn_section(layout));
}
+ // Record a target-specific program property in the .note.gnu.property
+ // section.
+ void
+ record_gnu_property(unsigned int, unsigned int, size_t,
+ const unsigned char*, const Object*);
+
+ // Merge the target-specific program properties from the current object.
+ void
+ merge_gnu_properties(const Object*);
+
+ // Finalize the target-specific program properties and add them back to
+ // the layout.
+ void
+ do_finalize_gnu_properties(Layout*) const;
+
// Information about this specific target which we pass to the
// general Target structure.
static const Target::Target_info i386_info;
@@ -898,6 +917,26 @@ class Target_i386 : public Sized_target<32, false>
unsigned int got_mod_index_offset_;
// True if the _TLS_MODULE_BASE_ symbol has been defined.
bool tls_base_symbol_defined_;
+
+ // Target-specific program properties, from .note.gnu.property section.
+ // Each bit represents a specific feature.
+ uint32_t isa_1_used_;
+ uint32_t isa_1_needed_;
+ uint32_t feature_1_;
+ uint32_t feature_2_used_;
+ uint32_t feature_2_needed_;
+ // Target-specific properties from the current object.
+ // These bits get ORed into ISA_1_USED_ after all properties for the object
+ // have been processed. But if either is all zeroes (as when the property
+ // is absent from an object), the result should be all zeroes.
+ // (See PR ld/23486.)
+ uint32_t object_isa_1_used_;
+ // These bits get ANDed into FEATURE_1_ after all properties for the object
+ // have been processed.
+ uint32_t object_feature_1_;
+ uint32_t object_feature_2_used_;
+ // Whether we have seen our first object, for use in initializing FEATURE_1_.
+ bool seen_first_object_;
};
const Target::Target_info Target_i386::i386_info =
@@ -1042,6 +1081,126 @@ Target_i386::rel_irelative_section(Layout* layout)
return this->rel_irelative_;
}
+// Record a target-specific program property from the .note.gnu.property
+// section.
+void
+Target_i386::record_gnu_property(
+ unsigned int, unsigned int pr_type,
+ size_t pr_datasz, const unsigned char* pr_data,
+ const Object* object)
+{
+ uint32_t val = 0;
+
+ switch (pr_type)
+ {
+ case elfcpp::GNU_PROPERTY_X86_COMPAT_ISA_1_USED:
+ case elfcpp::GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED:
+ case elfcpp::GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED:
+ case elfcpp::GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED:
+ case elfcpp::GNU_PROPERTY_X86_ISA_1_USED:
+ case elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED:
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND:
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED:
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED:
+ if (pr_datasz != 4)
+ {
+ gold_warning(_("%s: corrupt .note.gnu.property section "
+ "(pr_datasz for property %d is not 4)"),
+ object->name().c_str(), pr_type);
+ return;
+ }
+ val = elfcpp::Swap<32, false>::readval(pr_data);
+ break;
+ default:
+ gold_warning(_("%s: unknown program property type 0x%x "
+ "in .note.gnu.property section"),
+ object->name().c_str(), pr_type);
+ break;
+ }
+
+ switch (pr_type)
+ {
+ case elfcpp::GNU_PROPERTY_X86_ISA_1_USED:
+ this->object_isa_1_used_ |= val;
+ break;
+ case elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED:
+ this->isa_1_needed_ |= val;
+ break;
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND:
+ // If we see multiple feature props in one object, OR them together.
+ this->object_feature_1_ |= val;
+ break;
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED:
+ this->object_feature_2_used_ |= val;
+ break;
+ case elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED:
+ this->feature_2_needed_ |= val;
+ break;
+ }
+}
+
+// Merge the target-specific program properties from the current object.
+void
+Target_i386::merge_gnu_properties(const Object*)
+{
+ if (this->seen_first_object_)
+ {
+ // If any object is missing the ISA_1_USED property, we must omit
+ // it from the output file.
+ if (this->object_isa_1_used_ == 0)
+ this->isa_1_used_ = 0;
+ else if (this->isa_1_used_ != 0)
+ this->isa_1_used_ |= this->object_isa_1_used_;
+ this->feature_1_ &= this->object_feature_1_;
+ // If any object is missing the FEATURE_2_USED property, we must
+ // omit it from the output file.
+ if (this->object_feature_2_used_ == 0)
+ this->feature_2_used_ = 0;
+ else if (this->feature_2_used_ != 0)
+ this->feature_2_used_ |= this->object_feature_2_used_;
+ }
+ else
+ {
+ this->isa_1_used_ = this->object_isa_1_used_;
+ this->feature_1_ = this->object_feature_1_;
+ this->feature_2_used_ = this->object_feature_2_used_;
+ this->seen_first_object_ = true;
+ }
+ this->object_isa_1_used_ = 0;
+ this->object_feature_1_ = 0;
+ this->object_feature_2_used_ = 0;
+}
+
+static inline void
+add_property(Layout* layout, unsigned int pr_type, uint32_t val)
+{
+ unsigned char buf[4];
+ elfcpp::Swap<32, false>::writeval(buf, val);
+ layout->add_gnu_property(elfcpp::NT_GNU_PROPERTY_TYPE_0, pr_type, 4, buf);
+}
+
+// Finalize the target-specific program properties and add them back to
+// the layout.
+void
+Target_i386::do_finalize_gnu_properties(Layout* layout) const
+{
+ if (this->isa_1_used_ != 0)
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_ISA_1_USED,
+ this->isa_1_used_);
+ if (this->isa_1_needed_ != 0)
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_ISA_1_NEEDED,
+ this->isa_1_needed_);
+ if (this->feature_1_ != 0)
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_1_AND,
+ this->feature_1_);
+ if (this->feature_2_used_ != 0)
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_2_USED,
+ this->feature_2_used_);
+ if (this->feature_2_needed_ != 0)
+ add_property(layout, elfcpp::GNU_PROPERTY_X86_FEATURE_2_NEEDED,
+ this->feature_2_needed_);
+}
+
// Write the first three reserved words of the .got.plt section.
// The remainder of the section is written while writing the PLT
// in Output_data_plt_i386::do_write.

View File

@ -0,0 +1,16 @@
diff -rup binutils.orig/gold/options.h binutils-2.41/gold/options.h
--- binutils.orig/gold/options.h 2024-01-04 09:52:09.282002253 +0000
+++ binutils-2.41/gold/options.h 2024-01-04 09:52:51.890972630 +0000
@@ -855,6 +855,12 @@ class General_options
N_("(ARM only) Do not warn about objects with incompatible "
"enum sizes"));
+ DEFINE_bool_ignore(error_execstack, options::TWO_DASHES, '\0',
+ N_("Ignored"), N_("Ignored"));
+
+ DEFINE_bool_ignore(error_rwx_segments, options::TWO_DASHES, '\0',
+ N_("Ignored"), N_("Ignored"));
+
DEFINE_special(exclude_libs, options::TWO_DASHES, '\0',
N_("Exclude libraries from automatic export"),
N_(("lib,lib ...")));

View File

@ -0,0 +1,19 @@
diff -rup binutils.orig/gold/layout.cc binutils-2.32/gold/layout.cc
--- binutils.orig/gold/layout.cc 2019-06-24 14:37:36.013086899 +0100
+++ binutils-2.32/gold/layout.cc 2019-06-24 14:41:40.054517479 +0100
@@ -868,6 +868,7 @@ Layout::get_output_section(const char* n
&& (same_name->flags() & elfcpp::SHF_TLS) == 0)
os = same_name;
}
+#if 0 /* BZ 1722715, PR 17556. */
else if ((flags & elfcpp::SHF_TLS) == 0)
{
elfcpp::Elf_Xword zero_flags = 0;
@@ -878,6 +879,7 @@ Layout::get_output_section(const char* n
if (p != this->section_name_map_.end())
os = p->second;
}
+#endif
}
if (os == NULL)

View File

@ -0,0 +1,27 @@
diff --git a/gold/options.cc b/gold/options.cc
index c9834b66159..91d7802fffe 100644
--- a/gold/options.cc
+++ b/gold/options.cc
@@ -989,7 +989,7 @@ parse_short_option(int argc, const char** argv, int pos_in_argv_i,
}
// If we're a -z option, we need to parse our argument as a
- // long-option, e.g. "-z stacksize=8192".
+ // long-option, e.g. "-z stack-size=8192".
if (retval == &dash_z)
{
int dummy_i = 0;
diff --git a/gold/options.h b/gold/options.h
index 46f658f23ea..d16e38066da 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -1110,6 +1110,9 @@ class General_options
N_("Generate package metadata note"),
N_("[=JSON]"));
+ DEFINE_bool_ignore(pack_relative_relocs, options::DASH_Z, '\0',
+ N_("Ignored"), N_("Ignored"));
+
DEFINE_bool(pie, options::ONE_DASH, '\0', false,
N_("Create a position independent executable"),
N_("Do not create a position independent executable"));

View File

@ -0,0 +1,48 @@
Only in binutils-2.34/gold: autom4te.cache
diff -rup binutils.orig/gold/configure binutils-2.34/gold/configure
--- binutils.orig/gold/configure 2020-04-20 12:35:13.048297305 +0100
+++ binutils-2.34/gold/configure 2020-04-20 14:02:06.743725696 +0100
@@ -5180,7 +5180,8 @@ for targ in $target $canon_targets; do
. ${srcdir}/configure.tgt
if test "$targ_obj" = "UNKNOWN"; then
- as_fn_error $? "\"unsupported target $targ\"" "$LINENO" 5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"unsupported target $targ\"" >&5
+$as_echo "$as_me: WARNING: \"unsupported target $targ\"" >&2;}
else
targetobjs="$targetobjs ${targ_obj}.\$(OBJEXT)"
if test "$targ_extra_obj" != ""; then
diff -rup binutils.orig/gold/configure.ac binutils-2.34/gold/configure.ac
--- binutils.orig/gold/configure.ac 2020-04-20 12:35:13.050297291 +0100
+++ binutils-2.34/gold/configure.ac 2020-04-20 14:01:46.435868770 +0100
@@ -181,7 +181,7 @@ for targ in $target $canon_targets; do
. ${srcdir}/configure.tgt
if test "$targ_obj" = "UNKNOWN"; then
- AC_MSG_ERROR("unsupported target $targ")
+ AC_MSG_WARN("unsupported target $targ")
else
targetobjs="$targetobjs ${targ_obj}.\$(OBJEXT)"
if test "$targ_extra_obj" != ""; then
--- binutils.orig/bfd/config.bfd 2020-04-20 12:35:13.038297375 +0100
+++ binutils-2.34/bfd/config.bfd 2020-04-20 14:25:26.452869193 +0100
@@ -473,7 +473,7 @@ case "${targ}" in
;;
#ifdef BFD64
- bpf-*-none)
+ bpf-*-none | bpf-*)
targ_defvec=bpf_elf64_le_vec
targ_selvecs=bpf_elf64_be_vec
targ_underscore=yes
--- binutils.orig/ld/configure.tgt 2026-01-05 08:51:02.908224792 +0000
+++ binutils-with-gold-2.45.50-be970c68891/ld/configure.tgt 2026-01-05 08:51:55.852677409 +0000
@@ -255,7 +255,7 @@ bfin-*-uclinux*) targ_emul=elf32bfin;
bfin-*-linux-uclibc*) targ_emul=elf32bfinfd;
targ_extra_libpath=elf32bfin
;;
-bpf-*-*) targ_emul=elf64bpf
+bpf-* | bpf-*-*) targ_emul=elf64bpf
;;
cr16-*-elf*) targ_emul=elf32cr16
;;

View File

@ -0,0 +1,52 @@
diff -rup binutils.orig/bfd/elflink.c binutils-with-gold-2.45.50-be970c68891/bfd/elflink.c
--- binutils.orig/bfd/elflink.c 2026-01-14 09:21:14.835847967 +0000
+++ binutils-with-gold-2.45.50-be970c68891/bfd/elflink.c 2026-01-14 09:23:48.780495205 +0000
@@ -13786,7 +13786,7 @@ _bfd_elf_final_link (bfd *abfd, struct b
{
if (info->textrel_check == textrel_check_error)
info->callbacks->einfo
- (_("%P%X: read-only segment has dynamic relocations\n"));
+ (_("%P%X: error: read-only segment has dynamic relocations\n"));
else if (bfd_link_dll (info))
info->callbacks->einfo
(_("%P: warning: creating DT_TEXTREL in a shared object\n"));
diff -rup binutils.orig/ld/testsuite/ld-aarch64/dt-memtag-mode.d binutils-with-gold-2.45.50-be970c68891/ld/testsuite/ld-aarch64/dt-memtag-mode.d
--- binutils.orig/ld/testsuite/ld-aarch64/dt-memtag-mode.d 2026-01-14 09:21:15.248851537 +0000
+++ binutils-with-gold-2.45.50-be970c68891/ld/testsuite/ld-aarch64/dt-memtag-mode.d 2026-01-14 09:22:24.603416270 +0000
@@ -1,5 +1,5 @@
#source: dt-memtag.s
-#ld: -shared -z memtag-mode=async
+#ld: -shared -z memtag-mode=async -z notext
#readelf: -d
#...
diff -rup binutils.orig/ld/testsuite/ld-aarch64/dt-memtag-stack.d binutils-with-gold-2.45.50-be970c68891/ld/testsuite/ld-aarch64/dt-memtag-stack.d
--- binutils.orig/ld/testsuite/ld-aarch64/dt-memtag-stack.d 2026-01-14 09:21:15.248851537 +0000
+++ binutils-with-gold-2.45.50-be970c68891/ld/testsuite/ld-aarch64/dt-memtag-stack.d 2026-01-14 09:24:19.594780414 +0000
@@ -1,5 +1,5 @@
#source: dt-memtag.s
-#ld: -shared -z memtag-stack
+#ld: -shared -z memtag-stack -z notext
#readelf: -d
#...
diff -rup binutils.orig/ld/testsuite/ld-aarch64/relr-text-pie.d binutils-with-gold-2.45.50-be970c68891/ld/testsuite/ld-aarch64/relr-text-pie.d
--- binutils.orig/ld/testsuite/ld-aarch64/relr-text-pie.d 2026-01-14 09:21:15.246851520 +0000
+++ binutils-with-gold-2.45.50-be970c68891/ld/testsuite/ld-aarch64/relr-text-pie.d 2026-01-14 09:24:45.363485698 +0000
@@ -1,5 +1,5 @@
#source: relr-text.s
-#ld: -pie -z pack-relative-relocs -T relocs.ld
+#ld: -pie -z pack-relative-relocs -T relocs.ld -z notext
#readelf: -drW
#...
diff -rup binutils.orig/ld/testsuite/ld-aarch64/relr-text-shared.d binutils-with-gold-2.45.50-be970c68891/ld/testsuite/ld-aarch64/relr-text-shared.d
--- binutils.orig/ld/testsuite/ld-aarch64/relr-text-shared.d 2026-01-14 09:21:15.246851520 +0000
+++ binutils-with-gold-2.45.50-be970c68891/ld/testsuite/ld-aarch64/relr-text-shared.d 2026-01-14 09:25:06.651664713 +0000
@@ -1,5 +1,5 @@
#source: relr-text.s
-#ld: -shared -z pack-relative-relocs -T relocs.ld
+#ld: -shared -z pack-relative-relocs -T relocs.ld -z notext
#readelf: -drW
#...

View File

@ -0,0 +1,236 @@
diff -rcp ../binutils-2.20.51.0.7.original/bfd/configure ./bfd/configure
--- a/bfd/configure 2010-04-08 14:53:48.000000000 +0100
+++ b/bfd/configure 2010-04-08 14:56:50.000000000 +0100
@@ -10762,10 +10762,34 @@
# before this can be enabled.
hardcode_into_libs=yes
+ # find out which ABI we are using
+ libsuff=
+ case "$host_cpu" in
+ x86_64*|s390*|powerpc*|ppc*|sparc*)
+ echo 'int i;' > conftest.$ac_ext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *64-bit*)
+ libsuff=64
+ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then
+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+ fi
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+ esac
+
# Append ld.so.conf contents to the search path
if test -f /etc/ld.so.conf; then
lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
fi
# We used to test for /lib/ld.so.1 and disable shared libraries on
diff -rcp ../binutils-2.20.51.0.7.original/binutils/configure ./binutils/configure
--- a/binutils/configure 2010-04-08 14:53:45.000000000 +0100
+++ b/binutils/configure 2010-04-08 14:56:21.000000000 +0100
@@ -10560,10 +10560,34 @@
# before this can be enabled.
hardcode_into_libs=yes
+ # find out which ABI we are using
+ libsuff=
+ case "$host_cpu" in
+ x86_64*|s390*|powerpc*|ppc*|sparc*)
+ echo 'int i;' > conftest.$ac_ext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *64-bit*)
+ libsuff=64
+ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then
+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+ fi
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+ esac
+
# Append ld.so.conf contents to the search path
if test -f /etc/ld.so.conf; then
lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
fi
# We used to test for /lib/ld.so.1 and disable shared libraries on
diff -rcp ../binutils-2.20.51.0.7.original/gas/configure ./gas/configure
--- a/gas/configure 2010-04-08 14:53:47.000000000 +0100
+++ b/gas/configure 2010-04-08 14:57:24.000000000 +0100
@@ -10547,10 +10547,34 @@
# before this can be enabled.
hardcode_into_libs=yes
+ # find out which ABI we are using
+ libsuff=
+ case "$host_cpu" in
+ x86_64*|s390*|powerpc*|ppc*|sparc*)
+ echo 'int i;' > conftest.$ac_ext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *64-bit*)
+ libsuff=64
+ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then
+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+ fi
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+ esac
+
# Append ld.so.conf contents to the search path
if test -f /etc/ld.so.conf; then
lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
fi
# We used to test for /lib/ld.so.1 and disable shared libraries on
diff -rcp ../binutils-2.20.51.0.7.original/gprof/configure ./gprof/configure
--- a/gprof/configure 2010-04-08 14:53:45.000000000 +0100
+++ b/gprof/configure 2010-04-08 14:57:50.000000000 +0100
@@ -10485,10 +10485,34 @@
# before this can be enabled.
hardcode_into_libs=yes
+ # find out which ABI we are using
+ libsuff=
+ case "$host_cpu" in
+ x86_64*|s390*|powerpc*|ppc*|sparc*)
+ echo 'int i;' > conftest.$ac_ext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *64-bit*)
+ libsuff=64
+ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then
+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+ fi
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+ esac
+
# Append ld.so.conf contents to the search path
if test -f /etc/ld.so.conf; then
lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
fi
# We used to test for /lib/ld.so.1 and disable shared libraries on
diff -rcp ../binutils-2.20.51.0.7.original/ld/configure ./ld/configure
--- a/ld/configure 2010-04-08 14:53:44.000000000 +0100
+++ b/ld/configure 2010-04-08 14:58:21.000000000 +0100
@@ -10966,10 +10966,34 @@
# before this can be enabled.
hardcode_into_libs=yes
+ # find out which ABI we are using
+ libsuff=
+ case "$host_cpu" in
+ x86_64*|s390*|powerpc*|ppc*|sparc*)
+ echo 'int i;' > conftest.$ac_ext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *64-bit*)
+ libsuff=64
+ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then
+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+ fi
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+ esac
+
# Append ld.so.conf contents to the search path
if test -f /etc/ld.so.conf; then
lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
fi
# We used to test for /lib/ld.so.1 and disable shared libraries on
Only in .: .#libtool.m4
Only in .: #libtool.m4#
diff -rcp ../binutils-2.20.51.0.7.original/opcodes/configure ./opcodes/configure
--- a/opcodes/configure 2010-04-08 14:53:45.000000000 +0100
+++ b/opcodes/configure 2010-04-08 14:59:10.000000000 +0100
@@ -10496,10 +10496,34 @@
# before this can be enabled.
hardcode_into_libs=yes
+ # find out which ABI we are using
+ libsuff=
+ case "$host_cpu" in
+ x86_64*|s390*|powerpc*|ppc*|sparc*)
+ echo 'int i;' > conftest.$ac_ext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *64-bit*)
+ libsuff=64
+ if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then
+ sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
+ fi
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+ esac
+
# Append ld.so.conf contents to the search path
if test -f /etc/ld.so.conf; then
lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
fi
# We used to test for /lib/ld.so.1 and disable shared libraries on

View File

@ -0,0 +1,28 @@
diff -rup binutils.orig/ltmain.sh binutils-2.37/ltmain.sh
--- binutils.orig/ltmain.sh 2022-01-27 16:23:09.304207432 +0000
+++ binutils-2.37/ltmain.sh 2022-01-27 16:23:18.380143759 +0000
@@ -7103,6 +7103,7 @@ EOF
rpath="$finalize_rpath"
test "$mode" != relink && rpath="$compile_rpath$rpath"
for libdir in $rpath; do
+ case "$libdir" in /usr/lib|/usr/lib64|/usr/lib/../lib|/usr/lib/../lib64) continue;; esac
if test -n "$hardcode_libdir_flag_spec"; then
if test -n "$hardcode_libdir_separator"; then
if test -z "$hardcode_libdirs"; then
@@ -7798,6 +7799,7 @@ EOF
rpath=
hardcode_libdirs=
for libdir in $compile_rpath $finalize_rpath; do
+ case "$libdir" in /usr/lib|/usr/lib64|/usr/lib/../lib|/usr/lib/../lib64) continue;; esac
if test -n "$hardcode_libdir_flag_spec"; then
if test -n "$hardcode_libdir_separator"; then
if test -z "$hardcode_libdirs"; then
@@ -7849,6 +7851,7 @@ EOF
rpath=
hardcode_libdirs=
for libdir in $finalize_rpath; do
+ case "$libdir" in /usr/lib|/usr/lib64|/usr/lib/../lib|/usr/lib/../lib64) continue;; esac
if test -n "$hardcode_libdir_flag_spec"; then
if test -n "$hardcode_libdir_separator"; then
if test -z "$hardcode_libdirs"; then
Only in binutils-2.37: ltmain.sh.orig

View File

@ -0,0 +1,28 @@
--- a/bfd/bfd-in.h 2012-08-02 10:56:34.561769686 +0100
+++ b/bfd/bfd-in.h 2012-08-02 11:13:27.134797755 +0100
@@ -25,11 +25,6 @@
#ifndef __BFD_H_SEEN__
#define __BFD_H_SEEN__
-/* PR 14072: Ensure that config.h is included first. */
-#if !defined PACKAGE && !defined PACKAGE_VERSION
-#error config.h must be included before this header
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
--- a/bfd/bfd-in2.h 2012-08-02 10:56:34.349769680 +0100
+++ b/bfd/bfd-in2.h 2012-08-02 11:13:40.015798113 +0100
@@ -32,11 +32,6 @@
#ifndef __BFD_H_SEEN__
#define __BFD_H_SEEN__
-/* PR 14072: Ensure that config.h is included first. */
-#if !defined PACKAGE && !defined PACKAGE_VERSION
-#error config.h must be included before this header
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -0,0 +1,53 @@
--- binutils-with-gold-2.45.50.orig/binutils/readelf.c 2025-12-08 10:51:19.287135564 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/binutils/readelf.c 2025-12-08 10:59:34.414789154 +0000
@@ -14667,6 +14667,18 @@ print_symbol_size (uint64_t vma, int bas
}
}
+/* The AArch64, ARM and RISC-V architectures define mapping
+ symbols (eg $d, $x, $t) which sometime should be ignored. */
+
+static bool
+is_mapping_symbol (const char * name)
+{
+ return name[0] == '$'
+ && name [1] != 0
+ /* FIXME: Check that name[1] is lower case ASCII ? */
+ && name [2] == 0;
+}
+
/* Print information on a single symbol. */
static void
@@ -14803,7 +14815,9 @@ print_symbol (Filedata * filed
/* Local symbols whose value is larger than their section's size are suspicious
especially if that section is mergeable - and hence might change offsets of
- the contents inside the section. */
+ the contents inside the section.
+ Note - for some reason we can get mapping symbols that do not relate to their
+ section's contents - so we ignore those type of symbol as well. */
if (ELF_ST_BIND (psym->st_info) == STB_LOCAL
&& ! is_special
&& is_valid
@@ -14811,7 +14825,8 @@ print_symbol (Filedata * filed
&& filedata->section_headers != NULL
/* FIXME: Should we warn for non-mergeable sections ? */
&& (filedata->section_headers[psym->st_shndx].sh_flags & SHF_MERGE)
- && psym->st_value > filedata->section_headers[psym->st_shndx].sh_size)
+ && psym->st_value > filedata->section_headers[psym->st_shndx].sh_size
+ && ! is_mapping_symbol (strtab + psym->st_name))
warn (_("local symbol %s has a value (%#" PRIx64 ") which is larger than mergeable section %s's size (%#" PRIx64 ")\n"),
strtab + psym->st_name,
psym->st_value,
@@ -23034,9 +23049,7 @@ get_symbol_for_build_attribute (Filedata
/* The AArch64, ARM and RISC-V architectures define mapping symbols
(eg $d, $x, $t) which we want to ignore. */
- if (ba_cache.strtab[sym->st_name] == '$'
- && ba_cache.strtab[sym->st_name + 1] != 0
- && ba_cache.strtab[sym->st_name + 2] == 0)
+ if (is_mapping_symbol (ba_cache.strtab + sym->st_name))
continue;
if (is_open_attr)

View File

@ -0,0 +1,33 @@
diff -rup binutils.orig/ld/testsuite/ld-x86-64/x86-64.exp binutils-with-gold-2.45.50-96b8a8a633a/ld/testsuite/ld-x86-64/x86-64.exp
--- binutils.orig/ld/testsuite/ld-x86-64/x86-64.exp 2025-11-20 12:02:23.738336155 +0000
+++ binutils-with-gold-2.45.50-96b8a8a633a/ld/testsuite/ld-x86-64/x86-64.exp 2025-11-20 12:03:17.894485264 +0000
@@ -1413,14 +1413,6 @@ if { [isnative] && [check_compiler_avail
"libprotected-func-2b.so" \
] \
[list \
- "Build protected-func-2 without PIE" \
- "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-func-2b.so" \
- "$DIRECT_EXTERN_ACCESS_CFLAGS $NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
- { protected-func-1b.c } \
- {} \
- "protected-func-2" \
- ] \
- [list \
"Build libprotected-func-2c.so" \
"-shared" \
"-fPIC -Wa,-mx86-used-note=yes" \
@@ -1429,14 +1421,6 @@ if { [isnative] && [check_compiler_avail
"libprotected-func-2c.so" \
] \
[list \
- "Build protected-func-2a without PIE" \
- "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/libprotected-func-2c.so" \
- "$DIRECT_EXTERN_ACCESS_CFLAGS $NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
- { protected-func-1b.c } \
- {} \
- "protected-func-2a" \
- ] \
- [list \
"Build libprotected-data-1a.so" \
"-shared -z noindirect-extern-access" \
"-fPIC -Wa,-mx86-used-note=yes" \

View File

@ -0,0 +1,167 @@
diff -rup binutils.orig/ld/testsuite/ld-i386/pltgot-1.d binutils-2.29.1/ld/testsuite/ld-i386/pltgot-1.d
--- binutils.orig/ld/testsuite/ld-i386/pltgot-1.d 2017-11-15 13:32:39.335065263 +0000
+++ binutils-2.29.1/ld/testsuite/ld-i386/pltgot-1.d 2017-11-15 15:03:55.649727195 +0000
@@ -2,6 +2,7 @@
#readelf: -S --wide
#as: --32
+#pass
#...
+\[ *[0-9]+\] \.plt +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+10 +.*
#...
diff -rup binutils.orig/ld/testsuite/ld-i386/pltgot-2.d binutils-2.29.1/ld/testsuite/ld-i386/pltgot-2.d
--- binutils.orig/ld/testsuite/ld-i386/pltgot-2.d 2017-11-15 13:32:39.329065335 +0000
+++ binutils-2.29.1/ld/testsuite/ld-i386/pltgot-2.d 2017-11-15 15:04:20.803430034 +0000
@@ -3,7 +3,6 @@
#readelf: -d --wide
#as: --32
-#failif
#...
+0x[0-9a-f]+ +\(PLTREL.*
#...
diff -rup binutils.orig/ld/testsuite/ld-i386/pr19636-2d.d binutils-2.29.1/ld/testsuite/ld-i386/pr19636-2d.d
--- binutils.orig/ld/testsuite/ld-i386/pr19636-2d.d 2017-11-15 13:32:39.336065251 +0000
+++ binutils-2.29.1/ld/testsuite/ld-i386/pr19636-2d.d 2017-11-15 15:03:00.413379749 +0000
@@ -9,7 +9,7 @@ Relocation section '\.rel\.dyn' at offse
[0-9a-f]+ +[0-9a-f]+ +R_386_32 +0+ +func
[0-9a-f]+ +[0-9a-f]+ +R_386_PC32 +0+ +func
[0-9a-f]+ +[0-9a-f]+ +R_386_GLOB_DAT +0+ +func
-
+#...
Symbol table '\.dynsym' contains [0-9]+ entries:
+Num: +Value +Size Type +Bind +Vis +Ndx Name
#...
diff -rup binutils.orig/ld/testsuite/ld-i386/pr19636-2e.d binutils-2.29.1/ld/testsuite/ld-i386/pr19636-2e.d
--- binutils.orig/ld/testsuite/ld-i386/pr19636-2e.d 2017-11-15 13:32:39.330065323 +0000
+++ binutils-2.29.1/ld/testsuite/ld-i386/pr19636-2e.d 2017-11-15 15:03:28.928042882 +0000
@@ -9,7 +9,7 @@ Relocation section '\.rel\.dyn' at offse
[0-9a-f]+ +[0-9a-f]+ +R_386_32 +0+ +func
[0-9a-f]+ +[0-9a-f]+ +R_386_PC32 +0+ +func
[0-9a-f]+ +[0-9a-f]+ +R_386_GLOB_DAT +0+ +func
-
+#...
Symbol table '\.dynsym' contains [0-9]+ entries:
+Num: +Value +Size Type +Bind +Vis +Ndx Name
#...
diff -rup binutils.orig/ld/testsuite/ld-x86-64/pltgot-1.d binutils-2.29.1/ld/testsuite/ld-x86-64/pltgot-1.d
--- binutils.orig/ld/testsuite/ld-x86-64/pltgot-1.d 2017-11-15 13:32:39.415064300 +0000
+++ binutils-2.29.1/ld/testsuite/ld-x86-64/pltgot-1.d 2017-11-15 15:08:39.333375801 +0000
@@ -2,8 +2,4 @@
#readelf: -S --wide
#as: --64
-#...
- +\[ *[0-9]+\] \.plt +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+10 +.*
-#...
- +\[ *[0-9]+\] \.got\.plt +PROGBITS +[0-9a-f]+ +[0-9a-f]+ +0+18 +.*
#pass
diff -rup binutils.orig/ld/testsuite/ld-x86-64/pltgot-2.d binutils-2.29.1/ld/testsuite/ld-x86-64/pltgot-2.d
--- binutils.orig/ld/testsuite/ld-x86-64/pltgot-2.d 2017-11-15 13:32:39.404064432 +0000
+++ binutils-2.29.1/ld/testsuite/ld-x86-64/pltgot-2.d 2017-11-15 15:08:59.031143095 +0000
@@ -3,7 +3,6 @@
#readelf: -d --wide
#as: --64
-#failif
#...
+0x[0-9a-f]+ +\(PLTREL.*
#...
diff -rup binutils.orig/ld/testsuite/ld-x86-64/plt-main.rd binutils-2.29.1/ld/testsuite/ld-x86-64/plt-main.rd
--- binutils.orig/ld/testsuite/ld-x86-64/plt-main.rd 2017-11-15 13:32:39.407064397 +0000
+++ binutils-2.29.1/ld/testsuite/ld-x86-64/plt-main.rd 2017-11-15 15:06:17.244054423 +0000
@@ -1,4 +1,3 @@
-#failif
#...
[0-9a-f ]+R_X86_64_JUMP_SLOT +0+ +bar \+ 0
#...
diff -rup binutils.orig/ld/testsuite/ld-x86-64/pr20830a.d binutils-2.29.1/ld/testsuite/ld-x86-64/pr20830a.d
--- binutils.orig/ld/testsuite/ld-x86-64/pr20830a.d 2017-11-15 13:32:39.412064336 +0000
+++ binutils-2.29.1/ld/testsuite/ld-x86-64/pr20830a.d 2017-11-15 15:15:09.918750288 +0000
@@ -20,6 +20,7 @@ Contents of the .eh_frame section:
DW_CFA_offset: r16 \(rip\) at cfa-8
DW_CFA_nop
DW_CFA_nop
+#pass
0+18 0000000000000014 0000001c FDE cie=00000000 pc=00000000000001c8..00000000000001d4
DW_CFA_nop
diff -rup binutils.orig/ld/testsuite/ld-x86-64/pr20830a-now.d binutils-2.29.1/ld/testsuite/ld-x86-64/pr20830a-now.d
--- binutils.orig/ld/testsuite/ld-x86-64/pr20830a-now.d 2017-11-15 13:32:39.413064324 +0000
+++ binutils-2.29.1/ld/testsuite/ld-x86-64/pr20830a-now.d 2017-11-15 15:16:08.227055104 +0000
@@ -20,6 +20,7 @@ Contents of the .eh_frame section:
DW_CFA_offset: r16 \(rip\) at cfa-8
DW_CFA_nop
DW_CFA_nop
+#pass
0+18 0000000000000014 0000001c FDE cie=00000000 pc=00000000000001c8..00000000000001d4
DW_CFA_nop
diff -rup binutils.orig/ld/testsuite/ld-x86-64/pr20830b.d binutils-2.29.1/ld/testsuite/ld-x86-64/pr20830b.d
--- binutils.orig/ld/testsuite/ld-x86-64/pr20830b.d 2017-11-15 13:32:39.413064324 +0000
+++ binutils-2.29.1/ld/testsuite/ld-x86-64/pr20830b.d 2017-11-15 15:16:20.115913358 +0000
@@ -20,7 +20,8 @@ Contents of the .eh_frame section:
DW_CFA_offset: r16 \(rip\) at cfa-8
DW_CFA_nop
DW_CFA_nop
-
+#pass
+
0+18 0000000000000010 0000001c FDE cie=00000000 pc=0000000000000138..0000000000000144
DW_CFA_nop
DW_CFA_nop
diff -rup binutils.orig/ld/testsuite/ld-x86-64/pr20830b-now.d binutils-2.29.1/ld/testsuite/ld-x86-64/pr20830b-now.d
--- binutils.orig/ld/testsuite/ld-x86-64/pr20830b-now.d 2017-11-15 13:32:39.411064348 +0000
+++ binutils-2.29.1/ld/testsuite/ld-x86-64/pr20830b-now.d 2017-11-15 15:16:29.012807282 +0000
@@ -20,7 +20,8 @@ Contents of the .eh_frame section:
DW_CFA_offset: r16 \(rip\) at cfa-8
DW_CFA_nop
DW_CFA_nop
-
+#pass
+
0+18 0000000000000010 0000001c FDE cie=00000000 pc=0000000000000138..0000000000000144
DW_CFA_nop
DW_CFA_nop
diff -rup binutils.orig/ld/testsuite/ld-x86-64/tlspic2.rd binutils-2.29.1/ld/testsuite/ld-x86-64/tlspic2.rd
--- binutils.orig/ld/testsuite/ld-x86-64/tlspic2.rd 2017-11-15 13:32:39.417064276 +0000
+++ binutils-2.29.1/ld/testsuite/ld-x86-64/tlspic2.rd 2017-11-15 15:05:02.950932110 +0000
@@ -14,6 +14,7 @@ Section Headers:
+\[[ 0-9]+\] .dynsym +.*
+\[[ 0-9]+\] .dynstr +.*
+\[[ 0-9]+\] .rela.dyn +.*
+#pass
+\[[ 0-9]+\] .plt +.*
+\[[ 0-9]+\] .plt.got +.*
+\[[ 0-9]+\] .text +PROGBITS +0+1000 0+1000 0+31a 00 +AX +0 +0 4096
--- binutils.orig/bfd/elfxx-x86.c 2018-01-22 15:59:25.875788033 +0000
+++ binutils-2.30.0/bfd/elfxx-x86.c 2018-01-22 16:00:20.789146597 +0000
@@ -107,7 +107,7 @@ elf_x86_allocate_dynrelocs (struct elf_l
plt_entry_size = htab->plt.plt_entry_size;
resolved_to_zero = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
-
+#if 0
/* We can't use the GOT PLT if pointer equality is needed since
finish_dynamic_symbol won't clear symbol value and the dynamic
linker won't update the GOT slot. We will get into an infinite
@@ -125,7 +125,7 @@ elf_x86_allocate_dynrelocs (struct elf_l
/* Use the GOT PLT. */
eh->plt_got.refcount = 1;
}
-
+#endif
/* Since STT_GNU_IFUNC symbol must go through PLT, we handle it
here if it is defined and referenced in a non-shared object. */
if (h->type == STT_GNU_IFUNC
--- binutils.orig/ld/testsuite/ld-i386/pr20830.d 2018-07-09 09:49:51.277239857 +0100
+++ binutils-2.30.90/ld/testsuite/ld-i386/pr20830.d 2018-07-09 10:32:41.113356733 +0100
@@ -19,7 +19,7 @@ Contents of the .eh_frame section:
DW_CFA_offset: r8 \(eip\) at cfa-4
DW_CFA_nop
DW_CFA_nop
-
+#pass
0+18 00000010 0000001c FDE cie=00000000 pc=00000128..00000133
DW_CFA_nop
DW_CFA_nop

View File

@ -0,0 +1,81 @@
diff -rup binutils.orig/bfd/elflink.c binutils-with-gold-2.45.50-96b8a8a633a/bfd/elflink.c
--- binutils.orig/bfd/elflink.c 2025-11-20 09:01:31.653839370 +0000
+++ binutils-with-gold-2.45.50-96b8a8a633a/bfd/elflink.c 2025-11-20 09:02:21.703952373 +0000
@@ -11158,13 +11158,7 @@ elf_link_output_extsym (struct bfd_hash_
else
{
if (h->verinfo.vertree == NULL)
- {
- iversym.vs_vers = 1;
- if (elf_tdata (flinfo->output_bfd)->cverdefs == 0)
- /* Defined symbol has no version if there is no
- linker version script. */
- noversion = true;
- }
+ iversym.vs_vers = 1;
else
iversym.vs_vers = h->verinfo.vertree->vernum + 1;
if (flinfo->info->create_default_symver)
diff -rup binutils.orig/binutils/readelf.c binutils-with-gold-2.45.50-96b8a8a633a/binutils/readelf.c
--- binutils.orig/binutils/readelf.c 2025-11-20 09:01:32.656841480 +0000
+++ binutils-with-gold-2.45.50-96b8a8a633a/binutils/readelf.c 2025-11-20 09:03:05.707055021 +0000
@@ -14074,7 +14074,7 @@ process_version_sections (Filedata * fil
while (ivn.vn_next);
}
- if (data[cnt + j] != (VERSYM_HIDDEN | VERSYM_BASE)
+ if (data[cnt + j] != 0x8001
&& filedata->version_info[DT_VERSIONTAGIDX (DT_VERDEF)])
{
Elf_Internal_Verdef ivd;
@@ -14500,10 +14500,6 @@ get_symbol_version_string (Filedata *fil
*sym_info = (vers_data & VERSYM_HIDDEN) != 0 ? symbol_hidden : symbol_public;
max_vd_ndx = 0;
- /* Return the empty string for the base version. */
- if ((vers_data & VERSYM_VERSION) == VERSYM_BASE)
- return "";
-
/* Usually we'd only see verdef for defined symbols, and verneed for
undefined symbols. However, symbols defined by the linker in
.dynbss for variables copied from a shared library in order to
@@ -14514,7 +14510,7 @@ get_symbol_version_string (Filedata *fil
verneed. .dynbss might not be mapped to a SHT_NOBITS section. */
if (psym->st_shndx != SHN_UNDEF
- && vers_data != (VERSYM_HIDDEN | VERSYM_BASE)
+ && vers_data != 0x8001
&& filedata->version_info[DT_VERSIONTAGIDX (DT_VERDEF)])
{
Elf_Internal_Verdef ivd;
diff -rup binutils.orig/ld/testsuite/ld-elfvers/vers16.dsym binutils-with-gold-2.45.50-96b8a8a633a/ld/testsuite/ld-elfvers/vers16.dsym
--- binutils.orig/ld/testsuite/ld-elfvers/vers16.dsym 2025-11-20 09:01:33.016842237 +0000
+++ binutils-with-gold-2.45.50-96b8a8a633a/ld/testsuite/ld-elfvers/vers16.dsym 2025-11-20 09:02:55.496031202 +0000
@@ -1,2 +1,2 @@
-[0-9a-f]+ g +DF (\.text|\.opd|\*ABS\*) [0-9a-f]+ +(0x[0-9a-f]+ )?_?show_bar
+[0-9a-f]+ g +DF (\.text|\.opd|\*ABS\*) [0-9a-f]+( +Base +)? +(0x[0-9a-f]+ )?_?show_bar
[0-9a-f]+ +DF \*UND\* [0-9a-f]+ +(0x[0-9a-f]+ )?_?show_foo
diff -rup binutils.orig/ld/testsuite/ld-elf/pr33599.d binutils-with-gold-2.45.50-96b8a8a633a/ld/testsuite/ld-elf/pr33599.d
--- binutils.orig/ld/testsuite/ld-elf/pr33599.d 2025-11-20 14:11:24.398747907 +0000
+++ binutils-with-gold-2.45.50-96b8a8a633a/ld/testsuite/ld-elf/pr33599.d 2025-11-20 14:18:55.353205025 +0000
@@ -5,7 +5,7 @@
Symbol table '\.dynsym' contains [0-9]+ entries:
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +OBJECT +GLOBAL +DEFAULT +[0-9]+ +bar@@
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +OBJECT +GLOBAL +DEFAULT +[0-9]+ +bar@.*
#...
- +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo@
+ +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo.*
#pass
--- binutils-with-gold-2.45.50-beab972c07d.orig/ld/testsuite/ld-elfvers/vers.exp 2025-11-24 09:39:57.717018589 +0000
+++ binutils-with-gold-2.45.50-beab972c07d/ld/testsuite/ld-elfvers/vers.exp 2025-11-24 09:41:49.185852008 +0000
@@ -1019,6 +1019,8 @@ build_vers_lib_pic "vers31" vers31.c ver
build_vers_lib_pic "vers32a" vers32a.c vers32a "" vers32.map vers32a.ver vers32a.dsym ""
build_vers_lib_pic_flags "vers32b" vers32b.c vers32b "vers32a.so" vers32.map vers32b.ver vers32b.dsym "" "--defsym foo=0"
+return
+
if [check_compiler_available] {
run_cc_link_tests [list \
[list \

View File

@ -0,0 +1,124 @@
--- binutils.orig/ld/scripttempl/elf.sc 2024-11-01 10:17:24.308959289 +0000
+++ binutils-2.43.50-22c62092858/ld/scripttempl/elf.sc 2024-11-01 10:17:39.730019895 +0000
@@ -397,19 +397,6 @@ fi
# ===========================================================================
# Functions for generating parts of the linker script
-# Helper function for putting comments into scripts.
-# Useful when trying to track down script composition problems.
-# Use by adding:
-# emit_comment "a message"
-# wherever necessary.
-
-emit_comment()
-{
-cat <<EOF
- /* $1 */
-EOF
-}
-
emit_header()
{
cat <<EOF
@@ -438,6 +425,7 @@ emit_early_ro()
{
cat <<EOF
${INITIAL_READONLY_SECTIONS}
+ .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) }
EOF
}
@@ -448,11 +436,6 @@ cat <<EOF
${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}}
${CREATE_PIE+${RELOCATING+PROVIDE (__executable_start = ${SHLIB_TEXT_START_ADDR}); . = ${SHLIB_TEXT_START_ADDR}${SIZEOF_HEADERS_CODE};}}
-
- /* Place build-id as close to the ELF headers as possible. This
- maximises the chance the build-id will be present in core files,
- which GDB can then use to locate the associated debuginfo file. */
- .note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) }
EOF
}
@@ -574,7 +557,6 @@ EOF
align_text()
{
cat <<EOF
- ${RELOCATING+/* Align the text segment. */}
${RELOCATING+${TEXT_SEGMENT_ALIGN}}
EOF
}
@@ -816,28 +798,11 @@ EOF
emit_executable_start
if test -z "${ALL_TEXT_BEFORE_RO}"; then
- # We are allowed to put R/O sections before code sections.
-
test -n "${SEPARATE_CODE}" || emit_early_ro
test -n "${NON_ALLOC_DYN}${SEPARATE_CODE}" || emit_dyn
-
- # We only need the alignment if we have emitted some sections.
- if test -z "${SEPARATE_CODE}"; then
- align_text
- elif test -z "${NON_ALLOC_DYN}${SEPARATE_CODE}"; then
- align_text
- fi
fi
- # We do not align the code segment here as doing so will increase the file size.
- # Normally having the text segment at the start of the file will automatically
- # mean that it is aligned(*), and if we have emitted any r/o sections due to the
- # tests of SEPARATE_CODE above, then extra alignment will have already been
- # generated.
- #
- # *: Including the ELF headers and .note.gnu.build-id section in the code segment
- # is a very small theoretical risk.
-
+ align_text
emit_text
align_rodata
diff -rup binutils.orig/ld/testsuite/ld-i386/pr32191.d binutils-2.43.50-22c62092858/ld/testsuite/ld-i386/pr32191.d
--- binutils.orig/ld/testsuite/ld-i386/pr32191.d 2024-11-01 13:56:39.584115148 +0000
+++ binutils-2.43.50-22c62092858/ld/testsuite/ld-i386/pr32191.d 2024-11-01 13:58:30.962432716 +0000
@@ -2,6 +2,7 @@
#as: --32 -mx86-used-note=yes
#ld: -shared -m elf_i386 -z separate-code --build-id --rosegment
#readelf: -lW
+#xfail: *-*-*
#...
+[0-9]+ +\.note\.gnu\.build-id \.text
diff -rup binutils.orig/ld/testsuite/ld-x86-64/pr32191-x32.d binutils-2.43.50-22c62092858/ld/testsuite/ld-x86-64/pr32191-x32.d
--- binutils.orig/ld/testsuite/ld-x86-64/pr32191-x32.d 2024-11-01 13:56:39.652115341 +0000
+++ binutils-2.43.50-22c62092858/ld/testsuite/ld-x86-64/pr32191-x32.d 2024-11-01 13:59:27.626595088 +0000
@@ -2,6 +2,7 @@
#as: --x32 -mx86-used-note=yes
#ld: -shared -m elf32_x86_64 -z separate-code --build-id --rosegment
#readelf: -lW
+#xfail: *-*-*
#...
+[0-9]+ +\.note\.gnu\.build-id \.text
diff -rup binutils.orig/ld/testsuite/ld-x86-64/pr32191.d binutils-2.43.50-22c62092858/ld/testsuite/ld-x86-64/pr32191.d
--- binutils.orig/ld/testsuite/ld-x86-64/pr32191.d 2024-11-01 13:56:39.652115341 +0000
+++ binutils-2.43.50-22c62092858/ld/testsuite/ld-x86-64/pr32191.d 2024-11-01 13:59:12.906552493 +0000
@@ -2,6 +2,7 @@
#as: --64 -mx86-used-note=yes
#ld: -shared -m elf_x86_64 -z separate-code --build-id --rosegment
#readelf: -lW
+#xfail: *-*-*
#...
+[0-9]+ +\.note\.gnu\.build-id \.text
diff -rup bin.orig/ld/testsuite/ld-elf/pr23658-1e.d binutils-2.43.50-55e32b3c682/ld/testsuite/ld-elf/pr23658-1e.d
--- bin.orig/ld/testsuite/ld-elf/pr23658-1e.d 2024-11-04 12:18:57.021055380 +0000
+++ binutils-2.43.50-55e32b3c682/ld/testsuite/ld-elf/pr23658-1e.d 2024-11-04 12:19:06.522083958 +0000
@@ -16,6 +16,7 @@
#xfail: *-*-hpux*
#xfail: arc*-* avr-* m68hc1*-* microblaze*-* nds32*-* spu-*-* xstormy16-*-*
#noxfail: microblaze*-linux*
+#xfail: *-*-*
#...
+[0-9]+ +\.note.gnu.build-id +

View File

@ -0,0 +1,322 @@
diff -rup binutils.orig/ld/testsuite/ld-riscv-elf/attr-phdr.d binutils-2.40/ld/testsuite/ld-riscv-elf/attr-phdr.d
--- binutils.orig/ld/testsuite/ld-riscv-elf/attr-phdr.d 2023-02-16 10:11:38.656875289 +0000
+++ binutils-2.40/ld/testsuite/ld-riscv-elf/attr-phdr.d 2023-02-16 10:49:26.786573665 +0000
@@ -12,8 +12,8 @@ Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
RISCV_ATTRIBUT .*
LOAD .*
-
+#...
Section to Segment mapping:
Segment Sections...
00 .riscv.attributes
- 01 .text
+#pass
diff -rup binutils.orig/ld/testsuite/ld-riscv-elf/pcgp-relax-01.d binutils-2.40/ld/testsuite/ld-riscv-elf/pcgp-relax-01.d
--- binutils.orig/ld/testsuite/ld-riscv-elf/pcgp-relax-01.d 2023-02-16 10:11:38.659875285 +0000
+++ binutils-2.40/ld/testsuite/ld-riscv-elf/pcgp-relax-01.d 2023-02-16 10:42:54.803431287 +0000
@@ -8,7 +8,7 @@
Disassembly of section \.text:
0+[0-9a-f]+ <_start>:
-.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a0,a0,[0-9]+
+.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a0,a0,\-[0-9]+
.*:[ ]+[0-9a-f]+[ ]+jal[ ]+ra,[0-9a-f]+ <_start>
.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a1,gp,\-[0-9]+ # [0-9a-f]+ <data_g>
.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a2,gp,\-[0-9]+ # [0-9a-f]+ <data_g>
diff -rup binutils.orig/ld/testsuite/ld-riscv-elf/pcgp-relax-02.d binutils-2.40/ld/testsuite/ld-riscv-elf/pcgp-relax-02.d
--- binutils.orig/ld/testsuite/ld-riscv-elf/pcgp-relax-02.d 2023-02-16 10:11:38.659875285 +0000
+++ binutils-2.40/ld/testsuite/ld-riscv-elf/pcgp-relax-02.d 2023-02-16 10:43:49.540306593 +0000
@@ -11,5 +11,5 @@ Disassembly of section .text:
[0-9a-f]+ <_start>:
.*:[ ]+[0-9a-f]+[ ]+auipc[ ]+a1.*
.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a0,gp.*<data_a>
-.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a1,a1.*<data_b>
+.*:[ ]+[0-9a-f]+[ ]+mv[ ]+a1,a1
#pass
diff -rup binutils.orig/ld/testsuite/ld-riscv-elf/pcrel-lo-addend-2a.d binutils-2.40/ld/testsuite/ld-riscv-elf/pcrel-lo-addend-2a.d
--- binutils.orig/ld/testsuite/ld-riscv-elf/pcrel-lo-addend-2a.d 2023-02-16 10:11:38.659875285 +0000
+++ binutils-2.40/ld/testsuite/ld-riscv-elf/pcrel-lo-addend-2a.d 2023-02-16 10:46:55.570899994 +0000
@@ -2,4 +2,5 @@
#source: pcrel-lo-addend-2a.s
#as: -march=rv32ic
#ld: -m[riscv_choose_ilp32_emul] --no-relax
+#skip: *-*-*
#error: .*dangerous relocation: %pcrel_lo overflow with an addend, the value of %pcrel_hi is 0x1000 without any addend, but may be 0x2000 after adding the %pcrel_lo addend
diff -rup binutils.orig/ld/testsuite/ld-elf/dwarf.exp binutils-2.40/ld/testsuite/ld-elf/dwarf.exp
--- binutils.orig/ld/testsuite/ld-elf/dwarf.exp 2023-02-16 10:11:38.515875516 +0000
+++ binutils-2.40/ld/testsuite/ld-elf/dwarf.exp 2023-02-16 11:08:52.209377332 +0000
@@ -29,6 +29,10 @@ if ![is_elf_format] {
return
}
+if { [istarget riscv*-*-*] } then {
+ return
+}
+
# Skip targets where -shared is not supported
if ![check_shared_lib_support] {
diff -rup binutils.orig/ld/testsuite/ld-elf/tls.exp binutils-2.40/ld/testsuite/ld-elf/tls.exp
--- binutils.orig/ld/testsuite/ld-elf/tls.exp 2023-02-16 10:11:38.540875476 +0000
+++ binutils-2.40/ld/testsuite/ld-elf/tls.exp 2023-02-16 11:08:56.944369374 +0000
@@ -28,6 +28,10 @@ if { !([istarget *-*-linux*]
return
}
+if { [istarget riscv*-*-*] } then {
+ return
+}
+
# Check to see if the C compiler works.
if { ![check_compiler_available] } {
return
--- binutils.orig/binutils/testsuite/binutils-all/objcopy.exp 2023-08-24 07:48:30.429195480 +0100
+++ binutils-2.41/binutils/testsuite/binutils-all/objcopy.exp 2023-08-24 07:57:05.535302711 +0100
@@ -1409,6 +1409,8 @@ proc objcopy_test_without_global_symbol
# The AArch64 and ARM targets preserve mapping symbols
# in object files, so they will fail this test.
setup_xfail aarch64*-*-* arm*-*-*
+# The RISC-V target compiles with annotation enabled and these symbols remain after stripping.
+setup_xfail riscv*-*-*
objcopy_test_without_global_symbol
--- binutils.orig/ld/testsuite/ld-plugin/plugin.exp 2023-08-24 07:48:31.808196076 +0100
+++ binutils-2.41/ld/testsuite/ld-plugin/plugin.exp 2023-08-24 07:59:30.285716568 +0100
@@ -132,6 +132,10 @@ if [is_pecoff_format] {
append libs " --image-base=0x10000000"
}
+if { [istarget riscv*-*-*] } then {
+ return
+}
+
set plugin_tests [list \
[list "load plugin" "-plugin $plugin_path \
$testobjfiles $libs" "" "" "" {{ld plugin-1.d}} "main.x" ] \
--- binutils.orig/binutils/testsuite/binutils-all/compress.exp 2023-12-11 10:09:16.923374463 +0000
+++ binutils-2.41/binutils/testsuite/binutils-all/compress.exp 2023-12-12 09:00:15.150036675 +0000
@@ -818,6 +818,10 @@ proc test_gnu_debuglink {} {
}
}
+if { [istarget riscv*-*-*] } then {
+ return
+}
+
if {[is_elf_format]} then {
test_gnu_debuglink
}
--- binutils-2.41/ld/testsuite/ld-riscv-elf/pcgp-relax-01-norelaxgp.d 2023-07-03 00:00:00.000000000 +0100
+++ binutils.new/ld/testsuite/ld-riscv-elf/pcgp-relax-01-norelaxgp.d 2023-12-12 11:52:54.564057931 +0000
@@ -8,10 +8,10 @@
Disassembly of section \.text:
0+[0-9a-f]+ <_start>:
-.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a0,a0,[0-9]+
+.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a0,a0,\-[0-9]+
.*:[ ]+[0-9a-f]+[ ]+jal[ ]+ra,[0-9a-f]+ <_start>
.*:[ ]+[0-9a-f]+[ ]+auipc[ ]+a1,0x[0-9a-f]+
-.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a1,a1,[0-9]+ # [0-9a-f]+ <data_g>
+.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a1,a1,\-[0-9]+ # [0-9a-f]+ <data_g>
.*:[ ]+[0-9a-f]+[ ]+lui[ ]+a2,0x[0-9a-f]+
.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a2,a2,[0-9]+ # [0-9a-f]+ <data_g>
.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a3,tp,0 # 0 <data_t>
--- binutils.orig/binutils/testsuite/binutils-all/objcopy.exp 2023-12-12 14:21:10.225342926 +0000
+++ binutils-2.41/binutils/testsuite/binutils-all/objcopy.exp 2023-12-12 14:22:12.453421499 +0000
@@ -1410,7 +1410,7 @@ proc objcopy_test_without_global_symbol
# in object files, so they will fail this test.
setup_xfail aarch64*-*-* arm*-*-*
# The RISC-V target compiles with annotation enabled and these symbols remain after stripping.
-setup_xfail riscv*-*-*
+# setup_xfail riscv*-*-*
objcopy_test_without_global_symbol
diff -rup binutils.orig/ld/testsuite/ld-riscv-elf/pcgp-relax-01-norelaxgp.d binutils-2.43.50-1f4aee70ed1/ld/testsuite/ld-riscv-elf/pcgp-relax-01-norelaxgp.d
--- binutils.orig/ld/testsuite/ld-riscv-elf/pcgp-relax-01-norelaxgp.d 2024-10-03 15:21:47.926570551 +0100
+++ binutils-2.43.50-1f4aee70ed1/ld/testsuite/ld-riscv-elf/pcgp-relax-01-norelaxgp.d 2024-10-03 15:24:26.152502612 +0100
@@ -8,10 +8,10 @@
Disassembly of section \.text:
0+[0-9a-f]+ <_start>:
-.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a0,a0,\-[0-9]+
+.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a0,a0,.*
.*:[ ]+[0-9a-f]+[ ]+jal[ ]+ra,[0-9a-f]+ <_start>
.*:[ ]+[0-9a-f]+[ ]+auipc[ ]+a1,0x[0-9a-f]+
-.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a1,a1,\-[0-9]+ # [0-9a-f]+ <data_g>
+.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a1,a1,.*
.*:[ ]+[0-9a-f]+[ ]+lui[ ]+a2,0x[0-9a-f]+
.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a2,a2,[0-9]+ # [0-9a-f]+ <data_g>
.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a3,tp,0 # 0 <data_t>
diff -rup binutils.orig/ld/testsuite/ld-riscv-elf/pcgp-relax-01.d binutils-2.43.50-1f4aee70ed1/ld/testsuite/ld-riscv-elf/pcgp-relax-01.d
--- binutils.orig/ld/testsuite/ld-riscv-elf/pcgp-relax-01.d 2024-10-03 15:21:47.926570551 +0100
+++ binutils-2.43.50-1f4aee70ed1/ld/testsuite/ld-riscv-elf/pcgp-relax-01.d 2024-10-03 15:23:54.512530979 +0100
@@ -8,7 +8,7 @@
Disassembly of section \.text:
0+[0-9a-f]+ <_start>:
-.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a0,a0,\-[0-9]+
+.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a0,a0,.*
.*:[ ]+[0-9a-f]+[ ]+jal[ ]+ra,[0-9a-f]+ <_start>
.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a1,gp,\-[0-9]+ # [0-9a-f]+ <data_g>
.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a2,gp,\-[0-9]+ # [0-9a-f]+ <data_g>
diff -rup binutils.orig/ld/testsuite/ld-riscv-elf/pcgp-relax-02.d binutils-2.43.50-1f4aee70ed1/ld/testsuite/ld-riscv-elf/pcgp-relax-02.d
--- binutils.orig/ld/testsuite/ld-riscv-elf/pcgp-relax-02.d 2024-10-03 15:21:47.926570551 +0100
+++ binutils-2.43.50-1f4aee70ed1/ld/testsuite/ld-riscv-elf/pcgp-relax-02.d 2024-10-03 15:25:01.687468496 +0100
@@ -11,5 +11,5 @@ Disassembly of section .text:
[0-9a-f]+ <_start>:
.*:[ ]+[0-9a-f]+[ ]+auipc[ ]+a1.*
.*:[ ]+[0-9a-f]+[ ]+addi[ ]+a0,gp.*<data_a>
-.*:[ ]+[0-9a-f]+[ ]+mv[ ]+a1,a1
+.*:[ ]+[0-9a-f]+[ ]+.*
#pass
--- binutils-with-gold-2.45.50-79b2b564fec.orig/ld/testsuite/ld-riscv-elf/zicfilp-unlabeled-plt.d 2025-09-09 15:52:30.684689609 +0100
+++ binutils-with-gold-2.45.50-79b2b564fec/ld/testsuite/ld-riscv-elf/zicfilp-unlabeled-plt.d 2025-09-09 15:53:12.837859447 +0100
@@ -30,6 +30,6 @@ Disassembly of section \.plt:
[0-9a-f]+ <bar@plt>:
.*:[ ]+[0-9a-f]+[ ]+lpad[ ]+0x0
-.*:[ ]+[0-9a-f]+[ ]+auipc[ ]+t3,0x1
+.*:[ ]+[0-9a-f]+[ ]+auipc[ ]+t3,0x[0-9a-f]+
.*:[ ]+[0-9a-f]+[ ]+ld[ ]+t3,[0-9]+\(t3\) # [0-9a-f]+ <bar>
.*:[ ]+[0-9a-f]+[ ]+jalr[ ]+t1,t3
diff -rup binutils-with-gold-2.45.50-beab972c07d,orig/binutils/testsuite/binutils-all/objcopy.exp binutils-with-gold-2.45.50-beab972c07d/binutils/testsuite/binutils-all/objcopy.exp
--- binutils-with-gold-2.45.50-beab972c07d,orig/binutils/testsuite/binutils-all/objcopy.exp 2025-12-02 12:47:19.063123207 +0000
+++ binutils-with-gold-2.45.50-beab972c07d/binutils/testsuite/binutils-all/objcopy.exp 2025-12-04 12:39:26.079989597 +0000
@@ -602,14 +602,19 @@ proc strip_test { } {
set exec_output [binutils_run $STRIP "$STRIPFLAGS $objfile"]
set exec_output [prune_warnings $exec_output]
if ![string equal "" $exec_output] {
- fail $test
+ fail "$test (warnings in linker output)"
+ verbose $exec_output
return
}
set exec_output [binutils_run $NM "-a $NMFLAGS $objfile"]
set exec_output [prune_warnings $exec_output]
if ![string match "*: no symbols*" $exec_output] {
- fail $test
+
+ # The RISC-V target compiles with annotation enabled and these symbols remain after stripping.
+ setup_xfail riscv*-*-*
+
+ fail "$test (symbols in nm output)"
return
}
@@ -659,6 +664,9 @@ proc strip_test_with_saving_a_symbol { }
pass $test
}
+# The RISC-V target compiles with annotation enabled and these symbols remain after stripping.
+setup_xfail riscv*-*-*
+
strip_test_with_saving_a_symbol
# Test stripping an archive.
@@ -1503,7 +1519,7 @@ proc objcopy_test_without_global_symbol
# in object files, so they will fail this test.
setup_xfail aarch64*-*-* arm*-*-*
# The RISC-V target compiles with annotation enabled and these symbols remain after stripping.
-# setup_xfail riscv*-*-*
+setup_xfail riscv*-*-*
objcopy_test_without_global_symbol
diff -rup binutils-with-gold-2.45.50-beab972c07d,orig/ld/testsuite/lib/ld-lib.exp binutils-with-gold-2.45.50-beab972c07d/ld/testsuite/lib/ld-lib.exp
--- binutils-with-gold-2.45.50-beab972c07d,orig/ld/testsuite/lib/ld-lib.exp 2025-12-02 12:47:19.201090894 +0000
+++ binutils-with-gold-2.45.50-beab972c07d/ld/testsuite/lib/ld-lib.exp 2025-12-03 09:30:07.184360005 +0000
@@ -1633,6 +1633,12 @@ proc compile_one_cc { src output additio
proc check_ctf_available { } {
global ctf_available_saved
+ # Skip CTF tests for the Risc-V target for now, as the
+ # tests have not been tweaked to support the riscv format.
+ if { [istarget "riscv*-*-linux*"] } {
+ return 0
+ }
+
if {![info exists ctf_available_saved]} {
set ctf_available_saved 0
--- binutils.orig/binutils/testsuite/lib/binutils-common.exp 2026-01-05 08:49:32.868601146 +0000
+++ binutils-with-gold-2.45.50-be970c68891/binutils/testsuite/lib/binutils-common.exp 2026-01-05 08:50:01.876703040 +0000
@@ -757,6 +757,9 @@ proc prune_warnings_extra { text } {
regsub -all "(^|\n)(\[^\n\]*lto-wrapper: warning: using serial compilation of \[0-9\]+ LTRANS jobs\[^\n\]*\n?)+" $text "\\1" text
regsub -all "(^|\n)(\[^\n\]*lto-wrapper: note: \[^\n\]*\n?)+" $text "\\1" text
+ # Skip warnings about the LTO plugin being needed.
+ regsub -all "(^|\n)(\[^\n\]*:\[^\n\]*plugin needed to handle lto object\[^\n\]*\n?)+" $text "\\1" text
+
return $text
}
diff -rup binutils.orig/ld/testsuite/ld-riscv-elf/data-reloc-rv32-pic.d binutils-with-gold-2.46/ld/testsuite/ld-riscv-elf/data-reloc-rv32-pic.d
--- binutils.orig/ld/testsuite/ld-riscv-elf/data-reloc-rv32-pic.d 2026-03-20 13:02:05.468700958 +0000
+++ binutils-with-gold-2.46/ld/testsuite/ld-riscv-elf/data-reloc-rv32-pic.d 2026-03-20 13:05:31.155200130 +0000
@@ -1,6 +1,6 @@
#source: data-reloc.s
#as: -march=rv32i -mabi=ilp32 -defsym __abs__=1 -defsym __addr__=1 -defsym __undef__=1
-#ld: -m[riscv_choose_ilp32_emul] -Ttext 0x8000 --defsym _start=0x0 --defsym abs=0x100 --defsym abs_local=0x200 -shared
+#ld: -m[riscv_choose_ilp32_emul] -Ttext 0x8000 --defsym _start=0x0 --defsym abs=0x100 --defsym abs_local=0x200 -shared -z notext
#objdump: -dR
.*:[ ]+file format .*
diff -rup binutils.orig/ld/testsuite/ld-riscv-elf/data-reloc-rv32-pie.d binutils-with-gold-2.46/ld/testsuite/ld-riscv-elf/data-reloc-rv32-pie.d
--- binutils.orig/ld/testsuite/ld-riscv-elf/data-reloc-rv32-pie.d 2026-03-20 13:02:05.468700958 +0000
+++ binutils-with-gold-2.46/ld/testsuite/ld-riscv-elf/data-reloc-rv32-pie.d 2026-03-20 13:05:52.846252771 +0000
@@ -1,6 +1,6 @@
#source: data-reloc.s
#as: -march=rv32i -mabi=ilp32 -defsym __abs__=1 -defsym __addr__=1
-#ld: -m[riscv_choose_ilp32_emul] -Ttext 0x8000 --defsym _start=0x0 --defsym abs=0x100 --defsym abs_local=0x200 -pie
+#ld: -m[riscv_choose_ilp32_emul] -Ttext 0x8000 --defsym _start=0x0 --defsym abs=0x100 --defsym abs_local=0x200 -pie -z notext
#objdump: -dR
.*:[ ]+file format .*
diff -rup binutils.orig/ld/testsuite/ld-riscv-elf/data-reloc-rv32-symbolic.d binutils-with-gold-2.46/ld/testsuite/ld-riscv-elf/data-reloc-rv32-symbolic.d
--- binutils.orig/ld/testsuite/ld-riscv-elf/data-reloc-rv32-symbolic.d 2026-03-20 13:02:05.468700958 +0000
+++ binutils-with-gold-2.46/ld/testsuite/ld-riscv-elf/data-reloc-rv32-symbolic.d 2026-03-20 13:06:01.427273593 +0000
@@ -1,6 +1,6 @@
#source: data-reloc.s
#as: -march=rv32i -mabi=ilp32 -defsym __abs__=1 -defsym __addr__=1 -defsym __undef__=1
-#ld: -m[riscv_choose_ilp32_emul] -Ttext 0x8000 --defsym _start=0x0 --defsym abs=0x100 --defsym abs_local=0x200 -shared -Bsymbolic
+#ld: -m[riscv_choose_ilp32_emul] -Ttext 0x8000 --defsym _start=0x0 --defsym abs=0x100 --defsym abs_local=0x200 -shared -Bsymbolic -z notext
#objdump: -dR
.*:[ ]+file format .*
diff -rup binutils.orig/ld/testsuite/ld-riscv-elf/data-reloc-rv64-pic.d binutils-with-gold-2.46/ld/testsuite/ld-riscv-elf/data-reloc-rv64-pic.d
--- binutils.orig/ld/testsuite/ld-riscv-elf/data-reloc-rv64-pic.d 2026-03-20 13:02:05.468700958 +0000
+++ binutils-with-gold-2.46/ld/testsuite/ld-riscv-elf/data-reloc-rv64-pic.d 2026-03-20 13:04:07.601997355 +0000
@@ -1,6 +1,6 @@
#source: data-reloc.s
#as: -march=rv64i -mabi=lp64 -defsym __64_bit__=1 -defsym __abs__=1 -defsym __addr__=1 -defsym __undef__=1
-#ld: -m[riscv_choose_lp64_emul] -Ttext 0x8000 --defsym _start=0x0 --defsym abs=0x100 --defsym abs_local=0x200 -shared
+#ld: -m[riscv_choose_lp64_emul] -Ttext 0x8000 --defsym _start=0x0 --defsym abs=0x100 --defsym abs_local=0x200 -shared -z notext
#objdump: -dR
.*:[ ]+file format .*
diff -rup binutils.orig/ld/testsuite/ld-riscv-elf/data-reloc-rv64-pie.d binutils-with-gold-2.46/ld/testsuite/ld-riscv-elf/data-reloc-rv64-pie.d
--- binutils.orig/ld/testsuite/ld-riscv-elf/data-reloc-rv64-pie.d 2026-03-20 13:02:05.468700958 +0000
+++ binutils-with-gold-2.46/ld/testsuite/ld-riscv-elf/data-reloc-rv64-pie.d 2026-03-20 13:04:57.106117494 +0000
@@ -1,6 +1,6 @@
#source: data-reloc.s
#as: -march=rv64i -mabi=lp64 -defsym __64_bit__=1 -defsym __abs__=1 -defsym __addr__=1
-#ld: -m[riscv_choose_lp64_emul] -Ttext 0x8000 --defsym _start=0x0 --defsym abs=0x100 --defsym abs_local=0x200 -pie
+#ld: -m[riscv_choose_lp64_emul] -Ttext 0x8000 --defsym _start=0x0 --defsym abs=0x100 --defsym abs_local=0x200 -pie -z notext
#objdump: -dR
.*:[ ]+file format .*
diff -rup binutils.orig/ld/testsuite/ld-riscv-elf/data-reloc-rv64-symbolic.d binutils-with-gold-2.46/ld/testsuite/ld-riscv-elf/data-reloc-rv64-symbolic.d
--- binutils.orig/ld/testsuite/ld-riscv-elf/data-reloc-rv64-symbolic.d 2026-03-20 13:02:05.468700958 +0000
+++ binutils-with-gold-2.46/ld/testsuite/ld-riscv-elf/data-reloc-rv64-symbolic.d 2026-03-20 13:05:14.650160073 +0000
@@ -1,6 +1,6 @@
#source: data-reloc.s
#as: -march=rv64i -mabi=lp64 -defsym __64_bit__=1 -defsym __abs__=1 -defsym __addr__=1 -defsym __undef__=1
-#ld: -m[riscv_choose_lp64_emul] -Ttext 0x8000 --defsym _start=0x0 --defsym abs=0x100 --defsym abs_local=0x200 -shared -Bsymbolic
+#ld: -m[riscv_choose_lp64_emul] -Ttext 0x8000 --defsym _start=0x0 --defsym abs=0x100 --defsym abs_local=0x200 -shared -Bsymbolic -z notext
#objdump: -dR
.*:[ ]+file format .*

360
binutils-strchr-fixes.patch Normal file
View File

@ -0,0 +1,360 @@
--- fred/bfd/elflink.c 2025-12-18 13:16:00.675277329 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/bfd/elflink.c 2025-12-18 13:31:20.160942245 +0000
@@ -596,7 +596,7 @@ bfd_elf_link_record_dynamic_symbol (stru
if (h->dynindx == -1)
{
struct elf_strtab_hash *dynstr;
- char *p;
+ const char *p;
const char *name;
size_t indx;
@@ -726,7 +726,7 @@ bfd_elf_record_link_assignment (bfd *out
if (h->versioned == unknown)
{
/* Set versioned if symbol version is unknown. */
- char *version = strrchr (name, ELF_VER_CHR);
+ const char *version = strrchr (name, ELF_VER_CHR);
if (version)
{
if (version > name && version[-1] != ELF_VER_CHR)
@@ -1161,7 +1161,7 @@ _bfd_elf_merge_symbol (bfd *abfd,
bool newdyn, olddyn, olddef, newdef, newdyncommon, olddyncommon;
bool newweak, oldweak, newfunc, oldfunc;
const struct elf_backend_data *bed;
- char *new_version;
+ const char *new_version;
bool default_sym = *matched;
struct elf_link_hash_table *htab;
@@ -1241,7 +1241,7 @@ _bfd_elf_merge_symbol (bfd *abfd,
{
/* OLD_VERSION is the symbol version of the existing
symbol. */
- char *old_version;
+ const char *old_version;
if (h->versioned >= versioned)
old_version = strrchr (h->root.root.string,
diff -rup fred/bfd/bfd.c binutils-with-gold-2.45.50-8e992ccb1e4/bfd/bfd.c
--- fred/bfd/bfd.c 2025-12-18 13:42:14.848482826 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/bfd/bfd.c 2025-12-18 13:56:21.112280708 +0000
@@ -1060,7 +1060,7 @@ _bfd_doprnt (bfd_print_callback print, v
if (*ptr != '%')
{
/* While we have regular characters, print them. */
- char *end = strchr (ptr, '%');
+ const char *end = strchr (ptr, '%');
if (end != NULL)
result = print (stream, "%.*s", (int) (end - ptr), ptr);
else
diff -rup fred/bfd/elflink.c binutils-with-gold-2.45.50-8e992ccb1e4/bfd/elflink.c
--- fred/bfd/elflink.c 2025-12-18 13:42:15.062484033 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/bfd/elflink.c 2025-12-18 13:58:58.202355216 +0000
@@ -1965,7 +1965,7 @@ _bfd_elf_add_default_symbol (bfd *abfd,
bool collect;
bool dynamic;
bfd *override;
- char *p;
+ const char *p;
size_t len, shortlen;
asection *tmp_sec;
bool matched;
@@ -2657,7 +2657,7 @@ _bfd_elf_link_assign_sym_version (struct
struct bfd_link_info *info;
const struct elf_backend_data *bed;
struct elf_info_failed eif;
- char *p;
+ const char *p;
bool hide;
sinfo = (struct elf_info_failed *) data;
@@ -5665,7 +5665,7 @@ elf_link_add_object_symbols (bfd *abfd,
&& !dynamic
&& (abfd->flags & BFD_PLUGIN) == 0)
{
- char *p = strchr (name, ELF_VER_CHR);
+ const char *p = strchr (name, ELF_VER_CHR);
if (p != NULL && p[1] != ELF_VER_CHR)
{
/* Queue non-default versions so that .symver x, x@FOO
@@ -5915,7 +5915,8 @@ elf_link_add_object_symbols (bfd *abfd,
for (cnt = 0; cnt < nondeflt_vers_cnt; ++cnt)
{
struct elf_link_hash_entry *h = nondeflt_vers[cnt], *hi;
- char *shortname, *p;
+ char *shortname;
+ const char *p;
size_t amt;
p = strchr (h->root.root.string, ELF_VER_CHR);
@@ -6187,7 +6188,8 @@ _bfd_elf_archive_symbol_lookup (bfd *abf
const char *name)
{
struct bfd_link_hash_entry *h;
- char *p, *copy;
+ const char *p;
+ char *copy;
size_t len, first;
h = bfd_link_hash_lookup (info->hash, name, false, false, true);
@@ -6482,7 +6484,7 @@ elf_collect_hash_codes (struct elf_link_
name = h->root.root.string;
if (h->versioned >= versioned)
{
- char *p = strchr (name, ELF_VER_CHR);
+ const char *p = strchr (name, ELF_VER_CHR);
if (p != NULL)
{
alc = (char *) bfd_malloc (p - name + 1);
@@ -6556,7 +6558,7 @@ elf_collect_gnu_hash_codes (struct elf_l
name = h->root.root.string;
if (h->versioned >= versioned)
{
- char *p = strchr (name, ELF_VER_CHR);
+ const char *p = strchr (name, ELF_VER_CHR);
if (p != NULL)
{
alc = (char *) bfd_malloc (p - name + 1);
@@ -10373,8 +10375,8 @@ elf_link_output_symstrtab (void *finf,
{
/* Keep only one '@' for versioned symbols defined in
shared objects. */
- char *version = strrchr (name, ELF_VER_CHR);
- char *base_end = strchr (name, ELF_VER_CHR);
+ const char *version = strrchr (name, ELF_VER_CHR);
+ const char *base_end = strchr (name, ELF_VER_CHR);
if (version != base_end)
{
size_t base_len;
@@ -11117,7 +11119,7 @@ elf_link_output_extsym (struct bfd_hash_
|| h->ref_dynamic
|| !h->def_regular))
{
- char *p = strrchr (h->root.root.string, ELF_VER_CHR);
+ const char *p = strrchr (h->root.root.string, ELF_VER_CHR);
if (p && p [1] != '\0')
{
diff -rup fred/bfd/targets.c binutils-with-gold-2.45.50-8e992ccb1e4/bfd/targets.c
--- fred/bfd/targets.c 2025-12-18 13:42:15.038483898 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/bfd/targets.c 2025-12-18 13:56:48.120465447 +0000
@@ -1664,7 +1664,7 @@ bfd_get_target_info (const char *target_
if (arches && tname)
{
- char *hyp = strchr (tname, '-');
+ const char *hyp = strchr (tname, '-');
if (hyp != NULL)
{
diff -rup fred/binutils/addr2line.c binutils-with-gold-2.45.50-8e992ccb1e4/binutils/addr2line.c
--- fred/binutils/addr2line.c 2025-12-18 13:42:17.309496707 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/binutils/addr2line.c 2025-12-18 13:59:57.785762778 +0000
@@ -385,7 +385,7 @@ translate_addresses (bfd *abfd, asection
if (base_names && filename != NULL)
{
- char *h;
+ const char *h;
h = strrchr (filename, '/');
if (h != NULL)
diff -rup fred/binutils/nm.c binutils-with-gold-2.45.50-8e992ccb1e4/binutils/nm.c
--- fred/binutils/nm.c 2025-12-18 13:42:17.107495568 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/binutils/nm.c 2025-12-18 14:00:12.481863299 +0000
@@ -686,7 +686,7 @@ print_symname (const char *form, struct
if (!with_symbol_versions
&& bfd_get_flavour (abfd) == bfd_target_elf_flavour)
{
- char *atver = strchr (name, '@');
+ const char *atver = strchr (name, '@');
if (atver)
{
diff -rup fred/binutils/prdbg.c binutils-with-gold-2.45.50-8e992ccb1e4/binutils/prdbg.c
--- fred/binutils/prdbg.c 2025-12-18 13:42:17.301496662 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/binutils/prdbg.c 2025-12-18 13:59:36.386616403 +0000
@@ -2641,7 +2641,7 @@ tg_start_function (void *p, const char *
info->stack->method = NULL;
if (dname != NULL)
{
- char *sep;
+ const char *sep;
sep = strstr (dname, "::");
if (sep)
{
diff -rup fred/gprof/source.c binutils-with-gold-2.45.50-8e992ccb1e4/gprof/source.c
--- fred/gprof/source.c 2025-12-18 13:42:17.459497553 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/gprof/source.c 2025-12-18 14:00:40.554055311 +0000
@@ -98,7 +98,8 @@ annotate_source (Source_File *sf, unsign
bool new_line;
char buf[8192];
char *fname;
- char *annotation, *name_only;
+ char *annotation;
+ const char *name_only;
FILE *ifp, *ofp;
Search_List_Elem *sle = src_search_list.head;
diff -rup fred/ld/emultempl/pe.em binutils-with-gold-2.45.50-8e992ccb1e4/ld/emultempl/pe.em
--- fred/ld/emultempl/pe.em 2025-12-18 13:42:17.632498529 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/ld/emultempl/pe.em 2025-12-18 14:03:21.043153069 +0000
@@ -1149,7 +1149,7 @@ pe_fixup_stdcalls (void)
if (undef->type == bfd_link_hash_undefined)
{
const char * name = undef->root.string;
- char * at;
+ const char * at;
int lead_at = (*name == '@');
if (lead_at)
@@ -1750,7 +1750,7 @@ gld${EMULATION_NAME}_after_open (void)
{
if (is->the_bfd->my_archive)
{
- char *pnt;
+ const char *pnt;
/* Microsoft import libraries may contain archive members for
one or more DLLs, together with static object files.
@@ -2146,7 +2146,7 @@ gld${EMULATION_NAME}_place_orphan (asect
int constraint)
{
const char *orig_secname = secname;
- char *dollar = NULL;
+ const char *dollar = NULL;
lang_output_section_statement_type *os;
lang_statement_list_type add_child;
lang_output_section_statement_type *match_by_name = NULL;
diff -rup fred/ld/emultempl/pep.em binutils-with-gold-2.45.50-8e992ccb1e4/ld/emultempl/pep.em
--- fred/ld/emultempl/pep.em 2025-12-18 13:42:17.635498546 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/ld/emultempl/pep.em 2025-12-18 14:03:30.187215617 +0000
@@ -1089,7 +1089,7 @@ pep_fixup_stdcalls (void)
for (undef = link_info.hash->undefs; undef; undef=undef->u.undef.next)
if (undef->type == bfd_link_hash_undefined)
{
- char* at = strchr (undef->root.string, '@');
+ const char* at = strchr (undef->root.string, '@');
int lead_at = (*undef->root.string == '@');
if (lead_at)
at = strchr (undef->root.string + 1, '@');
@@ -1737,7 +1737,7 @@ gld${EMULATION_NAME}_after_open (void)
{
if (is->the_bfd->my_archive)
{
- char *pnt;
+ const char *pnt;
/* Microsoft import libraries may contain archive members for
one or more DLLs, together with static object files.
@@ -1986,7 +1986,7 @@ gld${EMULATION_NAME}_place_orphan (asect
int constraint)
{
const char *orig_secname = secname;
- char *dollar = NULL;
+ const char *dollar = NULL;
lang_output_section_statement_type *os;
lang_statement_list_type add_child;
lang_output_section_statement_type *match_by_name = NULL;
diff -rup fred/ld/ldelf.c binutils-with-gold-2.45.50-8e992ccb1e4/ld/ldelf.c
--- fred/ld/ldelf.c 2025-12-18 13:42:17.598498337 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/ld/ldelf.c 2025-12-18 14:04:08.331476531 +0000
@@ -794,7 +794,7 @@ ldelf_parse_ld_so_conf_include (struct l
if (pattern[0] != '/')
{
- char *p = strrchr (filename, '/');
+ const char *p = strrchr (filename, '/');
size_t patlen = strlen (pattern) + 1;
newp = xmalloc (p - filename + 1 + patlen);
diff -rup fred/ld/ldlang.c binutils-with-gold-2.45.50-8e992ccb1e4/ld/ldlang.c
--- fred/ld/ldlang.c 2025-12-18 13:42:17.601498354 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/ld/ldlang.c 2025-12-18 14:00:59.914187740 +0000
@@ -338,7 +338,7 @@ stat_ldirname (const char *name)
static char *
archive_path (const char *pattern)
{
- char *p = NULL;
+ const char *p = NULL;
if (link_info.path_separator == 0)
return p;
--- fred/bfd/targets.c 2025-12-18 14:08:06.859108084 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/bfd/targets.c 2025-12-18 14:10:18.726010065 +0000
@@ -1675,11 +1675,12 @@ bfd_get_target_info (const char *target_
if (!_bfd_find_arch_match (tname, arches, def_target_arch))
{
char new_tname[50];
+ char * p;
strcpy (new_tname, hyp);
- while ((hyp = strrchr (new_tname, '-')) != NULL)
+ while ((p = strrchr (new_tname, '-')) != NULL)
{
- *hyp = 0;
+ *p = 0;
if (_bfd_find_arch_match (new_tname, arches,
def_target_arch))
break;
--- fred/binutils/prdbg.c 2025-12-18 14:56:04.149155693 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/binutils/prdbg.c 2025-12-18 14:56:38.583341964 +0000
@@ -2641,24 +2641,26 @@ tg_start_function (void *p, const char *
info->stack->method = NULL;
if (dname != NULL)
{
- const char *sep;
+ char *sep;
+ char *n;
sep = strstr (dname, "::");
if (sep)
{
info->stack->method = dname;
dname = NULL;
*sep = 0;
- name = sep + 2;
+ n = sep + 2;
}
else
{
info->stack->method = xstrdup ("");
- name = dname;
+ n = dname;
}
- sep = strchr (name, '(');
+ sep = strchr (n, '(');
if (sep)
*sep = 0;
/* Obscure functions as type_info function. */
+ name = n;
}
free (info->stack->parents);
--- fred/ld/emultempl/pep.em 2025-12-18 15:04:44.143968641 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/ld/emultempl/pep.em 2025-12-18 15:06:39.787550440 +0000
@@ -1101,9 +1101,10 @@ pep_fixup_stdcalls (void)
if (lead_at)
*cname = '_';
- at = strchr (cname, '@');
- if (at)
- *at = 0;
+ char * c;
+ c = strchr (cname, '@');
+ if (c)
+ *c = 0;
sym = bfd_link_hash_lookup (link_info.hash, cname, 0, 0, 1);
if (sym && sym->type == bfd_link_hash_defined)
--- fred/ld/ldelf.c 2025-12-18 15:24:43.775771267 +0000
+++ binutils-with-gold-2.45.50-8e992ccb1e4/ld/ldelf.c 2025-12-18 15:25:32.150970709 +0000
@@ -535,7 +535,7 @@ ldelf_search_needed (const char *path, s
}
replacement = freeme;
- if ((slash = strrchr (replacement, '/')) != NULL)
+ if ((slash = strrchr (freeme, '/')) != NULL)
* slash = 0;
}
}

View File

@ -0,0 +1,537 @@
From a0d3507d10755c2ccaed3204db22c21308bfc4d6 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 22 Jul 2025 14:09:48 -0700
Subject: [PATCH] strip: Properly handle LLVM IR bitcode
commit 717a38e9a02109fcbcb18bb2ec3aa251e2ad0a0d
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Sun May 4 05:12:46 2025 +0800
strip: Add GCC LTO IR support
added "-R .gnu.lto_.*" to strip to remove all GCC LTO sections. When
"-R .gnu.lto_.*" is used, the plugin target is ignored so that all LTO
sections are stripped as the regular sections. It works for the slim
GCC LTO IR since the GCC LTO IR is stored in the regular sections. When
the plugin target is ignored, the GCC LTO IR can be recognized as the
normal object files. But it doesn't work for the slim LLVM IR which
is stored in a standalone file.
1. Add bfd_check_format_matches_lto and bfd_check_format_lto to take an
argument, lto_sections_removed, to indicate if all LTO sections should
be removed.
2. Update strip to always enable the plugin target so that the plugin
target is enabled when checking for bfd_archive.
3. Update strip to ignore the plugin target for bfd_object when all LTO
sections should be removed. If the object is unknown, copy it as an
unknown file without any messages.
4. Treat the "-R .llvm.lto" strip option as removing all LTO sections.
bfd/
PR binutils/33198
* format.c (bfd_check_format_lto): New function.
(bfd_check_format): Call bfd_check_format_matches_lto.
(bfd_check_format_matches): Renamed to ...
(bfd_check_format_matches_lto): This. Add an argument,
lto_sections_removed, to indicate if all LTO sections should be
removed and don't match the plugin target if lto_sections_removed
is true.
(bfd_check_format_matches): Call bfd_check_format_matches_lto.
* bfd-in2.h: Regenerated.
binutils/
PR binutils/33198
* objcopy.c (copy_archive): Call bfd_check_format_lto, instead
of bfd_check_format, and pass lto_sections_removed. Remove the
non-fatal message on unknown element since it will be copied as
an unknown file.
(copy_file): Don't check lto_sections_removed when enabling LTO
plugin in strip.
(copy_file): Ignore the plugin target first if all LTO sections
should be removed. Try with the plugin target next if ignoring
the plugin target failed to match the format.
(strip_main): Also set lto_sections_removed for -R .llvm.lto.
* testsuite/binutils-all/x86-64/pr33198.c: New file.
* testsuite/binutils-all/x86-64/x86-64.exp (run_pr33198_test):
New.
Run binutils/33198 tests.
* testsuite/lib/binutils-common.exp (llvm_plug_opt): New.
(CLANG_FOR_TARGET): New. Set to "clang" for native build if
"clang -v" reports "clang version".
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit f752be8f916efa70aea9c2e4f664c75690fd136c)
---
bfd/bfd-in2.h | 7 +
bfd/format.c | 84 ++++++++--
binutils/objcopy.c | 40 +++--
.../testsuite/binutils-all/x86-64/pr33198.c | 4 +
.../testsuite/binutils-all/x86-64/x86-64.exp | 158 ++++++++++++++++++
binutils/testsuite/lib/binutils-common.exp | 27 +++
6 files changed, 299 insertions(+), 21 deletions(-)
create mode 100644 binutils/testsuite/binutils-all/x86-64/pr33198.c
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index b013ef954da..2ff3e930bfa 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -2903,8 +2903,15 @@ bool generic_core_file_matches_executable_p
(bfd *core_bfd, bfd *exec_bfd);
/* Extracted from format.c. */
+bool bfd_check_format_lto (bfd *abfd, bfd_format format,
+ bool lto_sections_removed);
+
bool bfd_check_format (bfd *abfd, bfd_format format);
+bool bfd_check_format_matches_lto
+ (bfd *abfd, bfd_format format, char ***matching,
+ bool lto_sections_removed);
+
bool bfd_check_format_matches
(bfd *abfd, bfd_format format, char ***matching);
diff --git a/bfd/format.c b/bfd/format.c
index a909b70fe81..f3a0774af08 100644
--- a/bfd/format.c
+++ b/bfd/format.c
@@ -56,16 +56,19 @@ extern const size_t _bfd_target_vector_entries;
/*
FUNCTION
- bfd_check_format
+ bfd_check_format_lto
SYNOPSIS
- bool bfd_check_format (bfd *abfd, bfd_format format);
+ bool bfd_check_format_lto (bfd *abfd, bfd_format format,
+ bool lto_sections_removed);
DESCRIPTION
Verify if the file attached to the BFD @var{abfd} is compatible
with the format @var{format} (i.e., one of <<bfd_object>>,
<<bfd_archive>> or <<bfd_core>>).
+ If LTO_SECTION_REMOVED is true, ignore plugin target.
+
If the BFD has been set to a specific target before the
call, only the named target and format combination is
checked. If the target has not been set, or has been set to
@@ -99,10 +102,31 @@ DESCRIPTION
itself.
*/
+bool
+bfd_check_format_lto (bfd *abfd, bfd_format format,
+ bool lto_sections_removed)
+{
+ return bfd_check_format_matches_lto (abfd, format, NULL,
+ lto_sections_removed);
+}
+
+
+/*
+FUNCTION
+ bfd_check_format
+
+SYNOPSIS
+ bool bfd_check_format (bfd *abfd, bfd_format format);
+
+DESCRIPTION
+ Similar to bfd_check_format_plugin, except plugin target isn't
+ ignored.
+*/
+
bool
bfd_check_format (bfd *abfd, bfd_format format)
{
- return bfd_check_format_matches (abfd, format, NULL);
+ return bfd_check_format_matches_lto (abfd, format, NULL, false);
}
struct bfd_preserve
@@ -407,11 +431,12 @@ bfd_set_lto_type (bfd *abfd ATTRIBUTE_UNUSED)
/*
FUNCTION
- bfd_check_format_matches
+ bfd_check_format_matches_lto
SYNOPSIS
- bool bfd_check_format_matches
- (bfd *abfd, bfd_format format, char ***matching);
+ bool bfd_check_format_matches_lto
+ (bfd *abfd, bfd_format format, char ***matching,
+ bool lto_sections_removed);
DESCRIPTION
Like <<bfd_check_format>>, except when it returns FALSE with
@@ -423,10 +448,14 @@ DESCRIPTION
When done with the list that @var{matching} points to, the caller
should free it.
+
+ If LTO_SECTION_REMOVED is true, ignore plugin target.
*/
bool
-bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
+bfd_check_format_matches_lto (bfd *abfd, bfd_format format,
+ char ***matching,
+ bool lto_sections_removed ATTRIBUTE_UNUSED)
{
extern const bfd_target binary_vec;
const bfd_target * const *target;
@@ -495,8 +524,13 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
if (!bfd_preserve_save (abfd, &preserve, NULL))
goto err_ret;
- /* If the target type was explicitly specified, just check that target. */
- if (!abfd->target_defaulted)
+ /* If the target type was explicitly specified, just check that target.
+ If LTO_SECTION_REMOVED is true, don't match the plugin target. */
+ if (!abfd->target_defaulted
+#if BFD_SUPPORTS_PLUGINS
+ && (!lto_sections_removed || !bfd_plugin_target_p (abfd->xvec))
+#endif
+ )
{
if (bfd_seek (abfd, 0, SEEK_SET) != 0) /* rewind! */
goto err_ret;
@@ -540,10 +574,12 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
searching. Don't match the plugin target if we have another
alternative since we want to properly set the input format
before allowing a plugin to claim the file. Also, don't
- check the default target twice. */
+ check the default target twice. If LTO_SECTION_REMOVED is
+ true, don't match the plugin target. */
if (*target == &binary_vec
#if BFD_SUPPORTS_PLUGINS
- || (match_count != 0 && bfd_plugin_target_p (*target))
+ || ((lto_sections_removed || match_count != 0)
+ && bfd_plugin_target_p (*target))
#endif
|| (!abfd->target_defaulted && *target == save_targ))
continue;
@@ -795,6 +831,32 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
return false;
}
+/*
+FUNCTION
+ bfd_check_format_matches
+
+SYNOPSIS
+ bool bfd_check_format_matches
+ (bfd *abfd, bfd_format format, char ***matching);
+
+DESCRIPTION
+ Like <<bfd_check_format>>, except when it returns FALSE with
+ <<bfd_errno>> set to <<bfd_error_file_ambiguously_recognized>>. In that
+ case, if @var{matching} is not NULL, it will be filled in with
+ a NULL-terminated list of the names of the formats that matched,
+ allocated with <<malloc>>.
+ Then the user may choose a format and try again.
+
+ When done with the list that @var{matching} points to, the caller
+ should free it.
+*/
+
+bool
+bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching)
+{
+ return bfd_check_format_matches_lto (abfd, format, matching, false);
+}
+
/*
FUNCTION
bfd_set_format
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 8c9077356f1..038f6555c0b 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -3748,10 +3748,13 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
l->obfd = NULL;
list = l;
+#if BFD_SUPPORTS_PLUGINS
+ /* Ignore plugin target if all LTO sections should be removed. */
+ ok_object = bfd_check_format_lto (this_element, bfd_object,
+ lto_sections_removed);
+#else
ok_object = bfd_check_format (this_element, bfd_object);
- if (!ok_object)
- bfd_nonfatal_message (NULL, this_element, NULL,
- _("Unable to recognise the format of file"));
+#endif
/* PR binutils/3110: Cope with archives
containing multiple target types. */
@@ -3887,9 +3890,8 @@ copy_file (const char *input_filename, const char *output_filename, int ofd,
}
#if BFD_SUPPORTS_PLUGINS
- /* Enable LTO plugin in strip unless all LTO sections should be
- removed. */
- if (is_strip && !target && !lto_sections_removed)
+ /* Enable LTO plugin in strip. */
+ if (is_strip && !target)
target = "plugin";
#endif
@@ -3987,7 +3989,21 @@ copy_file (const char *input_filename, const char *output_filename, int ofd,
input_arch))
status = 1;
}
- else if (bfd_check_format_matches (ibfd, bfd_object, &obj_matching))
+ else if (
+#if BFD_SUPPORTS_PLUGINS
+ /* Ignore plugin target first if all LTO sections should be
+ removed. Try with plugin target next if ignoring plugin
+ target fails to match the format. */
+ bfd_check_format_matches_lto (ibfd, bfd_object, &obj_matching,
+ lto_sections_removed)
+ || (lto_sections_removed
+ && bfd_check_format_matches_lto (ibfd, bfd_object,
+ &obj_matching, false))
+#else
+ bfd_check_format_matches_lto (ibfd, bfd_object, &obj_matching,
+ false)
+#endif
+ )
{
bfd *obfd;
do_copy:
@@ -5043,9 +5059,13 @@ strip_main (int argc, char *argv[])
#if BFD_SUPPORTS_PLUGINS
/* Check if all GCC LTO sections should be removed, assuming all LTO
sections will be removed with -R .gnu.lto_.*. * Remove .gnu.lto_.*
- sections will also remove .gnu.debuglto_. sections. */
- lto_sections_removed = !!find_section_list (".gnu.lto_.*", false,
- SECTION_CONTEXT_REMOVE);
+ sections will also remove .gnu.debuglto_. sections. LLVM IR
+ bitcode is stored in .llvm.lto section which will be removed with
+ -R .llvm.lto. */
+ lto_sections_removed = (!!find_section_list (".gnu.lto_.*", false,
+ SECTION_CONTEXT_REMOVE)
+ || !!find_section_list (".llvm.lto", false,
+ SECTION_CONTEXT_REMOVE));
#endif
i = optind;
diff --git a/binutils/testsuite/binutils-all/x86-64/pr33198.c b/binutils/testsuite/binutils-all/x86-64/pr33198.c
new file mode 100644
index 00000000000..cd0130cacdf
--- /dev/null
+++ b/binutils/testsuite/binutils-all/x86-64/pr33198.c
@@ -0,0 +1,4 @@
+void
+foo (void)
+{
+}
diff --git a/binutils/testsuite/binutils-all/x86-64/x86-64.exp b/binutils/testsuite/binutils-all/x86-64/x86-64.exp
index 05c73047b60..ab1aa50a9a1 100644
--- a/binutils/testsuite/binutils-all/x86-64/x86-64.exp
+++ b/binutils/testsuite/binutils-all/x86-64/x86-64.exp
@@ -96,3 +96,161 @@ if {[catch "system \"bzip2 -dc $t > $tempfile\""] != 0} {
}
}
}
+
+proc run_pr33198_test { fat strip_flags } {
+ global srcdir
+ global subdir
+ global llvm_plug_opt
+ global AR
+ global CLANG_FOR_TARGET
+ global NM
+ global READELF
+ global STRIP
+
+ set test pr33198
+ set testname "${test}${fat} with $strip_flags"
+
+ if { [istarget "x86_64-*-linux*-gnux32"] \
+ || ![info exists CLANG_FOR_TARGET]
+ || [string match "" $llvm_plug_opt] } then {
+ untested $testname
+ return
+ }
+
+ set src $srcdir/$subdir/${test}.c
+ set obj tmpdir/${test}${fat}.o
+ set archive tmpdir/${test}${fat}.a
+ set CLANG_CFLAGS "-c -O2 -flto"
+ if { "$fat" == "-fat" } {
+ append CLANG_CFLAGS " -ffat-lto-objects"
+ }
+
+ append strip_flags " --strip-unneeded $llvm_plug_opt"
+
+ set cmd "$CLANG_FOR_TARGET $CLANG_CFLAGS -o $obj $src"
+ send_log "$cmd\n"
+ verbose "$cmd" 1
+ catch "exec $cmd" got
+ if ![string match "" $got] then {
+ send_log "$got\n"
+ verbose "$got" 1
+ fail "$testname ($obj)"
+ return
+ }
+
+ set cmd "$NM $llvm_plug_opt $obj\n"
+ send_log "$cmd\n"
+ verbose "$cmd" 1
+ catch "exec $cmd" got
+ if ![regexp "0+ T foo" $got] then {
+ send_log "$got\n"
+ verbose "$got" 1
+ fail "$testname ($obj)"
+ return
+ }
+
+ pass "$testname ($obj)"
+
+ set cmd "$STRIP $strip_flags $obj -o ${obj}.strip"
+ send_log "$cmd\n"
+ verbose "$cmd" 1
+ catch "exec $cmd" got
+ if ![string match "" $got] then {
+ send_log "$got\n"
+ verbose "$got" 1
+ fail "$testname (strip $obj)"
+ return
+ }
+
+ set cmd "$NM $llvm_plug_opt ${obj}.strip"
+ send_log "$cmd\n"
+ verbose "$cmd" 1
+ catch "exec $cmd" got
+ if ![regexp "0+ T foo" $got] then {
+ send_log "$got\n"
+ verbose "$got" 1
+ fail "$testname (strip $obj)"
+ return
+ }
+
+ if { "$fat" == "-fat" } {
+ set cmd "$READELF -SW ${obj}.strip"
+ send_log "$cmd\n"
+ verbose "$cmd" 1
+ catch "exec $cmd" got
+ if [regexp "\.llvm\.lto *LLVM_LTO *" $got] then {
+ send_log "$got\n"
+ verbose "$got" 1
+ fail "$testname (strip $obj)"
+ return
+ }
+ }
+
+ pass "$testname (strip $obj)"
+
+ set cmd "$AR $llvm_plug_opt -s -r -c $archive $obj"
+ send_log "$cmd\n"
+ verbose "$cmd" 1
+ catch "exec $cmd" got
+ if ![string match "" $got] then {
+ send_log "$got\n"
+ verbose "$got" 1
+ fail "$testname ($archive)"
+ return
+ }
+
+ set cmd "$NM $llvm_plug_opt $archive\n"
+ send_log "$cmd\n"
+ verbose "$cmd" 1
+ catch "exec $cmd" got
+ if ![regexp "0+ T foo" $got] then {
+ send_log "$got\n"
+ verbose "$got" 1
+ fail "$testname ($archive)"
+ return
+ }
+
+ pass "$testname ($archive)"
+
+ set cmd "$STRIP $strip_flags $archive -o ${archive}.strip"
+ send_log "$cmd\n"
+ verbose "$cmd" 1
+ catch "exec $cmd" got
+ if ![string match "" $got] then {
+ send_log "$got\n"
+ verbose "$got" 1
+ fail "$testname (strip $archive)"
+ return
+ }
+
+ set cmd "$NM $llvm_plug_opt ${archive}.strip"
+ send_log "$cmd\n"
+ verbose "$cmd" 1
+ catch "exec $cmd" got
+ if ![regexp "0+ T foo" $got] then {
+ send_log "$got\n"
+ verbose "$got" 1
+ fail "$testname (strip $archive)"
+ return
+ }
+
+ if { "$fat" == "-fat" } {
+ set cmd "$READELF -SW ${archive}.strip"
+ send_log "$cmd\n"
+ verbose "$cmd" 1
+ catch "exec $cmd" got
+ if [regexp "\.llvm\.lto *LLVM_LTO *" $got] then {
+ send_log "$got\n"
+ verbose "$got" 1
+ fail "$testname (strip $archive)"
+ return
+ }
+ }
+
+ pass "$testname (strip $archive)"
+}
+
+run_pr33198_test "" "-R .gnu.lto_* -R .gnu.debuglto_* -R .llvm.lto -N __gnu_lto_v1"
+run_pr33198_test "-fat" "-R .gnu.lto_* -R .gnu.debuglto_* -R .llvm.lto -N __gnu_lto_v1"
+run_pr33198_test "" "-R .llvm.lto"
+run_pr33198_test "-fat" "-R .llvm.lto"
diff --git a/binutils/testsuite/lib/binutils-common.exp b/binutils/testsuite/lib/binutils-common.exp
index 2da7138e211..ec246f45257 100644
--- a/binutils/testsuite/lib/binutils-common.exp
+++ b/binutils/testsuite/lib/binutils-common.exp
@@ -1813,3 +1813,30 @@ proc get_standard_section_names {} {
}
return
}
+
+set llvm_plug_opt ""
+if { [isnative] } then {
+ if ![info exists CLANG_FOR_TARGET] then {
+ catch "exec clang -v" got
+ if [regexp "clang version" $got] then {
+ set CLANG_FOR_TARGET clang
+ }
+ }
+ if [info exists CLANG_FOR_TARGET] then {
+ set llvm_plug_so [string trim [exec $CLANG_FOR_TARGET -print-file-name=LLVMgold.so]]
+ if { $llvm_plug_so ne "LLVMgold.so" } then {
+ set llvm_plug_opt "--plugin $llvm_plug_so"
+ }
+
+ if { $llvm_plug_opt eq "" } then {
+ # If it is still blank, try llvm-config --libdir. Clang
+ # searches CLANG_INSTALL_LIBDIR_BASENAME which corresponds
+ # to this.
+ catch "exec llvm-config --libdir" got
+ if {[file isdirectory $got] \
+ && [file isfile $got/LLVMgold.so]} then {
+ set llvm_plug_opt "--plugin $got/LLVMgold.so"
+ }
+ }
+ }
+}
--
2.50.1

View File

@ -0,0 +1,13 @@
--- binutils.orig/ld/testsuite/ld-elf/linux-x86.exp 2024-01-24 11:52:35.288014542 +0000
+++ binutils-2.41/ld/testsuite/ld-elf/linux-x86.exp 2024-01-24 17:31:39.356167357 +0000
@@ -225,6 +225,10 @@ if { [check_ifunc_attribute_available] }
# Old gcc silently ignores __attribute__ ((aligned())) with too big alignment.
proc compiler_honours_aligned { } {
global CC_FOR_TARGET READELF srcdir subdir
+
+ # Temporary fix for CentOS-10 kernel issue. (RHEL-22466)
+ return 0
+
ld_compile $CC_FOR_TARGET $srcdir/$subdir/p_align-1.c tmpdir/p_align-1.o
set output [run_host_cmd "$READELF" "-SW tmpdir/p_align-1.o"]
if { [regexp { [.]data *PROGBITS .* 8388608[\n]} $output] } {

File diff suppressed because it is too large Load Diff

46
binutils-version.patch Normal file
View File

@ -0,0 +1,46 @@
diff -rup binutils.orig/bfd/Makefile.am binutils-2.38/bfd/Makefile.am
--- binutils.orig/bfd/Makefile.am 2022-02-09 14:10:42.659300681 +0000
+++ binutils-2.38/bfd/Makefile.am 2022-02-09 14:12:40.562532916 +0000
@@ -977,8 +977,8 @@ DISTCLEANFILES = $(BUILD_CFILES) $(BUILD
bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in
$(AM_V_GEN)\
bfd_version=`echo "$(VERSION)" | $(SED) -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\
- bfd_version_string="\"$(VERSION)\"" ;\
- bfd_soversion="$(VERSION)" ;\
+ bfd_version_string="\"$(VERSION)-%{release}\"" ;\
+ bfd_soversion="$(VERSION)-%{release}" ;\
bfd_version_package="\"$(PKGVERSION)\"" ;\
report_bugs_to="\"$(REPORT_BUGS_TO)\"" ;\
. $(srcdir)/development.sh ;\
@@ -989,7 +989,7 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/
fi ;\
$(SED) -e "s,@bfd_version@,$$bfd_version," \
-e "s,@bfd_version_string@,$$bfd_version_string," \
- -e "s,@bfd_version_package@,$$bfd_version_package," \
+ -e "s,@bfd_version_package@,\"version \"," \
-e "s,@report_bugs_to@,$$report_bugs_to," \
< $(srcdir)/version.h > $@; \
echo "$${bfd_soversion}" > libtool-soversion
diff -rup binutils.orig/bfd/Makefile.in binutils-2.38/bfd/Makefile.in
--- binutils.orig/bfd/Makefile.in 2022-02-09 14:10:42.653300720 +0000
+++ binutils-2.38/bfd/Makefile.in 2022-02-09 14:19:03.362040188 +0000
@@ -2094,8 +2094,8 @@ stmp-lcoff-h: $(LIBCOFF_H_FILES) $(MKDOC
bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in
$(AM_V_GEN)\
bfd_version=`echo "$(VERSION)" | $(SED) -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\
- bfd_version_string="\"$(VERSION)\"" ;\
- bfd_soversion="$(VERSION)" ;\
+ bfd_version_string="\"$(VERSION)-%{release}\"" ;\
+ bfd_soversion="$(VERSION)-%{release}" ;\
bfd_version_package="\"$(PKGVERSION)\"" ;\
report_bugs_to="\"$(REPORT_BUGS_TO)\"" ;\
. $(srcdir)/development.sh ;\
@@ -2106,7 +2106,7 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/
fi ;\
$(SED) -e "s,@bfd_version@,$$bfd_version," \
-e "s,@bfd_version_string@,$$bfd_version_string," \
- -e "s,@bfd_version_package@,$$bfd_version_package," \
+ -e "s,@bfd_version_package@,\"version \"," \
-e "s,@report_bugs_to@,$$report_bugs_to," \
< $(srcdir)/version.h > $@; \
echo "$${bfd_soversion}" > libtool-soversion

1637
binutils.spec Normal file

File diff suppressed because it is too large Load Diff

70
binutilscompare Normal file
View File

@ -0,0 +1,70 @@
#! /usr/bin/perl
# Compare build logs for the testsuite results regressions.
# $Id$
use strict;
use warnings;
use Data::Dumper;
my $reverse=shift @ARGV if ($ARGV[0]||"") eq "-r";
sub readfile($)
{
my($filename)=@_;
local *F;
open F,$filename or die "open \"$filename\": $!";
my $F=do { local $/; <F>; };
close F or die "close \"$filename\": $!";
return $F;
}
sub writefile($$)
{
my($filename,$content)=@_;
local *F;
open F,">$filename" or die "create \"$filename\": $!";
print F $content or die "write \"$filename\": $!";
close F or die "close \"$filename\": $!";
}
local *DIR;
opendir DIR,"tests" or die "opendir: $!";
my %arch;
for my $name (sort readdir(DIR)) {
next if $name!~/-([^-]*)[.]log$/o;
my $arch=$1;
(my $sum=$name)=~s/log$/sum/ or die;
my $i=readfile "tests/$name";
my $o="";
while ($i=~/\n(Native configuration is.*?Summary ===\n.*?\n)make\Q[\E/gs) {
$o.=$1;
}
# Version string differs.
$o=~s{/builddir/build/BUILD/binutils-[^/]*/+}{}g;
$o=~s{^(Version .*) 20\d{6}$}{$1}mg;
$o=~s{^(\Q../as-new\E) 20\d{6}$}{$1}mg;
$o=~s{^(build-[^/]*/ld/ld-new) 20\d{6}$}{$1}mg;
writefile "tests/$sum",$o;
push @{$arch{$arch}},$sum;
}
closedir DIR or die "closedir: $!";
for (values(%arch)) {
next if 2==@$_;
warn "Single element: ".${$_}[0]."\n" if 1==@$_;
die "Not 2 elements:\n".Dumper($_) if 1!=@$_;
}
system("rm -f tests/gdbcompare-*.diff") and die;
for my $arch (sort keys(%arch)) {
next if 2!=@{$arch{$arch}};
# sub trans { return {"."=>0,"-"=>1}->{($_[0]=~/([-.])[^-.]+[.]\w+$/)[0]}.$_[0]; };
sub trans { return $_[0]; };
my @sorted=sort { my $a1=trans $a; my $b1=trans $b; ($b1 cmp $a1) * ($reverse ? -1 : +1); } @{$arch{$arch}};
do { system $_ and die $_; } for "diff -u tests/'".$sorted[1]."' tests/'".$sorted[0]."' >tests/gdbcompare-'$arch'.sum.diff;true";
}
system("vim tests/gdbcompare-*.sum.diff");

14
gating.yaml Normal file
View File

@ -0,0 +1,14 @@
--- !Policy
product_versions:
- fedora-*
decision_context: bodhi_update_push_stable
subject_type: koji_build
rules:
- !PassingTestCaseRule {test_case_name: baseos-qe.koji-build.scratch-build.validation}
--- !Policy
product_versions:
- rhel-10
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.gate-build-fast-lane.functional}
- !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.gate-build-slow-lane.functional}

0
plans/.gitkeep Normal file
View File

25
plans/build-gating.fmf Normal file
View File

@ -0,0 +1,25 @@
#
# Build/PR gating tests for binutils
#
/common:
plan:
import:
url: https://gitlab.com/redhat/centos-stream/tests/binutils.git
ref: main
name: /plans/build-gating/common
/kernel-rebuild:
plan:
import:
url: https://gitlab.com/redhat/centos-stream/tests/binutils.git
ref: main
name: /plans/build-gating/kernel-rebuild
adjust+:
- because: "Plan to be ran when executed locally, or executed by CI system to gate a build or PR."
when: >-
trigger is defined
and trigger != commit
and trigger != build
enabled: false

16
rpminspect.yaml Normal file
View File

@ -0,0 +1,16 @@
---
debuginfo:
ignore:
- /usr/lib/debug/opt/rh/gcc-toolset-16/root/usr/lib64/*.debug
- /usr/lib/debug/opt/rh/gcc-toolset-16/root/usr/lib64/bfd-plugins/*.debug
- /usr/lib/debug/opt/rh/gcc-toolset-16/root/usr/lib64/gprofng/*.debug
- /usr/lib/debug/opt/rh/gcc-toolset-16/root/usr/bin/*.debug
- /usr/lib/debug/opt/rh/gcc-toolset-16/root/usr/lib/*.debug
- /usr/lib/debug/opt/rh/gcc-toolset-16/root/usr/lib/bfd-plugins/*.debug
specname:
primary: filename
unicode:
exclude: ^binutils-\d+.\d+\/gas\/testsuite\/gas\/all\/multibyte.s$

2
sources Normal file
View File

@ -0,0 +1,2 @@
SHA512 (binutils-with-gold-2.46.tar.xz) = 20540d217cd57c53bc51151046b3e406ee75b80917c9b0b6c37aafaf61702ea4caec533b5554f4dea12e6e211452a6adbaa02004fec12c56e0ef31028acc427a
SHA512 (binutils-2.19.50.0.1-output-format.sed) = 2f8686b0c8af13c98cda056824c2820416f6e2d003f70b78ccf5314525b9ee3684d421dfa83e638a2d42d06ea4d4bdaf5226b64d6ec26f7ff59c44ffb2a23dd2