SHA256
3
0
forked from pool/binutils

- Update to current 2.43.1 branch:

* PR32109 - fuzzing problem
  * PR32083 - LTO vs overridden common symbols
  * PR32067 - crash with LTO-plugin and --oformat=binary
  * PR31956 - LTO vs wrapper symbols
  * riscv - add Zimop and Zcmop extensions
- Adjusted binutils-2.43-branch.diff.gz.

OBS-URL: https://build.opensuse.org/package/show/devel:gcc/binutils?expand=0&rev=475
This commit is contained in:
Michael Matz 2024-08-28 13:25:33 +00:00 committed by Git OBS Bridge
commit 1e122fb9d2
35 changed files with 7998 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

19
_constraints Normal file
View File

@ -0,0 +1,19 @@
<constraints>
<hardware>
<disk>
<size unit="G">6</size>
</disk>
</hardware>
<overwrite>
<conditions>
<arch>ppc</arch>
<arch>ppc64</arch>
<arch>ppc64le</arch>
</conditions>
<hardware>
<physicalmemory>
<size unit="G">4</size>
</physicalmemory>
</hardware>
</overwrite>
</constraints>

26
_multibuild Normal file
View File

@ -0,0 +1,26 @@
<multibuild>
<flavor>aarch64</flavor>
<flavor>hppa</flavor>
<flavor>hppa64</flavor>
<flavor>arm</flavor>
<flavor>i386</flavor>
<flavor>x86_64</flavor>
<flavor>s390</flavor>
<flavor>s390x</flavor>
<flavor>ppc</flavor>
<flavor>ppc64</flavor>
<flavor>ppc64le</flavor>
<flavor>ia64</flavor>
<flavor>sparc</flavor>
<flavor>sparc64</flavor>
<flavor>spu</flavor>
<flavor>avr</flavor>
<flavor>pru</flavor>
<flavor>mips</flavor>
<flavor>m68k</flavor>
<flavor>epiphany</flavor>
<flavor>rx</flavor>
<flavor>riscv64</flavor>
<flavor>xtensa</flavor>
<flavor>bpf</flavor>
</multibuild>

View File

@ -0,0 +1,56 @@
Change default common-page-size to 64K on aarch64. This enables the use
of RELRO since we are using 64K pages.
Index: binutils-2.41/bfd/elfnn-aarch64.c
===================================================================
--- binutils-2.41.orig/bfd/elfnn-aarch64.c 2023-07-03 01:00:00.000000000 +0200
+++ binutils-2.41/bfd/elfnn-aarch64.c 2023-08-16 16:31:51.238779641 +0200
@@ -10251,7 +10251,7 @@ const struct elf_size_info elfNN_aarch64
#define ELF_ARCH bfd_arch_aarch64
#define ELF_MACHINE_CODE EM_AARCH64
#define ELF_MAXPAGESIZE 0x10000
-#define ELF_COMMONPAGESIZE 0x1000
+#define ELF_COMMONPAGESIZE 0x10000
#define bfd_elfNN_bfd_free_cached_info \
elfNN_aarch64_bfd_free_cached_info
Index: binutils-2.41/gold/aarch64.cc
===================================================================
--- binutils-2.41.orig/gold/aarch64.cc 2023-07-03 01:00:00.000000000 +0200
+++ binutils-2.41/gold/aarch64.cc 2023-08-16 16:28:35.959450565 +0200
@@ -3555,7 +3555,7 @@ const Target::Target_info Target_aarch64
"/lib/ld.so.1", // program interpreter
0x400000, // default_text_segment_address
0x10000, // abi_pagesize (overridable by -z max-page-size)
- 0x1000, // common_pagesize (overridable by -z common-page-size)
+ 0x10000, // common_pagesize (overridable by -z common-page-size)
false, // isolate_execinstr
0, // rosegment_gap
elfcpp::SHN_UNDEF, // small_common_shndx
@@ -3584,7 +3584,7 @@ const Target::Target_info Target_aarch64
"/lib/ld.so.1", // program interpreter
0x400000, // default_text_segment_address
0x10000, // abi_pagesize (overridable by -z max-page-size)
- 0x1000, // common_pagesize (overridable by -z common-page-size)
+ 0x10000, // common_pagesize (overridable by -z common-page-size)
false, // isolate_execinstr
0, // rosegment_gap
elfcpp::SHN_UNDEF, // small_common_shndx
@@ -3613,7 +3613,7 @@ const Target::Target_info Target_aarch64
"/lib/ld.so.1", // program interpreter
0x400000, // default_text_segment_address
0x10000, // abi_pagesize (overridable by -z max-page-size)
- 0x1000, // common_pagesize (overridable by -z common-page-size)
+ 0x10000, // common_pagesize (overridable by -z common-page-size)
false, // isolate_execinstr
0, // rosegment_gap
elfcpp::SHN_UNDEF, // small_common_shndx
@@ -3642,7 +3642,7 @@ const Target::Target_info Target_aarch64
"/lib/ld.so.1", // program interpreter
0x400000, // default_text_segment_address
0x10000, // abi_pagesize (overridable by -z max-page-size)
- 0x1000, // common_pagesize (overridable by -z common-page-size)
+ 0x10000, // common_pagesize (overridable by -z common-page-size)
false, // isolate_execinstr
0, // rosegment_gap
elfcpp::SHN_UNDEF, // small_common_shndx

4
baselibs.conf Normal file
View File

@ -0,0 +1,4 @@
binutils-devel
requires -binutils-<targettype>
obsoletes "binutils-<targettype> < <version>"

BIN
binutils-2.43-branch.diff.gz (Stored with Git LFS) Normal file

Binary file not shown.

BIN
binutils-2.43.tar.bz2 (Stored with Git LFS) Normal file

Binary file not shown.

16
binutils-2.43.tar.bz2.sig Normal file
View File

@ -0,0 +1,16 @@
-----BEGIN PGP SIGNATURE-----
iQIzBAABCAAdFiEEOiS8Ho+0CfqfFDcYE/zvid2ePE8FAmaviv8ACgkQE/zvid2e
PE9C2hAAw9RCvIe7c6zdMBslwnHm5lJE4P8OLgfvQhW1LyNMM7q6UtJC0oG1mCAk
qpfDkp62XXXLu8QUVvuGhLOrAC7PkkwRs+RKaidOmQ1DDaFsh6h1EilbRbeXhwT6
+GgL9gmoflWQ+/VTi8ETc6F0kxfbOFLDgWQf8LZ66g9Z5RzoUaRfcktljjPpmgvh
kp2V/8QsY6rTtJDpTfSp5ysvvfkuh0DQBN/aOlnjcbupaj2p2aBrs0PiAmtiNfGZ
616FCFytqNYX8KxVV3OZcTOCKARcFxXc/4q1za+0musaqLHGlw8h27jTEU51lQJy
gemDWIJbVoth/jK4/pIl7rsiLte136qj6JybsAh3LLM7JTcwf9rha0DyU0nBmSyt
4PfzOsoSRjfIBTTPlmS7L2thY8+Y0sYPcIf8lj8ue9YZyYYSix/8KUm/0vvmwJr8
XUiw0sUpGcSUTFjqhNxcjqORSQBWb9kjRod+PdU9LEFE4cp3mexkzjIgEWDkRjqP
sTdstNT1A5LiX5XhcMKVze9D28y2XQRxkbvbBbm4nt4cIBvk1QtsZZH4bR5ABgyF
q8kp0FpBrbvOBTDQsuAuvL9lOg5unngZLAOeogxsOJblirzX6cPku5NDQgY7GYUP
SIEOJaMU5OoI6NU9iVt1LBZZaMO6+16PTNQ2MArgI0g2B1HNC3U=
=vvKA
-----END PGP SIGNATURE-----

16
binutils-bfd_h.patch Normal file
View File

@ -0,0 +1,16 @@
Remove the #error to avoid issues with legacy not dealing with this
--- bfd/bfd-in.h.orig 2012-11-30 13:44:35.715871571 +0100
+++ bfd/bfd-in.h 2012-11-30 13:44:43.428871298 +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

View File

@ -0,0 +1,13 @@
Index: ld/ldmain.c
===================================================================
--- ld/ldmain.c.orig 2017-07-26 10:07:31.862559913 +0200
+++ ld/ldmain.c 2017-07-26 10:07:31.886560303 +0200
@@ -309,6 +309,8 @@ main (int argc, char **argv)
yydebug = 1;
}
#endif
+ if (getenv ("SUSE_ASNEEDED") && atoi(getenv ("SUSE_ASNEEDED")) > 0)
+ input_flags.add_DT_NEEDED_for_regular = true;
config.build_constructors = true;
config.rpath_separator = ':';

View File

@ -0,0 +1,63 @@
This adjusts some testcases that expect new behaviour:
* that relaxable relocations are generated
* that separate-code is default
- this also implies that default max-page-size is 0x1000, instead of the
old 0x200000, so some testcases need to encode that as well
diff --git a/ld/testsuite/ld-elf/linux-x86.exp b/ld/testsuite/ld-elf/linux-x86.exp
index 2e0cbd37f17..fcd3dd920e4 100644
--- a/ld/testsuite/ld-elf/linux-x86.exp
+++ b/ld/testsuite/ld-elf/linux-x86.exp
@@ -275,7 +275,7 @@ proc check_pr25749a {testname srcfilea srcfileb cflags ldflags lderror} {
}
# Suppress warning for unsupported attribute from older GCC.
- append cflags " -w"
+ append cflags " -w -Wa,-mrelax-relocations=yes"
exec cp $srcdir/$subdir/$srcfilea $srcfilea
exec chmod +w $srcfilea
@@ -396,7 +396,7 @@ proc check_pr25749b {testname srcfilea srcfileb cflags ldflags dsoldflags args}
[list \
"Build lib${testname}.so ($dsoldflags)" \
"-shared $dsoldflags tmpdir/pr25749-bin.o -z noexecstack" \
- "-fPIC -I../bfd" \
+ "-fPIC -I../bfd -Wa,-mrelax-relocations=yes" \
[list $srcfileb] \
{{readelf {-Wr} pr25749.rd}} \
"lib${testname}.so" \
diff --git a/ld/testsuite/ld-i386/report-reloc-1.d b/ld/testsuite/ld-i386/report-reloc-1.d
index 162161592a1..ee96047043d 100644
--- a/ld/testsuite/ld-i386/report-reloc-1.d
+++ b/ld/testsuite/ld-i386/report-reloc-1.d
@@ -1,6 +1,6 @@
#source: report-reloc-1.s
#as: --32
-#ld: -pie -melf_i386 -z report-relative-reloc $NO_DT_RELR_LDFLAGS
+#ld: -pie -melf_i386 -z report-relative-reloc -z separate-code $NO_DT_RELR_LDFLAGS
#warning_output: report-reloc-1.l
#readelf: -r --wide
diff --git a/ld/testsuite/ld-x86-64/report-reloc-1-x32.d b/ld/testsuite/ld-x86-64/report-reloc-1-x32.d
index 63fe7b1bb8a..29a94ff8762 100644
--- a/ld/testsuite/ld-x86-64/report-reloc-1-x32.d
+++ b/ld/testsuite/ld-x86-64/report-reloc-1-x32.d
@@ -1,6 +1,6 @@
#source: report-reloc-1.s
#as: --x32
-#ld: -pie -melf32_x86_64 -z report-relative-reloc $NO_DT_RELR_LDFLAGS
+#ld: -pie -melf32_x86_64 -z report-relative-reloc -z separate-code -z max-page-size=4096 $NO_DT_RELR_LDFLAGS
#warning_output: report-reloc-1.l
#readelf: -r --wide
diff --git a/ld/testsuite/ld-x86-64/report-reloc-1.d b/ld/testsuite/ld-x86-64/report-reloc-1.d
index 69f164c9434..63079acc98a 100644
--- a/ld/testsuite/ld-x86-64/report-reloc-1.d
+++ b/ld/testsuite/ld-x86-64/report-reloc-1.d
@@ -1,6 +1,6 @@
#source: report-reloc-1.s
#as: --64
-#ld: -pie -melf_x86_64 -z report-relative-reloc $NO_DT_RELR_LDFLAGS
+#ld: -pie -melf_x86_64 -z report-relative-reloc -z separate-code -z max-page-size=4096 $NO_DT_RELR_LDFLAGS
#warning_output: report-reloc-1.l
#readelf: -r --wide

View File

@ -0,0 +1,25 @@
Index: binutils-2.42/gas/config/tc-i386.c
===================================================================
--- binutils-2.42.orig/gas/config/tc-i386.c 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/config/tc-i386.c 2024-02-05 17:54:33.515139672 +0100
@@ -2992,13 +2992,17 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
{
check_cpu_arch_compatible (string, cpu_arch[j].enable);
+ /* XXX code in the wild calls 'as --64' (to generate ELF64),
+ but then does '.arch i386' first and only then '.code32' or
+ '.code16'. This checking here would require swapping these
+ two directives, so just warn for the time being. */
if (flag_code == CODE_64BIT && !cpu_arch[j].enable.bitfield.cpu64 )
{
- as_bad (_("64bit mode not supported on `%s'."),
+ as_warn (_("64bit mode not supported on `%s' (consider swapping .arch and .code directives)."),
cpu_arch[j].name);
- (void) restore_line_pointer (e);
+ /*(void) restore_line_pointer (e);
ignore_rest_of_line ();
- return;
+ return;*/
}
if (flag_code == CODE_32BIT && !cpu_arch[j].enable.bitfield.cpui386)

View File

@ -0,0 +1,43 @@
This fixes an error message given too eagerly on ppc64le,
when no input files are used and as-needed is in effect. E.g.:
% ld-new --as-needed -o /dev/null -lc
gives an error message about input and output ABI versions being
incompatible. This is because the ABI setting of "unknown" (0)
to "from-input" is done in ppc64_elf_before_check_relocs, which
isn't called for as-needed libraries (via check_directives callback).
merge_private_bfd_data is called for as-needed and not-as-needed inputs
(via notice_as_needed), so copy that code there.
This construct is used in some packages to check for availability
of libraries (e.g. in nvme-cli to check for -luuid). Redircting error
output makes this siletently fail.
Index: binutils-2.35/bfd/elf64-ppc.c
===================================================================
--- binutils-2.35.orig/bfd/elf64-ppc.c 2020-07-24 11:12:19.000000000 +0200
+++ binutils-2.35/bfd/elf64-ppc.c 2020-08-10 17:25:00.205219071 +0200
@@ -5310,11 +5310,17 @@ ppc64_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
if (iflags & ~EF_PPC64_ABI)
{
- _bfd_error_handler
- /* xgettext:c-format */
- (_("%pB uses unknown e_flags 0x%lx"), ibfd, iflags);
- bfd_set_error (bfd_error_bad_value);
- return false;
+ if (abiversion (info->output_bfd) == 0)
+ set_abiversion (info->output_bfd, abiversion (ibfd));
+ else
+ {
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%pB: ABI version %ld is not compatible with ABI version %ld output"),
+ ibfd, iflags, oflags);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
}
else if (iflags != oflags && iflags != 0)
{

View File

@ -0,0 +1,25 @@
Also reported as PR25210. There's a problem when using the two
linker options '--fix-cortex-a53-835769 --fix-cortex-a53-843419'
together. This is the default in our distro, but not upstream so
it went unnoticed.
Leads to an error while linking any code that sports one of the
sequences that triggers the errata fixup (gcc being one of those),
namely:
ld: can not size stub section: invalid operation
ld: warning: cannot find entry symbol _start; defaulting to 0000000000400078
ld: linker stubs: file class ELFCLASSNONE incompatible with ELFCLASS64
ld: final link failed: file in wrong format
--- bfd/elfnn-aarch64.c.mm 2019-09-09 13:19:43.000000000 +0000
+++ bfd/elfnn-aarch64.c 2019-11-20 11:44:00.000000000 +0000
@@ -4312,7 +4312,8 @@ elfNN_aarch64_size_stubs (bfd *output_bfd,
|| (input_bfd->flags & BFD_LINKER_CREATED) != 0)
continue;
- if (!_bfd_aarch64_erratum_835769_scan (input_bfd, info,
+ if (input_bfd != stub_bfd
+ && !_bfd_aarch64_erratum_835769_scan (input_bfd, info,
&num_erratum_835769_fixes))
return false;
}

20
binutils-fix-relax.diff Normal file
View File

@ -0,0 +1,20 @@
Fix for bsc#1179341
the movload->movconst relaxation can be done only with REX
rewriting, and hence needs a GOTPCRELX relocation. With old object
files we might still see GOTPCREL relocs, even with REX bytes available.
We still can't do such rewriting and hence need to stay with the old
rewriting into a lea.
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 549a8be6a6..b89b0023db 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -1731,7 +1731,7 @@ elf_x86_64_convert_load_reloc (bfd *abfd,
if (opcode == 0x8b)
{
- if (abs_symbol && local_ref && relocx)
+ if (abs_symbol && local_ref && relocx && rex)
to_reloc_pc32 = false;
if (to_reloc_pc32)

View File

@ -0,0 +1,365 @@
This reverts commit b10b530a4566, because generating 'jgnop'
from 'bcrl' confuses some parsing tools (in particular kernels
recordmcount.pl tool) on s390x.
Due to the way the assembler and disassembler are implemented we need
to disable both, the assembly and disassembly of the problematic
mnemonic (that's only a problem for jgnop vs brcl, but still).
So, just revert the whole commit.
v2: this adjusts the reversion of above commit to care for commit
0cfd6cffde32726ca69cde6ed3cc1ece21b9cf7c that changes the touched
testcases so that it applies again, so it's not a simple revert of
above commit anymore.
v3: Adjust for 9c422a59953 and 3f3c1e513.
(We leave out the patch to ChangeLog in the reversion)
Index: binutils-2.42/gas/testsuite/gas/s390/esa-g5.d
===================================================================
--- binutils-2.42.orig/gas/testsuite/gas/s390/esa-g5.d 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/testsuite/gas/s390/esa-g5.d 2024-01-30 17:37:08.609356666 +0100
@@ -78,15 +78,11 @@ Disassembly of section .text:
.*: 07 29 [ ]*bhr %r9
.*: 07 f9 [ ]*br %r9
*([\da-f]+): a7 95 00 00 [ ]*bras %r9,\1 <foo\+0x\1>
- *([\da-f]+): a7 65 00 00 [ ]*bras %r6,\1 <foo\+0x\1>
*([\da-f]+): a7 64 00 00 [ ]*jlh \1 <foo\+0x\1>
*([\da-f]+): a7 64 00 00 [ ]*jlh \1 <foo\+0x\1>
*([\da-f]+): a7 66 00 00 [ ]*brct %r6,\1 <foo\+0x\1>
- *([\da-f]+): a7 66 00 00 [ ]*brct %r6,\1 <foo\+0x\1>
- *([\da-f]+): 84 69 00 00 [ ]*brxh %r6,%r9,\1 <foo\+0x\1>
*([\da-f]+): 84 69 00 00 [ ]*brxh %r6,%r9,\1 <foo\+0x\1>
*([\da-f]+): 85 69 00 00 [ ]*brxle %r6,%r9,\1 <foo\+0x\1>
- *([\da-f]+): 85 69 00 00 [ ]*brxle %r6,%r9,\1 <foo\+0x\1>
.*: b2 5a 00 69 [ ]*bsa %r6,%r9
.*: b2 58 00 69 [ ]*bsg %r6,%r9
.*: 0b 69 [ ]*bsm %r6,%r9
@@ -206,28 +202,6 @@ Disassembly of section .text:
*([\da-f]+): a7 14 00 00 [ ]*jo \1 <foo\+0x\1>
*([\da-f]+): a7 24 00 00 [ ]*jh \1 <foo\+0x\1>
*([\da-f]+): a7 84 00 00 [ ]*je \1 <foo\+0x\1>
- *([\da-f]+): a7 04 00 00 [ ]*jnop \1 <foo\+0x\1>
- *([\da-f]+): a7 14 00 00 [ ]*jo \1 <foo\+0x\1>
- *([\da-f]+): a7 24 00 00 [ ]*jh \1 <foo\+0x\1>
- *([\da-f]+): a7 24 00 00 [ ]*jh \1 <foo\+0x\1>
- *([\da-f]+): a7 34 00 00 [ ]*jnle \1 <foo\+0x\1>
- *([\da-f]+): a7 44 00 00 [ ]*jl \1 <foo\+0x\1>
- *([\da-f]+): a7 44 00 00 [ ]*jl \1 <foo\+0x\1>
- *([\da-f]+): a7 54 00 00 [ ]*jnhe \1 <foo\+0x\1>
- *([\da-f]+): a7 64 00 00 [ ]*jlh \1 <foo\+0x\1>
- *([\da-f]+): a7 74 00 00 [ ]*jne \1 <foo\+0x\1>
- *([\da-f]+): a7 74 00 00 [ ]*jne \1 <foo\+0x\1>
- *([\da-f]+): a7 84 00 00 [ ]*je \1 <foo\+0x\1>
- *([\da-f]+): a7 84 00 00 [ ]*je \1 <foo\+0x\1>
- *([\da-f]+): a7 94 00 00 [ ]*jnlh \1 <foo\+0x\1>
- *([\da-f]+): a7 a4 00 00 [ ]*jhe \1 <foo\+0x\1>
- *([\da-f]+): a7 b4 00 00 [ ]*jnl \1 <foo\+0x\1>
- *([\da-f]+): a7 b4 00 00 [ ]*jnl \1 <foo\+0x\1>
- *([\da-f]+): a7 c4 00 00 [ ]*jle \1 <foo\+0x\1>
- *([\da-f]+): a7 d4 00 00 [ ]*jnh \1 <foo\+0x\1>
- *([\da-f]+): a7 d4 00 00 [ ]*jnh \1 <foo\+0x\1>
- *([\da-f]+): a7 e4 00 00 [ ]*jno \1 <foo\+0x\1>
- *([\da-f]+): a7 f4 00 00 [ ]*j \1 <foo\+0x\1>
.*: ed 65 af ff 00 18 [ ]*kdb %f6,4095\(%r5,%r10\)
.*: b3 18 00 69 [ ]*kdbr %f6,%f9
.*: ed 65 af ff 00 08 [ ]*keb %f6,4095\(%r5,%r10\)
@@ -510,4 +484,4 @@ Disassembly of section .text:
.*: f8 58 5f ff af ff [ ]*zap 4095\(6,%r5\),4095\(9,%r10\)
.*: b2 21 b0 69 [ ]*ipte %r6,%r9,%r11
.*: b2 21 bd 69 [ ]*ipte %r6,%r9,%r11,13
-.*: 07 07 [ ]*nopr %r7
+.*: 07 07 [ ]*nopr %r7
Index: binutils-2.42/gas/testsuite/gas/s390/esa-g5.s
===================================================================
--- binutils-2.42.orig/gas/testsuite/gas/s390/esa-g5.s 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/testsuite/gas/s390/esa-g5.s 2024-01-30 17:11:14.563730960 +0100
@@ -72,15 +72,11 @@ foo:
bpr %r9
br %r9
bras %r9,.
- jas %r6,.
brc 6,.
jc 6,.
brct 6,.
- jct %r6,.
brxh %r6,%r9,.
- jxh %r6,%r9,.
brxle %r6,%r9,.
- jxle %r6,%r9,.
bsa %r6,%r9
bsg %r6,%r9
bsm %r6,%r9
@@ -200,28 +196,6 @@ foo:
jo .
jp .
jz .
- jnop .
- bro .
- brh .
- brp .
- brnle .
- brl .
- brm .
- brnhe .
- brlh .
- brne .
- brnz .
- bre .
- brz .
- brnlh .
- brhe .
- brnl .
- brnm .
- brle .
- brnh .
- brnp .
- brno .
- bru .
kdb %f6,4095(%r5,%r10)
kdbr %f6,%f9
keb %f6,4095(%r5,%r10)
Index: binutils-2.42/gas/testsuite/gas/s390/esa-z900.d
===================================================================
--- binutils-2.42.orig/gas/testsuite/gas/s390/esa-z900.d 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/testsuite/gas/s390/esa-z900.d 2024-01-30 17:46:09.638230382 +0100
@@ -7,28 +7,6 @@ Disassembly of section .text:
.* <foo>:
.*: c0 f4 00 00 00 00 [ ]*jg 0 <foo>
- *([\da-f]+): c0 04 00 00 00 00 [ ]*jgnop \1 <foo\+0x\1>
- *([\da-f]+): c0 14 00 00 00 00 [ ]*jgo \1 <foo\+0x\1>
- *([\da-f]+): c0 24 00 00 00 00 [ ]*jgh \1 <foo\+0x\1>
- *([\da-f]+): c0 24 00 00 00 00 [ ]*jgh \1 <foo\+0x\1>
- *([\da-f]+): c0 34 00 00 00 00 [ ]*jgnle \1 <foo\+0x\1>
- *([\da-f]+): c0 44 00 00 00 00 [ ]*jgl \1 <foo\+0x\1>
- *([\da-f]+): c0 44 00 00 00 00 [ ]*jgl \1 <foo\+0x\1>
- *([\da-f]+): c0 54 00 00 00 00 [ ]*jgnhe \1 <foo\+0x\1>
- *([\da-f]+): c0 64 00 00 00 00 [ ]*jglh \1 <foo\+0x\1>
- *([\da-f]+): c0 74 00 00 00 00 [ ]*jgne \1 <foo\+0x\1>
- *([\da-f]+): c0 74 00 00 00 00 [ ]*jgne \1 <foo\+0x\1>
- *([\da-f]+): c0 84 00 00 00 00 [ ]*jge \1 <foo\+0x\1>
- *([\da-f]+): c0 84 00 00 00 00 [ ]*jge \1 <foo\+0x\1>
- *([\da-f]+): c0 94 00 00 00 00 [ ]*jgnlh \1 <foo\+0x\1>
- *([\da-f]+): c0 a4 00 00 00 00 [ ]*jghe \1 <foo\+0x\1>
- *([\da-f]+): c0 b4 00 00 00 00 [ ]*jgnl \1 <foo\+0x\1>
- *([\da-f]+): c0 b4 00 00 00 00 [ ]*jgnl \1 <foo\+0x\1>
- *([\da-f]+): c0 c4 00 00 00 00 [ ]*jgle \1 <foo\+0x\1>
- *([\da-f]+): c0 d4 00 00 00 00 [ ]*jgnh \1 <foo\+0x\1>
- *([\da-f]+): c0 d4 00 00 00 00 [ ]*jgnh \1 <foo\+0x\1>
- *([\da-f]+): c0 e4 00 00 00 00 [ ]*jgno \1 <foo\+0x\1>
- *([\da-f]+): c0 f4 00 00 00 00 [ ]*jg \1 <foo\+0x\1>
*([\da-f]+): c0 14 00 00 00 00 [ ]*jgo \1 <foo\+0x\1>
*([\da-f]+): c0 24 00 00 00 00 [ ]*jgh \1 <foo\+0x\1>
*([\da-f]+): c0 24 00 00 00 00 [ ]*jgh \1 <foo\+0x\1>
@@ -51,11 +29,8 @@ Disassembly of section .text:
*([\da-f]+): c0 e4 00 00 00 00 [ ]*jgno \1 <foo\+0x\1>
*([\da-f]+): c0 f4 00 00 00 00 [ ]*jg \1 <foo\+0x\1>
*([\da-f]+): c0 65 00 00 00 00 [ ]*brasl %r6,\1 <foo\+0x\1>
- *([\da-f]+): c0 65 00 00 00 00 [ ]*brasl %r6,\1 <foo\+0x\1>
- *([\da-f]+): c0 65 80 00 00 00 [ ]*brasl %r6,\1 <foo\+0x\1>
*([\da-f]+): c0 65 80 00 00 00 [ ]*brasl %r6,\1 <foo\+0x\1>
-.*: c0 65 7f ff ff ff [ ]*brasl %r6,11e <foo\+0x11e>
-.*: c0 65 7f ff ff ff [ ]*brasl %r6,124 <foo\+0x124>
+.*: c0 65 7f ff ff ff [ ]*brasl %r6,8e <foo\+0x8e>
.*: 01 0b [ ]*tam
.*: 01 0c [ ]*sam24
.*: 01 0d [ ]*sam31
@@ -76,4 +51,3 @@ Disassembly of section .text:
.*: e3 65 af ff 00 98 [ ]*alc %r6,4095\(%r5,%r10\)
.*: e3 65 af ff 00 99 [ ]*slb %r6,4095\(%r5,%r10\)
.*: eb 69 5f ff 00 1d [ ]*rll %r6,%r9,4095\(%r5\)
-.*: 07 07 [ ]*nopr %r7
Index: binutils-2.42/gas/testsuite/gas/s390/esa-z900.s
===================================================================
--- binutils-2.42.orig/gas/testsuite/gas/s390/esa-z900.s 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/testsuite/gas/s390/esa-z900.s 2024-01-30 17:05:15.811158036 +0100
@@ -1,7 +1,6 @@
.text
foo:
brcl 15,.
- jgnop .
jgo .
jgh .
jgp .
@@ -23,33 +22,9 @@ foo:
jgnp .
jgno .
jg .
- brol .
- brhl .
- brpl .
- brnlel .
- brll .
- brml .
- brnhel .
- brlhl .
- brnel .
- brnzl .
- brel .
- brzl .
- brnlhl .
- brhel .
- brnll .
- brnml .
- brlel .
- brnhl .
- brnpl .
- brnol .
- brul .
brasl %r6,.
- jasl %r6,.
brasl %r6,.-0x100000000
- jasl %r6,.-0x100000000
brasl %r6,.+0xfffffffe
- jasl %r6,.+0xfffffffe
tam
sam24
sam31
Index: binutils-2.42/gas/testsuite/gas/s390/zarch-z900.d
===================================================================
--- binutils-2.42.orig/gas/testsuite/gas/s390/zarch-z900.d 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/testsuite/gas/s390/zarch-z900.d 2024-01-30 17:51:15.809891527 +0100
@@ -20,11 +20,8 @@ Disassembly of section .text:
.*: e3 95 af ff 00 46 [ ]*bctg %r9,4095\(%r5,%r10\)
.*: b9 46 00 96 [ ]*bctgr %r9,%r6
*([\da-f]+): a7 97 00 00 [ ]*brctg %r9,\1 <foo\+0x\1>
- *([\da-f]+): a7 67 00 00 [ ]*brctg %r6,\1 <foo\+0x\1>
*([\da-f]+): ec 96 00 00 00 44 [ ]*brxhg %r9,%r6,\1 <foo\+0x\1>
- *([\da-f]+): ec 69 00 00 00 44 [ ]*brxhg %r6,%r9,\1 <foo\+0x\1>
*([\da-f]+): ec 96 00 00 00 45 [ ]*brxlg %r9,%r6,\1 <foo\+0x\1>
- *([\da-f]+): ec 69 00 00 00 45 [ ]*brxlg %r6,%r9,\1 <foo\+0x\1>
.*: eb 96 5f ff 00 44 [ ]*bxhg %r9,%r6,4095\(%r5\)
.*: eb 96 5f ff 00 45 [ ]*bxleg %r9,%r6,4095\(%r5\)
.*: b3 a5 00 96 [ ]*cdgbr %f9,%r6
@@ -151,9 +148,5 @@ Disassembly of section .text:
.*: e3 95 af ff 00 82 [ ]*xg %r9,4095\(%r5,%r10\)
.*: b9 82 00 96 [ ]*xgr %r9,%r6
*([\da-f]+): c0 65 00 00 00 00 [ ]*brasl %r6,\1 <foo\+0x\1>
- *([\da-f]+): c0 65 00 00 00 00 [ ]*brasl %r6,\1 <foo\+0x\1>
- *([\da-f]+): c0 65 80 00 00 00 [ ]*brasl %r6,ffffffff0+\1 <foo\+0xffffffff0+\1>
*([\da-f]+): c0 65 80 00 00 00 [ ]*brasl %r6,ffffffff0+\1 <foo\+0xffffffff0+\1>
-.*: c0 65 7f ff ff ff [ ]*brasl %r6,1000002d4 <foo\+0x1000002d4>
-.*: c0 65 7f ff ff ff [ ]*brasl %r6,1000002da <foo\+0x1000002da>
-.*: 07 07 [ ]*nopr %r7
+.*: c0 65 7f ff ff ff [ ]*brasl %r6,1000002b8 <foo\+0x1000002b8>
Index: binutils-2.42/gas/testsuite/gas/s390/zarch-z900.s
===================================================================
--- binutils-2.42.orig/gas/testsuite/gas/s390/zarch-z900.s 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/testsuite/gas/s390/zarch-z900.s 2024-01-30 17:23:32.652555451 +0100
@@ -14,11 +14,8 @@ foo:
bctg %r9,4095(%r5,%r10)
bctgr %r9,%r6
brctg %r9,.
- jctg %r6,.
brxhg %r9,%r6,.
- jxhg %r6,%r9,.
brxlg %r9,%r6,.
- jxleg %r6,%r9,.
bxhg %r9,%r6,4095(%r5)
bxleg %r9,%r6,4095(%r5)
cdgbr %f9,%r6
@@ -145,8 +142,5 @@ foo:
xg %r9,4095(%r5,%r10)
xgr %r9,%r6
brasl %r6,.
- jasl %r6,.
brasl %r6,.-0x100000000
- jasl %r6,.-0x100000000
brasl %r6,.+0xfffffffe
- jasl %r6,.+0xfffffffe
Index: binutils-2.42/ld/testsuite/ld-s390/tlsbin_64.dd
===================================================================
--- binutils-2.42.orig/ld/testsuite/ld-s390/tlsbin_64.dd 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/ld/testsuite/ld-s390/tlsbin_64.dd 2024-01-30 17:05:15.811158036 +0100
@@ -87,26 +87,26 @@ Disassembly of section .text:
+[0-9a-f]+: 41 22 90 00 la %r2,0\(%r2,%r9\)
# GD -> LE with global variable defined in executable
+[0-9a-f]+: e3 20 d0 10 00 04 lg %r2,16\(%r13\)
- +[0-9a-f]+: c0 04 00 00 00 00 jgnop [0-9a-f]+ <fn2\+0xca>
+ +[0-9a-f]+: c0 04 00 00 00 00 brcl 0,[0-9a-f]+ <fn2\+0xca>
+[0-9a-f]+: 41 22 90 00 la %r2,0\(%r2,%r9\)
# GD -> LE with local variable defined in executable
+[0-9a-f]+: e3 20 d0 18 00 04 lg %r2,24\(%r13\)
- +[0-9a-f]+: c0 04 00 00 00 00 jgnop [0-9a-f]+ <fn2\+0xda>
+ +[0-9a-f]+: c0 04 00 00 00 00 brcl 0,[0-9a-f]+ <fn2\+0xda>
+[0-9a-f]+: 41 22 90 00 la %r2,0\(%r2,%r9\)
# GD -> LE with hidden variable defined in executable
+[0-9a-f]+: e3 20 d0 20 00 04 lg %r2,32\(%r13\)
- +[0-9a-f]+: c0 04 00 00 00 00 jgnop [0-9a-f]+ <fn2\+0xea>
+ +[0-9a-f]+: c0 04 00 00 00 00 brcl 0,[0-9a-f]+ <fn2\+0xea>
+[0-9a-f]+: 41 22 90 00 la %r2,0\(%r2,%r9\)
# LD -> LE
+[0-9a-f]+: e3 20 d0 28 00 04 lg %r2,40\(%r13\)
- +[0-9a-f]+: c0 04 00 00 00 00 jgnop [0-9a-f]+ <fn2\+0xfa>
+ +[0-9a-f]+: c0 04 00 00 00 00 brcl 0,[0-9a-f]+ <fn2\+0xfa>
+[0-9a-f]+: 41 32 90 00 la %r3,0\(%r2,%r9\)
+[0-9a-f]+: e3 40 d0 30 00 04 lg %r4,48\(%r13\)
+[0-9a-f]+: 41 54 30 00 la %r5,0\(%r4,%r3\)
+[0-9a-f]+: e3 40 d0 38 00 04 lg %r4,56\(%r13\)
+[0-9a-f]+: 41 54 30 00 la %r5,0\(%r4,%r3\)
+[0-9a-f]+: e3 20 d0 40 00 04 lg %r2,64\(%r13\)
- +[0-9a-f]+: c0 04 00 00 00 00 jgnop [0-9a-f]+ <fn2\+0x11e>
+ +[0-9a-f]+: c0 04 00 00 00 00 brcl 0,[0-9a-f]+ <fn2\+0x11e>
+[0-9a-f]+: 41 32 90 00 la %r3,0\(%r2,%r9\)
+[0-9a-f]+: e3 40 d0 48 00 04 lg %r4,72\(%r13\)
+[0-9a-f]+: 41 54 30 00 la %r5,0\(%r4,%r3\)
Index: binutils-2.42/opcodes/s390-opc.txt
===================================================================
--- binutils-2.42.orig/opcodes/s390-opc.txt 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/opcodes/s390-opc.txt 2024-01-30 17:10:00.085838136 +0100
@@ -246,14 +246,10 @@ d7 xc SS_L0RDRD "exclusive or" g5 esa,za
f8 zap SS_LLRDRD "zero and add" g5 esa,zarch
a70a ahi RI_RI "add halfword immediate" g5 esa,zarch
84 brxh RSI_RRP "branch relative on index high" g5 esa,zarch condjump
-84 jxh RSI_RRP "branch relative on index high" g5 esa,zarch condjump
85 brxle RSI_RRP "branch relative on index low or equal" g5 esa,zarch condjump
-85 jxle RSI_RRP "branch relative on index low or equal" g5 esa,zarch condjump
a705 bras RI_RP "branch relative and save" g5 esa,zarch jumpsr
-a705 jas RI_RP "branch relative and save" g5 esa,zarch jumpsr
a704 brc RI_UP "branch relative on condition" g5 esa,zarch condjump
a706 brct RI_RP "branch relative on count" g5 esa,zarch condjump
-a706 jct RI_RP "branch relative on count" g5 esa,zarch condjump
b241 cksm RRE_RR "checksum" g5 esa,zarch
a70e chi RI_RI "compare halfword immediate" g5 esa,zarch
a9 clcle RS_RRRD "compare logical long extended" g5 esa,zarch
@@ -273,11 +269,8 @@ a701 tml RI_RU "test under mask low" g5
4700 b*8 RX_0RRD "conditional branch" g5 esa,zarch
47f0 b RX_0RRD "unconditional branch" g5 esa,zarch
a704 jc RI_UP "conditional jump" g5 esa,zarch condjump
-a704 jnop RI_0P "nop jump" g5 esa,zarch
a704 j*8 RI_0P "conditional jump" g5 esa,zarch condjump
-a704 br*8 RI_0P "conditional jump" g5 esa,zarch condjump
a7f4 j RI_0P "unconditional jump" g5 esa,zarch jump
-a7f4 bru RI_0P "unconditional jump" g5 esa,zarch jump
b34a axbr RRE_FEFE "add extended bfp" g5 esa,zarch
b31a adbr RRE_FF "add long bfp" g5 esa,zarch
ed000000001a adb RXE_FRRD "add long bfp" g5 esa,zarch
@@ -447,9 +440,7 @@ e3000000001b slgf RXE_RRRD "subtract log
e3000000000c msg RXE_RRRD "multiply single 64" z900 zarch
e3000000001c msgf RXE_RRRD "multiply single 64<32" z900 zarch
ec0000000044 brxhg RIE_RRP "branch relative on index high 64" z900 zarch condjump
-ec0000000044 jxhg RIE_RRP "branch relative on index high 64" z900 zarch condjump
ec0000000045 brxlg RIE_RRP "branch relative on index low or equal 64" z900 zarch condjump
-ec0000000045 jxleg RIE_RRP "branch relative on index low or equal 64" z900 zarch condjump
eb0000000044 bxhg RSE_RRRD "branch on index high 64" z900 zarch
eb0000000045 bxleg RSE_RRRD "branch on index low or equal 64" z900 zarch
eb000000000c srlg RSE_RRRD "shift right single logical 64" z900 zarch
@@ -475,16 +466,11 @@ a702 tmhh RI_RU "test under mask high hi
a703 tmhl RI_RU "test under mask high low" z900 zarch
c004 brcl RIL_UP "branch relative on condition long" z900 esa,zarch condjump
# jlc omitted due to missing jl* (see jl*8) and not added as non-standard jgc
-c004 jgnop RIL_0P "nop jump long" z900 esa,zarch
c004 jg*8 RIL_0P "conditional jump long" z900 esa,zarch condjump
# jl*8 omitted due to clash with non-standard j*8 flavors jle and jlh; exists as non-standard jg*8 instead
-c004 br*8l RIL_0P "conditional jump long" z900 esa,zarch condjump
c0f4 jg RIL_0P "unconditional jump long" z900 esa,zarch jump
-c0f4 brul RIL_0P "unconditional jump long" z900 esa,zarch jump
c005 brasl RIL_RP "branch relative and save long" z900 esa,zarch jumpsr
-c005 jasl RIL_RP "branch relative and save long" z900 esa,zarch jumpsr
a707 brctg RI_RP "branch relative on count 64" z900 zarch condjump
-a707 jctg RI_RP "branch relative on count 64" z900 zarch condjump
a709 lghi RI_RI "load halfword immediate 64" z900 zarch
a70b aghi RI_RI "add halfword immediate 64" z900 zarch
a70d mghi RI_RI "multiply halfword immediate 64" z900 zarch

View File

@ -0,0 +1,34 @@
Some packages of ours rely on the output of nm to not contain
symversions. E.g. perf uses 'nm -D' to construct a linker input
file with symbol names. ld errors on the '@' characters. Until
those packages are fixed we use this patch. We have to carry it
for old code streams forever.
diff --git a/binutils/nm.c b/binutils/nm.c
index 2637756c647..253714ef179 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -666,7 +666,7 @@ print_symname (const char *form, struct extended_symbol_info *info,
name = convert_utf8 (name);
}
- if (info != NULL && info->elfinfo && with_symbol_versions)
+ if (info != NULL && info->elfinfo && with_symbol_versions && 0)
{
const char *version_string;
bool hidden;
diff --git a/ld/testsuite/ld-elf/pr25708.d b/ld/testsuite/ld-elf/pr25708.d
index 60b8e31807a..1b62e25347e 100644
--- a/ld/testsuite/ld-elf/pr25708.d
+++ b/ld/testsuite/ld-elf/pr25708.d
@@ -2,8 +2,9 @@
#ld: -shared -version-script pr13195.t
#nm: -D --with-symbol-versions
#target: *-*-linux* *-*-gnu* arm*-*-uclinuxfdpiceabi
-#xfail: hppa64-*-* ![check_shared_lib_support]
+#xfail: *-*-* ![check_shared_lib_support]
# h8300 doesn't support -shared, and hppa64 creates .foo
+# our binutils revert the printing of symversions with nm -D
#..
0+ A VERS_2.0

View File

@ -0,0 +1,572 @@
This reverts the below commit to not generate PLT32 relocs
on branches by default. Used for old distros to not have to
update several packages/tools that can't handle them. I.e.
a compatibility patch.
The patch isn't exactly the reverse of commit bd7ab16b
because commit 83924b38 later moved the checking code
around somewhat.
The changes in nop-[345].d and pr22842b.S are followups to
not break the testsuite because of this revert.
As are the changes to x86-64-branch-2.d and x86-64-branch-3.d.
commit bd7ab16b4537788ad53521c45469a1bdae84ad4a
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Tue Feb 13 07:34:22 2018 -0800
x86-64: Generate branch with PLT32 relocation
Since there is no need to prepare for PLT branch on x86-64, generate
R_X86_64_PLT32, instead of R_X86_64_PC32, if possible, which can be
used as a marker for 32-bit PC-relative branches.
To compile Linux kernel, this patch:
From: "H.J. Lu" <hjl.tools@gmail.com>
Subject: [PATCH] x86: Treat R_X86_64_PLT32 as R_X86_64_PC32
On i386, there are 2 types of PLTs, PIC and non-PIC. PIE and shared
objects must use PIC PLT. To use PIC PLT, you need to load
_GLOBAL_OFFSET_TABLE_ into EBX first. There is no need for that on
x86-64 since x86-64 uses PC-relative PLT.
On x86-64, for 32-bit PC-relative branches, we can generate PLT32
relocation, instead of PC32 relocation, which can also be used as
a marker for 32-bit PC-relative branches. Linker can always reduce
PLT32 relocation to PC32 if function is defined locally. Local
functions should use PC32 relocation. As far as Linux kernel is
concerned, R_X86_64_PLT32 can be treated the same as R_X86_64_PC32
since Linux kernel doesn't use PLT.
is needed. It is available on hjl/plt32/master branch at
https://github.com/hjl-tools/linux
bfd/
PR gas/22791
* elf64-x86-64.c (is_32bit_relative_branch): Removed.
(elf_x86_64_relocate_section): Check PIC relocations in PIE.
Remove is_32bit_relative_branch usage. Disallow PC32 reloc
against protected function in shared object.
gas/
PR gas/22791
* config/tc-i386.c (need_plt32_p): New function.
(output_jump): Generate BFD_RELOC_X86_64_PLT32 if possible.
(md_estimate_size_before_relax): Likewise.
* testsuite/gas/i386/reloc64.d: Updated.
* testsuite/gas/i386/x86-64-jump.d: Likewise.
* testsuite/gas/i386/x86-64-mpx-branch-1.d: Likewise.
* testsuite/gas/i386/x86-64-mpx-branch-2.d: Likewise.
* testsuite/gas/i386/x86-64-relax-2.d: Likewise.
* testsuite/gas/i386/x86-64-relax-3.d: Likewise.
* testsuite/gas/i386/ilp32/reloc64.d: Likewise.
* testsuite/gas/i386/ilp32/x86-64-branch.d: Likewise.
ld/
PR gas/22791
* testsuite/ld-x86-64/mpx1c.rd: Updated.
* testsuite/ld-x86-64/pr22791-1.err: New file.
* testsuite/ld-x86-64/pr22791-1a.c: Likewise.
* testsuite/ld-x86-64/pr22791-1b.s: Likewise.
* testsuite/ld-x86-64/pr22791-2.rd: Likewise.
* testsuite/ld-x86-64/pr22791-2a.s: Likewise.
* testsuite/ld-x86-64/pr22791-2b.c: Likewise.
* testsuite/ld-x86-64/pr22791-2c.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run PR ld/22791 tests.
Index: binutils-2.42/bfd/elf64-x86-64.c
===================================================================
--- binutils-2.42.orig/bfd/elf64-x86-64.c 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/bfd/elf64-x86-64.c 2024-01-30 16:57:58.483994137 +0100
@@ -1981,6 +1981,24 @@ elf_x86_64_convert_load_reloc (bfd *abfd
return true;
}
+/* Is the instruction before OFFSET in CONTENTS a 32bit relative
+ branch? */
+
+static bool
+is_32bit_relative_branch (bfd_byte *contents, bfd_vma offset)
+{
+ /* Opcode Instruction
+ 0xe8 call
+ 0xe9 jump
+ 0x0f 0x8x conditional jump */
+ return ((offset > 0
+ && (contents [offset - 1] == 0xe8
+ || contents [offset - 1] == 0xe9))
+ || (offset > 1
+ && contents [offset - 2] == 0x0f
+ && (contents [offset - 1] & 0xf0) == 0x80));
+}
+
/* Look through the relocs for a section during the first phase, and
calculate needed space in the global offset table, and procedure
linkage table. */
@@ -3337,9 +3355,6 @@ elf_x86_64_relocate_section (bfd *output
&& (eh == NULL
|| !UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
eh)))
- || (bfd_link_pie (info)
- && !SYMBOL_DEFINED_NON_SHARED_P (h)
- && h->def_dynamic)
|| (no_copyreloc_p
&& h->def_dynamic
&& !(h->root.u.def.section->flags & SEC_CODE))))
@@ -3348,20 +3363,25 @@ elf_x86_64_relocate_section (bfd *output
|| bfd_link_dll (info)))
{
bool fail = false;
+ bool branch
+ = ((r_type == R_X86_64_PC32
+ || r_type == R_X86_64_PC32_BND)
+ && is_32bit_relative_branch (contents, rel->r_offset));
+
if (SYMBOL_REFERENCES_LOCAL_P (info, h))
{
/* Symbol is referenced locally. Make sure it is
- defined locally. */
- fail = !SYMBOL_DEFINED_NON_SHARED_P (h);
+ defined locally or for a branch. */
+ fail = !SYMBOL_DEFINED_NON_SHARED_P (h) && !branch;
}
else if (bfd_link_pie (info))
{
/* We can only use PC-relative relocations in PIE
- from non-code sections. */
+ from non-code sections or branches. */
if (h->root.type == bfd_link_hash_undefweak
|| (h->type == STT_FUNC
&& (sec->flags & SEC_CODE) != 0))
- fail = true;
+ fail = !branch;
}
else if (no_copyreloc_p || bfd_link_dll (info))
{
@@ -3370,9 +3390,10 @@ elf_x86_64_relocate_section (bfd *output
relocations against default and protected
symbols since address of protected function
and location of protected data may not be in
- the shared object. */
+ the shared object. We do allow branch to symbol
+ with non-default visibility. */
fail = (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
- || ELF_ST_VISIBILITY (h->other) == STV_PROTECTED);
+ || !branch);
}
if (fail)
Index: binutils-2.42/gas/config/tc-i386.c
===================================================================
--- binutils-2.42.orig/gas/config/tc-i386.c 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/config/tc-i386.c 2024-01-30 16:58:57.504959847 +0100
@@ -10699,55 +10699,12 @@ output_branch (void)
frag_var (rs_machine_dependent, 5, i.reloc[0], subtype, sym, off, p);
}
-#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
-/* Return TRUE iff PLT32 relocation should be used for branching to
- symbol S. */
-
-static bool
-need_plt32_p (symbolS *s)
-{
- /* PLT32 relocation is ELF only. */
- if (!IS_ELF)
- return false;
-
-#ifdef TE_SOLARIS
- /* Don't emit PLT32 relocation on Solaris: neither native linker nor
- krtld support it. */
- return false;
-#endif
-
- /* Since there is no need to prepare for PLT branch on x86-64, we
- can generate R_X86_64_PLT32, instead of R_X86_64_PC32, which can
- be used as a marker for 32-bit PC-relative branches. */
- if (!object_64bit)
- return false;
-
- if (s == NULL)
- return false;
-
- /* Weak or undefined symbol need PLT32 relocation. */
- if (S_IS_WEAK (s) || !S_IS_DEFINED (s))
- return true;
-
- /* Non-global symbol doesn't need PLT32 relocation. */
- if (! S_IS_EXTERNAL (s))
- return false;
-
- /* Other global symbols need PLT32 relocation. NB: Symbol with
- non-default visibilities are treated as normal global symbol
- so that PLT32 relocation can be used as a marker for 32-bit
- PC-relative branches. It is useful for linker relaxation. */
- return true;
-}
-#endif
-
static void
output_jump (void)
{
char *p;
int size;
fixS *fixP;
- bfd_reloc_code_real_type jump_reloc = i.reloc[0];
if (i.tm.opcode_modifier.jump == JUMP_BYTE)
{
@@ -10821,17 +10778,8 @@ output_jump (void)
abort ();
}
-#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
- if (flag_code == CODE_64BIT && size == 4
- && jump_reloc == NO_RELOC && i.op[0].disps->X_add_number == 0
- && need_plt32_p (i.op[0].disps->X_add_symbol))
- jump_reloc = BFD_RELOC_X86_64_PLT32;
-#endif
-
- jump_reloc = reloc (size, 1, 1, jump_reloc);
-
fixP = fix_new_exp (frag_now, p - frag_now->fr_literal, size,
- i.op[0].disps, 1, jump_reloc);
+ i.op[0].disps, 1, reloc (size, 1, 1, i.reloc[0]));
/* All jumps handled here are signed, but don't unconditionally use a
signed limit check for 32 and 16 bit jumps as we want to allow wrap
@@ -15083,12 +15031,6 @@ md_estimate_size_before_relax (fragS *fr
reloc_type = (enum bfd_reloc_code_real) fragP->fr_var;
else if (size == 2)
reloc_type = BFD_RELOC_16_PCREL;
-#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
- else if (fragP->tc_frag_data.code == CODE_64BIT
- && fragP->fr_offset == 0
- && need_plt32_p (fragP->fr_symbol))
- reloc_type = BFD_RELOC_X86_64_PLT32;
-#endif
else
reloc_type = BFD_RELOC_32_PCREL;
Index: binutils-2.42/gas/testsuite/gas/i386/ilp32/reloc64.d
===================================================================
--- binutils-2.42.orig/gas/testsuite/gas/i386/ilp32/reloc64.d 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/testsuite/gas/i386/ilp32/reloc64.d 2024-01-30 16:57:58.487327524 +0100
@@ -17,7 +17,7 @@ Disassembly of section \.text:
.*[ ]+R_X86_64_PC8[ ]+xtrn\+0x0*1
.*[ ]+R_X86_64_PC32[ ]+xtrn-0x0*4
.*[ ]+R_X86_64_PC32[ ]+xtrn-0x0*4
-.*[ ]+R_X86_64_PLT32[ ]+xtrn-0x0*4
+.*[ ]+R_X86_64_PC32[ ]+xtrn-0x0*4
.*[ ]+R_X86_64_PC8[ ]+xtrn-0x0*1
.*[ ]+R_X86_64_GOT32[ ]+xtrn
.*[ ]+R_X86_64_GOT32[ ]+xtrn
Index: binutils-2.42/gas/testsuite/gas/i386/ilp32/x86-64-branch.d
===================================================================
--- binutils-2.42.orig/gas/testsuite/gas/i386/ilp32/x86-64-branch.d 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/testsuite/gas/i386/ilp32/x86-64-branch.d 2024-01-30 16:57:58.487327524 +0100
@@ -20,9 +20,9 @@ Disassembly of section .text:
[ ]*[a-f0-9]+: 66 ff 20 data16 jmp \*\(%rax\)
[ ]*[a-f0-9]+: e8 00 00 00 00 call (0x)?1f <.*> 1b: R_X86_64_PC32 \*ABS\*\+0x10003c
[ ]*[a-f0-9]+: e9 00 00 00 00 jmp (0x)?24 <.*> 20: R_X86_64_PC32 \*ABS\*\+0x10003c
-[ ]*[a-f0-9]+: 66 e8 00 00 00 00 data16 call (0x)?2a <.*> 26: R_X86_64_PLT32 foo-0x4
-[ ]*[a-f0-9]+: 66 e9 00 00 00 00 data16 jmp (0x)?30 <.*> 2c: R_X86_64_PLT32 foo-0x4
-[ ]*[a-f0-9]+: 66 0f 82 00 00 00 00 data16 jb (0x)?37 <.*> 33: R_X86_64_PLT32 foo-0x4
+[ ]*[a-f0-9]+: 66 e8 00 00 00 00 data16 call (0x)?2a <.*> 26: R_X86_64_PC32 foo-0x4
+[ ]*[a-f0-9]+: 66 e9 00 00 00 00 data16 jmp (0x)?30 <.*> 2c: R_X86_64_PC32 foo-0x4
+[ ]*[a-f0-9]+: 66 0f 82 00 00 00 00 data16 jb (0x)?37 <.*> 33: R_X86_64_PC32 foo-0x4
[ ]*[a-f0-9]+: 66 c3 data16 ret
[ ]*[a-f0-9]+: 66 c2 08 00 data16 ret \$0x8
[ ]*[a-f0-9]+: 3e 74 03[ ]+je,pt +[0-9a-fx]+ <.*>
Index: binutils-2.42/gas/testsuite/gas/i386/reloc64.d
===================================================================
--- binutils-2.42.orig/gas/testsuite/gas/i386/reloc64.d 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/testsuite/gas/i386/reloc64.d 2024-01-30 16:57:58.487327524 +0100
@@ -20,7 +20,7 @@ Disassembly of section \.text:
.*[ ]+R_X86_64_PC8[ ]+xtrn\+0x0*1
.*[ ]+R_X86_64_PC32[ ]+xtrn-0x0*4
.*[ ]+R_X86_64_PC32[ ]+xtrn-0x0*4
-.*[ ]+R_X86_64_PLT32[ ]+xtrn-0x0*4
+.*[ ]+R_X86_64_PC32[ ]+xtrn-0x0*4
.*[ ]+R_X86_64_PC8[ ]+xtrn-0x0*1
.*[ ]+R_X86_64_GOT64[ ]+xtrn
.*[ ]+R_X86_64_GOT32[ ]+xtrn
Index: binutils-2.42/gas/testsuite/gas/i386/x86-64-branch-2.d
===================================================================
--- binutils-2.42.orig/gas/testsuite/gas/i386/x86-64-branch-2.d 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/testsuite/gas/i386/x86-64-branch-2.d 2024-01-30 16:57:58.487327524 +0100
@@ -9,12 +9,12 @@ Disassembly of section .text:
0+ <bar-0xb>:
[ ]*[a-f0-9]+: 66 e9 00 00 jmpw 4 <bar-0x7> 2: R_X86_64_PC16 foo-0x2
-[ ]*[a-f0-9]+: 66 48 e9 00 00 00 00 data16 rex\.W jmp b <bar> 7: R_X86_64_PLT32 foo-0x4
+[ ]*[a-f0-9]+: 66 48 e9 00 00 00 00 data16 rex\.W jmp b <bar> 7: R_X86_64_PC32 foo-0x4
0+b <bar>:
[ ]*[a-f0-9]+: 89 c3 mov %eax,%ebx
[ ]*[a-f0-9]+: 66 e8 00 00 callw 11 <bar\+0x6> f: R_X86_64_PC16 foo-0x2
-[ ]*[a-f0-9]+: 66 48 e8 00 00 00 00 data16 rex\.W call 18 <bar\+0xd> 14: R_X86_64_PLT32 foo-0x4
+[ ]*[a-f0-9]+: 66 48 e8 00 00 00 00 data16 rex\.W call 18 <bar\+0xd> 14: R_X86_64_PC32 foo-0x4
[ ]*[a-f0-9]+: 66 c3 retw
[ ]*[a-f0-9]+: 66 c2 08 00 retw \$0x8
#pass
Index: binutils-2.42/gas/testsuite/gas/i386/x86-64-jump.d
===================================================================
--- binutils-2.42.orig/gas/testsuite/gas/i386/x86-64-jump.d 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/testsuite/gas/i386/x86-64-jump.d 2024-01-30 16:57:58.487327524 +0100
@@ -9,7 +9,7 @@ Disassembly of section .text:
0+ <.text>:
[ ]*[a-f0-9]+: eb fe jmp (0x0|0 <.text>)
-[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 0x7 3: R_X86_64_PLT32 xxx-0x4
+[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 0x7 3: R_X86_64_PC32 xxx-0x4
[ ]*[a-f0-9]+: ff 24 25 00 00 00 00 jmp \*0x0 a: R_X86_64_32S xxx
[ ]*[a-f0-9]+: ff e7 jmp \*%rdi
[ ]*[a-f0-9]+: ff 27 jmp \*\(%rdi\)
@@ -18,7 +18,7 @@ Disassembly of section .text:
[ ]*[a-f0-9]+: ff 2c 25 00 00 00 00 ljmp \*0x0 24: R_X86_64_32S xxx
[ ]*[a-f0-9]+: 66 ff 2c 25 00 00 00 00 ljmpw \*0x0 2c: R_X86_64_32S xxx
[ ]*[a-f0-9]+: e8 cb ff ff ff call 0x0
-[ ]*[a-f0-9]+: e8 00 00 00 00 call 0x3a 36: R_X86_64_PLT32 xxx-0x4
+[ ]*[a-f0-9]+: e8 00 00 00 00 call 0x3a 36: R_X86_64_PC32 xxx-0x4
[ ]*[a-f0-9]+: ff 14 25 00 00 00 00 call \*0x0 3d: R_X86_64_32S xxx
[ ]*[a-f0-9]+: ff d7 call \*%rdi
[ ]*[a-f0-9]+: ff 17 call \*\(%rdi\)
Index: binutils-2.42/gas/testsuite/gas/i386/x86-64-nop-3.d
===================================================================
--- binutils-2.42.orig/gas/testsuite/gas/i386/x86-64-nop-3.d 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/testsuite/gas/i386/x86-64-nop-3.d 2024-01-30 16:57:58.487327524 +0100
@@ -18,5 +18,5 @@ Disassembly of section .text:
Disassembly of section .altinstr_replacement:
0+ <.altinstr_replacement>:
- +[a-f0-9]+: e9 00 00 00 00 jmp 5 <_start\+0x5> 1: R_X86_64_PLT32 foo-0x4
+ +[a-f0-9]+: e9 00 00 00 00 jmp 5 <_start\+0x5> 1: R_X86_64_PC32 foo-0x4
#pass
Index: binutils-2.42/gas/testsuite/gas/i386/x86-64-nop-4.d
===================================================================
--- binutils-2.42.orig/gas/testsuite/gas/i386/x86-64-nop-4.d 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/testsuite/gas/i386/x86-64-nop-4.d 2024-01-30 16:57:58.487327524 +0100
@@ -21,5 +21,5 @@ Disassembly of section .altinstr_replace
+[a-f0-9]+: 89 c0 mov %eax,%eax
+[a-f0-9]+: 89 c0 mov %eax,%eax
+[a-f0-9]+: 89 c0 mov %eax,%eax
- +[a-f0-9]+: e9 00 00 00 00 jmp b <_start\+0xb> 7: R_X86_64_PLT32 foo-0x4
+ +[a-f0-9]+: e9 00 00 00 00 jmp b <_start\+0xb> 7: R_X86_64_PC32 foo-0x4
#pass
Index: binutils-2.42/gas/testsuite/gas/i386/x86-64-nop-5.d
===================================================================
--- binutils-2.42.orig/gas/testsuite/gas/i386/x86-64-nop-5.d 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/testsuite/gas/i386/x86-64-nop-5.d 2024-01-30 16:57:58.487327524 +0100
@@ -24,5 +24,5 @@ Disassembly of section .altinstr_replace
+[a-f0-9]+: 89 c0 mov %eax,%eax
+[a-f0-9]+: 89 c0 mov %eax,%eax
+[a-f0-9]+: 89 c0 mov %eax,%eax
- +[a-f0-9]+: e9 00 00 00 00 jmp d <_start\+0xd> 9: R_X86_64_PLT32 foo-0x4
+ +[a-f0-9]+: e9 00 00 00 00 jmp d <_start\+0xd> 9: R_X86_64_PC32 foo-0x4
#pass
Index: binutils-2.42/gas/testsuite/gas/i386/x86-64-relax-2.d
===================================================================
--- binutils-2.42.orig/gas/testsuite/gas/i386/x86-64-relax-2.d 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/testsuite/gas/i386/x86-64-relax-2.d 2024-01-30 16:57:58.487327524 +0100
@@ -11,12 +11,12 @@ Disassembly of section .text:
0+ <foo>:
[ ]*[a-f0-9]+: eb 24 jmp 26 <local>
[ ]*[a-f0-9]+: eb 1e jmp 22 <hidden_def>
-[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 9 <foo\+0x9> 5: R_X86_64_PLT32 global_def-0x4
+[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 9 <foo\+0x9> 5: R_X86_64_PC32 global_def-0x4
[ ]*[a-f0-9]+: e9 00 00 00 00 jmp e <foo\+0xe> a: R_X86_64_PLT32 global_def-0x4
-[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 13 <foo\+0x13> f: R_X86_64_PLT32 weak_def-0x4
-[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 18 <foo\+0x18> 14: R_X86_64_PLT32 weak_hidden_undef-0x4
-[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 1d <foo\+0x1d> 19: R_X86_64_PLT32 weak_hidden_def-0x4
-[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 22 <hidden_def> 1e: R_X86_64_PLT32 hidden_undef-0x4
+[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 13 <foo\+0x13> f: R_X86_64_PC32 weak_def-0x4
+[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 18 <foo\+0x18> 14: R_X86_64_PC32 weak_hidden_undef-0x4
+[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 1d <foo\+0x1d> 19: R_X86_64_PC32 weak_hidden_def-0x4
+[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 22 <hidden_def> 1e: R_X86_64_PC32 hidden_undef-0x4
0+22 <hidden_def>:
[ ]*[a-f0-9]+: c3 ret
Index: binutils-2.42/gas/testsuite/gas/i386/x86-64-relax-3.d
===================================================================
--- binutils-2.42.orig/gas/testsuite/gas/i386/x86-64-relax-3.d 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/gas/testsuite/gas/i386/x86-64-relax-3.d 2024-01-30 16:57:58.487327524 +0100
@@ -12,10 +12,10 @@ Disassembly of section .text:
[ ]*[a-f0-9]+: eb 1b jmp 1f <hidden_def>
[ ]*[a-f0-9]+: eb 1b jmp 21 <global_def>
[ ]*[a-f0-9]+: e9 00 00 00 00 jmp b <foo\+0xb> 7: R_X86_64_PLT32 global_def-0x4
-[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 10 <foo\+0x10> c: R_X86_64_PLT32 weak_def-0x4
-[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 15 <foo\+0x15> 11: R_X86_64_PLT32 weak_hidden_undef-0x4
-[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 1a <foo\+0x1a> 16: R_X86_64_PLT32 weak_hidden_def-0x4
-[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 1f <hidden_def> 1b: R_X86_64_PLT32 hidden_undef-0x4
+[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 10 <foo\+0x10> c: R_X86_64_PC32 weak_def-0x4
+[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 15 <foo\+0x15> 11: R_X86_64_PC32 weak_hidden_undef-0x4
+[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 1a <foo\+0x1a> 16: R_X86_64_PC32 weak_hidden_def-0x4
+[ ]*[a-f0-9]+: e9 00 00 00 00 jmp 1f <hidden_def> 1b: R_X86_64_PC32 hidden_undef-0x4
0+1f <hidden_def>:
[ ]*[a-f0-9]+: c3 ret
Index: binutils-2.42/ld/testsuite/ld-x86-64/pr22791-1.err
===================================================================
--- binutils-2.42.orig/ld/testsuite/ld-x86-64/pr22791-1.err 2024-01-29 01:00:00.000000000 +0100
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,2 +0,0 @@
-.*relocation R_X86_64_PC32 against symbol `foo' can not be used when making a PIE object; recompile with -fPIE
-#...
Index: binutils-2.42/ld/testsuite/ld-x86-64/pr22791-1a.c
===================================================================
--- binutils-2.42.orig/ld/testsuite/ld-x86-64/pr22791-1a.c 2024-01-29 01:00:00.000000000 +0100
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,4 +0,0 @@
-void
-foo (void)
-{
-}
Index: binutils-2.42/ld/testsuite/ld-x86-64/pr22791-1b.s
===================================================================
--- binutils-2.42.orig/ld/testsuite/ld-x86-64/pr22791-1b.s 2024-01-29 01:00:00.000000000 +0100
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,7 +0,0 @@
- .text
- .globl main
- .type main, @function
-main:
- movl foo(%rip), %eax
- .size main, .-main
- .section .note.GNU-stack
Index: binutils-2.42/ld/testsuite/ld-x86-64/pr22791-2.rd
===================================================================
--- binutils-2.42.orig/ld/testsuite/ld-x86-64/pr22791-2.rd 2024-01-29 01:00:00.000000000 +0100
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,6 +0,0 @@
-#failif
-#...
-.*\(TEXTREL\).*
-#...
-[0-9a-f ]+R_X86_64_NONE.*
-#...
Index: binutils-2.42/ld/testsuite/ld-x86-64/pr22791-2a.s
===================================================================
--- binutils-2.42.orig/ld/testsuite/ld-x86-64/pr22791-2a.s 2024-01-29 01:00:00.000000000 +0100
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,8 +0,0 @@
- .text
- .p2align 4,,15
- .globl foo
- .type foo, @function
-foo:
- jmp bar
- .size foo, .-foo
- .section .note.GNU-stack,"",@progbits
Index: binutils-2.42/ld/testsuite/ld-x86-64/pr22791-2b.c
===================================================================
--- binutils-2.42.orig/ld/testsuite/ld-x86-64/pr22791-2b.c 2024-01-29 01:00:00.000000000 +0100
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,7 +0,0 @@
-#include <stdio.h>
-
-void
-bar (void)
-{
- puts ("PASS");
-}
Index: binutils-2.42/ld/testsuite/ld-x86-64/pr22791-2c.s
===================================================================
--- binutils-2.42.orig/ld/testsuite/ld-x86-64/pr22791-2c.s 2024-01-29 01:00:00.000000000 +0100
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,12 +0,0 @@
- .text
- .p2align 4,,15
- .globl main
- .type main, @function
-main:
- subq $8, %rsp
- call foo
- xorl %eax, %eax
- addq $8, %rsp
- ret
- .size main, .-main
- .section .note.GNU-stack,"",@progbits
Index: binutils-2.42/ld/testsuite/ld-x86-64/pr22842b.S
===================================================================
--- binutils-2.42.orig/ld/testsuite/ld-x86-64/pr22842b.S 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/ld/testsuite/ld-x86-64/pr22842b.S 2024-01-30 16:57:58.487327524 +0100
@@ -7,7 +7,7 @@ main:
leaq bar(%rip), %rdi
addq %rax, %rdi
- callq foo
+ callq foo@PLT
xorl %eax, %eax
popq %rcx
retq
Index: binutils-2.42/ld/testsuite/ld-x86-64/x86-64.exp
===================================================================
--- binutils-2.42.orig/ld/testsuite/ld-x86-64/x86-64.exp 2024-01-29 01:00:00.000000000 +0100
+++ binutils-2.42/ld/testsuite/ld-x86-64/x86-64.exp 2024-01-30 16:57:58.487327524 +0100
@@ -1235,44 +1235,6 @@ if { [isnative] && [check_compiler_avail
"pr22393-3-static" \
] \
[list \
- "Build pr22791-1.so" \
- "-shared" \
- "-fPIC -Wa,-mx86-used-note=yes" \
- { pr22791-1a.c } \
- {} \
- "pr22791-1.so" \
- ] \
- [list \
- "Build pr22791-1" \
- "-pie -Wl,--no-as-needed,-z,notext tmpdir/pr22791-1.so" \
- "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
- { pr22791-1b.s } \
- {{error_output "pr22791-1.err"}} \
- "pr22791-1" \
- ] \
- [list \
- "Build pr22791-2a.o" \
- "" \
- "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
- { pr22791-2a.s } \
- ] \
- [list \
- "Build pr22791-2.so" \
- "-shared tmpdir/pr22791-2a.o" \
- "-fPIC -Wa,-mx86-used-note=yes" \
- { pr22791-2b.c } \
- {{readelf -drW pr22791-2.rd}} \
- "pr22791-2.so" \
- ] \
- [list \
- "Build pr22791-2" \
- "-pie -Wl,--no-as-needed tmpdir/pr22791-2.so" \
- "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
- { pr22791-2c.s } \
- {{readelf -drW pr22791-2.rd}} \
- "pr22791-2" \
- ] \
- [list \
"Build pr22842.so" \
"-shared" \
"-fPIC -Wa,-mx86-used-note=yes" \
@@ -1762,15 +1724,6 @@ if { [isnative] && [check_compiler_avail
"pass.out" \
] \
[list \
- "Run pr22791-2" \
- "-pie -Wl,--no-as-needed tmpdir/pr22791-2.so" \
- "-Wa,-mx86-used-note=yes" \
- { pr22791-2c.s } \
- "pr22791-2" \
- "pass.out" \
- "$NOPIE_CFLAGS" \
- ] \
- [list \
"Run pr22842" \
"-pie -Wl,--no-as-needed tmpdir/pr22842.so" \
"-Wa,-mx86-used-note=yes" \

375
binutils-revert-rela.diff Normal file
View File

@ -0,0 +1,375 @@
This is for bsc#1198422
This essentially reverts commit 17c6c3b99156fe82c1e637e1a5fd9f163ac788c8
to return back to old behaviour regarding RELA relocs: old binutils
used the relocated field as additional addend, relying on it being
zero for normal RELA behaviour. This isn't correct according to the
psABI, but some old tools (e.g. older ICC) emit object files where
the in-field "addend" is to be used (and record the zero in the A field
of the RELA reloc). This change was included starting with binutils 2.37,
but for older codestreams we want to be compatible with the old (buggy)
behaviour. We revert the change for all relocs and not just those for
which it arguably made some sense or where we had a report about (PLT32).
On x86-64 this reversion interacts with the linker support for DT_RELR,
i.e. packed relative relocs. To calculate the info for that the linker
goes through the input relocation multiple times and the obvious result
with the above reversion happens: the addends are added multiple times
resulting in those packed relative relocs to all have an addend twice
as large as wanted. As old codestreams don't have the necessary support
for DT_RELR anyway (in the dynamic linker) we disable it whole-sale as
well. Only x86-64 and ppc64(le) have packed relative relocs
and while ppc64le DT_RELR support would work there's still the problem
of missing support in ld.so.
(This also disables the few explicit dt-relr tests that don't use the
proper predicate to guard themself)
Index: binutils-2.43/bfd/elf64-x86-64.c
===================================================================
--- binutils-2.43.orig/bfd/elf64-x86-64.c 2024-08-06 16:48:34.104745566 +0200
+++ binutils-2.43/bfd/elf64-x86-64.c 2024-08-06 16:48:36.554787135 +0200
@@ -48,127 +48,127 @@ static reloc_howto_type x86_64_elf_howto
bfd_elf_generic_reloc, "R_X86_64_NONE", false, 0, 0x00000000,
false),
HOWTO(R_X86_64_64, 0, 8, 64, false, 0, complain_overflow_dont,
- bfd_elf_generic_reloc, "R_X86_64_64", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_64", false, MINUS_ONE, MINUS_ONE,
false),
HOWTO(R_X86_64_PC32, 0, 4, 32, true, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_PC32", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_PC32", false, 0xffffffff, 0xffffffff,
true),
HOWTO(R_X86_64_GOT32, 0, 4, 32, false, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_GOT32", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_GOT32", false, 0xffffffff, 0xffffffff,
false),
HOWTO(R_X86_64_PLT32, 0, 4, 32, true, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_PLT32", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_PLT32", false, 0xffffffff, 0xffffffff,
true),
HOWTO(R_X86_64_COPY, 0, 4, 32, false, 0, complain_overflow_bitfield,
- bfd_elf_generic_reloc, "R_X86_64_COPY", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_COPY", false, 0xffffffff, 0xffffffff,
false),
HOWTO(R_X86_64_GLOB_DAT, 0, 8, 64, false, 0, complain_overflow_dont,
- bfd_elf_generic_reloc, "R_X86_64_GLOB_DAT", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_GLOB_DAT", false, MINUS_ONE, MINUS_ONE,
false),
HOWTO(R_X86_64_JUMP_SLOT, 0, 8, 64, false, 0, complain_overflow_dont,
- bfd_elf_generic_reloc, "R_X86_64_JUMP_SLOT", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_JUMP_SLOT", false, MINUS_ONE, MINUS_ONE,
false),
HOWTO(R_X86_64_RELATIVE, 0, 8, 64, false, 0, complain_overflow_dont,
- bfd_elf_generic_reloc, "R_X86_64_RELATIVE", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_RELATIVE", false, MINUS_ONE, MINUS_ONE,
false),
HOWTO(R_X86_64_GOTPCREL, 0, 4, 32, true, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_GOTPCREL", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_GOTPCREL", false, 0xffffffff, 0xffffffff,
true),
HOWTO(R_X86_64_32, 0, 4, 32, false, 0, complain_overflow_unsigned,
- bfd_elf_generic_reloc, "R_X86_64_32", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_32", false, 0xffffffff, 0xffffffff,
false),
HOWTO(R_X86_64_32S, 0, 4, 32, false, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_32S", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_32S", false, 0xffffffff, 0xffffffff,
false),
HOWTO(R_X86_64_16, 0, 2, 16, false, 0, complain_overflow_bitfield,
- bfd_elf_generic_reloc, "R_X86_64_16", false, 0, 0xffff, false),
+ bfd_elf_generic_reloc, "R_X86_64_16", false, 0xffff, 0xffff, false),
HOWTO(R_X86_64_PC16, 0, 2, 16, true, 0, complain_overflow_bitfield,
- bfd_elf_generic_reloc, "R_X86_64_PC16", false, 0, 0xffff, true),
+ bfd_elf_generic_reloc, "R_X86_64_PC16", false, 0xffff, 0xffff, true),
HOWTO(R_X86_64_8, 0, 1, 8, false, 0, complain_overflow_bitfield,
- bfd_elf_generic_reloc, "R_X86_64_8", false, 0, 0xff, false),
+ bfd_elf_generic_reloc, "R_X86_64_8", false, 0xff, 0xff, false),
HOWTO(R_X86_64_PC8, 0, 1, 8, true, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_PC8", false, 0, 0xff, true),
+ bfd_elf_generic_reloc, "R_X86_64_PC8", false, 0xff, 0xff, true),
HOWTO(R_X86_64_DTPMOD64, 0, 8, 64, false, 0, complain_overflow_dont,
- bfd_elf_generic_reloc, "R_X86_64_DTPMOD64", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_DTPMOD64", false, MINUS_ONE, MINUS_ONE,
false),
HOWTO(R_X86_64_DTPOFF64, 0, 8, 64, false, 0, complain_overflow_dont,
- bfd_elf_generic_reloc, "R_X86_64_DTPOFF64", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_DTPOFF64", false, MINUS_ONE, MINUS_ONE,
false),
HOWTO(R_X86_64_TPOFF64, 0, 8, 64, false, 0, complain_overflow_dont,
- bfd_elf_generic_reloc, "R_X86_64_TPOFF64", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_TPOFF64", false, MINUS_ONE, MINUS_ONE,
false),
HOWTO(R_X86_64_TLSGD, 0, 4, 32, true, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_TLSGD", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_TLSGD", false, 0xffffffff, 0xffffffff,
true),
HOWTO(R_X86_64_TLSLD, 0, 4, 32, true, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_TLSLD", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_TLSLD", false, 0xffffffff, 0xffffffff,
true),
HOWTO(R_X86_64_DTPOFF32, 0, 4, 32, false, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_DTPOFF32", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_DTPOFF32", false, 0xffffffff, 0xffffffff,
false),
HOWTO(R_X86_64_GOTTPOFF, 0, 4, 32, true, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_GOTTPOFF", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_GOTTPOFF", false, 0xffffffff, 0xffffffff,
true),
HOWTO(R_X86_64_TPOFF32, 0, 4, 32, false, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_TPOFF32", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_TPOFF32", false, 0xffffffff, 0xffffffff,
false),
HOWTO(R_X86_64_PC64, 0, 8, 64, true, 0, complain_overflow_dont,
- bfd_elf_generic_reloc, "R_X86_64_PC64", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_PC64", false, MINUS_ONE, MINUS_ONE,
true),
HOWTO(R_X86_64_GOTOFF64, 0, 8, 64, false, 0, complain_overflow_dont,
- bfd_elf_generic_reloc, "R_X86_64_GOTOFF64", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_GOTOFF64", false, MINUS_ONE, MINUS_ONE,
false),
HOWTO(R_X86_64_GOTPC32, 0, 4, 32, true, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_GOTPC32", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_GOTPC32", false, 0xffffffff, 0xffffffff,
true),
HOWTO(R_X86_64_GOT64, 0, 8, 64, false, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_GOT64", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_GOT64", false, MINUS_ONE, MINUS_ONE,
false),
HOWTO(R_X86_64_GOTPCREL64, 0, 8, 64, true, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_GOTPCREL64", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_GOTPCREL64", false, MINUS_ONE, MINUS_ONE,
true),
HOWTO(R_X86_64_GOTPC64, 0, 8, 64, true, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_GOTPC64", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_GOTPC64", false, MINUS_ONE, MINUS_ONE,
true),
HOWTO(R_X86_64_GOTPLT64, 0, 8, 64, false, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_GOTPLT64", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_GOTPLT64", false, MINUS_ONE, MINUS_ONE,
false),
HOWTO(R_X86_64_PLTOFF64, 0, 8, 64, false, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_PLTOFF64", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_PLTOFF64", false, MINUS_ONE, MINUS_ONE,
false),
HOWTO(R_X86_64_SIZE32, 0, 4, 32, false, 0, complain_overflow_unsigned,
- bfd_elf_generic_reloc, "R_X86_64_SIZE32", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_SIZE32", false, 0xffffffff, 0xffffffff,
false),
HOWTO(R_X86_64_SIZE64, 0, 8, 64, false, 0, complain_overflow_dont,
- bfd_elf_generic_reloc, "R_X86_64_SIZE64", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_SIZE64", false, MINUS_ONE, MINUS_ONE,
false),
HOWTO(R_X86_64_GOTPC32_TLSDESC, 0, 4, 32, true, 0,
complain_overflow_bitfield, bfd_elf_generic_reloc,
- "R_X86_64_GOTPC32_TLSDESC", false, 0, 0xffffffff, true),
+ "R_X86_64_GOTPC32_TLSDESC", false, 0xffffffff, 0xffffffff, true),
HOWTO(R_X86_64_TLSDESC_CALL, 0, 0, 0, false, 0,
complain_overflow_dont, bfd_elf_generic_reloc,
"R_X86_64_TLSDESC_CALL",
false, 0, 0, false),
HOWTO(R_X86_64_TLSDESC, 0, 8, 64, false, 0,
complain_overflow_dont, bfd_elf_generic_reloc,
- "R_X86_64_TLSDESC", false, 0, MINUS_ONE, false),
+ "R_X86_64_TLSDESC", false, MINUS_ONE, MINUS_ONE, false),
HOWTO(R_X86_64_IRELATIVE, 0, 8, 64, false, 0, complain_overflow_dont,
- bfd_elf_generic_reloc, "R_X86_64_IRELATIVE", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_IRELATIVE", false, MINUS_ONE, MINUS_ONE,
false),
HOWTO(R_X86_64_RELATIVE64, 0, 8, 64, false, 0, complain_overflow_dont,
- bfd_elf_generic_reloc, "R_X86_64_RELATIVE64", false, 0, MINUS_ONE,
+ bfd_elf_generic_reloc, "R_X86_64_RELATIVE64", false, MINUS_ONE, MINUS_ONE,
false),
HOWTO(R_X86_64_PC32_BND, 0, 4, 32, true, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_PC32_BND", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_PC32_BND", false, 0xffffffff, 0xffffffff,
true),
HOWTO(R_X86_64_PLT32_BND, 0, 4, 32, true, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_PLT32_BND", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_PLT32_BND", false, 0xffffffff, 0xffffffff,
true),
HOWTO(R_X86_64_GOTPCRELX, 0, 4, 32, true, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_GOTPCRELX", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_GOTPCRELX", false, 0xffffffff, 0xffffffff,
true),
HOWTO(R_X86_64_REX_GOTPCRELX, 0, 4, 32, true, 0, complain_overflow_signed,
- bfd_elf_generic_reloc, "R_X86_64_REX_GOTPCRELX", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_REX_GOTPCRELX", false, 0xffffffff, 0xffffffff,
true),
HOWTO(R_X86_64_CODE_4_GOTPCRELX, 0, 4, 32, true, 0, complain_overflow_signed,
bfd_elf_generic_reloc, "R_X86_64_CODE_4_GOTPCRELX", false, 0, 0xffffffff,
@@ -216,7 +216,7 @@ static reloc_howto_type x86_64_elf_howto
/* Use complain_overflow_bitfield on R_X86_64_32 for x32. */
HOWTO(R_X86_64_32, 0, 4, 32, false, 0, complain_overflow_bitfield,
- bfd_elf_generic_reloc, "R_X86_64_32", false, 0, 0xffffffff,
+ bfd_elf_generic_reloc, "R_X86_64_32", false, 0xffffffff, 0xffffffff,
false)
};
Index: binutils-2.43/gas/testsuite/gas/i386/rela.d
===================================================================
--- binutils-2.43.orig/gas/testsuite/gas/i386/rela.d 2024-08-06 16:48:34.104745566 +0200
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,13 +0,0 @@
-#name: x86-64 rela relocs w/ non-zero relocated fields
-#objdump: -rsj .data
-
-.*: +file format .*
-
-RELOCATION RECORDS FOR \[\.data\]:
-
-OFFSET +TYPE +VALUE
-0*0 R_X86_64_64 *q
-0*8 R_X86_64_32 *l
-
-Contents of section .data:
- 0+0 11 ?11 ?11 ?11 22 ?22 ?22 ?22 33 ?33 ?33 ?33 44 ?44 ?44 ?44 .*
Index: binutils-2.43/gas/testsuite/gas/i386/rela.s
===================================================================
--- binutils-2.43.orig/gas/testsuite/gas/i386/rela.s 2024-08-06 16:48:34.104745566 +0200
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,14 +0,0 @@
-# Note: This file is also used by an ld test case.
-
- .text
- .global _start
-_start:
- ret
-
- .data
- .p2align 4
-l: .long 0x11111111, 0x22222222
-q: .quad 0x4444444433333333
-
- .reloc l, BFD_RELOC_64, q
- .reloc q, BFD_RELOC_32, l
Index: binutils-2.43/ld/testsuite/ld-x86-64/rela.d
===================================================================
--- binutils-2.43.orig/ld/testsuite/ld-x86-64/rela.d 2024-08-06 16:48:34.104745566 +0200
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,10 +0,0 @@
-#name: x86-64 rela relocs w/ non-zero relocated fields
-#as: --64
-#source: ${srcdir}/../../../gas/testsuite/gas/i386/rela.s
-#ld: -melf_x86_64
-#objdump: -sj .data
-
-.*: +file format .*
-
-Contents of section .data:
- *[0-9a-f]*0 .8 ?.. ?.. ?.. 00 ?00 ?00 ?00 .0 ?.. ?.. ?.. 44 ?44 ?44 ?44 .*
Index: binutils-2.43/ld/testsuite/ld-x86-64/x86-64.exp
===================================================================
--- binutils-2.43.orig/ld/testsuite/ld-x86-64/x86-64.exp 2024-08-06 16:48:34.104745566 +0200
+++ binutils-2.43/ld/testsuite/ld-x86-64/x86-64.exp 2024-08-06 16:48:36.554787135 +0200
@@ -309,7 +309,6 @@ run_dump_test "apic"
run_dump_test "pcrel8"
run_dump_test "pcrel16"
run_dump_test "pcrel16-2"
-run_dump_test "rela"
run_dump_test "tlsgd2"
run_dump_test "tlsgd3"
run_dump_test "tlsgd12"
@@ -524,10 +523,10 @@ run_dump_test "pr27491-1c"
run_dump_test "pr27491-2"
run_dump_test "pr27491-3"
run_dump_test "pr27491-4"
-run_dump_test "dt-relr-1a"
-run_dump_test "dt-relr-1a-x32"
-run_dump_test "dt-relr-1b"
-run_dump_test "dt-relr-1b-x32"
+#run_dump_test "dt-relr-1a"
+#run_dump_test "dt-relr-1a-x32"
+#run_dump_test "dt-relr-1b"
+#run_dump_test "dt-relr-1b-x32"
run_dump_test "pr30787"
run_dump_test "pr31047"
run_dump_test "pr31047-x32"
Index: binutils-2.43/binutils/testsuite/lib/binutils-common.exp
===================================================================
--- binutils-2.43.orig/binutils/testsuite/lib/binutils-common.exp 2024-08-06 16:48:34.104745566 +0200
+++ binutils-2.43/binutils/testsuite/lib/binutils-common.exp 2024-08-06 16:48:36.554787135 +0200
@@ -470,6 +470,8 @@ proc supports_persistent_section {} {
# Whether a target support DT_RELR sections.
proc supports_dt_relr {} {
+ # on old codestreams we don't support DT_RELR anywhere
+ return 0
if { ([istarget x86_64-*-*]
|| [istarget i?86-*-*]
|| [istarget powerpc64*-*-*]
Index: binutils-2.43/ld/emulparams/dt-relr.sh
===================================================================
--- binutils-2.43.orig/ld/emulparams/dt-relr.sh 2024-08-06 16:48:34.104745566 +0200
+++ binutils-2.43/ld/emulparams/dt-relr.sh 2024-08-06 16:48:36.554787135 +0200
@@ -1,3 +1,8 @@
+if false; then
+ # on old codestreams we don't have the DT_RELR support in the dynamic
+ # linker, and additionally DT_RELR support will generate bad relocs
+ # when binutils-revert-rela.diff is active (as addends will be
+ # applied multiple times). Just disable all DT_RELR support.
HAVE_DT_RELR=yes
PARSE_AND_LIST_OPTIONS_PACK_RELATIVE_RELOCS='
fprintf (file, _("\
@@ -16,3 +21,5 @@ PARSE_AND_LIST_ARGS_CASE_Z_PACK_RELATIVE
PARSE_AND_LIST_OPTIONS="$PARSE_AND_LIST_OPTIONS $PARSE_AND_LIST_OPTIONS_PACK_RELATIVE_RELOCS"
PARSE_AND_LIST_ARGS_CASE_Z="$PARSE_AND_LIST_ARGS_CASE_Z $PARSE_AND_LIST_ARGS_CASE_Z_PACK_RELATIVE_RELOCS"
+
+fi
Index: binutils-2.43/ld/testsuite/ld-i386/i386.exp
===================================================================
--- binutils-2.43.orig/ld/testsuite/ld-i386/i386.exp 2024-08-06 16:48:34.104745566 +0200
+++ binutils-2.43/ld/testsuite/ld-i386/i386.exp 2024-08-06 16:48:36.554787135 +0200
@@ -507,8 +507,8 @@ run_dump_test "pr27491-1c"
run_dump_test "pr27491-2"
run_dump_test "pr27491-3"
run_dump_test "pr27491-4"
-run_dump_test "dt-relr-1a"
-run_dump_test "dt-relr-1b"
+#run_dump_test "dt-relr-1a"
+#run_dump_test "dt-relr-1b"
run_dump_test "pr28870"
run_dump_test "pr28894"
run_dump_test "pr30787"
Index: binutils-2.43/ld/testsuite/ld-powerpc/powerpc.exp
===================================================================
--- binutils-2.43.orig/ld/testsuite/ld-powerpc/powerpc.exp 2024-08-06 16:48:34.104745566 +0200
+++ binutils-2.43/ld/testsuite/ld-powerpc/powerpc.exp 2024-08-06 16:48:36.554787135 +0200
@@ -378,14 +378,14 @@ set ppc64elftests {
"-a64" {abs-reloc.s}
{{objdump {-sdr} abs-shared.d}
{readelf {-rW} abs-shared.r}} "abs-shared"}
- {"abs-pie-relr" "-melf64ppc -pie --hash-style=sysv -z pack-relative-relocs --defsym a=1 --defsym 'HIDDEN(b=2)' --defsym c=0x123456789abcdef0" ""
- "-a64" {abs-reloc.s}
- {{objdump {-sdr} abs-pie-relr.d}
- {readelf {-rW} abs-pie-relr.r}} "abs-pie-relr"}
- {"abs-shared-relr" "-melf64ppc -shared --hash-style=sysv -z pack-relative-relocs --defsym a=1 --defsym 'HIDDEN(b=2)' --defsym c=0x123456789abcdef0" ""
- "-a64" {abs-reloc.s}
- {{objdump {-sdr} abs-shared-relr.d}
- {readelf {-rW} abs-shared-relr.r}} "abs-shared-relr"}
+# {"abs-pie-relr" "-melf64ppc -pie --hash-style=sysv -z pack-relative-relocs --defsym a=1 --defsym 'HIDDEN(b=2)' --defsym c=0x123456789abcdef0" ""
+# "-a64" {abs-reloc.s}
+# {{objdump {-sdr} abs-pie-relr.d}
+# {readelf {-rW} abs-pie-relr.r}} "abs-pie-relr"}
+# {"abs-shared-relr" "-melf64ppc -shared --hash-style=sysv -z pack-relative-relocs --defsym a=1 --defsym 'HIDDEN(b=2)' --defsym c=0x123456789abcdef0" ""
+# "-a64" {abs-reloc.s}
+# {{objdump {-sdr} abs-shared-relr.d}
+# {readelf {-rW} abs-shared-relr.r}} "abs-shared-relr"}
}
set ppceabitests {
Index: binutils-2.43/gas/testsuite/gas/i386/x86-64.exp
===================================================================
--- binutils-2.43.orig/gas/testsuite/gas/i386/x86-64.exp 2024-08-06 16:48:34.104745566 +0200
+++ binutils-2.43/gas/testsuite/gas/i386/x86-64.exp 2024-08-06 16:48:36.554787135 +0200
@@ -653,7 +653,6 @@ if [is_elf_format] then {
run_list_test "reloc64" "--defsym _bad_=1"
run_list_test "x86-64-inval-tls"
run_dump_test "mixed-mode-reloc64"
- run_dump_test "rela"
run_dump_test "x86-64-ifunc"
if { [gas_32_check] } then {
run_dump_test "x86-64-opcode-inval"

127
binutils-skip-rpaths.patch Normal file
View File

@ -0,0 +1,127 @@
diff --git a/ld/emultempl/elf.em b/ld/emultempl/elf.em
index 42c552b36e..dd0a6b1e60 100644
--- a/ld/emultempl/elf.em
+++ b/ld/emultempl/elf.em
@@ -135,6 +135,8 @@ if test x"$LDEMUL_BEFORE_ALLOCATION" != xgld"$EMULATION_NAME"_before_allocation;
if test x"${ELF_INTERPRETER_NAME}" = x; then
ELF_INTERPRETER_NAME=NULL
fi
+
+ libpath_nl=`echo ${NATIVE_LIB_DIRS// /\\\n}`
fragment <<EOF
/* This is called after the sections have been attached to output
diff --git a/ld/ldelf.c b/ld/ldelf.c
index 2e27cf48a8..7162d0cf91 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -1506,6 +1506,31 @@ ldelf_append_to_separated_string (char **to, char *op_arg)
}
}
+static int
+ldelf_is_contained (const char *path, const char *dc)
+{
+ while (*dc)
+ {
+ const char *pc = path;
+
+ while (*dc && *pc && *dc == *pc && *dc != '\n'
+ && *pc != ':' && *dc != '=')
+ {
+ dc++;
+ pc++;
+ }
+ if ((*pc == 0 || *pc == ':') && (*dc == '\n' || *dc == '=' || *dc == 0))
+ return 1;
+
+ while (*dc && *dc != '\n')
+ dc++;
+ if (*dc == '\n')
+ dc++;
+ }
+
+ return 0;
+}
+
/* This is called after the sections have been attached to output
sections, but before any sizes or addresses have been set. */
@@ -1513,7 +1538,7 @@ void
ldelf_before_allocation (char *audit, char *depaudit,
const char *default_interpreter_name)
{
- const char *rpath;
+ char *rpath;
asection *sinterp;
bfd *abfd;
struct bfd_link_hash_entry *ehdr_start = NULL;
@@ -1608,7 +1633,67 @@ ldelf_before_allocation (char *audit, char *depaudit,
by dynamic linking. */
rpath = command_line.rpath;
if (rpath == NULL)
- rpath = (const char *) getenv ("LD_RUN_PATH");
+ rpath = getenv ("LD_RUN_PATH");
+
+ if (rpath != NULL && getenv ("SUSE_IGNORED_RPATHS"))
+ {
+ char *dirs = 0;
+ FILE *ldso = fopen (getenv ("SUSE_IGNORED_RPATHS"), "r");
+ if (ldso)
+ {
+ off_t endcur = 0;
+ fseek (ldso, 0, SEEK_END);
+ endcur = ftell (ldso);
+ fseek (ldso, 0, SEEK_SET);
+ dirs = xmalloc (endcur + 1);
+ if (fread (dirs, 1, endcur, ldso) != (size_t) endcur)
+ {
+ free (dirs);
+ dirs = NULL;
+ }
+ else
+ dirs[endcur] = '\0';
+ }
+ if (dirs)
+ {
+ char *cr;
+ rpath = xstrdup (rpath);
+ cr = rpath; /* cursor read */
+
+ while (*cr)
+ {
+ if (ldelf_is_contained (cr, dirs)
+ || ldelf_is_contained (cr, "$libpath_nl"))
+ {
+ char *cc = cr, *cw = cr;
+ while (*cc && *cc != ':')
+ cc++;
+ if (*cc == ':')
+ {
+ cc++;
+ for (; *cc; cc++, cw++)
+ *cw = *cc;
+ }
+ else if (cw > rpath)
+ cw[-1] = 0;
+
+ *cw = 0;
+ }
+ else
+ {
+ while (*cr && *cr != ':')
+ cr++;
+ if (*cr == ':')
+ cr++;
+ }
+ }
+ if (*rpath == '\0')
+ {
+ free (rpath);
+ rpath = NULL;
+ }
+ }
+ }
for (abfd = link_info.input_bfds; abfd; abfd = abfd->link.next)
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)

15
binutils-znow.patch Normal file
View File

@ -0,0 +1,15 @@
Index: binutils-2.38/ld/ldmain.c
===================================================================
--- ld/ldmain.c
+++ ld/ldmain.c
@@ -309,6 +309,10 @@ main (int argc, char **argv)
#endif
if (getenv ("SUSE_ASNEEDED") && atoi(getenv ("SUSE_ASNEEDED")) > 0)
input_flags.add_DT_NEEDED_for_regular = true;
+ if (getenv ("SUSE_ZNOW") && atoi(getenv ("SUSE_ZNOW")) > 0) {
+ link_info.flags |= (bfd_vma) DF_BIND_NOW;
+ link_info.flags_1 |= (bfd_vma) DF_1_NOW;
+ }
config.build_constructors = true;
config.rpath_separator = ':';

4643
binutils.changes Normal file

File diff suppressed because it is too large Load Diff

70
binutils.keyring Normal file
View File

@ -0,0 +1,70 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFm/2cUBEADkvRqMWfAryJ52T4J/640Av5cam9ojdFih9MjcX7QWFxIzJfTF
Yq2z+nb4omdfZosdCJL2zGcn6C0AxpHNvxR9HMDkEyFHKrjDh4xWU+pH4z9azQEq
Jh331X7UzbZldqQo16VkuVavgsTJaHcXm+nGIBTcUbl2oiTtHhmuaYxx6JTMcFjC
7vyO5mLBw78wt52HBYweJ0NjHBvvH/JxbAAULSPRUC61K0exlO49VFbFETQNG1hZ
TKEji95fPbre7PpXQ0ewQShUgttEE/J3UA4jYaF9lOcZgUzbA27xTV//KomP0D30
yr4e4EJEJYYNKa3hofTEHDXeeNgM25tprhBUMdbVRZpf2Keuk2uDVwc+EiOVri48
rb1NU+60sOXvoGO6Ks81+mhAGmrBrlgLhAp8K1HPHI4MG4gHnrMqX2rEGUGRPFjC
3qqVVlPm8H05PnosNqDLQ1Pf7C0pVgsCx6hKQB7Y1qBui7aoj9zeFaQgpYef+CEE
RIKEcWwrjaOJwK3pi9HFdxS0NNWYZj8HPzz/AsgTTQdsbulPlVq2SsctmOnL42CZ
OCTppGYwl53CG/EqVY+UQBzFzJBaY8TJRFFYVEy5/HH4H11rMoZwqIkk71EOGU3X
6mWlANRikR3M4GhVITRzuaV69Fed+OeXcCmP94ASLfuhBR2uynmcHpBKpwARAQAB
tDtOaWNrIENsaWZ0b24gKENoaWVmIEJpbnV0aWxzIE1haW50YWluZXIpIDxuaWNr
Y0ByZWRoYXQuY29tPokBMwQQAQgAHRYhBB/mNI7eqCWiKXDlxI3TBA8SPMP0BQJb
cLUsAAoJEI3TBA8SPMP0yTMIAJ26/vabAMQ9Uy6THBY9akFrvtBfvhXE6lcoxlSC
tLMcxcqjT7qwA4EloZqf68HY6nIqih4bpYj2TWE7O74dI3k0NHocOeunS/P6i4Jh
sw7sECwcbk7xgy+DrxV7T5lx6Jp5g91luQuhwpJf8u5nJ0u+oJHwfnrmbHa63eqr
JUhCUAaGI4PGsYAftTK4Qwtyw/2BstR3GIt1xMfDZa5dZ9KcBe4aDJakTwU8Xsx2
t+YEa5mMXhZ5M/8cTTV2GAtsV4Ie2vY3AN5NyB3zxzUo8yCrG7WelGhx0WPVwHho
sbuPnczk7ura0LN6JHWgTBlTZO7d19Mt8I7KBrsOq+4UoL6JATMEEAEIAB0WIQRs
wFHTwdmkr54mDFjT45SsdE4uuwUCW3hZ/QAKCRDT45SsdE4uu5IyCACkc7qi2+36
zk5YYVBLg1mlYvlHp/3mwBQnhD4peAmYQgdsSxuL8AxkotQU5R2ZH7/0UhKYTwZR
JdJZmoobr+qlmzHCxMaOWIbU2V6yAPMNQC3iMo070N65Sbz+09wHQUwSiEN2QViy
sDqU6p2/0UnkqpccsdLOPjomUhbL4/2CzhUUtJuLfqmMWv6HOu4BhY+q750BAnvl
qiRjHAduYCZexZTOrdO68D90Ibfc7A7IIt9duhdvzQs+EM0Ek4r63HKs7mg9iIoY
vE6DF+EzlxLhDPUtsrOjZZkZb/G/FGIIBPnPzfz8Ucf2QN0nL7xv7svHJSyeKpcs
7HpKSlmeyF99iQEzBBABCAAdFiEE9n59boAPJA6D68hn/2rJpkZN8JwFAlr5j8UA
CgkQ/2rJpkZN8JxKKgf/aRi3G/Zz4d4bdIzZ1NSdITDL7Z9jZV/JKPkO9IW2GqBC
9t0lfeOgn7JO1VKRe9+ScipdIi12o9Oh2nlEJehTwzcHaisSZaPicekpCUfXNdeP
cfteKyATIw++XM/kMuSrIwcZSC774nj5pmkfMjOzBcIBysGmCP+O+cs2mXSWLelP
RIGg9mih1Q/sPEb6JixkKKbY1aT/VhEQt1zyP7HFUh5M+E9ySSPoLJFvEYpIvn82
OOf7bg3tbJMHV19AjlBQILKVuyZ8iOUvjnUfJZ72VN8b0C1YHG1XgLYsTkS+ShKa
HTNbHaRuiNQLYyVL8KoCJLEiObBRomamNWkFBOCusYkCOAQTAQIAIgUCWb/ZxQIb
AwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQE/zvid2ePE9cOxAA3cX1bdDa
TFttTqukdPXLCtD2aNwJos4vB4LYPSgugLkYaHIQH9d1NQPhS0TlUeovnFNESLaV
soihv0YmBUCyL4jE52FRoTjE6fUhYkFNqIWN2HYwkVrSap2UUJFquRVoVbPkbSup
8P+D8eydBbdxsY6f+5E8Rtz5ibVnPZTib7CyqnFokJITWjzGdIP0Gn+JWVa6jtHT
ImWx1MtqiuVRDapUhrIoUIjf98HQn9/N5ylEFYQTw7tzaJNWeGUoGYS8+8n/0sNb
uYQUU/zwMVY9wpJcrXaas6yZXGpF/tua59t9LFCct+07YAUSWyaBXqBW3PKQz7QP
+oE8yje91XrhOQam04eJhPIBLO88g6/UrdKaY7evBB8bJ76Zpn1yqsYOXwAxifD0
gDcRTQcB2s5MYXYmizn2GoUm1MnCJeAfQCi/YMobR+c8xEEkRU83Tnnw3pmAbRU6
OcPihEFuK/+SOMKIuV1QWmjkbAr4g9XeXvaN+TRJ9Hl/k1k/sj+uOfyGIaFzM/fp
aLmFk8vHeej4i2/C6cL4mnahwYBDHAfHO65ZUIBAssdA6AeJ+PGsYeYhqs6zkpaA
2b0wT4f9s7BPSqi0Veky8bUYYY7WpjzDcHnj1gEeIU55EhOQ42dnEfv7WrIAXanO
P8SjhgqAUkb3R88azZCpEMTHiCE4bFxzOmi5Ag0EWb/ZxQEQALaJE/3u23rTvPLk
itaTJFqKkwPVylzkwmKdvd2qeEFk1qys2J3tACTMyYVnYTSXy5EJH2zJyhUfLnhL
p8jJZF4oU5QehOaJPcMmzI/CZS1AmH+jnm6pukdZAowTzJyt4IKSapr+7mxcxX1Y
Q2XewMnFYpLkAA2dHaChLSU/EHJXe3+O4DgEURTFMa3SRN/J4GNMBacKXnMSSYyl
I5DcIOZ/v0IGa5MAXHrP1Hwm1rBmloIcgmzexczBf+IcWgCLThyFPffv+2pfLK1X
aS82OzBC7fS01pB/eDOkjQuKy16sKZX6Rt57vud40uE5a0lpyItC2P7u7QWL4yT5
pMF+oS8bm3YWgEntV380RyZpqgJGZTZLNq2T4ZgfiaueEV4JzOnG2/QRGjOUrNQa
YzKy5V127CTnRg4BYF/uLEmizLcI3O3U1+mEz6h48wkAojO1B6AZ8Lm+JuxOW5ou
GcrkTEuIG56GcDwMWS/Pw/vNsDyNmOCjy9eEKWJgmMmLaq59HpfTd8IOeaYyuAQH
AsYt/zzKy0giMgjhCQtuc99E4nQE9KZ44DKsnqRabK9s3zYE3PIkCFIEZcUiJXSX
WWOIdJ43j+YyFHU5hqXfECM6rzKGBeBUGTzyWcOX6YwRM4LzQDVJwYG8cVfth+v4
/ImcXR43D4WVxxBEAjKag02b+1yfABEBAAGJAh8EGAECAAkFAlm/2cUCGwwACgkQ
E/zvid2ePE/dqQ/6ApUwgsZztps0MOdRddjPwz44pWXS5MG45irMQXELGQyxkraf
c8lwHeABYstoK8dpopTcJGE3dZGL3JNz1YWxQ5AV4uyqBn5N8RubcA8NzR6DQP+O
GPIwzMketvVC/cbbKDZqf0uTDy3jP65OFhSkTEIynYv1Mb4JJl3Sq+haUbfWLAV5
nboSuHmiZE6Bz2+TjdoVkNwHBfpqxu6MlWka+P98SUcmY8iVhPy9QC1XFOGdFDFf
1kYgHW27mFwds35NQhNARgftAVz9FZXruW6tFIIfisjr3rVjD9R8VgL7l5vMr9yl
OFpepnI6+wd2X1566HW7F1Zw1DIrY2NHL7kL5635bHrJY4n7o/n7Elk/Ca/MAqzd
IZxz6orfXeImsqZ6ODn4Y47PToS3Tr3bMNN9N6tmOPQZkJGHDBExbhAi/Jp8fpWx
MmpVCUl6c85cOBCR4s8tZsvGYOjR3CvqKrX4bb8GElrhOvAJa6DdmZXc7AyoVMaT
vhpq3gJYKmC64oqt7zwIHwaCxTbP6C6oUp9ENRV7nHnXN3BlvIgCo4QEs6HkDzkm
gYlCEOKBiDyVMSkPDZdsspa+K4GlU2Swi/BDJMjtDxyo+K0M81LXXxOeRfEIfPtZ
3ddxBKPva1uSsuz+pbN9d1JY8Ko5T/h16susi2ReUyNJEJaSnjO5z13TQ1U=
=8syL
-----END PGP PUBLIC KEY BLOCK-----

750
binutils.spec Normal file
View File

@ -0,0 +1,750 @@
#
# spec file for package binutils
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" != ""
%define cross 1
%define targetarch %(echo %flavor | sed -e 's/i.86/i586/;s/ppc/powerpc/')
%define TARGET %targetarch
# Spec parsing does not support execution of external command,
# that's why we use the if-else chain.
%if "%{flavor}" == "i386"
ExcludeArch: %ix86
%else
%if "%{flavor}" == "arm"
ExcludeArch: %arm
%else
ExcludeArch: %{flavor}
%endif
%endif
%endif
%if "%{flavor}" == ""
Name: binutils
%else
Name: cross-%{flavor}-binutils
%endif
BuildRequires: bc
BuildRequires: bison
BuildRequires: dejagnu
BuildRequires: fdupes
BuildRequires: flex
BuildRequires: gcc-c++
# for the testsuite
%if 0%{suse_version} >= 1210
BuildRequires: glibc-devel-static
%endif
%if 0%{suse_version} > 1220
BuildRequires: makeinfo
%endif
%if 0%{suse_version} > 1110
BuildRequires: zlib-devel-static
%else
BuildRequires: zlib-devel
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
Version: 2.43
Release: 0
# disable libalternatives for now until it's changed to not
# introduce cmake/cunit-tests into the bootstrap cycle
%if 0 && 0%{?suse_version} > 1500
%bcond_without libalternatives
%else
%bcond_with libalternatives
%endif
%bcond_without bootstrap
#
# RUN_TESTS
%define run_tests %(test ! -f %_sourcedir/RUN_TESTS ; echo $?)
# check the vanilla binutils, with no patches applied
# TEST_VANILLA
%define test_vanilla %(test ! -f %_sourcedir/TEST_VANILLA ; echo $?)
#
# handle test suite failures
#
%ifarch alpha %arm aarch64 hppa mips sh4 %sparc
%define make_check_handling true
%else
# XXX check again
# XXX disabled because gold is seriously broken for now
# Note that some gold tests fail due to gcc-PIE which leads PIE executables
%define make_check_handling true
%endif
# let make check fail anyway if RUN_TESTS was requested
%if %{run_tests}
%define make_check_handling false
%endif
# handle all binary object formats supported by SUSE (and a few more)
%ifarch %ix86 %arm aarch64 ia64 ppc ppc64 ppc64le riscv64 s390 s390x x86_64 %x86_64
%define build_multitarget 1
%else
%define build_multitarget 0
%endif
%define target_list aarch64 alpha armv5l armv6l armv7l armv8l avr pru epiphany hppa hppa64 i686 ia64 m68k mips powerpc powerpc64 powerpc64le riscv64 rx s390 s390x sh4 sparc sparc64 x86_64 xtensa
%define build_gprofng 0
%if %{suse_version} > 1500
%ifarch aarch64 %ix86 x86_64 %x86_64
%define build_gprofng 1
%endif
%endif
#
#
#
URL: https://www.gnu.org/software/binutils/
PreReq: %{install_info_prereq}
# bug437293
%ifarch ppc64
Obsoletes: binutils-64bit
%endif
#
Summary: GNU Binutils
License: GFDL-1.3-only AND GPL-3.0-or-later
Group: Development/Tools/Building
Source: binutils-%{version}.tar.bz2
Source2: binutils-%{version}.tar.bz2.sig
Source3: binutils.keyring
Source4: baselibs.conf
Patch1: binutils-2.43-branch.diff.gz
Patch3: binutils-skip-rpaths.patch
Patch4: s390-biarch.diff
Patch5: x86-64-biarch.patch
Patch6: unit-at-a-time.patch
Patch8: ld-relro.diff
Patch9: testsuite.diff
Patch10: enable-targets-gold.diff
Patch12: s390-pic-dso.diff
Patch14: binutils-build-as-needed.diff
Patch15: binutils-znow.patch
Patch22: binutils-bfd_h.patch
Patch34: aarch64-common-pagesize.patch
Patch37: binutils-revert-plt32-in-branches.diff
Patch38: binutils-fix-invalid-op-errata.diff
Patch39: binutils-revert-nm-symversion.diff
Patch40: binutils-fix-abierrormsg.diff
Patch41: binutils-fix-relax.diff
Patch42: binutils-compat-old-behaviour.diff
Patch43: binutils-revert-hlasm-insns.diff
Patch44: binutils-revert-rela.diff
Patch60: binutils-disable-code-arch-error.diff
Patch90: cross-avr-nesc-as.patch
Patch92: cross-avr-omit_section_dynsym.patch
Patch93: cross-avr-size.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if %{with libalternatives}
Requires: alts
%else
PreReq: update-alternatives
%endif
%description
C compiler utilities: ar, as, gprof, ld, nm, objcopy, objdump, ranlib,
size, strings, and strip. These utilities are needed whenever you want
to compile a program or kernel.
%package gold
Summary: The gold linker
License: GPL-3.0-or-later
Group: Development/Tools/Building
Requires: binutils = %{version}-%{release}
%if %{with libalternatives}
Requires: alts
%else
PreReq: update-alternatives
%endif
%if 0%{!?cross:1} && 0%{?suse_version} >= 1310
%define gold_archs %ix86 aarch64 %arm x86_64 %x86_64 ppc ppc64 ppc64le s390x %sparc
%endif
%description gold
gold is an ELF linker. It is intended to have complete support for ELF
and to run as fast as possible on modern systems. For normal use it is
a drop-in replacement for the older GNU linker.
%package devel
Summary: GNU binutils (BFD development files)
License: GPL-3.0-or-later
Group: Development/Libraries/C and C++
Requires: binutils = %{version}-%{release}
Requires: zlib-devel
%if %{suse_version} > 1500
Requires: libzstd-devel
%endif
Provides: binutils:/usr/include/bfd.h
%description devel
This package includes header files and static libraries necessary to
build programs which use the GNU BFD library, which is part of
binutils.
%package -n libctf0
Summary: Compact C Type Format library (runtime, BFD dependency)
License: GFDL-1.3-only AND GPL-3.0-or-later
Group: Development/Tools/Building
%description -n libctf0
This package includes the libctf shared library.
The Compact C Type Format (CTF) is a way of representing information about a binary program
%package -n libctf-nobfd0
Summary: Compact C Type Format library (runtime, no BFD dependency)
License: GFDL-1.3-only AND GPL-3.0-or-later
Group: Development/Tools/Building
%description -n libctf-nobfd0
This package includes the libctf-nobfd shared library.
The Compact C Type Format (CTF) is a way of representing information about a binary program
%package -n gprofng
Summary: The next generation profiling tool for Linux
License: GFDL-1.3-only AND GPL-3.0-or-later
Group: Development/Tools/Building
%description -n gprofng
The next generation profiling tool for Linux
%ifarch %arm
%define HOST %{_target_cpu}-suse-linux-gnueabi
%else
%define HOST %(echo %{_target_cpu} | sed -s -e "s/x86_64_v./x86_64/" -e "s/parisc/hppa/" -e "s/i.86/i586/" -e "s/ppc/powerpc/" -e "s/sparc64v.*/sparc64/" -e "s/sparcv.*/sparc/")-suse-linux
%endif
%define DIST %(echo '%distribution' | sed 's/ (.*)//')
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
echo "make check will return with %{make_check_handling} in case of testsuite failures."
%setup -q -n binutils-%{version}
# Backup flex and biscon files for later verification.
cp ld/ldlex.l ld/ldlex.l.orig
cp ld/ldgram.y ld/ldgram.y.orig
# Patch is outside test_vanilla because it's supposed to be the
# patch bringing the tarball to the newest upstream version
%patch -P 1 -p1
%if !%{test_vanilla}
%patch -P 3 -p1
%patch -P 4
%patch -P 5
%patch -P 6
%patch -P 8
%patch -P 9
%patch -P 10
%patch -P 12
%patch -P 14
%patch -P 15
%patch -P 22
%patch -P 34 -p1
%if %{suse_version} < 1550
%patch -P 37 -p1
%endif
%patch -P 38
%patch -P 39 -p1
%patch -P 40 -p1
%patch -P 41 -p1
%if %{suse_version} < 1550
%patch -P 42 -p1
%patch -P 43 -p1
%patch -P 44 -p1
%endif
%patch -P 60 -p1
%if "%{TARGET}" == "avr"
cp gas/config/tc-avr.h gas/config/tc-avr-nesc.h
%patch -P 90
%patch -P 92
%patch -P 93 -p1
%endif
#
# test_vanilla
%endif
# Due to legacy flex version present in SLE-12 (and older), we cannot
# re-generate flex and bison files and so we verify that any patch modify these files.
diff -u ld/ldlex.l ld/ldlex.l.orig
diff -u ld/ldgram.y ld/ldgram.y.orig
%build
%define _lto_cflags %{nil}
sed -i -e '/BFD_VERSION_DATE/s/$/-%(echo %release | sed 's/\.[0-9]*$//')/' bfd/version.h
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -Wno-error"
%if 0%{!?cross:1}
# Building native binutils
echo "Building native binutils."
%if %build_multitarget
EXTRA_TARGETS="%(printf ,%%s-suse-linux %target_list)"
EXTRA_TARGETS="$EXTRA_TARGETS,powerpc-macos,powerpc-macos10,spu-elf,x86_64-pep,bpf-none"
%else
EXTRA_TARGETS=
%ifarch sparc
EXTRA_TARGETS="$EXTRA_TARGETS,sparc64-suse-linux"
%endif
%ifarch ppc
EXTRA_TARGETS="$EXTRA_TARGETS,powerpc64-suse-linux"
%endif
%ifarch s390
EXTRA_TARGETS="$EXTRA_TARGETS,s390x-suse-linux"
%endif
%ifarch s390x
EXTRA_TARGETS="$EXTRA_TARGETS,s390-suse-linux"
%endif
%ifarch %ix86
EXTRA_TARGETS="$EXTRA_TARGETS,x86_64-suse-linux"
%endif
%ifarch ppc ppc64 ppc64le
EXTRA_TARGETS="$EXTRA_TARGETS,spu-elf"
%endif
%ifarch %arm
EXTRA_TARGETS="$EXTRA_TARGETS,arm-suse-linux-gnueabi"
%endif
%ifarch aarch64
EXTRA_TARGETS="$EXTRA_TARGETS,aarch64-suse-linux"
%endif
%endif
# Normally we'd like to add --enable-deterministic-archives
# here (which by default makes uid/mtime be zero for archive
# members), to increase chances of getting a reproducable build
# But this breaks Makefile rules when directly accessing archives:
# rebuilding the same archive from unchanged .o files recreates
# it, because timestamps in the .a are 0, unequal to the actual timestamp
# of the .o files :-/
#
# Enable the following 2 configure options explicitly
# (--enable-warn-execstack=yes, --enable-warn-rwx-segments=yes)
# as they are not enabled by default for some targets (and we use --enable-targets=[many]).
%define common_flags CFLAGS="${RPM_OPT_FLAGS}" CXXFLAGS="${RPM_OPT_FLAGS}" \\\
--prefix=%{_prefix} --libdir=%{_libdir} \\\
--infodir=%{_infodir} --mandir=%{_mandir} \\\
--with-bugurl=https://bugs.opensuse.org/ \\\
--with-pkgversion="GNU Binutils; %{DIST}" \\\
--with-separate-debug-dir=%{_prefix}/lib/debug \\\
--with-pic --with-system-zlib --build=%{HOST}
mkdir build-dir
cd build-dir
../configure %common_flags \
${EXTRA_TARGETS:+--enable-targets="${EXTRA_TARGETS#,}"} \
--enable-plugins \
%ifarch %gold_archs
--enable-gold \
--enable-threads \
%endif
%if %{suse_version} <= 1320
CXX="g++ -std=gnu++11" \
--disable-x86-relax-relocations \
--disable-compressed-debug-sections \
%endif
%if %{suse_version} > 1320
--enable-compressed-debug-sections=gas \
%endif
%if %{suse_version} < 1550
--disable-x86-used-note \
--disable-separate-code \
%endif
--enable-new-dtags \
%if "%{TARGET}" != "mips"
--enable-default-hash-style=both \
%endif
--enable-shared \
%if %{suse_version} > 1500
%if %{with bootstrap} && 0%{?do_profiling}
--enable-pgo-build=lto \
%endif
--enable-colored-disassembly \
%endif
%if ! %build_gprofng
--disable-gprofng \
%endif
--enable-obsolete \
--enable-warn-execstack=yes \
--enable-warn-rwx-segments=yes
#FIXME: enable in the future
#%if %{suse_version} > 1550
# --enable-default-compressed-debug-sections-algorithm=zstd \
#%endif
# we patch headers (bfd-in.h) that are input to other headers
# which are generated only with --enable-maintainer-mode (which we
# don't do) or explicitely by make headers, so do this:
make %{?make_output_sync} %{?_smp_mflags} all-bfd TARGET-bfd=headers V=1
# the above interacts with --enable-pgo-build=lto because all-bfd doesn't
# have the PGO handling, hence it's config.cache files are wrong
# remove all of those for reconfigure
rm */config.cache
# force reconfiguring
rm bfd/Makefile
make %{?make_output_sync} %{?_smp_mflags} V=1
%else
# building cross-TARGET-binutils
echo "Building cross binutils."
mkdir build-dir
cd build-dir
EXTRA_TARGETS=
%if "%{TARGET}" == "sparc"
EXTRA_TARGETS="$EXTRA_TARGETS,sparc64-suse-linux"
%endif
%if "%{TARGET}" == "powerpc"
EXTRA_TARGETS="$EXTRA_TARGETS,powerpc64-suse-linux"
%endif
%if "%{TARGET}" == "s390"
EXTRA_TARGETS="$EXTRA_TARGETS,s390x-suse-linux"
%endif
%if "%{TARGET}" == "s390x"
EXTRA_TARGETS="$EXTRA_TARGETS,s390-suse-linux"
%endif
%if "%{TARGET}" == "i586"
EXTRA_TARGETS="$EXTRA_TARGETS,x86_64-suse-linux"
%endif
%if "%{TARGET}" == "hppa"
EXTRA_TARGETS="$EXTRA_TARGETS,hppa64-suse-linux"
%endif
%if "%{TARGET}" == "arm"
EXTRA_TARGETS="$EXTRA_TARGETS,arm-suse-linux-gnueabi"
%endif
%if "%{TARGET}" == "aarch64"
EXTRA_TARGETS="$EXTRA_TARGETS,aarch64-suse-linux"
%endif
%if "%{TARGET}" == "avr" || "%{TARGET}" == "spu" || "%{TARGET}" == "pru"
%define TARGET_OS %{TARGET}
%else
%if "%{TARGET}" == "epiphany" || "%{TARGET}" == "riscv32" || "%{TARGET}" == "rx"
%define TARGET_OS %{TARGET}-elf
%else
%if "%{TARGET}" == "arm"
%define TARGET_OS %{TARGET}-suse-linux-gnueabi
%else
%if "%{TARGET}" == "bpf"
%define TARGET_OS %{TARGET}-none
%else
%define TARGET_OS %{TARGET}-suse-linux
%endif
%endif
%endif
%endif
../configure CFLAGS="${RPM_OPT_FLAGS}" \
--prefix=%{_prefix} \
--with-bugurl=https://bugs.opensuse.org/ \
--with-pkgversion="GNU Binutils; %{DIST}" \
--with-system-zlib \
--disable-nls \
--enable-new-dtags \
--enable-obsolete \
--disable-gprofng \
%if %{suse_version} <= 1320
--disable-x86-relax-relocations \
%endif
--build=%{HOST} --target=%{TARGET_OS} \
%if "%{TARGET}" == "spu"
--with-sysroot=/usr/spu \
%else
--with-sysroot=%{_prefix}/%{TARGET_OS}/sys-root \
%endif
%if "%{TARGET}" != "mips"
--enable-default-hash-style=both \
%endif
${EXTRA_TARGETS:+--enable-targets="${EXTRA_TARGETS#,}"}
make %{?make_output_sync} %{?_smp_mflags} all-bfd TARGET-bfd=headers V=1
rm */config.cache
# force reconfiguring
rm bfd/Makefile
make %{?make_output_sync} %{?_smp_mflags} V=1
%if "%{TARGET}" == "avr"
# build an extra nesC version because nesC requires $'s in identifiers
cp -a gas gas-nesc
echo '#include "tc-%{TARGET}-nesc.h"' > gas-nesc/targ-cpu.h
make -C gas-nesc clean
make -C gas-nesc %{?make_output_sync} %{?_smp_mflags}
%endif
%endif
%check
unset SUSE_ASNEEDED
# newer distros set this envvar (e.g. to get deterministic archives by default)
# but of course that breaks tests that precisely are
# designed for checking file replacement in archives based on mtime.
# just get rid of it for the binutils testsuite
unset SOURCE_DATE_EPOCH
cd build-dir
%if 0%{?cross:1}
make -k check CFLAGS="-O2 -g" CXXFLAGS="-O2 -g" CFLAGS_FOR_TARGET="-O2 -g" CXXFLAGS_FOR_TARGET="-O2 -g" || %{make_check_handling}
%else
# _FORTIFY_SOURCE does not work with -O0
make -k check CFLAGS="-g $RPM_OPT_FLAGS -U_FORTIFY_SOURCE" CXXFLAGS="-g $RPM_OPT_FLAGS -U_FORTIFY_SOURCE" CFLAGS_FOR_TARGET="-g $RPM_OPT_FLAGS -U_FORTIFY_SOURCE" CXXFLAGS_FOR_TARGET="-g $RPM_OPT_FLAGS -U_FORTIFY_SOURCE" || %{make_check_handling}
%endif
%install
cd build-dir
%if 0%{!?cross:1}
# installing native binutils
%ifarch %gold_archs
make DESTDIR=%{buildroot} install-gold
ln -sf ld.gold %{buildroot}%{_bindir}/gold
%endif
make DESTDIR=%{buildroot} install-info install
make DESTDIR=%{buildroot} install-bfd install-opcodes
if [ ! -f "%{buildroot}/%_bindir/ld.bfd" ]; then
mv "%{buildroot}/%_bindir"/{ld,ld.bfd};
else
rm -f "%{buildroot}/%_bindir/ld";
fi
%if ! 0%{with libalternatives}
mkdir -p "%{buildroot}/%_sysconfdir/alternatives";
# Keep older versions of brp-symlink happy
%if %{suse_version} < 1310
ln -s "%_bindir/ld" "%{buildroot}/%_sysconfdir/alternatives/ld"
%endif
ln -s "%_sysconfdir/alternatives/ld" "%{buildroot}/%_bindir/ld";
%else
ln -s %{_bindir}/alts "%{buildroot}/%_bindir/ld";
mkdir -p %{buildroot}%{_datadir}/libalternatives/ld;
cat > %{buildroot}%{_datadir}/libalternatives/ld/1.conf <<EOF
binary=%{_bindir}/ld.gold
EOF
cat > %{buildroot}%{_datadir}/libalternatives/ld/2.conf <<EOF
binary=%{_bindir}/ld.bfd
EOF
%endif
rm -rf %{buildroot}%{_prefix}/%{HOST}/bin
mkdir -p %{buildroot}%{_prefix}/%{HOST}/bin
ln -sf ../../bin/{ar,as,ld,nm,ranlib,strip} %{buildroot}%{_prefix}/%{HOST}/bin
mv %{buildroot}%{_prefix}/%{HOST}/lib/ldscripts $RPM_BUILD_ROOT%{_libdir}
rm -f $RPM_BUILD_ROOT%{_libdir}/ldscripts/stamp
ln -sf ../../%{_lib}/ldscripts %{buildroot}%{_prefix}/%{HOST}/lib/ldscripts
# Install header files
make -C libiberty install_to_libdir target_header_dir=/usr/include DESTDIR=%{buildroot}
# We want the PIC libiberty.a
install -m 644 libiberty/pic/libiberty.a %{buildroot}%{_libdir}
#
chmod a+x %{buildroot}%{_libdir}/libbfd-*
chmod a+x %{buildroot}%{_libdir}/libopcodes-*
# No shared linking outside binutils
rm %{buildroot}%{_libdir}/lib{bfd,opcodes}.so
rm %{buildroot}%{_libdir}/lib{bfd,opcodes,ctf,ctf-nobfd}.la
rm -f %{buildroot}%{_libdir}/gprofng/lib*.{l,}a
# Remove unwanted files to shut up rpm
rm -f %{buildroot}%{_infodir}/configure* $RPM_BUILD_ROOT%{_infodir}/standards.info*
rm -f %{buildroot}%{_mandir}/man1/dlltool.1 $RPM_BUILD_ROOT%{_mandir}/man1/windres.1 $RPM_BUILD_ROOT%{_mandir}/man1/windmc.1
cd ..
%find_lang binutils
%find_lang bfd binutils.lang
%find_lang gas binutils.lang
%find_lang ld binutils.lang
%find_lang opcodes binutils.lang
%find_lang gprof binutils.lang
%ifarch %gold_archs
%find_lang gold binutils-gold.lang
%endif
mkdir -p %{buildroot}%{_docdir}/%{name}
install -m 644 binutils/NEWS %{buildroot}%{_docdir}/%{name}/NEWS-binutils
install -m 644 gas/NEWS %{buildroot}%{_docdir}/%{name}/NEWS-gas
install -m 644 ld/NEWS %{buildroot}%{_docdir}/%{name}/NEWS-ld
%else
# installing cross-TARGET-binutils and TARGET-binutils
make DESTDIR=%{buildroot} install
# Replace hard links by symlinks, so that rpmlint doesn't complain
T=$(basename %{buildroot}/usr/%{TARGET_OS})
for f in %{buildroot}/usr/$T/bin/* ; do
ln -sf /usr/bin/$T-$(basename $f) $f
done
%if "%{TARGET}" == "arm"
# Instead of building duplicate binutils, add symlinks
for f in %{buildroot}%{_bindir}/${T}-* ; do
_toolname=${f##$(dirname $f)/${T}-}
for p in arm-none-eabi; do
ln -sf %{_bindir}/$T-${_toolname} %{buildroot}%{_bindir}/$p-${_toolname}
done
done
%endif
%if "%{TARGET}" == "riscv64"
# Instead of building duplicate binutils, add symlinks
for f in %{buildroot}/usr/$T/bin/* ; do
for p in riscv64-elf; do
ln -sf %{_bindir}/$T-$(basename $f) %{buildroot}%{_bindir}/$p-$(basename $f)
done
done
%endif
%if "%{TARGET}" == "avr"
install -c gas-nesc/as-new %{buildroot}%{_prefix}/bin/%{TARGET_OS}-nesc-as
ln -sf ../../bin/%{TARGET_OS}-nesc-as %{buildroot}%{_prefix}/%{TARGET_OS}/bin/nesc-as
%endif
rm -rf %{buildroot}%{_mandir}
rm -rf %{buildroot}%{_infodir}
rm -rf %{buildroot}%{_prefix}/lib*
rm -rf %{buildroot}%{_prefix}/include
rm -f %{buildroot}%{_prefix}/bin/*-c++filt
> ../binutils.lang
%endif
%fdupes %{buildroot}%{_prefix}
%if 0%{!?cross:1}
%post
/sbin/ldconfig
%if ! %{with libalternatives}
"%_sbindir/update-alternatives" --install \
"%_bindir/ld" ld "%_bindir/ld.bfd" 2
%endif
%install_info --info-dir=%{_infodir} %{_infodir}/as.info.gz
%install_info --info-dir=%{_infodir} %{_infodir}/bfd.info.gz
%install_info --info-dir=%{_infodir} %{_infodir}/binutils.info.gz
%install_info --info-dir=%{_infodir} %{_infodir}/gprof.info.gz
%install_info --info-dir=%{_infodir} %{_infodir}/ld.info.gz
%if ! %{with libalternatives}
%post gold
"%_sbindir/update-alternatives" --install \
"%_bindir/ld" ld "%_bindir/ld.gold" 1
%endif
%post -n libctf0 -p /sbin/ldconfig
%post -n libctf-nobfd0 -p /sbin/ldconfig
%if %{with libalternatives}
%pre
# removing old update-alternatives entries
if [ "$1" -gt 0 ] && [ -f %{_sbindir}/update-alternatives ] ; then
"%_sbindir/update-alternatives" --remove ld "%_bindir/ld.bfd";
fi;
%pre gold
# removing old update-alternatives entries
if [ "$1" -gt 0 ] && [ -f %{_sbindir}/update-alternatives ] ; then
"%_sbindir/update-alternatives" --remove ld "%_bindir/ld.gold";
fi;
%endif
%preun
%install_info_delete --info-dir=%{_infodir} %{_infodir}/as.info.gz
%install_info_delete --info-dir=%{_infodir} %{_infodir}/bfd.info.gz
%install_info_delete --info-dir=%{_infodir} %{_infodir}/binutils.info.gz
%install_info_delete --info-dir=%{_infodir} %{_infodir}/gprof.info.gz
%install_info_delete --info-dir=%{_infodir} %{_infodir}/ld.info.gz
%if ! %{with libalternatives}
if [ "$1" = 0 ]; then
"%_sbindir/update-alternatives" --remove ld "%_bindir/ld.bfd";
fi;
%endif
%if ! %{with libalternatives}
%preun gold
if [ "$1" = 0 ]; then
"%_sbindir/update-alternatives" --remove ld "%_bindir/ld.gold";
fi;
%endif
%postun -n libctf0 -p /sbin/ldconfig
%postun -n libctf-nobfd0 -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%endif
%files -f binutils.lang
%defattr(-,root,root)
%if 0%{!?cross:1}
%{_docdir}/%{name}
%{_prefix}/%{HOST}/bin/*
%{_prefix}/%{HOST}/lib/ldscripts
%{_libdir}/ldscripts
%{_libdir}/libsframe.so.*
%if %build_gprofng
%{_libdir}/libgprofng.so.*
%endif
%dir %{_libdir}/bfd-plugins
%{_libdir}/bfd-plugins/libdep.so
%{_bindir}/*
%if ! 0%{with libalternatives}
%ghost %_sysconfdir/alternatives/ld
%else
%dir %{_datadir}/libalternatives
%dir %{_datadir}/libalternatives/ld
%{_datadir}/libalternatives/ld/2.conf
%endif
%ifarch %gold_archs
%exclude %{_bindir}/gold
%exclude %{_bindir}/ld.gold
%endif
%doc %{_infodir}/*.gz
%{_libdir}/lib*-%{version}*.so
%doc %{_mandir}/man1/*.1.gz
%else
%{_prefix}/%{TARGET_OS}
%{_prefix}/bin/*
%endif
%ifarch %gold_archs
%files gold -f binutils-gold.lang
%defattr(-,root,root)
%doc gold/NEWS gold/README
%{_bindir}/gold
%{_bindir}/ld.gold
%if %{with libalternatives}
%dir %{_datadir}/libalternatives
%dir %{_datadir}/libalternatives/ld
%{_datadir}/libalternatives/ld/1.conf
%endif
%endif
%if 0%{!?cross:1}
%files devel
%defattr(-,root,root)
%{_prefix}/include/*.h
%{_libdir}/lib*.*a
%{_libdir}/libctf.so
%{_libdir}/libctf-nobfd.so
%{_libdir}/libsframe.so
%if %build_gprofng
%{_libdir}/libgprofng.so
%endif
%files -n libctf0
%defattr(-,root,root)
%{_libdir}/libctf.so.*
%files -n libctf-nobfd0
%defattr(-,root,root)
%{_libdir}/libctf-nobfd.so.*
%if %{suse_version} > 1500
%ifarch %ix86 x86_64 %x86_64 aarch64
%files -n gprofng
%defattr(-,root,root)
%dir %{_libdir}/gprofng/
%{_libdir}/gprofng/lib*.so
%{_distconfdir}/gprofng.rc
%endif
%endif
%endif
%changelog

40
cross-avr-nesc-as.patch Normal file
View File

@ -0,0 +1,40 @@
Index: gas/config/tc-avr-nesc.h
===================================================================
--- gas/config/tc-avr-nesc.h.orig 2016-02-01 09:58:37.419903606 +0100
+++ gas/config/tc-avr-nesc.h 2016-02-01 09:58:39.631928732 +0100
Index: gas/expr.c
@@ -143,8 +143,12 @@ extern int avr_force_relocation (struct fix *);
would print `12 34 56 78'. The default value is 4. */
#define LISTING_WORD_SIZE 2
-/* AVR port uses `$' as a logical line separator by default. */
-#define LEX_DOLLAR 0
+/* AVR port uses `$' as a logical line separator and doesn't
+ allow it in symbols. We allow it in the middle of symbols.
+ We also hack get_symbol_end to disallow it at the end of a symbol. */
+#define LEX_DOLLAR 1
+#define TC_EOL_IN_INSN(PTR) (*(PTR) == '$' && is_part_of_name((PTR)[-1]) && is_part_of_name((PTR)[1]))
+#define TC_FORBID_DOLLAR_AT_END
/* An `.lcomm' directive with no explicit alignment parameter will
use this macro to set P2VAR to the alignment that a request for
===================================================================
--- gas/expr.c.orig 2016-02-01 09:58:35.743884569 +0100
+++ gas/expr.c 2016-02-01 09:58:39.631928732 +0100
@@ -2342,6 +2342,15 @@ get_symbol_name (char ** ilp_return)
;
if (is_name_ender (c))
c = *input_line_pointer++;
+#ifdef TC_FORBID_DOLLAR_AT_END
+ /* This is for the Atmel AVR platforms. We want to allow $ in symbols
+ but also as a line separator. Yucky. */
+ if (input_line_pointer[-2] == '$')
+ {
+ input_line_pointer--;
+ c = '$';
+ }
+#endif
}
else if (c == '"')
{

View File

@ -0,0 +1,18 @@
Index: bfd/elf32-avr.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-avr.c,v
retrieving revision 1.27
diff -c -3 -p -r1.27 elf32-avr.c
*** bfd/elf32-avr.c 28 Sep 2006 13:27:33 -0000 1.27
--- bfd/elf32-avr.c 19 Jan 2007 12:22:49 -0000
*************** elf32_avr_build_stubs (struct bfd_link_i
*** 2915,2920 ****
--- 2915,2922 ----
#define elf_backend_final_write_processing \
bfd_elf_avr_final_write_processing
#define elf_backend_object_p elf32_avr_object_p
+ #define elf_backend_omit_section_dynsym \
+ _bfd_elf_omit_section_dynsym_all
#define bfd_elf32_bfd_relax_section elf32_avr_relax_section
#define bfd_elf32_bfd_get_relocated_section_contents \

445
cross-avr-size.patch Normal file
View File

@ -0,0 +1,445 @@
diff --git a/binutils/size.c b/binutils/size.c
index 8e9adcd1caa..a10d6f49601 100644
--- a/binutils/size.c
+++ b/binutils/size.c
@@ -51,6 +51,7 @@ enum output_format
{
FORMAT_BERKLEY,
FORMAT_SYSV,
+ FORMAT_AVR,
FORMAT_GNU
};
static enum output_format selected_output_format =
@@ -74,6 +75,246 @@ static bfd_size_type total_textsize;
/* Program exit status. */
static int return_code = 0;
+
+/* AVR Size specific stuff */
+
+#define AVR64 64UL
+#define AVR128 128UL
+#define AVR256 256UL
+#define AVR512 512UL
+#define AVR1K 1024UL
+#define AVR2K 2048UL
+#define AVR4K 4096UL
+#define AVR8K 8192UL
+#define AVR16K 16384UL
+#define AVR20K 20480UL
+#define AVR24K 24576UL
+#define AVR32K 32768UL
+#define AVR36K 36864UL
+#define AVR40K 40960UL
+#define AVR64K 65536UL
+#define AVR68K 69632UL
+#define AVR128K 131072UL
+#define AVR136K 139264UL
+#define AVR200K 204800UL
+#define AVR256K 262144UL
+#define AVR264K 270336UL
+
+typedef struct
+{
+ char *name;
+ long flash;
+ long ram;
+ long eeprom;
+} avr_device_t;
+
+avr_device_t avr[] =
+{
+ {"atxmega256a3", AVR264K, AVR16K, AVR4K},
+ {"atxmega256a3b", AVR264K, AVR16K, AVR4K},
+ {"atxmega256d3", AVR264K, AVR16K, AVR4K},
+
+ {"atmega2560", AVR256K, AVR8K, AVR4K},
+ {"atmega2561", AVR256K, AVR8K, AVR4K},
+
+ {"atxmega192a3", AVR200K, AVR16K, AVR2K},
+ {"atxmega192d3", AVR200K, AVR16K, AVR2K},
+
+ {"atxmega128a1", AVR136K, AVR8K, AVR2K},
+ {"atxmega128a1u", AVR136K, AVR8K, AVR2K},
+ {"atxmega128a3", AVR136K, AVR8K, AVR2K},
+ {"atxmega128d3", AVR136K, AVR8K, AVR2K},
+
+ {"at43usb320", AVR128K, 608UL, 0UL},
+ {"at90can128", AVR128K, AVR4K, AVR4K},
+ {"at90usb1286", AVR128K, AVR8K, AVR4K},
+ {"at90usb1287", AVR128K, AVR8K, AVR4K},
+ {"atmega128", AVR128K, AVR4K, AVR4K},
+ {"atmega1280", AVR128K, AVR8K, AVR4K},
+ {"atmega1281", AVR128K, AVR8K, AVR4K},
+ {"atmega1284p", AVR128K, AVR16K, AVR4K},
+ {"atmega128rfa1", AVR128K, AVR16K, AVR4K},
+ {"atmega103", AVR128K, 4000UL, AVR4K},
+
+ {"atxmega64a1", AVR68K, AVR4K, AVR2K},
+ {"atxmega64a1u", AVR68K, AVR4K, AVR2K},
+ {"atxmega64a3", AVR68K, AVR4K, AVR2K},
+ {"atxmega64d3", AVR68K, AVR4K, AVR2K},
+
+ {"at90can64", AVR64K, AVR4K, AVR2K},
+ {"at90scr100", AVR64K, AVR4K, AVR2K},
+ {"at90usb646", AVR64K, AVR4K, AVR2K},
+ {"at90usb647", AVR64K, AVR4K, AVR2K},
+ {"atmega64", AVR64K, AVR4K, AVR2K},
+ {"atmega640", AVR64K, AVR8K, AVR4K},
+ {"atmega644", AVR64K, AVR4K, AVR2K},
+ {"atmega644a", AVR64K, AVR4K, AVR2K},
+ {"atmega644p", AVR64K, AVR4K, AVR2K},
+ {"atmega644pa", AVR64K, AVR4K, AVR2K},
+ {"atmega645", AVR64K, AVR4K, AVR2K},
+ {"atmega645a", AVR64K, AVR4K, AVR2K},
+ {"atmega645p", AVR64K, AVR4K, AVR2K},
+ {"atmega6450", AVR64K, AVR4K, AVR2K},
+ {"atmega6450a", AVR64K, AVR4K, AVR2K},
+ {"atmega6450p", AVR64K, AVR4K, AVR2K},
+ {"atmega649", AVR64K, AVR4K, AVR2K},
+ {"atmega649a", AVR64K, AVR4K, AVR2K},
+ {"atmega649p", AVR64K, AVR4K, AVR2K},
+ {"atmega6490", AVR64K, AVR4K, AVR2K},
+ {"atmega6490a", AVR64K, AVR4K, AVR2K},
+ {"atmega6490p", AVR64K, AVR4K, AVR2K},
+ {"atmega64c1", AVR64K, AVR4K, AVR2K},
+ {"atmega64hve", AVR64K, AVR4K, AVR1K},
+ {"atmega64m1", AVR64K, AVR4K, AVR2K},
+ {"m3000", AVR64K, AVR4K, 0UL},
+
+ {"atmega406", AVR40K, AVR2K, AVR512},
+
+ {"atxmega32a4", AVR36K, AVR4K, AVR1K},
+ {"atxmega32d4", AVR36K, AVR4K, AVR1K},
+
+ {"at90can32", AVR32K, AVR2K, AVR1K},
+ {"at94k", AVR32K, AVR4K, 0UL},
+ {"atmega32", AVR32K, AVR2K, AVR1K},
+ {"atmega323", AVR32K, AVR2K, AVR1K},
+ {"atmega324a", AVR32K, AVR2K, AVR1K},
+ {"atmega324p", AVR32K, AVR2K, AVR1K},
+ {"atmega324pa", AVR32K, AVR2K, AVR1K},
+ {"atmega325", AVR32K, AVR2K, AVR1K},
+ {"atmega325a", AVR32K, AVR2K, AVR1K},
+ {"atmega325p", AVR32K, AVR2K, AVR1K},
+ {"atmega3250", AVR32K, AVR2K, AVR1K},
+ {"atmega3250a", AVR32K, AVR2K, AVR1K},
+ {"atmega3250p", AVR32K, AVR2K, AVR1K},
+ {"atmega328", AVR32K, AVR2K, AVR1K},
+ {"atmega328p", AVR32K, AVR2K, AVR1K},
+ {"atmega329", AVR32K, AVR2K, AVR1K},
+ {"atmega329a", AVR32K, AVR2K, AVR1K},
+ {"atmega329p", AVR32K, AVR2K, AVR1K},
+ {"atmega329pa", AVR32K, AVR2K, AVR1K},
+ {"atmega3290", AVR32K, AVR2K, AVR1K},
+ {"atmega3290a", AVR32K, AVR2K, AVR1K},
+ {"atmega3290p", AVR32K, AVR2K, AVR1K},
+ {"atmega32hvb", AVR32K, AVR2K, AVR1K},
+ {"atmega32c1", AVR32K, AVR2K, AVR1K},
+ {"atmega32hvb", AVR32K, AVR2K, AVR1K},
+ {"atmega32m1", AVR32K, AVR2K, AVR1K},
+ {"atmega32u2", AVR32K, AVR1K, AVR1K},
+ {"atmega32u4", AVR32K, 2560UL, AVR1K},
+ {"atmega32u6", AVR32K, 2560UL, AVR1K},
+
+ {"at43usb355", AVR24K, 1120UL, 0UL},
+
+ {"atxmega16a4", AVR20K, AVR2K, AVR1K},
+ {"atxmega16d4", AVR20K, AVR2K, AVR1K},
+
+ {"at76c711", AVR16K, AVR2K, 0UL},
+ {"at90pwm216", AVR16K, AVR1K, AVR512},
+ {"at90pwm316", AVR16K, AVR1K, AVR512},
+ {"at90usb162", AVR16K, AVR512, AVR512},
+ {"atmega16", AVR16K, AVR1K, AVR512},
+ {"atmega16a", AVR16K, AVR1K, AVR512},
+ {"atmega161", AVR16K, AVR1K, AVR512},
+ {"atmega162", AVR16K, AVR1K, AVR512},
+ {"atmega163", AVR16K, AVR1K, AVR512},
+ {"atmega164", AVR16K, AVR1K, AVR512},
+ {"atmega164a", AVR16K, AVR1K, AVR512},
+ {"atmega164p", AVR16K, AVR1K, AVR512},
+ {"atmega165a", AVR16K, AVR1K, AVR512},
+ {"atmega165", AVR16K, AVR1K, AVR512},
+ {"atmega165p", AVR16K, AVR1K, AVR512},
+ {"atmega168", AVR16K, AVR1K, AVR512},
+ {"atmega168a", AVR16K, AVR1K, AVR512},
+ {"atmega168p", AVR16K, AVR1K, AVR512},
+ {"atmega169", AVR16K, AVR1K, AVR512},
+ {"atmega169a", AVR16K, AVR1K, AVR512},
+ {"atmega169p", AVR16K, AVR1K, AVR512},
+ {"atmega169pa", AVR16K, AVR1K, AVR512},
+ {"atmega16hva", AVR16K, 768UL, AVR256},
+ {"atmega16hva2", AVR16K, AVR1K, AVR256},
+ {"atmega16hvb", AVR16K, AVR1K, AVR512},
+ {"atmega16m1", AVR16K, AVR1K, AVR512},
+ {"atmega16u2", AVR16K, AVR512, AVR512},
+ {"atmega16u4", AVR16K, 1280UL, AVR512},
+ {"attiny167", AVR16K, AVR512, AVR512},
+
+ {"at90c8534", AVR8K, 352UL, AVR512},
+ {"at90pwm1", AVR8K, AVR512, AVR512},
+ {"at90pwm2", AVR8K, AVR512, AVR512},
+ {"at90pwm2b", AVR8K, AVR512, AVR512},
+ {"at90pwm3", AVR8K, AVR512, AVR512},
+ {"at90pwm3b", AVR8K, AVR512, AVR512},
+ {"at90pwm81", AVR8K, AVR256, AVR512},
+ {"at90s8515", AVR8K, AVR512, AVR512},
+ {"at90s8535", AVR8K, AVR512, AVR512},
+ {"at90usb82", AVR8K, AVR512, AVR512},
+ {"ata6289", AVR8K, AVR512, 320UL},
+ {"atmega8", AVR8K, AVR1K, AVR512},
+ {"atmega8515", AVR8K, AVR512, AVR512},
+ {"atmega8535", AVR8K, AVR512, AVR512},
+ {"atmega88", AVR8K, AVR1K, AVR512},
+ {"atmega88a", AVR8K, AVR1K, AVR512},
+ {"atmega88p", AVR8K, AVR1K, AVR512},
+ {"atmega88pa", AVR8K, AVR1K, AVR512},
+ {"atmega8hva", AVR8K, 768UL, AVR256},
+ {"atmega8u2", AVR8K, AVR512, AVR512},
+ {"attiny84", AVR8K, AVR512, AVR512},
+ {"attiny84a", AVR8K, AVR512, AVR512},
+ {"attiny85", AVR8K, AVR512, AVR512},
+ {"attiny861", AVR8K, AVR512, AVR512},
+ {"attiny861a", AVR8K, AVR512, AVR512},
+ {"attiny87", AVR8K, AVR512, AVR512},
+ {"attiny88", AVR8K, AVR512, AVR64},
+
+ {"at90s4414", AVR4K, 352UL, AVR256},
+ {"at90s4433", AVR4K, AVR128, AVR256},
+ {"at90s4434", AVR4K, 352UL, AVR256},
+ {"atmega48", AVR4K, AVR512, AVR256},
+ {"atmega48a", AVR4K, AVR512, AVR256},
+ {"atmega48p", AVR4K, AVR512, AVR256},
+ {"attiny4313", AVR4K, AVR256, AVR256},
+ {"attiny43u", AVR4K, AVR256, AVR64},
+ {"attiny44", AVR4K, AVR256, AVR256},
+ {"attiny44a", AVR4K, AVR256, AVR256},
+ {"attiny45", AVR4K, AVR256, AVR256},
+ {"attiny461", AVR4K, AVR256, AVR256},
+ {"attiny461a", AVR4K, AVR256, AVR256},
+ {"attiny48", AVR4K, AVR256, AVR64},
+
+ {"at86rf401", AVR2K, 224UL, AVR128},
+ {"at90s2313", AVR2K, AVR128, AVR128},
+ {"at90s2323", AVR2K, AVR128, AVR128},
+ {"at90s2333", AVR2K, 224UL, AVR128},
+ {"at90s2343", AVR2K, AVR128, AVR128},
+ {"attiny20", AVR2K, AVR128, 0UL},
+ {"attiny22", AVR2K, 224UL, AVR128},
+ {"attiny2313", AVR2K, AVR128, AVR128},
+ {"attiny2313a", AVR2K, AVR128, AVR128},
+ {"attiny24", AVR2K, AVR128, AVR128},
+ {"attiny24a", AVR2K, AVR128, AVR128},
+ {"attiny25", AVR2K, AVR128, AVR128},
+ {"attiny26", AVR2K, AVR128, AVR128},
+ {"attiny261", AVR2K, AVR128, AVR128},
+ {"attiny261a", AVR2K, AVR128, AVR128},
+ {"attiny28", AVR2K, 0UL, 0UL},
+ {"attiny40", AVR2K, AVR256, 0UL},
+
+ {"at90s1200", AVR1K, 0UL, AVR64},
+ {"attiny9", AVR1K, 32UL, 0UL},
+ {"attiny10", AVR1K, 32UL, 0UL},
+ {"attiny11", AVR1K, 0UL, AVR64},
+ {"attiny12", AVR1K, 0UL, AVR64},
+ {"attiny13", AVR1K, AVR64, AVR64},
+ {"attiny13a", AVR1K, AVR64, AVR64},
+ {"attiny15", AVR1K, 0UL, AVR64},
+
+ {"attiny4", AVR512, 32UL, 0UL},
+ {"attiny5", AVR512, 32UL, 0UL},
+};
+
+static char *avrmcu = NULL;
+
+
static char *target = NULL;
/* Forward declarations. */
@@ -89,7 +330,8 @@ usage (FILE *stream, int status)
fprintf (stream, _(" Displays the sizes of sections inside binary files\n"));
fprintf (stream, _(" If no input file(s) are specified, a.out is assumed\n"));
fprintf (stream, _(" The options are:\n\
- -A|-B|-G --format={sysv|berkeley|gnu} Select output style (default is %s)\n\
+ -A|-B|-C|-G --format={sysv|berkeley|avr|gnu} Select output style (default is %s)\n\
+ --mcu=<avrmcu> MCU name for AVR format only\n\
-o|-d|-x --radix={8|10|16} Display numbers in octal, decimal or hex\n\
-t --totals Display the total sizes (Berkeley only)\n\
-f Ignored.\n\
@@ -114,6 +356,7 @@ usage (FILE *stream, int status)
#define OPTION_FORMAT (200)
#define OPTION_RADIX (OPTION_FORMAT + 1)
#define OPTION_TARGET (OPTION_RADIX + 1)
+#define OPTION_MCU (OPTION_TARGET + 1)
static struct option long_options[] =
{
@@ -121,6 +364,7 @@ static struct option long_options[] =
{"format", required_argument, 0, OPTION_FORMAT},
{"radix", required_argument, 0, OPTION_RADIX},
{"target", required_argument, 0, OPTION_TARGET},
+ {"mcu", required_argument, 0, 203},
{"totals", no_argument, &show_totals, 1},
{"version", no_argument, &show_version, 1},
{"help", no_argument, &show_help, 1},
@@ -152,13 +396,17 @@ main (int argc, char **argv)
fatal (_("fatal error: libbfd ABI mismatch"));
set_default_bfd_target ();
- while ((c = getopt_long (argc, argv, "ABGHhVvdfotx", long_options,
+ while ((c = getopt_long (argc, argv, "ABCGHhVvdfotx", long_options,
(int *) 0)) != EOF)
switch (c)
{
case OPTION_FORMAT:
switch (*optarg)
{
+ case 'A':
+ case 'a':
+ selected_output_format = FORMAT_AVR;
+ break;
case 'B':
case 'b':
selected_output_format = FORMAT_BERKLEY;
@@ -177,6 +425,10 @@ main (int argc, char **argv)
}
break;
+ case OPTION_MCU:
+ avrmcu = optarg;
+ break;
+
case OPTION_TARGET:
target = optarg;
break;
@@ -210,6 +462,9 @@ main (int argc, char **argv)
case 'B':
selected_output_format = FORMAT_BERKLEY;
break;
+ case 'C':
+ selected_output_format = FORMAT_AVR;
+ break;
case 'G':
selected_output_format = FORMAT_GNU;
break;
@@ -649,13 +904,115 @@ print_sysv_format (bfd *file)
printf ("\n\n");
}
+static avr_device_t *
+avr_find_device (void)
+{
+ unsigned int i;
+ if (avrmcu != NULL)
+ {
+ for (i = 0; i < sizeof(avr) / sizeof(avr[0]); i++)
+ {
+ if (strcmp(avr[i].name, avrmcu) == 0)
+ {
+ /* Match found */
+ return (&avr[i]);
+ }
+ }
+ }
+ return (NULL);
+}
+
+static void
+print_avr_format (bfd *file)
+{
+ char *avr_name = "Unknown";
+ int flashmax = 0;
+ int rammax = 0;
+ int eeprommax = 0;
+ asection *section;
+ datasize = 0;
+ textsize = 0;
+ bsssize = 0;
+ bfd_size_type bootloadersize = 0;
+ bfd_size_type noinitsize = 0;
+ bfd_size_type eepromsize = 0;
+
+ avr_device_t *avrdevice = avr_find_device();
+ if (avrdevice != NULL)
+ {
+ avr_name = avrdevice->name;
+ flashmax = avrdevice->flash;
+ rammax = avrdevice->ram;
+ eeprommax = avrdevice->eeprom;
+ }
+
+ if ((section = bfd_get_section_by_name (file, ".data")) != NULL)
+ datasize = bfd_section_size (section);
+ if ((section = bfd_get_section_by_name (file, ".text")) != NULL)
+ textsize = bfd_section_size (section);
+ if ((section = bfd_get_section_by_name (file, ".bss")) != NULL)
+ bsssize = bfd_section_size (section);
+ if ((section = bfd_get_section_by_name (file, ".bootloader")) != NULL)
+ bootloadersize = bfd_section_size (section);
+ if ((section = bfd_get_section_by_name (file, ".noinit")) != NULL)
+ noinitsize = bfd_section_size (section);
+ if ((section = bfd_get_section_by_name (file, ".eeprom")) != NULL)
+ eepromsize = bfd_section_size (section);
+
+ bfd_size_type text = textsize + datasize + bootloadersize;
+ bfd_size_type data = datasize + bsssize + noinitsize;
+ bfd_size_type eeprom = eepromsize;
+
+ printf ("AVR Memory Usage\n"
+ "----------------\n"
+ "Device: %s\n\n", avr_name);
+
+ /* Text size */
+ printf ("Program:%8ld bytes", text);
+ if (flashmax > 0)
+ {
+ printf (" (%2.1f%% Full)", ((float)text / flashmax) * 100);
+ }
+ printf ("\n(.text + .data + .bootloader)\n\n");
+
+ /* Data size */
+ printf ("Data: %8ld bytes", data);
+ if (rammax > 0)
+ {
+ printf (" (%2.1f%% Full)", ((float)data / rammax) * 100);
+ }
+ printf ("\n(.data + .bss + .noinit)\n\n");
+
+ /* EEPROM size */
+ if (eeprom > 0)
+ {
+ printf ("EEPROM: %8ld bytes", eeprom);
+ if (eeprommax > 0)
+ {
+ printf (" (%2.1f%% Full)", ((float)eeprom / eeprommax) * 100);
+ }
+ printf ("\n(.eeprom)\n\n");
+ }
+}
+
+
static void
print_sizes (bfd *file)
{
if (show_common)
calculate_common_size (file);
- if (selected_output_format == FORMAT_SYSV)
- print_sysv_format (file);
- else
- print_berkeley_or_gnu_format (file);
+ switch (selected_output_format)
+ {
+ case FORMAT_SYSV:
+ print_sysv_format (file);
+ break;
+ case FORMAT_BERKLEY:
+ case FORMAT_GNU:
+ print_berkeley_or_gnu_format (file);
+ break;
+ case FORMAT_AVR:
+ default:
+ print_avr_format (file);
+ break;
+ }
}

14
enable-targets-gold.diff Normal file
View File

@ -0,0 +1,14 @@
Index: gold/configure
===================================================================
--- gold/configure.orig 2018-07-16 09:55:04.675278145 +0200
+++ gold/configure 2018-07-16 09:55:36.007836031 +0200
@@ -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

63
ld-relro.diff Normal file
View File

@ -0,0 +1,63 @@
Index: ld/lexsup.c
===================================================================
--- ld/lexsup.c.orig 2024-08-04 01:00:00.000000000 +0200
+++ ld/lexsup.c 2024-08-06 16:02:35.554864901 +0200
@@ -772,6 +772,9 @@ parse_args (unsigned argc, char **argv)
}
}
+ optarg = "relro";
+ ldemul_handle_option ('z');
+
last_optind = -1;
while (1)
{
Index: ld/testsuite/config/default.exp
===================================================================
--- ld/testsuite/config/default.exp.orig 2024-08-04 01:00:00.000000000 +0200
+++ ld/testsuite/config/default.exp 2024-08-06 16:05:13.860859897 +0200
@@ -39,7 +39,7 @@ if [info exists env(LD_UNDER_TEST)] {
}
if ![info exists ld] then {
- set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]]
+ set ld "[findfile $base_dir/ld-new $base_dir/ld-new [transform ld]] -znorelro"
}
if ![info exists as] then {
@@ -92,7 +92,7 @@ if {[info exists ld_testsuite_bindir]} {
}
catch "exec ln -s ld tmpdir/ld/collect-ld" status
catch "exec ln -s ../../../gas/as-new tmpdir/ld/as" status
- set gcc_B_opt "-B[pwd]/tmpdir/ld/"
+ set gcc_B_opt "-B[pwd]/tmpdir/ld/ -Wl,-z,norelro"
}
# load the linker path
@@ -343,7 +343,7 @@ if ![info exists ELFEDIT] then {
}
if ![info exists LD] then {
- set LD [findfile $base_dir/ld-new ./ld-new [transform ld]]
+ set LD "[findfile $base_dir/ld-new ./ld-new [transform ld]] -znorelro"
}
if ![info exists LDFLAGS] then {
Index: ld/testsuite/ld-bootstrap/bootstrap.exp
===================================================================
--- ld/testsuite/ld-bootstrap/bootstrap.exp.orig 2024-08-04 01:00:00.000000000 +0200
+++ ld/testsuite/ld-bootstrap/bootstrap.exp 2024-08-06 16:02:35.554864901 +0200
@@ -112,7 +112,12 @@ foreach flags $test_flags {
# This test can only be run if we have the ld build directory,
# since we need the object files.
- if {[file normalize $ld] != [file normalize $objdir/ld-new]} {
+ set ldexe $ld
+ set ldparm [string first " " $ld]
+ if { $ldparm > 0 } then {
+ set ldexe [string range $ld 0 $ldparm]
+ }
+ if {[file normalize $ldexe] != [file normalize $objdir/ld-new]} {
untested $testname
continue
}

23
s390-biarch.diff Normal file
View File

@ -0,0 +1,23 @@
Index: ld/emulparams/elf_s390.sh
===================================================================
--- ld/emulparams/elf_s390.sh.orig 2024-01-29 01:00:00.000000000 +0100
+++ ld/emulparams/elf_s390.sh 2024-01-30 14:45:36.996853073 +0100
@@ -13,3 +13,18 @@ GENERATE_PIE_SCRIPT=yes
NO_SMALL_DATA=yes
IREL_IN_PLT=
SYMBOL_ABI_ALIGNMENT=2
+
+# Treat a host that matches the target with the possible exception of "x"
+# in the name as if it were native.
+if test `echo "$host" | sed -e s/x//` = `echo "$target" | sed -e s/x//`; then
+ case " $EMULATION_LIBPATH " in
+ *" ${EMULATION_NAME} "*)
+ NATIVE=yes
+ ;;
+ esac
+fi
+
+# Look for 64 bit target libraries in /lib64, /usr/lib64 etc., first.
+case "$EMULATION_NAME" in
+ *64*) LIBPATH_SUFFIX=64 ;;
+esac

32
s390-pic-dso.diff Normal file
View File

@ -0,0 +1,32 @@
Index: bfd/elf32-s390.c
===================================================================
--- bfd/elf32-s390.c.orig 2016-01-25 09:51:06.000000000 +0100
+++ bfd/elf32-s390.c 2016-01-27 15:24:52.947115619 +0100
@@ -2782,6 +2782,27 @@ elf_s390_relocate_section (bfd *output_b
case R_390_PC24DBL:
case R_390_PC32DBL:
case R_390_PC32:
+ /* This is strictly required only for PC32DBL, which
+ is not handled by ld.so, but let's be helpful to the user also
+ in the other cases. */
+ if (bfd_link_pic (info)
+ && !SYMBOL_REFERENCES_LOCAL (info, h)
+ && (input_section->flags & SEC_ALLOC) != 0
+ && (input_section->flags & SEC_READONLY) != 0
+ && (!h->def_regular
+ || r_type != R_390_PC32DBL
+ || h->type != STT_FUNC
+ || ELF_ST_VISIBILITY (h->other) != STV_PROTECTED))
+ {
+ (*_bfd_error_handler)
+ (_("%pB: relocation %s against `%s' can not be used when "
+ "making a shared object; recompile with -fPIC"),
+ input_bfd, elf_howto_table[r_type].name,
+ h->root.root.string);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
if (h != NULL
&& s390_is_ifunc_symbol_p (h)
&& h->def_regular

26
testsuite.diff Normal file
View File

@ -0,0 +1,26 @@
Index: binutils/testsuite/binutils-all/windres/windres.exp
===================================================================
--- binutils/testsuite/binutils-all/windres/windres.exp.orig
+++ binutils/testsuite/binutils-all/windres/windres.exp
@@ -36,6 +36,7 @@ set wr "$WINDRES --include-dir $srcdir/$
if [file exists "$srcdir/../../winsup/w32api/include"] {
set wr "$wr --include-dir $srcdir/../../winsup/w32api/include"
} else {
+ return
send_log "\nWarning: Assuming windres can find the win32 headers\n\n"
}
Index: ld/testsuite/ld-srec/srec.exp
===================================================================
--- ld/testsuite/ld-srec/srec.exp.orig
+++ ld/testsuite/ld-srec/srec.exp
@@ -20,6 +20,9 @@
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
# MA 02110-1301, USA.
+# Too fragile.
+return
+
# Get the offset from an S-record line to the start of the data.
proc srec_off { l } {

15
unit-at-a-time.patch Normal file
View File

@ -0,0 +1,15 @@
Index: ld/testsuite/ld-selective/selective.exp
===================================================================
--- ld/testsuite/ld-selective/selective.exp
+++ ld/testsuite/ld-selective/selective.exp
@@ -46,8 +46,8 @@ set seltests {
{A::foo() B::foo() dropme1() dropme2()} {*-*-*}}
}
-set cflags "-w -O -ffunction-sections -fdata-sections $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
-set cxxflags "-fno-exceptions -fno-rtti $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
+set cflags "-w -O -ffunction-sections -fdata-sections -fno-unit-at-a-time $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
+set cxxflags "-fno-exceptions -fno-rtti -fno-unit-at-a-time $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
set ldflags "--gc-sections -Bstatic"
if [istarget mips*-*] {

15
x86-64-biarch.patch Normal file
View File

@ -0,0 +1,15 @@
Index: ld/emulparams/elf_i386.sh
===================================================================
--- ld/emulparams/elf_i386.sh.orig 2014-10-14 17:39:02.000000000 +0200
+++ ld/emulparams/elf_i386.sh 2014-10-14 17:39:44.000000000 +0200
@@ -23,6 +23,10 @@ case "$target" in
LIBPATH_SUFFIX=32
LIBPATH_SUFFIX_SKIP=64
;;
+ *64*)
+ LIBPATH_SUFFIX=64
+ LIBPATH_SUFFIX_SKIP=32
+ ;;
esac
;;
esac