From e7b9706c4317546ed43f402dea2d1c9da5022d41 Mon Sep 17 00:00:00 2001 From: Toshaan Bharvani Date: Tue, 26 Dec 2023 14:50:41 +0100 Subject: [PATCH] initial package creation Signed-off-by: Toshaan Bharvani --- SOURCES/binutils-CIE-generation.patch | 155 ++ SOURCES/binutils-CVE-2023-25587.patch | 34 + SOURCES/binutils-aarch64-flagm.patch | 152 ++ SOURCES/binutils-aarch64-rng.patch | 53 + SOURCES/binutils-autoconf-version.patch | 11 + ...s-increase-the-max-number-of-open-fi.patch | 17 + SOURCES/binutils-ld-ir-plugin.patch | 59 + ...mory-access-when-parsing-an-elf-file.patch | 17 + .../binutils-no-comment-in-bfd-stdint.patch | 30 + SOURCES/binutils-s390-z16.patch | 51 + SOURCES/binutils-s390x-static-PIE.patch | 143 ++ SOURCES/binutils-undefined-ref-to-sym.patch | 15 + SOURCES/binutils.gold.dwarf-5-support.patch | 1299 +++++++++++++++++ SOURCES/gcc12-libtool-no-rpath.patch | 28 + SPECS/binutils.spec | 940 ++++++++---- 15 files changed, 2715 insertions(+), 289 deletions(-) create mode 100644 SOURCES/binutils-CIE-generation.patch create mode 100644 SOURCES/binutils-CVE-2023-25587.patch create mode 100644 SOURCES/binutils-aarch64-flagm.patch create mode 100644 SOURCES/binutils-aarch64-rng.patch create mode 100644 SOURCES/binutils-autoconf-version.patch create mode 100644 SOURCES/binutils-increase-the-max-number-of-open-fi.patch create mode 100644 SOURCES/binutils-ld-ir-plugin.patch create mode 100644 SOURCES/binutils-memory-access-when-parsing-an-elf-file.patch create mode 100644 SOURCES/binutils-no-comment-in-bfd-stdint.patch create mode 100644 SOURCES/binutils-s390-z16.patch create mode 100644 SOURCES/binutils-s390x-static-PIE.patch create mode 100644 SOURCES/binutils-undefined-ref-to-sym.patch create mode 100644 SOURCES/binutils.gold.dwarf-5-support.patch create mode 100644 SOURCES/gcc12-libtool-no-rpath.patch diff --git a/SOURCES/binutils-CIE-generation.patch b/SOURCES/binutils-CIE-generation.patch new file mode 100644 index 0000000..7983514 --- /dev/null +++ b/SOURCES/binutils-CIE-generation.patch @@ -0,0 +1,155 @@ +--- binutils.orig/gas/dw2gencfi.c 2022-09-08 13:54:05.539276706 +0100 ++++ binutils-2.35.2/gas/dw2gencfi.c 2022-09-08 14:05:56.128016840 +0100 +@@ -2054,6 +2054,64 @@ output_fde (struct fde_entry *fde, struc + symbol_set_value_now (end_address); + } + ++/* Allow these insns to be put in the initial sequence of a CIE. ++ If J is non-NULL, then compare I and J insns for a match. */ ++ ++static inline bfd_boolean ++initial_cie_insn (const struct cfi_insn_data *i, const struct cfi_insn_data *j) ++{ ++ if (j && i->insn != j->insn) ++ return FALSE; ++ ++ switch (i->insn) ++ { ++ case DW_CFA_offset: ++ case DW_CFA_def_cfa: ++ case DW_CFA_val_offset: ++ if (j) ++ { ++ if (i->u.ri.reg != j->u.ri.reg) ++ return FALSE; ++ if (i->u.ri.offset != j->u.ri.offset) ++ return FALSE; ++ } ++ break; ++ ++ case DW_CFA_register: ++ if (j) ++ { ++ if (i->u.rr.reg1 != j->u.rr.reg1) ++ return FALSE; ++ if (i->u.rr.reg2 != j->u.rr.reg2) ++ return FALSE; ++ } ++ break; ++ ++ case DW_CFA_def_cfa_register: ++ case DW_CFA_restore: ++ case DW_CFA_undefined: ++ case DW_CFA_same_value: ++ if (j) ++ { ++ if (i->u.r != j->u.r) ++ return FALSE; ++ } ++ break; ++ ++ case DW_CFA_def_cfa_offset: ++ if (j) ++ { ++ if (i->u.i != j->u.i) ++ return FALSE; ++ } ++ break; ++ ++ default: ++ return FALSE; ++ } ++ return TRUE; ++} ++ + static struct cie_entry * + select_cie_for_fde (struct fde_entry *fde, bfd_boolean eh_frame, + struct cfi_insn_data **pfirst, int align) +@@ -2099,71 +2157,15 @@ select_cie_for_fde (struct fde_entry *fd + i != cie->last && j != NULL; + i = i->next, j = j->next) + { +- if (i->insn != j->insn) +- goto fail; +- switch (i->insn) +- { +- case DW_CFA_advance_loc: +- case DW_CFA_remember_state: +- /* We reached the first advance/remember in the FDE, +- but did not reach the end of the CIE list. */ +- goto fail; +- +- case DW_CFA_offset: +- case DW_CFA_def_cfa: +- if (i->u.ri.reg != j->u.ri.reg) +- goto fail; +- if (i->u.ri.offset != j->u.ri.offset) +- goto fail; +- break; +- +- case DW_CFA_register: +- if (i->u.rr.reg1 != j->u.rr.reg1) +- goto fail; +- if (i->u.rr.reg2 != j->u.rr.reg2) +- goto fail; +- break; +- +- case DW_CFA_def_cfa_register: +- case DW_CFA_restore: +- case DW_CFA_undefined: +- case DW_CFA_same_value: +- if (i->u.r != j->u.r) +- goto fail; +- break; +- +- case DW_CFA_def_cfa_offset: +- if (i->u.i != j->u.i) +- goto fail; +- break; +- +- case CFI_escape: +- case CFI_val_encoded_addr: +- case CFI_label: +- /* Don't bother matching these for now. */ +- goto fail; +- +- default: +- abort (); +- } ++ if (!initial_cie_insn (i, j)) ++ break; + } + +- /* Success if we reached the end of the CIE list, and we've either +- run out of FDE entries or we've encountered an advance, +- remember, or escape. */ +- if (i == cie->last +- && (!j +- || j->insn == DW_CFA_advance_loc +- || j->insn == DW_CFA_remember_state +- || j->insn == CFI_escape +- || j->insn == CFI_val_encoded_addr +- || j->insn == CFI_label)) ++ if (i == cie->last) + { + *pfirst = j; + return cie; + } +- +- fail:; + } + + cie = XNEW (struct cie_entry); +@@ -2181,11 +2183,7 @@ select_cie_for_fde (struct fde_entry *fd + #endif + + for (i = cie->first; i ; i = i->next) +- if (i->insn == DW_CFA_advance_loc +- || i->insn == DW_CFA_remember_state +- || i->insn == CFI_escape +- || i->insn == CFI_val_encoded_addr +- || i->insn == CFI_label) ++ if (!initial_cie_insn (i, NULL)) + break; + + cie->last = i; diff --git a/SOURCES/binutils-CVE-2023-25587.patch b/SOURCES/binutils-CVE-2023-25587.patch new file mode 100644 index 0000000..ff60141 --- /dev/null +++ b/SOURCES/binutils-CVE-2023-25587.patch @@ -0,0 +1,34 @@ +--- binutils.orig/binutils/objdump.c 2023-03-03 11:37:39.209614222 +0000 ++++ binutils-2.35.2/binutils/objdump.c 2023-03-03 11:39:45.492428807 +0000 +@@ -1090,20 +1090,19 @@ compare_symbols (const void *ap, const v + return 1; + } + +- if (bfd_get_flavour (bfd_asymbol_bfd (a)) == bfd_target_elf_flavour ++ /* Sort larger size ELF symbols before smaller. See PR20337. */ ++ bfd_vma asz = 0; ++ if ((a->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0 ++ && bfd_get_flavour (bfd_asymbol_bfd (a)) == bfd_target_elf_flavour) ++ asz = ((elf_symbol_type *) a)->internal_elf_sym.st_size; ++ ++ bfd_vma bsz = 0; ++ if ((b->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0 + && bfd_get_flavour (bfd_asymbol_bfd (b)) == bfd_target_elf_flavour) +- { +- bfd_vma asz, bsz; ++ bsz = ((elf_symbol_type *) b)->internal_elf_sym.st_size; + +- asz = 0; +- if ((a->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0) +- asz = ((elf_symbol_type *) a)->internal_elf_sym.st_size; +- bsz = 0; +- if ((b->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0) +- bsz = ((elf_symbol_type *) b)->internal_elf_sym.st_size; +- if (asz != bsz) +- return asz > bsz ? -1 : 1; +- } ++ if (asz != bsz) ++ return asz > bsz ? -1 : 1; + + /* Symbols that start with '.' might be section names, so sort them + after symbols that don't start with '.'. */ diff --git a/SOURCES/binutils-aarch64-flagm.patch b/SOURCES/binutils-aarch64-flagm.patch new file mode 100644 index 0000000..9a359a3 --- /dev/null +++ b/SOURCES/binutils-aarch64-flagm.patch @@ -0,0 +1,152 @@ +diff -rup binutils.orig/gas/NEWS binutils-2.35.2/gas/NEWS +--- binutils.orig/gas/NEWS 2023-04-26 11:29:49.525097847 +0100 ++++ binutils-2.35.2/gas/NEWS 2023-04-26 11:30:59.811955065 +0100 +@@ -1,5 +1,7 @@ + -*- text -*- + ++* Add support for +flagm feature for -march in Armv8.4 AArch64. ++ + * Add support for Intel AMX instructions. + + * Add {disp16} pseudo prefix to x86 assembler. +diff -rup binutils.orig/gas/config/tc-aarch64.c binutils-2.35.2/gas/config/tc-aarch64.c +--- binutils.orig/gas/config/tc-aarch64.c 2023-04-26 11:29:48.944099025 +0100 ++++ binutils-2.35.2/gas/config/tc-aarch64.c 2023-04-26 11:31:42.994864009 +0100 +@@ -9080,6 +9080,8 @@ static const struct aarch64_option_cpu_v + AARCH64_FEATURE (AARCH64_FEATURE_SVE, 0)}, + {"f64mm", AARCH64_FEATURE (AARCH64_FEATURE_F64MM, 0), + AARCH64_FEATURE (AARCH64_FEATURE_SVE, 0)}, ++ {"flagm", AARCH64_FEATURE (AARCH64_FEATURE_FLAGM, 0), ++ AARCH64_ARCH_NONE}, + {NULL, AARCH64_ARCH_NONE, AARCH64_ARCH_NONE}, + }; + +diff -rup binutils.orig/gas/doc/c-aarch64.texi binutils-2.35.2/gas/doc/c-aarch64.texi +--- binutils.orig/gas/doc/c-aarch64.texi 2023-04-26 11:29:48.881099153 +0100 ++++ binutils-2.35.2/gas/doc/c-aarch64.texi 2023-04-26 11:32:22.402780914 +0100 +@@ -222,6 +222,8 @@ automatically cause those extensions to + @code{pmullt} and @code{pmullb} instructions. + @item @code{sve2-sha3} @tab ARMv8-A @tab No + @tab Enable SVE2 SHA3 Extension. ++@item @code{flagm} @tab ARMv8-A @tab ARMv8.4-A or later ++ @tab Enable Flag Manipulation instructions. + @end multitable + + @node AArch64 Syntax +diff -rup binutils.orig/include/opcode/aarch64.h binutils-2.35.2/include/opcode/aarch64.h +--- binutils.orig/include/opcode/aarch64.h 2023-04-26 11:29:48.702099517 +0100 ++++ binutils-2.35.2/include/opcode/aarch64.h 2023-04-26 11:35:17.346412224 +0100 +@@ -69,7 +69,7 @@ typedef uint32_t aarch64_insn; + #define AARCH64_FEATURE_AES (1ULL << 35) /* AES instructions. */ + #define AARCH64_FEATURE_F16_FML (1ULL << 36) /* v8.2 FP16FML ins. */ + #define AARCH64_FEATURE_V8_5 (1ULL << 37) /* ARMv8.5 processors. */ +-#define AARCH64_FEATURE_FLAGMANIP (1ULL << 38) /* Flag Manipulation insns. */ ++#define AARCH64_FEATURE_FLAGMANIP (1ULL << 38) /* v8.5 Flag Manipulation version 2. */ + #define AARCH64_FEATURE_FRINTTS (1ULL << 39) /* FRINT[32,64][Z,X] insns. */ + #define AARCH64_FEATURE_SB (1ULL << 40) /* SB instruction. */ + #define AARCH64_FEATURE_PREDRES (1ULL << 41) /* Execution and Data Prediction Restriction instructions. */ +@@ -84,6 +84,7 @@ typedef uint32_t aarch64_insn; + #define AARCH64_FEATURE_I8MM (1ULL << 52) /* Matrix Multiply instructions. */ + #define AARCH64_FEATURE_F32MM (1ULL << 53) + #define AARCH64_FEATURE_F64MM (1ULL << 54) ++#define AARCH64_FEATURE_FLAGM (1ULL << 55) /* v8.4 Flag Manipulation. */ + + /* Crypto instructions are the combination of AES and SHA2. */ + #define AARCH64_FEATURE_CRYPTO (AARCH64_FEATURE_SHA2 | AARCH64_FEATURE_AES) +@@ -109,6 +110,7 @@ typedef uint32_t aarch64_insn; + #define AARCH64_ARCH_V8_4 AARCH64_FEATURE (AARCH64_ARCH_V8_3, \ + AARCH64_FEATURE_V8_4 \ + | AARCH64_FEATURE_DOTPROD \ ++ | AARCH64_FEATURE_FLAGM \ + | AARCH64_FEATURE_F16_FML) + #define AARCH64_ARCH_V8_5 AARCH64_FEATURE (AARCH64_ARCH_V8_4, \ + AARCH64_FEATURE_V8_5 \ +diff -rup binutils.orig/opcodes/aarch64-tbl.h binutils-2.35.2/opcodes/aarch64-tbl.h +--- binutils.orig/opcodes/aarch64-tbl.h 2023-04-26 11:29:48.705099511 +0100 ++++ binutils-2.35.2/opcodes/aarch64-tbl.h 2023-04-26 11:37:27.299161621 +0100 +@@ -2406,6 +2406,8 @@ static const aarch64_feature_set aarch64 + static const aarch64_feature_set aarch64_feature_f64mm_sve = + AARCH64_FEATURE (AARCH64_FEATURE_V8_2 | AARCH64_FEATURE_F64MM + | AARCH64_FEATURE_SVE, 0); ++static const aarch64_feature_set aarch64_feature_flagm = ++ AARCH64_FEATURE (AARCH64_FEATURE_FLAGM, 0); + + + #define CORE &aarch64_feature_v8 +@@ -2450,6 +2452,7 @@ static const aarch64_feature_set aarch64 + #define F32MM_SVE &aarch64_feature_f32mm_sve + #define F64MM_SVE &aarch64_feature_f64mm_sve + #define I8MM &aarch64_feature_i8mm ++#define FLAGM &aarch64_feature_flagm + + #define CORE_INSN(NAME,OPCODE,MASK,CLASS,OP,OPS,QUALS,FLAGS) \ + { NAME, OPCODE, MASK, CLASS, OP, CORE, OPS, QUALS, FLAGS, 0, 0, NULL } +@@ -2553,6 +2556,8 @@ static const aarch64_feature_set aarch64 + { NAME, OPCODE, MASK, CLASS, 0, F64MM_SVE, OPS, QUALS, FLAGS, CONSTRAINTS, TIED, NULL } + #define F32MATMUL_SVE_INSNC(NAME,OPCODE,MASK,CLASS,OPS,QUALS,FLAGS, CONSTRAINTS, TIED) \ + { NAME, OPCODE, MASK, CLASS, 0, F32MM_SVE, OPS, QUALS, FLAGS, CONSTRAINTS, TIED, NULL } ++#define FLAGM_INSN(NAME,OPCODE,MASK,CLASS,OPS,QUALS,FLAGS) \ ++ { NAME, OPCODE, MASK, CLASS, 0, FLAGM, OPS, QUALS, FLAGS, 0, 0, NULL } + + struct aarch64_opcode aarch64_opcode_table[] = + { +@@ -3865,7 +3870,7 @@ struct aarch64_opcode aarch64_opcode_tab + potentially alias with too many instructions and so the tree can't be constructed. As a work + around we just place cfinv before msr. This means the order between these two shouldn't be + changed. */ +- V8_4_INSN ("cfinv", 0xd500401f, 0xffffffff, ic_system, OP0 (), {}, 0), ++ FLAGM_INSN ("cfinv", 0xd500401f, 0xffffffff, ic_system, OP0 (), {}, 0), + CORE_INSN ("msr", 0xd5000000, 0xffe00000, ic_system, 0, OP2 (SYSREG, Rt), QL_SRC_X, F_SYS_WRITE), + CORE_INSN ("sysl",0xd5280000, 0xfff80000, ic_system, 0, OP5 (Rt, UIMM3_OP1, CRn, CRm, UIMM3_OP2), QL_SYSL, 0), + CORE_INSN ("mrs", 0xd5200000, 0xffe00000, ic_system, 0, OP2 (Rt, SYSREG), QL_DST_X, F_SYS_READ), +@@ -5043,9 +5048,9 @@ struct aarch64_opcode aarch64_opcode_tab + FP16_V8_2_INSN ("fmlal2", 0x6f808000, 0xffc0f400, asimdelem, OP3 (Vd, Vn, Em16), QL_V2FML4S, 0), + FP16_V8_2_INSN ("fmlsl2", 0x6f80c000, 0xffc0f400, asimdelem, OP3 (Vd, Vn, Em16), QL_V2FML4S, 0), + /* System extensions ARMv8.4-a. */ +- V8_4_INSN ("rmif", 0xba000400, 0xffe07c10, ic_system, OP3 (Rn, IMM_2, MASK), QL_RMIF, 0), +- V8_4_INSN ("setf8", 0x3a00080d, 0xfffffc1f, ic_system, OP1 (Rn), QL_SETF, 0), +- V8_4_INSN ("setf16", 0x3a00480d, 0xfffffc1f, ic_system, OP1 (Rn), QL_SETF, 0), ++ FLAGM_INSN ("rmif", 0xba000400, 0xffe07c10, ic_system, OP3 (Rn, IMM_2, MASK), QL_RMIF, 0), ++ FLAGM_INSN ("setf8", 0x3a00080d, 0xfffffc1f, ic_system, OP1 (Rn), QL_SETF, 0), ++ FLAGM_INSN ("setf16", 0x3a00480d, 0xfffffc1f, ic_system, OP1 (Rn), QL_SETF, 0), + /* Memory access instructions ARMv8.4-a. */ + V8_4_INSN ("stlurb" , 0x19000000, 0xffe00c00, ldst_unscaled, OP2 (Rt, ADDR_OFFSET), QL_STLW, 0), + V8_4_INSN ("ldapurb", 0x19400000, 0xffe00c00, ldst_unscaled, OP2 (Rt, ADDR_OFFSET), QL_STLW, 0), +--- /dev/null 2023-04-26 09:16:03.694889721 +0100 ++++ binutils-2.35.2/gas/testsuite/gas/aarch64/flagm.d 2023-04-26 11:33:08.910682842 +0100 +@@ -0,0 +1,16 @@ ++#name: FLAGM (Condition flag manipulation) feature ++#objdump: -dr ++ ++.*: file format .* ++ ++Disassembly of section \.text: ++ ++0+ <.*>: ++.*: d500401f cfinv ++.*: ba0407cf rmif x30, #8, #15 ++.*: 3a00080d setf8 w0 ++.*: 3a00480d setf16 w0 ++.*: d500401f cfinv ++.*: ba0407cf rmif x30, #8, #15 ++.*: 3a00080d setf8 w0 ++.*: 3a00480d setf16 w0 +--- /dev/null 2023-04-26 09:16:03.694889721 +0100 ++++ binutils-2.35.2/gas/testsuite/gas/aarch64/flagm.s 2023-04-26 11:39:10.597962432 +0100 +@@ -0,0 +1,16 @@ ++/* FLAGM (Condition flag manipulation) feature from Armv8.4-A. */ ++.arch armv8.4-a ++ ++ cfinv ++ rmif x30, #8, #15 ++ setf8 w0 ++ setf16 w0 ++ ++ ++/* FLAGM feature enabled with +flagm. */ ++.arch armv8-a+flagm ++ ++ cfinv ++ rmif x30, #8, #15 ++ setf8 w0 ++ setf16 w0 diff --git a/SOURCES/binutils-aarch64-rng.patch b/SOURCES/binutils-aarch64-rng.patch new file mode 100644 index 0000000..c19b421 --- /dev/null +++ b/SOURCES/binutils-aarch64-rng.patch @@ -0,0 +1,53 @@ +Only in binutils-2.35.2/gas/testsuite/gas/aarch64: rng-1.d +Only in binutils-2.35.2/gas/testsuite/gas/aarch64: rng-1.s +diff -rup binutils.orig/opcodes/aarch64-opc.c binutils-2.35.2/opcodes/aarch64-opc.c +--- binutils.orig/opcodes/aarch64-opc.c 2022-04-05 11:50:10.131798329 +0100 ++++ binutils-2.35.2/opcodes/aarch64-opc.c 2022-04-05 11:54:32.596827591 +0100 +@@ -3810,9 +3810,6 @@ aarch64_print_operand (char *buf, size_t + #define SR_FEAT(n,e,f,feat) \ + SYSREG ((n), (e), (f) | F_ARCHEXT, AARCH64_FEATURE_##feat) + +-#define SR_RNG(n,e,f) \ +- SYSREG ((n), (e), (f) | F_ARCHEXT, AARCH64_FEATURE_RNG | AARCH64_FEATURE_V8_5) +- + #define SR_V8_1(n,e,f) SR_FEAT (n,e,f,V8_1) + #define SR_V8_2(n,e,f) SR_FEAT (n,e,f,V8_2) + #define SR_V8_3(n,e,f) SR_FEAT (n,e,f,V8_3) +@@ -3820,6 +3817,7 @@ aarch64_print_operand (char *buf, size_t + #define SR_V8_4(n,e,f) SR_FEAT (n,e,f,V8_4) + #define SR_PAN(n,e,f) SR_FEAT (n,e,f,PAN) + #define SR_RAS(n,e,f) SR_FEAT (n,e,f,RAS) ++#define SR_RNG(n,e,f) SR_FEAT (n,e,f,RNG) + #define SR_SSBS(n,e,f) SR_FEAT (n,e,f,SSBS) + #define SR_SVE(n,e,f) SR_FEAT (n,e,f,SVE) + #define SR_ID_PFR2(n,e,f) SR_FEAT (n,e,f,ID_PFR2) +--- /dev/null 2022-04-05 09:32:54.900867346 +0100 ++++ binutils-2.35.2/gas/testsuite/gas/aarch64/rng-1.s 2022-04-05 11:55:13.973674567 +0100 +@@ -0,0 +1,3 @@ ++ .arch armv8.4-a+rng ++ mrs x5, rndr ++ mrs x6, rndrrs +--- /dev/null 2022-04-05 09:32:54.900867346 +0100 ++++ binutils-2.35.2/gas/testsuite/gas/aarch64/rng-1.d 2022-04-05 11:55:45.338558554 +0100 +@@ -0,0 +1,10 @@ ++#source: rng-1.s ++#objdump: -dr ++ ++.*: file format .* ++ ++Disassembly of section \.text: ++ ++0+ <.*>: ++.*: d53b2405 mrs x5, rndr ++.*: d53b2426 mrs x6, rndrrs +--- binutils.orig/gas/config/tc-aarch64.c 2022-05-23 09:44:07.623234684 +0100 ++++ binutils-2.35.2/gas/config/tc-aarch64.c 2022-05-23 09:47:09.147696001 +0100 +@@ -9206,7 +9206,7 @@ aarch64_parse_features (const char *str, + break; + } + +- if (opt->name == NULL) ++ if (opt->name == NULL && adding_value) + { + as_bad (_("unknown architectural extension `%s'"), str); + return 0; diff --git a/SOURCES/binutils-autoconf-version.patch b/SOURCES/binutils-autoconf-version.patch new file mode 100644 index 0000000..f94fdad --- /dev/null +++ b/SOURCES/binutils-autoconf-version.patch @@ -0,0 +1,11 @@ +--- binutils.orig/config/override.m4 2021-08-31 14:20:17.275574804 +0100 ++++ binutils-2.37/config/override.m4 2021-08-31 14:36:37.793954247 +0100 +@@ -41,7 +41,7 @@ dnl Or for updating the whole tree at on + AC_DEFUN([_GCC_AUTOCONF_VERSION_CHECK], + [m4_if(m4_defn([_GCC_AUTOCONF_VERSION]), + m4_defn([m4_PACKAGE_VERSION]), [], +- [m4_fatal([Please use exactly Autoconf ]_GCC_AUTOCONF_VERSION[ instead of ]m4_defn([m4_PACKAGE_VERSION])[.])]) ++ []) + ]) + m4_define([AC_INIT], m4_defn([AC_INIT])[ + _GCC_AUTOCONF_VERSION_CHECK diff --git a/SOURCES/binutils-increase-the-max-number-of-open-fi.patch b/SOURCES/binutils-increase-the-max-number-of-open-fi.patch new file mode 100644 index 0000000..44f6116 --- /dev/null +++ b/SOURCES/binutils-increase-the-max-number-of-open-fi.patch @@ -0,0 +1,17 @@ + +diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp +index 3c129760498..dbda6c4465d 100644 +--- a/ld/testsuite/ld-plugin/lto.exp ++++ b/ld/testsuite/ld-plugin/lto.exp +@@ -721,7 +721,7 @@ if { [at_least_gcc_version 4 7] } { + ] \ + ] + set exec_output [run_host_cmd "sh" \ +- "-c \"ulimit -n 16; \ ++ "-c \" \ + $ar -rc $plug_opt \ + tmpdir/libpr23460.a \ + tmpdir/pr23460a.o \ +-- +2.38.1 + diff --git a/SOURCES/binutils-ld-ir-plugin.patch b/SOURCES/binutils-ld-ir-plugin.patch new file mode 100644 index 0000000..380f51e --- /dev/null +++ b/SOURCES/binutils-ld-ir-plugin.patch @@ -0,0 +1,59 @@ +diff -rup binutils.orig/bfd/elflink.c binutils-2.35.2/bfd/elflink.c +--- binutils.orig/bfd/elflink.c 2022-11-28 16:10:23.919422266 +0000 ++++ binutils-2.35.2/bfd/elflink.c 2022-11-28 16:14:24.308499080 +0000 +@@ -1260,14 +1260,25 @@ _bfd_elf_merge_symbol (bfd *abfd, + olddyn = (oldsec->symbol->flags & BSF_DYNAMIC) != 0; + } + +- /* Handle a case where plugin_notice won't be called and thus won't +- set the non_ir_ref flags on the first pass over symbols. */ + if (oldbfd != NULL +- && (oldbfd->flags & BFD_PLUGIN) != (abfd->flags & BFD_PLUGIN) +- && newdyn != olddyn) ++ && (oldbfd->flags & BFD_PLUGIN) != (abfd->flags & BFD_PLUGIN)) + { +- h->root.non_ir_ref_dynamic = TRUE; +- hi->root.non_ir_ref_dynamic = TRUE; ++ if (newdyn != olddyn) ++ { ++ /* Handle a case where plugin_notice won't be called and thus ++ won't set the non_ir_ref flags on the first pass over ++ symbols. */ ++ h->root.non_ir_ref_dynamic = TRUE; ++ hi->root.non_ir_ref_dynamic = TRUE; ++ } ++ ++ if ((oldbfd->flags & BFD_PLUGIN) != 0 ++ && hi->root.type == bfd_link_hash_indirect) ++ { ++ /* Change indirect symbol from IR to undefined. */ ++ hi->root.type = bfd_link_hash_undefined; ++ hi->root.u.undef.abfd = oldbfd; ++ } + } + + /* NEWDEF and OLDDEF indicate whether the new or old symbol, +diff -rup binutils.orig/bfd/linker.c binutils-2.35.2/bfd/linker.c +--- binutils.orig/bfd/linker.c 2022-11-28 16:10:23.822422639 +0000 ++++ binutils-2.35.2/bfd/linker.c 2022-11-28 16:13:28.709712603 +0000 +@@ -1672,7 +1672,7 @@ _bfd_generic_link_add_one_symbol (struct + case MIND: + /* Multiple indirect symbols. This is OK if they both point + to the same symbol. */ +- if (strcmp (h->u.i.link->root.string, string) == 0) ++ if (string != NULL && strcmp (h->u.i.link->root.string, string) == 0) + break; + /* Fall through. */ + case MDEF: +--- binutils.orig/bfd/elflink.c 2023-01-10 15:47:50.062668055 +0000 ++++ binutils-2.35.2/bfd/elflink.c 2023-01-10 15:47:59.554659559 +0000 +@@ -1271,8 +1271,7 @@ _bfd_elf_merge_symbol (bfd *abfd, + h->root.non_ir_ref_dynamic = TRUE; + hi->root.non_ir_ref_dynamic = TRUE; + } +- +- if ((oldbfd->flags & BFD_PLUGIN) != 0 ++ else if ((oldbfd->flags & BFD_PLUGIN) != 0 + && hi->root.type == bfd_link_hash_indirect) + { + /* Change indirect symbol from IR to undefined. */ diff --git a/SOURCES/binutils-memory-access-when-parsing-an-elf-file.patch b/SOURCES/binutils-memory-access-when-parsing-an-elf-file.patch new file mode 100644 index 0000000..ee3c963 --- /dev/null +++ b/SOURCES/binutils-memory-access-when-parsing-an-elf-file.patch @@ -0,0 +1,17 @@ +diff --git a/bfd/elf.c b/bfd/elf.c +index fe00e0f9189..7cd7febcf95 100644 +--- a/bfd/elf.c ++++ b/bfd/elf.c +@@ -8918,7 +8918,9 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver) + bfd_set_error (bfd_error_file_too_big); + goto error_return_verref; + } +- elf_tdata (abfd)->verref = (Elf_Internal_Verneed *) bfd_alloc (abfd, amt); ++ if (amt == 0) ++ goto error_return_verref; ++ elf_tdata (abfd)->verref = (Elf_Internal_Verneed *) bfd_zalloc (abfd, amt); + if (elf_tdata (abfd)->verref == NULL) + goto error_return_verref; + +-- +2.31.1 diff --git a/SOURCES/binutils-no-comment-in-bfd-stdint.patch b/SOURCES/binutils-no-comment-in-bfd-stdint.patch new file mode 100644 index 0000000..c0e8214 --- /dev/null +++ b/SOURCES/binutils-no-comment-in-bfd-stdint.patch @@ -0,0 +1,30 @@ +diff -rup binutils.orig/bfd/configure binutils-2.35.2/bfd/configure +--- binutils.orig/bfd/configure 2023-01-19 12:17:21.293513059 +0000 ++++ binutils-2.35.2/bfd/configure 2023-01-19 12:27:25.783974084 +0000 +@@ -18921,11 +18921,6 @@ _LT_EOF + esac + done ;; + "bfd_stdint.h":C) +-if test "$GCC" = yes; then +- echo "/* generated for " `$CC --version | sed 1q` "*/" > tmp-stdint.h +-else +- echo "/* generated for $CC */" > tmp-stdint.h +-fi + + sed 's/^ *//' >> tmp-stdint.h < tmp-stdint.h +-else +- echo "/* generated for $CC */" > tmp-stdint.h +-fi + + sed 's/^ *//' >> tmp-stdint.h <flags |= DF_STATIC_TLS; + /* Fall through */ + +@@ -1106,7 +1106,7 @@ elf_s390_check_relocs (bfd *abfd, + if (r_type == R_390_TLS_LE64 && bfd_link_pie (info)) + break; + +- if (!bfd_link_pic (info)) ++ if (!bfd_link_dll (info)) + break; + info->flags |= DF_STATIC_TLS; + /* Fall through */ +@@ -1570,7 +1570,7 @@ allocate_dynrelocs (struct elf_link_hash + to R_390_TLS_LE64 requiring no TLS entry. For GOTIE12 and IEENT + we can save the dynamic TLS relocation. */ + if (h->got.refcount > 0 +- && !bfd_link_pic (info) ++ && !bfd_link_dll (info) + && h->dynindx == -1 + && elf_s390_hash_entry(h)->tls_type >= GOT_TLS_IE) + { +@@ -1875,7 +1875,20 @@ elf_s390_size_dynamic_sections (bfd *out + else if (CONST_STRNEQ (bfd_section_name (s), ".rela")) + { + if (s->size != 0 && s != htab->elf.srelplt) +- relocs = TRUE; ++ { ++ relocs = TRUE; ++ if (s == htab->elf.irelplt) ++ { ++ /* In static-pie case, there are IRELATIVE-relocs in ++ .rela.iplt (htab->irelplt), which will later be grouped ++ to .rela.plt. On s390, the IRELATIVE relocations are ++ always located in .rela.iplt - even for non-static case. ++ Ensure that DT_JMPREL, DT_PLTRELA, DT_PLTRELASZ is added ++ to the dynamic section even if htab->srelplt->size == 0. ++ See _bfd_elf_add_dynamic_tags in bfd/elflink.c. */ ++ htab->elf.dt_jmprel_required = TRUE; ++ } ++ } + + /* We use the reloc_count field as a counter if we need + to copy relocs into the output file. */ +@@ -2661,7 +2674,7 @@ elf_s390_relocate_section (bfd *output_b + + /* Relocations for tls literal pool entries. */ + case R_390_TLS_IE64: +- if (bfd_link_pic (info)) ++ if (bfd_link_dll (info)) + { + Elf_Internal_Rela outrel; + asection *sreloc; +@@ -2689,7 +2702,7 @@ elf_s390_relocate_section (bfd *output_b + else if (h != NULL) + { + tls_type = elf_s390_hash_entry(h)->tls_type; +- if (!bfd_link_pic (info) && h->dynindx == -1 && tls_type >= GOT_TLS_IE) ++ if (!bfd_link_dll (info) && h->dynindx == -1 && tls_type >= GOT_TLS_IE) + r_type = R_390_TLS_LE64; + } + if (r_type == R_390_TLS_GD64 && tls_type >= GOT_TLS_IE) +@@ -2800,14 +2813,14 @@ elf_s390_relocate_section (bfd *output_b + if (local_got_offsets == NULL) + abort(); + off = local_got_offsets[r_symndx]; +- if (bfd_link_pic (info)) ++ if (bfd_link_dll (info)) + goto emit_tls_relocs; + } + else + { + off = h->got.offset; + tls_type = elf_s390_hash_entry(h)->tls_type; +- if (bfd_link_pic (info) || h->dynindx != -1 || tls_type < GOT_TLS_IE) ++ if (bfd_link_dll (info) || h->dynindx != -1 || tls_type < GOT_TLS_IE) + goto emit_tls_relocs; + } + +@@ -2824,7 +2837,7 @@ elf_s390_relocate_section (bfd *output_b + break; + + case R_390_TLS_LDM64: +- if (! bfd_link_pic (info)) ++ if (! bfd_link_dll (info)) + /* The literal pool entry this relocation refers to gets ignored + by the optimized code of the local exec model. Do nothing + and the value will turn out zero. */ +@@ -2899,7 +2912,7 @@ elf_s390_relocate_section (bfd *output_b + continue; + + case R_390_TLS_LDO64: +- if (bfd_link_pic (info) || (input_section->flags & SEC_DEBUGGING)) ++ if (bfd_link_dll (info) || (input_section->flags & SEC_DEBUGGING)) + relocation -= dtpoff_base (info); + else + /* When converting LDO to LE, we must negate. */ +@@ -2921,7 +2934,7 @@ elf_s390_relocate_section (bfd *output_b + + if (r_type == R_390_TLS_LOAD) + { +- if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1)) ++ if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1)) + { + /* IE->LE transition. Four valid cases: + lg %rx,(0,%ry) -> sllg %rx,%ry,0 +@@ -2971,7 +2984,7 @@ elf_s390_relocate_section (bfd *output_b + invalid_tls_insn (input_bfd, input_section, rel); + return FALSE; + } +- if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1)) ++ if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1)) + { + /* GD->LE transition. + brasl %r14,__tls_get_addr@plt -> brcl 0,. */ +@@ -2990,7 +3003,7 @@ elf_s390_relocate_section (bfd *output_b + } + else if (r_type == R_390_TLS_LDCALL) + { +- if (!bfd_link_pic (info)) ++ if (!bfd_link_dll (info)) + { + unsigned int insn0, insn1; + +Only in binutils-2.35.2/bfd: elf64-s390.c.orig +Only in binutils-2.35.2/bfd: elf64-s390.c.rej diff --git a/SOURCES/binutils-undefined-ref-to-sym.patch b/SOURCES/binutils-undefined-ref-to-sym.patch new file mode 100644 index 0000000..d0dc9a8 --- /dev/null +++ b/SOURCES/binutils-undefined-ref-to-sym.patch @@ -0,0 +1,15 @@ +--- binutils.orig/bfd/elflink.c 2022-06-13 14:22:15.071831986 +0100 ++++ binutils-2.35.2/bfd/elflink.c 2022-06-13 14:26:37.386163819 +0100 +@@ -5226,10 +5226,12 @@ elf_link_add_object_symbols (bfd *abfd, + if (!add_needed + && matched + && definition ++ && h->root.type != bfd_link_hash_indirect + && ((dynsym + && h->ref_regular_nonweak) + || (old_bfd != NULL + && (old_bfd->flags & BFD_PLUGIN) != 0 ++ && !info->lto_all_symbols_read + && bind != STB_WEAK) + || (h->ref_dynamic_nonweak + && (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0 diff --git a/SOURCES/binutils.gold.dwarf-5-support.patch b/SOURCES/binutils.gold.dwarf-5-support.patch new file mode 100644 index 0000000..c5df0cd --- /dev/null +++ b/SOURCES/binutils.gold.dwarf-5-support.patch @@ -0,0 +1,1299 @@ +diff -rup binutils.orig/elfcpp/dwarf.h binutils-2.35.2/elfcpp/dwarf.h +--- binutils.orig/elfcpp/dwarf.h 2023-04-19 12:23:43.626095364 +0100 ++++ binutils-2.35.2/elfcpp/dwarf.h 2023-04-19 12:23:58.356084971 +0100 +@@ -152,35 +152,48 @@ enum DW_EH_PE + DW_EH_PE_indirect = 0x80 + }; + ++// Line number table content type codes. ++ ++enum DW_LNCT ++{ ++ DW_LNCT_path = 0x1, ++ DW_LNCT_directory_index = 0x2, ++ DW_LNCT_timestamp = 0x3, ++ DW_LNCT_size = 0x4, ++ DW_LNCT_MD5 = 0x5, ++ DW_LNCT_lo_user = 0x2000, ++ DW_LNCT_hi_user = 0x3fff ++}; ++ + // Line number opcodes. + + enum DW_LINE_OPS + { +- DW_LNS_extended_op = 0, +- DW_LNS_copy = 1, +- DW_LNS_advance_pc = 2, +- DW_LNS_advance_line = 3, +- DW_LNS_set_file = 4, +- DW_LNS_set_column = 5, +- DW_LNS_negate_stmt = 6, +- DW_LNS_set_basic_block = 7, +- DW_LNS_const_add_pc = 8, +- DW_LNS_fixed_advance_pc = 9, ++ DW_LNS_extended_op = 0x00, ++ DW_LNS_copy = 0x01, ++ DW_LNS_advance_pc = 0x02, ++ DW_LNS_advance_line = 0x03, ++ DW_LNS_set_file = 0x04, ++ DW_LNS_set_column = 0x05, ++ DW_LNS_negate_stmt = 0x06, ++ DW_LNS_set_basic_block = 0x07, ++ DW_LNS_const_add_pc = 0x08, ++ DW_LNS_fixed_advance_pc = 0x09, + // DWARF 3. +- DW_LNS_set_prologue_end = 10, +- DW_LNS_set_epilogue_begin = 11, +- DW_LNS_set_isa = 12 ++ DW_LNS_set_prologue_end = 0x0a, ++ DW_LNS_set_epilogue_begin = 0x0b, ++ DW_LNS_set_isa = 0x0c + }; + + // Line number extended opcodes. + + enum DW_LINE_EXTENDED_OPS + { +- DW_LNE_end_sequence = 1, +- DW_LNE_set_address = 2, +- DW_LNE_define_file = 3, ++ DW_LNE_end_sequence = 0x01, ++ DW_LNE_set_address = 0x02, ++ DW_LNE_define_file = 0x03, + // DWARF4. +- DW_LNE_set_discriminator = 4, ++ DW_LNE_set_discriminator = 0x04, + // HP extensions. + DW_LNE_HP_negate_is_UV_update = 0x11, + DW_LNE_HP_push_context = 0x12, +@@ -191,13 +204,15 @@ enum DW_LINE_EXTENDED_OPS + DW_LNE_HP_negate_post_semantics = 0x17, + DW_LNE_HP_negate_function_exit = 0x18, + DW_LNE_HP_negate_front_end_logical = 0x19, +- DW_LNE_HP_define_proc = 0x20 ++ DW_LNE_HP_define_proc = 0x20, ++ DW_LNE_lo_user = 0x80, ++ DW_LNE_hi_user = 0xff + }; + + enum DW_CHILDREN + { +- DW_CHILDREN_no =0x00, +- DW_CHILDREN_yes =0x01 ++ DW_CHILDREN_no = 0, ++ DW_CHILDREN_yes = 1 + }; + + // Source language names and codes. +@@ -247,20 +262,38 @@ enum DW_LANG + DW_LANG_HP_Assembler = 0x8007 + }; + ++// Range list entry kinds in .debug_rnglists* section. ++ ++enum DW_RLE ++{ ++ DW_RLE_end_of_list = 0x00, ++ DW_RLE_base_addressx = 0x01, ++ DW_RLE_startx_endx = 0x02, ++ DW_RLE_startx_length = 0x03, ++ DW_RLE_offset_pair = 0x04, ++ DW_RLE_base_address = 0x05, ++ DW_RLE_start_end = 0x06, ++ DW_RLE_start_length = 0x07 ++}; ++ + // DWARF section identifiers used in the package format. + // Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFissionDWP. ++// Added (with changes) in DWARF 5. + + enum DW_SECT + { +- DW_SECT_INFO = 1, +- DW_SECT_TYPES = 2, +- DW_SECT_ABBREV = 3, +- DW_SECT_LINE = 4, +- DW_SECT_LOC = 5, ++ DW_SECT_INFO = 1, ++ DW_SECT_ABBREV = 3, ++ DW_SECT_LINE = 4, ++ DW_SECT_LOCLISTS = 5, + DW_SECT_STR_OFFSETS = 6, +- DW_SECT_MACINFO = 7, +- DW_SECT_MACRO = 8, +- DW_SECT_MAX = DW_SECT_MACRO, ++ DW_SECT_MACINFO = 7, ++ DW_SECT_RNGLISTS = 8, ++ DW_SECT_MAX = DW_SECT_RNGLISTS, ++ // These were used only for the experimental Fission support in DWARF 4. ++ DW_SECT_TYPES = 2, ++ DW_SECT_LOC = 5, ++ DW_SECT_MACRO = 8 + }; + + } // End namespace elfcpp. +diff -rup binutils.orig/gold/dwarf_reader.cc binutils-2.35.2/gold/dwarf_reader.cc +--- binutils.orig/gold/dwarf_reader.cc 2023-04-19 12:23:43.980095113 +0100 ++++ binutils-2.35.2/gold/dwarf_reader.cc 2023-04-19 12:24:08.898077535 +0100 +@@ -26,6 +26,7 @@ + #include + #include + ++#include "debug.h" + #include "elfcpp_swap.h" + #include "dwarf.h" + #include "object.h" +@@ -275,6 +276,14 @@ Dwarf_abbrev_table::do_get_abbrev(unsign + uint64_t form = read_unsigned_LEB_128(this->buffer_pos_, &len); + this->buffer_pos_ += len; + ++ // For DW_FORM_implicit_const, read the constant. ++ int64_t implicit_const = 0; ++ if (form == elfcpp::DW_FORM_implicit_const) ++ { ++ implicit_const = read_signed_LEB_128(this->buffer_pos_, &len); ++ this->buffer_pos_ += len; ++ } ++ + // A (0,0) pair terminates the list. + if (attr == 0 && form == 0) + break; +@@ -282,7 +291,7 @@ Dwarf_abbrev_table::do_get_abbrev(unsign + if (attr == elfcpp::DW_AT_sibling) + entry->has_sibling_attribute = true; + +- entry->add_attribute(attr, form); ++ entry->add_attribute(attr, form, implicit_const); + } + + this->store_abbrev(nextcode, entry); +@@ -302,8 +311,16 @@ Dwarf_ranges_table::read_ranges_table( + Relobj* object, + const unsigned char* symtab, + off_t symtab_size, +- unsigned int ranges_shndx) ++ unsigned int ranges_shndx, ++ unsigned int version) + { ++ const std::string section_name(version < 5 ++ ? ".debug_ranges" ++ : ".debug_rnglists"); ++ const std::string compressed_section_name(version < 5 ++ ? ".zdebug_ranges" ++ : ".zdebug_rnglists"); ++ + // If we've already read this abbrev table, return immediately. + if (this->ranges_shndx_ > 0 + && this->ranges_shndx_ == ranges_shndx) +@@ -318,7 +335,7 @@ Dwarf_ranges_table::read_ranges_table( + for (unsigned int i = 1; i < object->shnum(); ++i) + { + std::string name = object->section_name(i); +- if (name == ".debug_ranges" || name == ".zdebug_ranges") ++ if (name == section_name || name == compressed_section_name) + { + ranges_shndx = i; + this->output_section_offset_ = object->output_section_offset(i); +@@ -393,7 +410,7 @@ Dwarf_ranges_table::read_range_list( + { + Dwarf_range_list* ranges; + +- if (!this->read_ranges_table(object, symtab, symtab_size, ranges_shndx)) ++ if (!this->read_ranges_table(object, symtab, symtab_size, ranges_shndx, 4)) + return NULL; + + // Correct the offset. For incremental update links, we have a +@@ -459,6 +476,125 @@ Dwarf_ranges_table::read_range_list( + return ranges; + } + ++// Read a DWARF 5 range list from section RANGES_SHNDX at offset RANGES_OFFSET. ++ ++Dwarf_range_list* ++Dwarf_ranges_table::read_range_list_v5( ++ Relobj* object, ++ const unsigned char* symtab, ++ off_t symtab_size, ++ unsigned int addr_size, ++ unsigned int ranges_shndx, ++ off_t offset) ++{ ++ Dwarf_range_list* ranges; ++ ++ if (!this->read_ranges_table(object, symtab, symtab_size, ranges_shndx, 5)) ++ return NULL; ++ ++ ranges = new Dwarf_range_list(); ++ off_t base = 0; ++ unsigned int shndx0 = 0; ++ ++ // Correct the offset. For incremental update links, we have a ++ // relocated offset that is relative to the output section, but ++ // here we need an offset relative to the input section. ++ offset -= this->output_section_offset_; ++ ++ // Read the range list at OFFSET. ++ const unsigned char* prle = this->ranges_buffer_ + offset; ++ while (prle < this->ranges_buffer_end_) ++ { ++ off_t start; ++ off_t end; ++ unsigned int shndx1 = 0; ++ unsigned int shndx2 = 0; ++ size_t len; ++ ++ // Read the entry type. ++ unsigned int rle_type = *prle++; ++ offset += 1; ++ ++ if (rle_type == elfcpp::DW_RLE_end_of_list) ++ break; ++ ++ switch (rle_type) ++ { ++ case elfcpp::DW_RLE_base_address: ++ if (addr_size == 4) ++ base = this->dwinfo_->read_from_pointer<32>(prle); ++ else ++ base = this->dwinfo_->read_from_pointer<64>(prle); ++ if (this->ranges_reloc_mapper_ != NULL) ++ shndx0 = this->lookup_reloc(offset, &base); ++ prle += addr_size; ++ offset += addr_size; ++ break; ++ ++ case elfcpp::DW_RLE_offset_pair: ++ start = read_unsigned_LEB_128(prle, &len); ++ prle += len; ++ offset += len; ++ end = read_unsigned_LEB_128(prle, &len); ++ prle += len; ++ offset += len; ++ if (shndx0 == 0 || object->is_section_included(shndx0)) ++ ranges->add(shndx0, base + start, base + end); ++ break; ++ ++ case elfcpp::DW_RLE_start_end: ++ if (addr_size == 4) ++ { ++ start = this->dwinfo_->read_from_pointer<32>(prle); ++ end = this->dwinfo_->read_from_pointer<32>(prle + 4); ++ } ++ else ++ { ++ start = this->dwinfo_->read_from_pointer<64>(prle); ++ end = this->dwinfo_->read_from_pointer<64>(prle + 8); ++ } ++ if (this->ranges_reloc_mapper_ != NULL) ++ { ++ shndx1 = this->lookup_reloc(offset, &start); ++ shndx2 = this->lookup_reloc(offset + addr_size, &end); ++ if (shndx1 != shndx2) ++ gold_warning(_("%s: DWARF info may be corrupt; offsets in a " ++ "range list entry are in different sections"), ++ object->name().c_str()); ++ } ++ prle += addr_size * 2; ++ offset += addr_size * 2; ++ if (shndx1 == 0 || object->is_section_included(shndx1)) ++ ranges->add(shndx1, start, end); ++ break; ++ ++ case elfcpp::DW_RLE_start_length: ++ if (addr_size == 4) ++ start = this->dwinfo_->read_from_pointer<32>(prle); ++ else ++ start = this->dwinfo_->read_from_pointer<64>(prle); ++ if (this->ranges_reloc_mapper_ != NULL) ++ shndx1 = this->lookup_reloc(offset, &start); ++ prle += addr_size; ++ offset += addr_size; ++ end = start + read_unsigned_LEB_128(prle, &len); ++ prle += len; ++ offset += len; ++ if (shndx1 == 0 || object->is_section_included(shndx1)) ++ ranges->add(shndx1, start, end); ++ break; ++ ++ default: ++ gold_warning(_("%s: DWARF range list contains " ++ "unsupported entry type (%d)"), ++ object->name().c_str(), rle_type); ++ break; ++ } ++ } ++ ++ return ranges; ++} ++ + // Look for a relocation at offset OFF in the range table, + // and return the section index and offset of the target. + +@@ -709,7 +845,13 @@ Dwarf_die::read_attributes() + case elfcpp::DW_FORM_flag_present: + attr_value.val.intval = 1; + break; ++ case elfcpp::DW_FORM_implicit_const: ++ attr_value.val.intval = ++ this->abbrev_code_->attributes[i].implicit_const; ++ break; + case elfcpp::DW_FORM_strp: ++ case elfcpp::DW_FORM_strp_sup: ++ case elfcpp::DW_FORM_line_strp: + { + off_t str_off; + if (this->dwinfo_->offset_size() == 4) +@@ -722,6 +864,26 @@ Dwarf_die::read_attributes() + attr_value.val.refval = str_off; + break; + } ++ case elfcpp::DW_FORM_strx: ++ case elfcpp::DW_FORM_GNU_str_index: ++ attr_value.val.uintval = read_unsigned_LEB_128(pattr, &len); ++ pattr += len; ++ break; ++ case elfcpp::DW_FORM_strx1: ++ attr_value.val.uintval = *pattr++; ++ break; ++ case elfcpp::DW_FORM_strx2: ++ attr_value.val.uintval = ++ this->dwinfo_->read_from_pointer<16>(&pattr); ++ break; ++ case elfcpp::DW_FORM_strx3: ++ attr_value.val.uintval = ++ this->dwinfo_->read_3bytes_from_pointer(&pattr); ++ break; ++ case elfcpp::DW_FORM_strx4: ++ attr_value.val.uintval = ++ this->dwinfo_->read_from_pointer<32>(&pattr); ++ break; + case elfcpp::DW_FORM_sec_offset: + { + off_t sec_off; +@@ -747,7 +909,6 @@ Dwarf_die::read_attributes() + this->dwinfo_->lookup_reloc(attr_off, &sec_off); + attr_value.aux.shndx = shndx; + attr_value.val.refval = sec_off; +- ref_form = true; + break; + } + case elfcpp::DW_FORM_ref_addr: +@@ -815,6 +976,7 @@ Dwarf_die::read_attributes() + break; + } + case elfcpp::DW_FORM_ref4: ++ case elfcpp::DW_FORM_ref_sup4: + { + off_t sec_off; + sec_off = this->dwinfo_->read_from_pointer<32>(&pattr); +@@ -835,11 +997,20 @@ Dwarf_die::read_attributes() + attr_value.val.intval = sec_off; + break; + } ++ case elfcpp::DW_FORM_data16: ++ { ++ // For now, treat this as a 16-byte block. ++ attr_value.val.blockval = pattr; ++ attr_value.aux.blocklen = 16; ++ pattr += 16; ++ break; ++ } + case elfcpp::DW_FORM_ref_sig8: + attr_value.val.uintval = + this->dwinfo_->read_from_pointer<64>(&pattr); + break; + case elfcpp::DW_FORM_ref8: ++ case elfcpp::DW_FORM_ref_sup8: + { + off_t sec_off; + sec_off = this->dwinfo_->read_from_pointer<64>(&pattr); +@@ -856,11 +1027,29 @@ Dwarf_die::read_attributes() + pattr += len; + break; + case elfcpp::DW_FORM_udata: ++ attr_value.val.uintval = read_unsigned_LEB_128(pattr, &len); ++ pattr += len; ++ break; ++ case elfcpp::DW_FORM_addrx: + case elfcpp::DW_FORM_GNU_addr_index: +- case elfcpp::DW_FORM_GNU_str_index: + attr_value.val.uintval = read_unsigned_LEB_128(pattr, &len); + pattr += len; + break; ++ case elfcpp::DW_FORM_addrx1: ++ attr_value.val.uintval = *pattr++; ++ break; ++ case elfcpp::DW_FORM_addrx2: ++ attr_value.val.uintval = ++ this->dwinfo_->read_from_pointer<16>(&pattr); ++ break; ++ case elfcpp::DW_FORM_addrx3: ++ attr_value.val.uintval = ++ this->dwinfo_->read_3bytes_from_pointer(&pattr); ++ break; ++ case elfcpp::DW_FORM_addrx4: ++ attr_value.val.uintval = ++ this->dwinfo_->read_from_pointer<32>(&pattr); ++ break; + case elfcpp::DW_FORM_sdata: + attr_value.val.intval = read_signed_LEB_128(pattr, &len); + pattr += len; +@@ -870,6 +1059,11 @@ Dwarf_die::read_attributes() + len = strlen(attr_value.val.stringval); + pattr += len + 1; + break; ++ case elfcpp::DW_FORM_loclistx: ++ case elfcpp::DW_FORM_rnglistx: ++ attr_value.val.uintval = read_unsigned_LEB_128(pattr, &len); ++ pattr += len; ++ break; + default: + return false; + } +@@ -954,9 +1148,12 @@ Dwarf_die::skip_attributes() + switch(form) + { + case elfcpp::DW_FORM_flag_present: ++ case elfcpp::DW_FORM_implicit_const: + break; + case elfcpp::DW_FORM_strp: + case elfcpp::DW_FORM_sec_offset: ++ case elfcpp::DW_FORM_strp_sup: ++ case elfcpp::DW_FORM_line_strp: + pattr += this->dwinfo_->offset_size(); + break; + case elfcpp::DW_FORM_addr: +@@ -993,23 +1190,42 @@ Dwarf_die::skip_attributes() + case elfcpp::DW_FORM_data1: + case elfcpp::DW_FORM_ref1: + case elfcpp::DW_FORM_flag: ++ case elfcpp::DW_FORM_strx1: ++ case elfcpp::DW_FORM_addrx1: + pattr += 1; + break; + case elfcpp::DW_FORM_data2: + case elfcpp::DW_FORM_ref2: ++ case elfcpp::DW_FORM_strx2: ++ case elfcpp::DW_FORM_addrx2: + pattr += 2; + break; ++ case elfcpp::DW_FORM_strx3: ++ case elfcpp::DW_FORM_addrx3: ++ pattr += 3; ++ break; + case elfcpp::DW_FORM_data4: + case elfcpp::DW_FORM_ref4: ++ case elfcpp::DW_FORM_ref_sup4: ++ case elfcpp::DW_FORM_strx4: ++ case elfcpp::DW_FORM_addrx4: + pattr += 4; + break; + case elfcpp::DW_FORM_data8: + case elfcpp::DW_FORM_ref8: + case elfcpp::DW_FORM_ref_sig8: ++ case elfcpp::DW_FORM_ref_sup8: + pattr += 8; + break; ++ case elfcpp::DW_FORM_data16: ++ pattr += 16; ++ break; + case elfcpp::DW_FORM_ref_udata: + case elfcpp::DW_FORM_udata: ++ case elfcpp::DW_FORM_addrx: ++ case elfcpp::DW_FORM_strx: ++ case elfcpp::DW_FORM_loclistx: ++ case elfcpp::DW_FORM_rnglistx: + case elfcpp::DW_FORM_GNU_addr_index: + case elfcpp::DW_FORM_GNU_str_index: + read_unsigned_LEB_128(pattr, &len); +@@ -1313,6 +1529,13 @@ Dwarf_info_reader::do_parse() + elfcpp::Swap_unaligned<16, big_endian>::readval(pinfo); + pinfo += 2; + ++ // DWARF 5: Read the unit type (1 byte) and address size (1 byte). ++ if (this->cu_version_ >= 5) ++ { ++ this->unit_type_ = *pinfo++; ++ this->address_size_ = *pinfo++; ++ } ++ + // Read debug_abbrev_offset (4 or 8 bytes). + if (this->offset_size_ == 4) + abbrev_offset = elfcpp::Swap_unaligned<32, big_endian>::readval(pinfo); +@@ -1333,13 +1556,14 @@ Dwarf_info_reader::do_parse() + } + pinfo += this->offset_size_; + +- // Read address_size (1 byte). +- this->address_size_ = *pinfo++; ++ // DWARF 2-4: Read address_size (1 byte). ++ if (this->cu_version_ < 5) ++ this->address_size_ = *pinfo++; + + // For type units, read the two extra fields. + uint64_t signature = 0; + off_t type_offset = 0; +- if (this->is_type_unit_) ++ if (this->is_type_unit()) + { + if (!this->check_buffer(pinfo + 8 + this->offset_size_)) + break; +@@ -1369,7 +1593,7 @@ Dwarf_info_reader::do_parse() + if (root_die.tag() != 0) + { + // Visit the CU or TU. +- if (this->is_type_unit_) ++ if (this->is_type_unit()) + this->visit_type_unit(section_offset + this->cu_offset_, + cu_end - cu_start, type_offset, signature, + &root_die); +@@ -1460,6 +1684,19 @@ Dwarf_info_reader::read_from_pointer(con + return return_value; + } + ++// Read a 3-byte integer. Update SOURCE after read. ++inline typename elfcpp::Valtype_base<32>::Valtype ++Dwarf_info_reader::read_3bytes_from_pointer(const unsigned char** source) ++{ ++ typename elfcpp::Valtype_base<32>::Valtype return_value; ++ if (this->object_->is_big_endian()) ++ return_value = ((*source)[0] << 16) | ((*source)[1] << 8) | (*source)[2]; ++ else ++ return_value = ((*source)[2] << 16) | ((*source)[1] << 8) | (*source)[0]; ++ *source += 3; ++ return return_value; ++} ++ + // Look for a relocation at offset ATTR_OFF in the dwarf info, + // and return the section index and offset of the target. + +@@ -1561,27 +1798,40 @@ Sized_dwarf_line_info: + Object* object, + unsigned int read_shndx) + : data_valid_(false), buffer_(NULL), buffer_start_(NULL), ++ str_buffer_(NULL), str_buffer_start_(NULL), + reloc_mapper_(NULL), symtab_buffer_(NULL), directories_(), files_(), +- current_header_index_(-1) ++ current_header_index_(-1), reloc_map_(), line_number_map_() + { +- unsigned int debug_shndx; ++ unsigned int debug_line_shndx = 0; ++ unsigned int debug_line_str_shndx = 0; + +- for (debug_shndx = 1; debug_shndx < object->shnum(); ++debug_shndx) ++ for (unsigned int i = 1; i < object->shnum(); ++i) + { ++ section_size_type buffer_size; ++ bool is_new = false; ++ + // FIXME: do this more efficiently: section_name() isn't super-fast +- std::string name = object->section_name(debug_shndx); ++ std::string name = object->section_name(i); + if (name == ".debug_line" || name == ".zdebug_line") + { +- section_size_type buffer_size; +- bool is_new = false; +- this->buffer_ = object->decompressed_section_contents(debug_shndx, +- &buffer_size, +- &is_new); ++ this->buffer_ = ++ object->decompressed_section_contents(i, &buffer_size, &is_new); + if (is_new) + this->buffer_start_ = this->buffer_; + this->buffer_end_ = this->buffer_ + buffer_size; +- break; ++ debug_line_shndx = i; + } ++ else if (name == ".debug_line_str" || name == ".zdebug_line_str") ++ { ++ this->str_buffer_ = ++ object->decompressed_section_contents(i, &buffer_size, &is_new); ++ if (is_new) ++ this->str_buffer_start_ = this->str_buffer_; ++ this->str_buffer_end_ = this->str_buffer_ + buffer_size; ++ debug_line_str_shndx = i; ++ } ++ if (debug_line_shndx > 0 && debug_line_str_shndx > 0) ++ break; + } + if (this->buffer_ == NULL) + return; +@@ -1594,7 +1844,7 @@ Sized_dwarf_line_info: + unsigned int reloc_sh_type = object->section_type(i); + if ((reloc_sh_type == elfcpp::SHT_REL + || reloc_sh_type == elfcpp::SHT_RELA) +- && object->section_info(i) == debug_shndx) ++ && object->section_info(i) == debug_line_shndx) + { + reloc_shndx = i; + this->track_relocs_type_ = reloc_sh_type; +@@ -1640,65 +1890,80 @@ Sized_dwarf_line_info: + uint32_t initial_length = elfcpp::Swap_unaligned<32, big_endian>::readval(lineptr); + lineptr += 4; + +- // In DWARF2/3, if the initial length is all 1 bits, then the offset ++ // In DWARF, if the initial length is all 1 bits, then the offset + // size is 8 and we need to read the next 8 bytes for the real length. + if (initial_length == 0xffffffff) + { +- header_.offset_size = 8; ++ this->header_.offset_size = 8; + initial_length = elfcpp::Swap_unaligned<64, big_endian>::readval(lineptr); + lineptr += 8; + } + else +- header_.offset_size = 4; ++ this->header_.offset_size = 4; + +- header_.total_length = initial_length; ++ this->header_.total_length = initial_length; + +- gold_assert(lineptr + header_.total_length <= buffer_end_); ++ this->end_of_unit_ = lineptr + initial_length; ++ gold_assert(this->end_of_unit_ <= buffer_end_); + +- header_.version = elfcpp::Swap_unaligned<16, big_endian>::readval(lineptr); ++ this->header_.version = ++ elfcpp::Swap_unaligned<16, big_endian>::readval(lineptr); + lineptr += 2; + +- // Skip address size and segment selector for DWARF5. +- if (header_.version >= 5) +- lineptr += 2; +- +- if (header_.offset_size == 4) +- header_.prologue_length = elfcpp::Swap_unaligned<32, big_endian>::readval(lineptr); ++ // We can only read versions 2-5 of the DWARF line number table. ++ // For other versions, just skip the entire line number table. ++ if (this->header_.version < 2 || this->header_.version > 5) ++ return this->end_of_unit_; ++ ++ // DWARF 5 only: address size and segment selector. ++ if (this->header_.version >= 5) ++ { ++ this->header_.address_size = *lineptr; ++ // We ignore the segment selector. ++ lineptr += 2; ++ } ++ ++ if (this->header_.offset_size == 4) ++ this->header_.prologue_length = ++ elfcpp::Swap_unaligned<32, big_endian>::readval(lineptr); + else +- header_.prologue_length = elfcpp::Swap_unaligned<64, big_endian>::readval(lineptr); +- lineptr += header_.offset_size; ++ this->header_.prologue_length = ++ elfcpp::Swap_unaligned<64, big_endian>::readval(lineptr); ++ lineptr += this->header_.offset_size; + +- header_.min_insn_length = *lineptr; ++ this->end_of_header_length_ = lineptr; ++ ++ this->header_.min_insn_length = *lineptr; + lineptr += 1; + +- if (header_.version < 4) +- header_.max_ops_per_insn = 1; ++ if (this->header_.version < 4) ++ this->header_.max_ops_per_insn = 1; + else + { + // DWARF 4 added the maximum_operations_per_instruction field. +- header_.max_ops_per_insn = *lineptr; ++ this->header_.max_ops_per_insn = *lineptr; + lineptr += 1; + // TODO: Add support for values other than 1. +- gold_assert(header_.max_ops_per_insn == 1); ++ gold_assert(this->header_.max_ops_per_insn == 1); + } + +- header_.default_is_stmt = *lineptr; ++ this->header_.default_is_stmt = *lineptr; + lineptr += 1; + +- header_.line_base = *reinterpret_cast(lineptr); ++ this->header_.line_base = *reinterpret_cast(lineptr); + lineptr += 1; + +- header_.line_range = *lineptr; ++ this->header_.line_range = *lineptr; + lineptr += 1; + +- header_.opcode_base = *lineptr; ++ this->header_.opcode_base = *lineptr; + lineptr += 1; + +- header_.std_opcode_lengths.resize(header_.opcode_base + 1); +- header_.std_opcode_lengths[0] = 0; +- for (int i = 1; i < header_.opcode_base; i++) ++ this->header_.std_opcode_lengths.resize(this->header_.opcode_base + 1); ++ this->header_.std_opcode_lengths[0] = 0; ++ for (int i = 1; i < this->header_.opcode_base; i++) + { +- header_.std_opcode_lengths[i] = *lineptr; ++ this->header_.std_opcode_lengths[i] = *lineptr; + lineptr += 1; + } + +@@ -1707,10 +1972,11 @@ Sized_dwarf_line_info: + + // The header for a debug_line section is mildly complicated, because + // the line info is very tightly encoded. ++// This routine is for DWARF versions 2, 3, and 4. + + template + const unsigned char* +-Sized_dwarf_line_info::read_header_tables( ++Sized_dwarf_line_info::read_header_tables_v2( + const unsigned char* lineptr) + { + ++this->current_header_index_; +@@ -1775,6 +2041,169 @@ Sized_dwarf_line_info: + return lineptr; + } + ++// This routine is for DWARF version 5. ++ ++template ++const unsigned char* ++Sized_dwarf_line_info::read_header_tables_v5( ++ const unsigned char* lineptr) ++{ ++ size_t len; ++ ++ ++this->current_header_index_; ++ ++ gold_assert(static_cast(this->directories_.size()) ++ == this->current_header_index_); ++ gold_assert(static_cast(this->files_.size()) ++ == this->current_header_index_); ++ ++ // Read the directory list. ++ unsigned int format_count = *lineptr; ++ lineptr += 1; ++ ++ unsigned int *types = new unsigned int[format_count]; ++ unsigned int *forms = new unsigned int[format_count]; ++ ++ for (unsigned int i = 0; i < format_count; i++) ++ { ++ types[i] = read_unsigned_LEB_128(lineptr, &len); ++ lineptr += len; ++ forms[i] = read_unsigned_LEB_128(lineptr, &len); ++ lineptr += len; ++ } ++ ++ uint64_t entry_count = read_unsigned_LEB_128(lineptr, &len); ++ lineptr += len; ++ this->directories_.push_back(std::vector(0)); ++ std::vector& dir_list = this->directories_.back(); ++ ++ for (unsigned int j = 0; j < entry_count; j++) ++ { ++ std::string dirname; ++ ++ for (unsigned int i = 0; i < format_count; i++) ++ { ++ if (types[i] == elfcpp::DW_LNCT_path) ++ { ++ if (forms[i] == elfcpp::DW_FORM_string) ++ { ++ dirname = reinterpret_cast(lineptr); ++ lineptr += dirname.size() + 1; ++ } ++ else if (forms[i] == elfcpp::DW_FORM_line_strp) ++ { ++ uint64_t offset; ++ if (this->header_.offset_size == 4) ++ offset = ++ elfcpp::Swap_unaligned<32, big_endian>::readval(lineptr); ++ else ++ offset = ++ elfcpp::Swap_unaligned<64, big_endian>::readval(lineptr); ++ typename Reloc_map::const_iterator it ++ = this->reloc_map_.find(lineptr - this->buffer_); ++ if (it != reloc_map_.end()) ++ { ++ if (this->track_relocs_type_ == elfcpp::SHT_RELA) ++ offset = 0; ++ offset += it->second.second; ++ } ++ lineptr += this->header_.offset_size; ++ dirname = reinterpret_cast(this->str_buffer_ ++ + offset); ++ } ++ else ++ return lineptr; ++ } ++ else ++ return lineptr; ++ } ++ dir_list.push_back(dirname); ++ } ++ ++ delete[] types; ++ delete[] forms; ++ ++ // Read the filenames list. ++ format_count = *lineptr; ++ lineptr += 1; ++ ++ types = new unsigned int[format_count]; ++ forms = new unsigned int[format_count]; ++ ++ for (unsigned int i = 0; i < format_count; i++) ++ { ++ types[i] = read_unsigned_LEB_128(lineptr, &len); ++ lineptr += len; ++ forms[i] = read_unsigned_LEB_128(lineptr, &len); ++ lineptr += len; ++ } ++ ++ entry_count = read_unsigned_LEB_128(lineptr, &len); ++ lineptr += len; ++ this->files_.push_back( ++ std::vector >(0)); ++ std::vector >& file_list = this->files_.back(); ++ ++ for (unsigned int j = 0; j < entry_count; j++) ++ { ++ const char* path = NULL; ++ int dirindex = 0; ++ ++ for (unsigned int i = 0; i < format_count; i++) ++ { ++ if (types[i] == elfcpp::DW_LNCT_path) ++ { ++ if (forms[i] == elfcpp::DW_FORM_string) ++ { ++ path = reinterpret_cast(lineptr); ++ lineptr += strlen(path) + 1; ++ } ++ else if (forms[i] == elfcpp::DW_FORM_line_strp) ++ { ++ uint64_t offset; ++ if (this->header_.offset_size == 4) ++ offset = elfcpp::Swap_unaligned<32, big_endian>::readval(lineptr); ++ else ++ offset = elfcpp::Swap_unaligned<64, big_endian>::readval(lineptr); ++ typename Reloc_map::const_iterator it ++ = this->reloc_map_.find(lineptr - this->buffer_); ++ if (it != reloc_map_.end()) ++ { ++ if (this->track_relocs_type_ == elfcpp::SHT_RELA) ++ offset = 0; ++ offset += it->second.second; ++ } ++ lineptr += this->header_.offset_size; ++ path = reinterpret_cast(this->str_buffer_ ++ + offset); ++ } ++ else ++ return lineptr; ++ } ++ else if (types[i] == elfcpp::DW_LNCT_directory_index) ++ { ++ if (forms[i] == elfcpp::DW_FORM_udata) ++ { ++ dirindex = read_unsigned_LEB_128(lineptr, &len); ++ lineptr += len; ++ } ++ else ++ return lineptr; ++ } ++ else ++ return lineptr; ++ } ++ gold_debug(DEBUG_LOCATION, "File %3d: %s", ++ static_cast(file_list.size()), path); ++ file_list.push_back(std::make_pair(dirindex, path)); ++ } ++ ++ delete[] types; ++ delete[] forms; ++ ++ return lineptr; ++} ++ + // Process a single opcode in the .debug.line structure. + + template +@@ -1790,15 +2219,15 @@ Sized_dwarf_line_info: + + // If the opcode is great than the opcode_base, it is a special + // opcode. Most line programs consist mainly of special opcodes. +- if (opcode >= header_.opcode_base) ++ if (opcode >= this->header_.opcode_base) + { +- opcode -= header_.opcode_base; +- const int advance_address = ((opcode / header_.line_range) +- * header_.min_insn_length); ++ opcode -= this->header_.opcode_base; ++ const int advance_address = ((opcode / this->header_.line_range) ++ * this->header_.min_insn_length); + lsm->address += advance_address; + +- const int advance_line = ((opcode % header_.line_range) +- + header_.line_base); ++ const int advance_line = ((opcode % this->header_.line_range) ++ + this->header_.line_base); + lsm->line_num += advance_line; + lsm->basic_block = true; + *len = oplen; +@@ -1818,13 +2247,13 @@ Sized_dwarf_line_info: + const uint64_t advance_address + = read_unsigned_LEB_128(start, &templen); + oplen += templen; +- lsm->address += header_.min_insn_length * advance_address; ++ lsm->address += this->header_.min_insn_length * advance_address; + } + break; + + case elfcpp::DW_LNS_advance_line: + { +- const uint64_t advance_line = read_signed_LEB_128(start, &templen); ++ const int64_t advance_line = read_signed_LEB_128(start, &templen); + oplen += templen; + lsm->line_num += advance_line; + } +@@ -1865,9 +2294,9 @@ Sized_dwarf_line_info: + + case elfcpp::DW_LNS_const_add_pc: + { +- const int advance_address = (header_.min_insn_length +- * ((255 - header_.opcode_base) +- / header_.line_range)); ++ const int advance_address = (this->header_.min_insn_length ++ * ((255 - this->header_.opcode_base) ++ / this->header_.line_range)); + lsm->address += advance_address; + } + break; +@@ -1950,7 +2379,7 @@ Sized_dwarf_line_info: + default: + { + // Ignore unknown opcode silently +- for (int i = 0; i < header_.std_opcode_lengths[opcode]; i++) ++ for (int i = 0; i < this->header_.std_opcode_lengths[opcode]; i++) + { + size_t templen; + read_unsigned_LEB_128(start, &templen); +@@ -1970,28 +2399,24 @@ Sized_dwarf_line_info: + template + unsigned const char* + Sized_dwarf_line_info::read_lines(unsigned const char* lineptr, ++ unsigned const char* endptr, + unsigned int shndx) + { + struct LineStateMachine lsm; + +- // LENGTHSTART is the place the length field is based on. It is the +- // point in the header after the initial length field. +- const unsigned char* lengthstart = buffer_; +- +- // In 64 bit dwarf, the initial length is 12 bytes, because of the +- // 0xffffffff at the start. +- if (header_.offset_size == 8) +- lengthstart += 12; +- else +- lengthstart += 4; +- +- while (lineptr < lengthstart + header_.total_length) ++ while (lineptr < endptr) + { +- ResetLineStateMachine(&lsm, header_.default_is_stmt); ++ ResetLineStateMachine(&lsm, this->header_.default_is_stmt); + while (!lsm.end_sequence) + { + size_t oplength; ++ ++ if (lineptr >= endptr) ++ break; ++ + bool add_line = this->process_one_opcode(lineptr, &lsm, &oplength); ++ lineptr += oplength; ++ + if (add_line + && (shndx == -1U || lsm.shndx == -1U || shndx == lsm.shndx)) + { +@@ -2012,11 +2437,10 @@ Sized_dwarf_line_info: + map.back().last_line_for_offset = false; + map.push_back(entry); + } +- lineptr += oplength; + } + } + +- return lengthstart + header_.total_length; ++ return endptr; + } + + // Read the relocations into a Reloc_map. +@@ -2057,9 +2481,17 @@ Sized_dwarf_line_info: + { + const unsigned char* lineptr = this->buffer_; + lineptr = this->read_header_prolog(lineptr); +- lineptr = this->read_header_tables(lineptr); +- lineptr = this->read_lines(lineptr, shndx); +- this->buffer_ = lineptr; ++ if (this->header_.version >= 2 && this->header_.version <= 4) ++ { ++ lineptr = this->read_header_tables_v2(lineptr); ++ lineptr = this->read_lines(lineptr, this->end_of_unit_, shndx); ++ } ++ else if (this->header_.version == 5) ++ { ++ lineptr = this->read_header_tables_v5(lineptr); ++ lineptr = this->read_lines(lineptr, this->end_of_unit_, shndx); ++ } ++ this->buffer_ = this->end_of_unit_; + } + + // Sort the lines numbers, so addr2line can use binary search. +@@ -2215,6 +2647,9 @@ Sized_dwarf_line_info: + off_t offset, + std::vector* other_lines) + { ++ gold_debug(DEBUG_LOCATION, "do_addr2line: shndx %u offset %08x", ++ shndx, static_cast(offset)); ++ + if (this->data_valid_ == false) + return ""; + +diff -rup binutils.orig/gold/dwarf_reader.h binutils-2.35.2/gold/dwarf_reader.h +--- binutils.orig/gold/dwarf_reader.h 2023-04-19 12:23:43.990095106 +0100 ++++ binutils-2.35.2/gold/dwarf_reader.h 2023-04-19 12:24:05.282080087 +0100 +@@ -173,11 +173,12 @@ class Dwarf_abbrev_table + // An attribute list entry. + struct Attribute + { +- Attribute(unsigned int a, unsigned int f) +- : attr(a), form(f) ++ Attribute(unsigned int a, unsigned int f, int c) ++ : attr(a), form(f), implicit_const(c) + { } + unsigned int attr; + unsigned int form; ++ int implicit_const; + }; + + // An abbrev code entry. +@@ -190,9 +191,9 @@ class Dwarf_abbrev_table + } + + void +- add_attribute(unsigned int attr, unsigned int form) ++ add_attribute(unsigned int attr, unsigned int form, int implicit_const) + { +- this->attributes.push_back(Attribute(attr, form)); ++ this->attributes.push_back(Attribute(attr, form, implicit_const)); + } + + // The DWARF tag. +@@ -349,14 +350,15 @@ class Dwarf_ranges_table + delete this->ranges_reloc_mapper_; + } + +- // Read the ranges table from an object file. ++ // Fetch the contents of the ranges table from an object file. + bool + read_ranges_table(Relobj* object, + const unsigned char* symtab, + off_t symtab_size, +- unsigned int ranges_shndx); ++ unsigned int ranges_shndx, ++ unsigned int version); + +- // Read the range table from an object file. ++ // Read the DWARF 2/3/4 range table. + Dwarf_range_list* + read_range_list(Relobj* object, + const unsigned char* symtab, +@@ -365,6 +367,15 @@ class Dwarf_ranges_table + unsigned int ranges_shndx, + off_t ranges_offset); + ++ // Read the DWARF 5 rnglists table. ++ Dwarf_range_list* ++ read_range_list_v5(Relobj* object, ++ const unsigned char* symtab, ++ off_t symtab_size, ++ unsigned int address_size, ++ unsigned int ranges_shndx, ++ off_t ranges_offset); ++ + // Look for a relocation at offset OFF in the range table, + // and return the section index and offset of the target. + unsigned int +@@ -490,8 +501,6 @@ class Dwarf_die + unsigned int shndx; + // Block length for block forms. + unsigned int blocklen; +- // Attribute offset for DW_FORM_strp. +- unsigned int attr_off; + } aux; + }; + +@@ -684,6 +693,10 @@ class Dwarf_die + // calls the various visit_xxx() methods for each header. Clients + // should derive a new class from this one and implement the + // visit_compilation_unit() and visit_type_unit() functions. ++// IS_TYPE_UNIT is true if we are reading from a .debug_types section, ++// which is used only in DWARF 4. For DWARF 5, it will be false, ++// and we will determine whether it's a type init when we parse the ++// header. + + class Dwarf_info_reader + { +@@ -695,7 +708,7 @@ class Dwarf_info_reader + unsigned int shndx, + unsigned int reloc_shndx, + unsigned int reloc_type) +- : is_type_unit_(is_type_unit), object_(object), symtab_(symtab), ++ : object_(object), symtab_(symtab), + symtab_size_(symtab_size), shndx_(shndx), reloc_shndx_(reloc_shndx), + reloc_type_(reloc_type), abbrev_shndx_(0), string_shndx_(0), + buffer_(NULL), buffer_end_(NULL), cu_offset_(0), cu_length_(0), +@@ -703,7 +716,12 @@ class Dwarf_info_reader + abbrev_table_(), ranges_table_(this), + reloc_mapper_(NULL), string_buffer_(NULL), string_buffer_end_(NULL), + owns_string_buffer_(false), string_output_section_offset_(0) +- { } ++ { ++ // For DWARF 4, we infer the unit type from the section name. ++ // For DWARF 5, we will read this from the unit header. ++ this->unit_type_ = ++ (is_type_unit ? elfcpp::DW_UT_type : elfcpp::DW_UT_compile); ++ } + + virtual + ~Dwarf_info_reader() +@@ -714,6 +732,13 @@ class Dwarf_info_reader + delete[] this->string_buffer_; + } + ++ bool ++ is_type_unit() const ++ { ++ return (this->unit_type_ == elfcpp::DW_UT_type ++ || this->unit_type_ == elfcpp::DW_UT_split_type); ++ } ++ + // Begin parsing the debug info. This calls visit_compilation_unit() + // or visit_type_unit() for each compilation or type unit found in the + // section, and visit_die() for each top-level DIE. +@@ -745,6 +770,9 @@ class Dwarf_info_reader + inline typename elfcpp::Valtype_base::Valtype + read_from_pointer(const unsigned char** source); + ++ inline typename elfcpp::Valtype_base<32>::Valtype ++ read_3bytes_from_pointer(const unsigned char** source); ++ + // Look for a relocation at offset ATTR_OFF in the dwarf info, + // and return the section index and offset of the target. + unsigned int +@@ -818,12 +846,20 @@ class Dwarf_info_reader + Dwarf_range_list* + read_range_list(unsigned int ranges_shndx, off_t ranges_offset) + { +- return this->ranges_table_.read_range_list(this->object_, +- this->symtab_, +- this->symtab_size_, +- this->address_size_, +- ranges_shndx, +- ranges_offset); ++ if (this->cu_version_ < 5) ++ return this->ranges_table_.read_range_list(this->object_, ++ this->symtab_, ++ this->symtab_size_, ++ this->address_size_, ++ ranges_shndx, ++ ranges_offset); ++ else ++ return this->ranges_table_.read_range_list_v5(this->object_, ++ this->symtab_, ++ this->symtab_size_, ++ this->address_size_, ++ ranges_shndx, ++ ranges_offset); + } + + // Return the object. +@@ -873,8 +909,8 @@ class Dwarf_info_reader + bool + do_read_string_table(unsigned int string_shndx); + +- // True if this is a type unit; false for a compilation unit. +- bool is_type_unit_; ++ // The unit type (DW_UT_xxx). ++ unsigned int unit_type_; + // The object containing the .debug_info or .debug_types input section. + Relobj* object_; + // The ELF symbol table. +@@ -1008,6 +1044,8 @@ class Sized_dwarf_line_info : public Dwa + { + if (this->buffer_start_ != NULL) + delete[] this->buffer_start_; ++ if (this->str_buffer_start_ != NULL) ++ delete[] this->str_buffer_start_; + } + + private: +@@ -1030,19 +1068,23 @@ class Sized_dwarf_line_info : public Dwa + void + read_relocs(); + +- // Reads the DWARF2/3 header for this line info. Each takes as input ++ // Reads the DWARF header for this line info. Each takes as input + // a starting buffer position, and returns the ending position. + const unsigned char* + read_header_prolog(const unsigned char* lineptr); + + const unsigned char* +- read_header_tables(const unsigned char* lineptr); ++ read_header_tables_v2(const unsigned char* lineptr); ++ ++ const unsigned char* ++ read_header_tables_v5(const unsigned char* lineptr); + +- // Reads the DWARF2/3 line information. If shndx is non-negative, ++ // Reads the DWARF line information. If shndx is non-negative, + // discard all line information that doesn't pertain to the given + // section. + const unsigned char* +- read_lines(const unsigned char* lineptr, unsigned int shndx); ++ read_lines(const unsigned char* lineptr, const unsigned char* endptr, ++ unsigned int shndx); + + // Process a single line info opcode at START using the state + // machine at LSM. Return true if we should define a line using the +@@ -1069,6 +1111,7 @@ class Sized_dwarf_line_info : public Dwa + { + off_t total_length; + int version; ++ int address_size; + off_t prologue_length; + int min_insn_length; // insn stands for instruction + int max_ops_per_insn; // Added in DWARF-4. +@@ -1089,6 +1132,20 @@ class Sized_dwarf_line_info : public Dwa + // of the buffer. + const unsigned char* buffer_start_; + ++ // str_buffer is the buffer for the line table strings. ++ const unsigned char* str_buffer_; ++ const unsigned char* str_buffer_end_; ++ // If the buffer was allocated temporarily, and therefore must be ++ // deallocated in the dtor, this contains a pointer to the start ++ // of the buffer. ++ const unsigned char* str_buffer_start_; ++ ++ // Pointer to the end of the header_length field (aka prologue_length). ++ const unsigned char* end_of_header_length_; ++ ++ // Pointer to the end of the current compilation unit. ++ const unsigned char* end_of_unit_; ++ + // This has relocations that point into buffer. + Sized_elf_reloc_mapper* reloc_mapper_; + // The type of the reloc section in track_relocs_--SHT_REL or SHT_RELA. diff --git a/SOURCES/gcc12-libtool-no-rpath.patch b/SOURCES/gcc12-libtool-no-rpath.patch new file mode 100644 index 0000000..a4f90a1 --- /dev/null +++ b/SOURCES/gcc12-libtool-no-rpath.patch @@ -0,0 +1,28 @@ +diff -rup binutils.orig/ltmain.sh binutils-2.37/ltmain.sh +--- binutils.orig/ltmain.sh 2022-01-27 16:23:09.304207432 +0000 ++++ binutils-2.37/ltmain.sh 2022-01-27 16:23:18.380143759 +0000 +@@ -7103,6 +7103,7 @@ EOF + rpath="$finalize_rpath" + test "$mode" != relink && rpath="$compile_rpath$rpath" + for libdir in $rpath; do ++ case "$libdir" in /usr/lib|/usr/lib64|/usr/lib/../lib|/usr/lib/../lib64) continue;; esac + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then +@@ -7798,6 +7799,7 @@ EOF + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do ++ case "$libdir" in /usr/lib|/usr/lib64|/usr/lib/../lib|/usr/lib/../lib64) continue;; esac + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then +@@ -7849,6 +7851,7 @@ EOF + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do ++ case "$libdir" in /usr/lib|/usr/lib64|/usr/lib/../lib|/usr/lib/../lib64) continue;; esac + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then +Only in binutils-2.37: ltmain.sh.orig diff --git a/SPECS/binutils.spec b/SPECS/binutils.spec index 48b3dae..05ce0c0 100644 --- a/SPECS/binutils.spec +++ b/SPECS/binutils.spec @@ -1,45 +1,8 @@ -# Determine if this is a native build or a cross build. -# -# For a cross build add --define "binutils_target " to the command -# line when building the rpms. -# -# For example: -# --define "binutils_target aarch64-linux-gnu" -# -# Cross builds will create a set of binutils executables that will run on the -# host machine but which will create binaries suitable for running on the -# target machine. The cross tools will have the target name as a prefix, -# but for compatibility with the kernel the rpms will use the target name -# as an infix. So for example building with the above define will create a -# set of rpms like this: -# -# binutils-aarch64-linux-gnu-2.35.1-14.fc34.x86_64.rpm -# binutils-aarch64-linux-gnu-debuginfo-2.35.1-14.fc34.x86_64.rpm -# [etc] -# -# and the rpms will contain files like: -# -# /usr/bin/aarch64-linux-gnu-addr2line -# /usr/bin/aarch64-linux-gnu-ar -# /usr/bin/aarch64-linux-gnu-as -# [etc] - -%if 0%{!?binutils_target:1} -%define binutils_target %{_target_platform} -%define isnative 1 -%define enable_shared 1 -%else -%define cross %{binutils_target}- -%define name_cross -%{binutils_target} -%define isnative 0 -%define enable_shared 0 -%endif - Summary: A GNU collection of binary utilities -Name: binutils%{?name_cross}%{?_with_debug:-debug} +Name: binutils%{?_with_debug:-debug} Version: 2.35.2 -Release: 17%{?dist} +Release: 42%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -50,18 +13,23 @@ URL: https://sourceware.org/binutils # --define "binutils_target arm-linux-gnu" to create arm-linux-gnu-binutils. # -# --with bootstrap Build with minimal dependencies. -# --with debug Build without optimizations and without splitting +# --with bootstrap Build with minimal dependencies. +# --with debug Build without optimizations and without splitting # the debuginfo into a separate file. # --without docs Skip building documentation. # Default is with docs, except when building a cross binutils. # --without testsuite Do not run the testsuite. Default is to run it. # --without gold Disable building of the GOLD linker. -# --with clang To force building with the CLANG. +# --with clang To force building with the CLANG. # --without debuginfod Disable support for debuginfod. +# --without systemzlib Use the binutils version of zlib. +# --without crossbuilds Do not build cross targeted versions of the binutils. #---Start of Configure Options----------------------------------------------- +# Create shared libraries. +%define enable_shared 1 + # Create deterministic archives (ie ones without timestamps). # Default is off because of BZ 1195883. %define enable_deterministic_archives 0 @@ -118,11 +86,18 @@ URL: https://sourceware.org/binutils %bcond_with clang # Default: support debuginfod. %bcond_without debuginfod - # Use the system supplied version of the zlib compress library. # Change this to use the binutils builtin version instead. %bcond_without systemzlib +# Create cross targeted versions of the binutils. +# For now we only do this for x86_64 hosts. +%ifarch x86_64 +%bcond_without crossbuilds +%else +%bcond_with crossbuilds +%endif + %if %{with bootstrap} %undefine with_docs %undefine with_testsuite @@ -402,6 +377,69 @@ Patch51: binutils-x86-AMX-insns.patch # Lifetime: Fixed in 2.38. Patch52: binutils-gas-Use-the-directory-name-in-.file-0.patch +# Purpose: Stop libtool from inserting useless runpaths into binaries. +# Lifetime: Who knows. +Patch53: gcc12-libtool-no-rpath.patch + +# Purpose: Allow the AArch64 RNG extension to be used wihtout ARMv8.5. +# In addition stops the assembler from issuing error messages for +# unknown AArch64 architectural extensions that are being disabled. +# This can happen when compiling with -mcpu=native on a machine which +# does not support all of the extensions known to GCC. +# See BZ 2071038 for more details. +# Lifetime: Permanent. +Patch54: binutils-aarch64-rng.patch + +# Purpose: Allow 'z16' to be used as an alias for the arch14 +# extensions of the S390 architecture. +# Lifetime: Fixed in 2.39 +Patch55: binutils-s390-z16.patch + +# Purpose: Add support for generating s390x static PIE binaries. +# Lifetime: Fixed in 2.37 +Patch56: binutils-s390x-static-PIE.patch + +# Purpose: Fix bogus linker warnings about references to undefined symbols. +# Lifetime: Fixed in 2.36 +Patch57: binutils-undefined-ref-to-sym.patch + +# Purpose: Fix unnecessary generation of CIE debug frames. +# Lifetime: Fixed in 2.40 +Patch58: binutils-CIE-generation.patch + +# Purpose: Fix a problem with symbol versioning with the LTO plugin. +# Lifetime: Fixed in 2.38 +Patch59: binutils-ld-ir-plugin.patch + +# Purpose: Allow the binutils to be configured with any (recent) version of +# autoconf. +# Lifetime: Fixed in 2.39 (maybe ?) +Patch60: binutils-autoconf-version.patch + +# Purpose: Increase the max number of open files to 20 for upstream binutils +# PR23460 test which may have more than 16 file descriptors open +# Lifetime: Fixed in 2.39 +Patch61: binutils-increase-the-max-number-of-open-fi.patch + +# Purpose: Remove a comment from bfd_stdint.h, indicating how the file was generated. +# Lifetime: Fixed in 2.39 ? +Patch62: binutils-no-comment-in-bfd-stdint.patch + +# Purpose: Fix a potential seg-fault when dumping corrupt ELF files. +# Lifetime: Fixed in 2.40 +Patch63: binutils-CVE-2023-25587.patch + +# Purpose: Fix an illegal memory access when parsing an elf file containing corrupt symbol version information +# Lifetime: 2.39 +Patch64: binutils-memory-access-when-parsing-an-elf-file.patch + +# Purpose: Fix an illegal memory access when parsing an elf file containing corrupt DWARF information +# Lifetime: 2.38 +Patch65: binutils.gold.dwarf-5-support.patch + +# Purpose: Add support for the AArch64 'flagm' extenstion to the assembler. +# Lifetime: 2.36 +Patch66: binutils-aarch64-flagm.patch #---------------------------------------------------------------------------- Provides: bundled(libiberty) @@ -547,6 +585,62 @@ Conflicts: gcc-c++ < 4.0.0 %{!?ld_bfd_priority: %global ld_bfd_priority 50} +#---------------------------------------------------------------------------- +%if %{with crossbuilds} + +# Only undefine with_testsuite here when testing changes to the spec file. +# %%undefine with_testsuite + +%global cross_targets aarch64-redhat-linux ppc64le-redhat-linux s390x-redhat-linux x86_64-redhat-linux + +%package -n cross-binutils-aarch64 +Summary: Cross targeted AArch64 binutils for developer use. Not intended for production. +Provides: cross-binutils-aarch64 = %{version}-%{release} +Requires: zlib-devel coreutils +BuildRequires: autoconf automake perl sed coreutils make gcc findutils gcc-c++ +ExcludeArch: aarch64-linux-gnu aarch64-redhat-linux + +%description -n cross-binutils-aarch64 +This package contains an AArch64 cross targeted version of the binutils for +use by developers. It is NOT INTENDED FOR PRODUCTION use. + + +%package -n cross-binutils-ppc64le +Summary: Cross targeted PPC64LE binutils for developer use. Not intended for production. +Provides: cross-binutils-ppc64le = %{version}-%{release} +Requires: zlib-devel coreutils +BuildRequires: autoconf automake perl sed coreutils make gcc findutils gcc-c++ +ExcludeArch: ppc64le-linux-gnu ppc64le-redhat-linux + +%description -n cross-binutils-ppc64le +This package contains a PPC64LE cross targeted version of the binutils for +use by developers. It is NOT INTENDED FOR PRODUCTION use. + + +%package -n cross-binutils-s390x +Summary: Cross targeted S390X binutils for developer use. Not intended for production. +Provides: cross-binutils-s390x = %{version}-%{release} +Requires: zlib-devel coreutils +BuildRequires: autoconf automake perl sed coreutils make gcc findutils gcc-c++ +ExcludeArch: s390x-linux-gnu s390x-redhat-linux + +%description -n cross-binutils-s390x +This package contains a S390X cross targeted version of the binutils for +use by developers. It is NOT INTENDED FOR PRODUCTION use. + + +%package -n cross-binutils-x86_64 +Summary: Cross targeted X86_64 binutils for developer use. Not intended for production. +Provides: cross-binutils-x86_64 = %{version}-%{release} +Requires: zlib-devel coreutils +BuildRequires: autoconf automake perl sed coreutils make gcc findutils gcc-c++ +ExcludeArch: x86_64-linux-gnu x86_64-redhat-linux i686-linux-gnu i686-redhat-linux + +%description -n cross-binutils-x86_64 +This package contains a X86_64 cross targeted version of the binutils for +use by developers. It is NOT INTENDED FOR PRODUCTION use. + +%endif #---------------------------------------------------------------------------- %prep @@ -592,260 +686,395 @@ touch */configure #---------------------------------------------------------------------------- %build -echo target is %{binutils_target} -%ifarch %{power64} -export CFLAGS="$RPM_OPT_FLAGS -Wno-error" -%else -export CFLAGS="$RPM_OPT_FLAGS" -%endif - -CARGS= +set_build_configuration() +{ + CARGS="--quiet \ + --build=%{_target_platform} \ + --host=%{_target_platform} \ + --enable-ld \ + --enable-plugins \ + --enable-64-bit-bfd \ + --with-bugurl=http://bugzilla.redhat.com/bugzilla/" %if %{with debuginfod} -CARGS="$CARGS --with-debuginfod" + CARGS="$CARGS --with-debuginfod" %endif -case %{binutils_target} in i?86*|sparc*|ppc*|s390*|sh*|arm*|aarch64*|riscv*) - CARGS="$CARGS --enable-64-bit-bfd" - ;; -esac - -# Extra targets to build along with the default one. -# -# BZ 1920373: Enable PEP support for all targets as the PERF package's -# testsuite expects to be able to read PE format files ragrdless of -# the host's architecture. -# -# Also enable the BPF target so that strip will work on BPF files. -case %{binutils_target} in - s390*) - # FIXME: For some unknown reason settting --enable-targets=x86_64-pep - # here breaks the building of GOLD. I have no idea why, and not enough - # knowledge of how gold is configured to fix quickly. So instead I have - # found that supporting "all" targets works. - CARGS="$CARGS --enable-targets=all" - ;; - ia64*) - CARGS="$CARGS --enable-targets=ia64-linux,x86_64-pep,bpf-unknown-none" - ;; - ppc64-*) - CARGS="$CARGS --enable-targets=powerpc64le-linux,spu,x86_64-pep,bpf-unknown-none" - ;; - ppc64le*) - CARGS="$CARGS --enable-targets=powerpc-linux,spu,x86_64-pep,bpf-unknown-none" - ;; - *) - CARGS="$CARGS --enable-targets=x86_64-pep,bpf-unknown-none" - ;; -esac - %if %{default_relro} - CARGS="$CARGS --enable-relro=yes" + CARGS="$CARGS --enable-relro=yes" %else - CARGS="$CARGS --enable-relro=no" -%endif - -%if %{with debug} -export CFLAGS="$CFLAGS -O0 -ggdb2 -Wno-error -D_FORTIFY_SOURCE=0" -%define enable_shared 0 -%endif - -# BZ 1541027 - include the linker flags from redhat-rpm-config as well. -export LDFLAGS=$RPM_LD_FLAGS - -%if %{with clang} -%define _with_cc_clang 1 + CARGS="$CARGS --enable-relro=no" %endif -# Dependencies are not set up to rebuild the configure files -# in the subdirectories. So we just rebuild the ones we care -# about after applying the configure patches -pushd libiberty -autoconf -popd -pushd intl -autoconf -popd - - -# We could improve the cross build's size by setting --enable-shared but -# the produced binaries may be less convenient in the embedded environment. -%configure \ - --quiet \ - --build=%{_target_platform} --host=%{_target_platform} \ - --target=%{binutils_target} \ -%if %{with gold} - --enable-gold=default \ -%endif - --enable-ld \ -%if %{isnative} - --with-sysroot=/ \ -%else - --enable-targets=%{_host} \ - --with-sysroot=%{_prefix}/%{binutils_target}/sys-root \ - --program-prefix=%{cross} \ -%endif %if %{with systemzlib} - --with-system-zlib \ -%endif -%if %{enable_shared} - --enable-shared \ -%else - --disable-shared \ + CARGS="$CARGS --with-system-zlib" %endif + %if %{enable_deterministic_archives} - --enable-deterministic-archives \ + CARGS="$CARGS --enable-deterministic-archives" %else - --enable-deterministic-archives=no \ + CARGS="$CARGS --enable-deterministic-archives=no" %endif + %if %{enable_lto} - --enable-lto \ + CARGS="$CARGS --enable-lto" %endif + %if %{enable_new_dtags} - --enable-new-dtags \ + CARGS="$CARGS --enable-new-dtags" %endif + %if %{default_compress_debug} - --enable-compressed-debug-sections=all \ + CARGS="$CARGS --enable-compressed-debug-sections=all" %else - --enable-compressed-debug-sections=none \ + CARGS="$CARGS --enable-compressed-debug-sections=none" %endif + %if %{default_generate_notes} - --enable-generate-build-notes=yes \ + CARGS="$CARGS --enable-generate-build-notes=yes" %else - --enable-generate-build-notes=no \ + CARGS="$CARGS --enable-generate-build-notes=no" %endif + %if %{enable_threading} - --enable-threads=yes \ + CARGS="$CARGS --enable-threads=yes" +%else + CARGS="$CARGS --enable-threads=no" +%endif +} + +# ---------------------------------------------------------------- + +reconfigure_sources() +{ + # Dependencies are not set up to rebuild the configure files + # in the subdirectories. So we just rebuild the ones we care + # about after applying the configure patches + pushd libiberty + autoconf + popd + pushd intl + autoconf + popd +} + +# ---------------------------------------------------------------- +# +# build() +# Build the binutils. +# $1 is the target architecture +# $2 is 1 if this is a native build +# $3 is 1 if shared libraries should be built +# +build() +{ + local target="$1" + local native="$2" + local shared="$3" + local builddir=build-$target + + # Create a buyild directory + rm -rf $builddir + mkdir $builddir + pushd $builddir + + echo "BUILDING the binutils FOR TARGET $target (native ? $native) (shared ? $shared)" + +%ifarch %{power64} + export CFLAGS="$RPM_OPT_FLAGS -Wno-error" %else - --enable-threads=no \ + export CFLAGS="$RPM_OPT_FLAGS" +%endif + +%if %{with debug} + export CFLAGS="$CFLAGS -O0 -ggdb2 -Wno-error -D_FORTIFY_SOURCE=0" + shared=0 +%endif + + export CXXFLAGS="$CXXFLAGS $CFLAGS" + + # BZ 1541027 - include the linker flags from redhat-rpm-config as well. + export LDFLAGS=$RPM_LD_FLAGS + +%if %{with clang} +%define _with_cc_clang 1 %endif - $CARGS \ - --enable-plugins \ - --with-bugurl=http://bugzilla.redhat.com/bugzilla/ \ - || cat config.log + + + # Extra targets to build along with the default one. + # + # BZ 1920373: Enable PEP support for all targets as the PERF package's + # testsuite expects to be able to read PE format files ragrdless of + # the host's architecture. + # + # Also enable the BPF target so that strip will work on BPF files. + case $target in + s390*) + # Note - The s390-linux target is there so that the GOLD linker will + # build. By default, if configured for just s390x-linux, the GOLD + # configure system will only include support for 64-bit targets, but + # the s390x gold backend uses both 32-bit and 64-bit templates. + TARGS="--enable-targets=s390-linux,s390x-linux,x86_64-pep,bpf-unknown-none" + ;; + ia64*) + TARGS="--enable-targets=ia64-linux,x86_64-pep,bpf-unknown-none" + ;; + ppc64-*) + TARGS="--enable-targets=powerpc64le-linux,spu,x86_64-pep,bpf-unknown-none" + ;; + ppc64le*) + TARGS="--enable-targets=powerpc-linux,spu,x86_64-pep,bpf-unknown-none" + ;; + *) + TARGS="--enable-targets=x86_64-pep,bpf-unknown-none" + ;; + esac + + # We disable the GOLD linker for cross builds because although it does + # support sysroots specified on the command line, it does not support + # them in linker scripts via the =/$SYSROOT prefix. + + if test x$native == x1 ; then + SARGS="--with-sysroot=/ \ + --prefix=%{_prefix} \ + --libdir=%{_libdir} \ + --enable-gold=default" + else + TARGS="" + SARGS="--with-sysroot=yes \ + --program-prefix=$target- \ + --prefix=%{_prefix}/$target \ + --libdir=%{_libdir} \ + --exec-prefix=%{_usr} \ + --disable-gold" + fi + + if test x$shared == x1 ; then + RARGS="--enable-shared" + else + RARGS="--disable-shared" + fi + + ../configure --target=$target $SARGS $RARGS $CARGS $TARGS || cat config.log %if %{with docs} -%make_build %{_smp_mflags} tooldir=%{_prefix} all -%make_build %{_smp_mflags} tooldir=%{_prefix} info + # Because of parallel building, info has to be made after all. + %make_build %{_smp_mflags} tooldir=%{_prefix} all + %make_build %{_smp_mflags} tooldir=%{_prefix} info %else -%make_build %{_smp_mflags} tooldir=%{_prefix} MAKEINFO=true all + %make_build %{_smp_mflags} tooldir=%{_prefix} MAKEINFO=true all %endif + + popd +} -# Do not use %%check as it is run after %%install where libbfd.so is rebuilt -# with -fvisibility=hidden no longer being usable in its shared form. +#---------------------------------------------------------------------------- + +# +# run_tests() +# Test a built (but not installed) binutils. +# $1 is the target architecture +# $2 is 1 if this is a native build +# +run_tests() +{ + local target="$1" + local native="$2" + + echo "TESTING the binutils FOR TARGET $target (native ? $native)" + + # Do not use %%check as it is run after %%install where libbfd.so is rebuilt + # with -fvisibility=hidden no longer being usable in its shared form. %if %{without testsuite} -echo ====================TESTSUITE DISABLED========================= -%else -make -k check < /dev/null || : -echo ====================TESTING========================= -cat {gas/testsuite/gas,ld/ld,binutils/binutils}.sum + echo ================ $target == TESTSUITE DISABLED ==================== + return +%endif + + pushd build-$target + + if test x$native == x1 ; then + make -k check < /dev/null || : + else + make -k check-gas check-binutils < /dev/null || : + fi + + echo ================ $target == TESTING BEGINS ======================== + for f in {gas/testsuite/gas,ld/ld,binutils/binutils}.sum + do + if [ -f $f ]; then + cat $f + fi + done + %if %{with gold} -if [ -f gold/test-suite.log ]; then - cat gold/test-suite.log -fi -if [ -f gold/testsuite/test-suite.log ]; then - cat gold/testsuite/*.log -fi + if [ -f gold/test-suite.log ]; then + cat gold/test-suite.log + fi + if [ -f gold/testsuite/test-suite.log ]; then + cat gold/testsuite/*.log + fi %endif -echo ====================TESTING END===================== -for file in {gas/testsuite/gas,ld/ld,binutils/binutils}.{sum,log} -do - ln $file binutils-%{_target_platform}-$(basename $file) || : -done -tar cjf binutils-%{_target_platform}.tar.xz binutils-%{_target_platform}-*.{sum,log} -uuencode binutils-%{_target_platform}.tar.xz binutils-%{_target_platform}.tar.xz -rm -f binutils-%{_target_platform}.tar.xz binutils-%{_target_platform}-*.{sum,log} + echo ================ $target == TESTING END =========================== + + for file in {gas/testsuite/gas,ld/ld,binutils/binutils}.{sum,log} + do + if [ -f $file ]; then + ln $file binutils-$target-$(basename $file) || : + fi + done + tar cjf binutils-$target.tar.xz binutils-$target-*.{sum,log} + uuencode binutils-$target.tar.xz binutils-$target.tar.xz + rm -f binutils-$target.tar.xz binutils-$target-*.{sum,log} + %if %{with gold} -if [ -f gold/testsuite/test-suite.log ]; then - tar cjf binutils-%{_target_platform}-gold.log.tar.xz gold/testsuite/*.log - uuencode binutils-%{_target_platform}-gold.log.tar.xz binutils-%{_target_platform}-gold.log.tar.xz - rm -f binutils-%{_target_platform}-gold.log.tar.xz -fi + if [ -f gold/testsuite/test-suite.log ]; then + tar cjf binutils-$target-gold.log.tar.xz gold/testsuite/*.log + uuencode binutils-$target-gold.log.tar.xz binutils-$target-gold.log.tar.xz + rm -f binutils-$target-gold.log.tar.xz + fi %endif + + popd +} + +#---------------------------------------------------------------------------- + +set_build_configuration + +# reconfigure_sources + +build %{_target_platform} 1 %{enable_shared} + +run_tests %{_target_platform} 1 + +%if %{with crossbuilds} + +for f in %{cross_targets}; do + + if test x$f != x%{_target_platform}; then + # We could improve the cross build's size by enabling shared libraries but + # the produced binaries may be less convenient in the embedded environment. + build $f 0 0 + + run_tests $f 0 + fi +done + %endif +#---------------------------------------------------------------------------- #---------------------------------------------------------------------------- %install -%if %{with docs} -%make_install DESTDIR=%{buildroot} -%else -%make_install DESTDIR=%{buildroot} MAKEINFO=true -%endif -%if %{isnative} +# install_binutils() +# Install the binutils. +# $1 is the target architecture +# $2 is 1 if this is a native build +# $3 is 1 if shared libraries should be built +# +install_binutils() +{ + local target="$1" + local native="$2" + local shared="$3" + + local local_root=%{buildroot}/usr + local local_bindir=$local_root/bin + local local_libdir=%{buildroot}%{_libdir} + local local_mandir=$local_root/share/man/man1 + local local_incdir=$local_root/include + local local_infodir=$local_root/share/info + local local_libdir + + mkdir -p $local_libdir + mkdir -p $local_incdir + mkdir -p $local_mandir + mkdir -p $local_infodir + + echo "INSTALLING the binutils FOR TARGET $target (native ? $native) (shared ? $shared)" + + pushd build-$target + + if test x$native == x1 ; then + %if %{with docs} -make prefix=%{buildroot}%{_prefix} infodir=%{buildroot}%{_infodir} install-info + %make_install DESTDIR=%{buildroot} + make prefix=%{buildroot}%{_prefix} infodir=$local_infodir install-info +%else + %make_install DESTDIR=%{buildroot} MAKEINFO=true %endif -# Rebuild libiberty.a with -fPIC. -# Future: Remove it together with its header file, projects should bundle it. -%make_build -C libiberty clean -%set_build_flags -%make_build CFLAGS="-g -fPIC $RPM_OPT_FLAGS" -C libiberty - -# Rebuild libbfd.a with -fPIC. -# Without the hidden visibility the 3rd party shared libraries would export -# the bfd non-stable ABI. -%make_build -C bfd clean -%set_build_flags -%make_build CFLAGS="-g -fPIC $RPM_OPT_FLAGS -fvisibility=hidden" -C bfd - -# Rebuild libopcodes.a with -fPIC. -%make_build -C opcodes clean -%set_build_flags -%make_build CFLAGS="-g -fPIC $RPM_OPT_FLAGS" -C opcodes - -install -m 644 bfd/libbfd.a %{buildroot}%{_libdir} -install -m 644 libiberty/libiberty.a %{buildroot}%{_libdir} -install -m 644 include/libiberty.h %{buildroot}%{_prefix}/include -install -m 644 opcodes/libopcodes.a %{buildroot}%{_libdir} -# Remove Windows/Novell only man pages -rm -f %{buildroot}%{_mandir}/man1/{dlltool,nlmconv,windres,windmc}* + # Rebuild libiberty.a with -fPIC. + # Future: Remove it together with its header file, projects should bundle it. + %make_build -s -C libiberty clean + %set_build_flags + %make_build -s CFLAGS="-g -fPIC $RPM_OPT_FLAGS" -C libiberty + + # Rebuild libbfd.a with -fPIC. + # Without the hidden visibility the 3rd party shared libraries would export + # the bfd non-stable ABI. + %make_build -s -C bfd clean + %set_build_flags + %make_build -s CFLAGS="-g -fPIC $RPM_OPT_FLAGS -fvisibility=hidden" -C bfd + + # Rebuild libopcodes.a with -fPIC. + %make_build -s -C opcodes clean + %set_build_flags + %make_build -s CFLAGS="-g -fPIC $RPM_OPT_FLAGS" -C opcodes + + install -m 644 bfd/libbfd.a $local_libdir + install -m 644 libiberty/libiberty.a $local_libdir + install -m 644 ../include/libiberty.h $local_incdir + install -m 644 opcodes/libopcodes.a $local_libdir + + # Remove Windows/Novell only man pages + rm -f $local_mandir/{dlltool,nlmconv,windres,windmc}* %if %{without docs} -rm -f %{buildroot}%{_mandir}/man1/{addr2line,ar,as,c++filt,elfedit,gprof,ld,nm,objcopy,objdump,ranlib,readelf,size,strings,strip}* -rm -f %{buildroot}%{_infodir}/{as,bfd,binutils,gprof,ld}* + rm -f $local_mandir/{addr2line,ar,as,c++filt,elfedit,gprof,ld,nm,objcopy,objdump,ranlib,readelf,size,strings,strip}* + rm -f $local_infodir/{as,bfd,binutils,gprof,ld}* %endif %if %{enable_shared} -chmod +x %{buildroot}%{_libdir}/lib*.so* + chmod +x $local_libdir/lib*.so* %endif -# Prevent programs from linking against libbfd and libopcodes -# dynamically, as they are changed far too often. -rm -f %{buildroot}%{_libdir}/lib{bfd,opcodes}.so + # Prevent programs from linking against libbfd and libopcodes + # dynamically, as they are changed far too often. + rm -f $local_libdir/lib{bfd,opcodes}.so -# Remove libtool files, which reference the .so libs -rm -f %{buildroot}%{_libdir}/lib{bfd,opcodes}.la + # Remove libtool files, which reference the .so libs + rm -f %local_libdir/lib{bfd,opcodes}.la -# Sanity check --enable-64-bit-bfd really works. -grep '^#define BFD_ARCH_SIZE 64$' %{buildroot}%{_prefix}/include/bfd.h -# Fix multilib conflicts of generated values by __WORDSIZE-based expressions. + # Sanity check --enable-64-bit-bfd really works. + grep '^#define BFD_ARCH_SIZE 64$' $local_incdir/bfd.h + # Fix multilib conflicts of generated values by __WORDSIZE-based expressions. %ifarch %{ix86} x86_64 ppc %{power64} s390 s390x sh3 sh4 sparc sparc64 arm -sed -i -e '/^#include "ansidecl.h"/{p;s~^.*$~#include ~;}' \ - -e 's/^#define BFD_DEFAULT_TARGET_SIZE \(32\|64\) *$/#define BFD_DEFAULT_TARGET_SIZE __WORDSIZE/' \ - -e 's/^#define BFD_HOST_64BIT_LONG [01] *$/#define BFD_HOST_64BIT_LONG (__WORDSIZE == 64)/' \ - -e 's/^#define BFD_HOST_64_BIT \(long \)\?long *$/#if __WORDSIZE == 32\ + sed -i -e '/^#include "ansidecl.h"/{p;s~^.*$~#include ~;}' \ + -e 's/^#define BFD_DEFAULT_TARGET_SIZE \(32\|64\) *$/#define BFD_DEFAULT_TARGET_SIZE __WORDSIZE/' \ + -e 's/^#define BFD_HOST_64BIT_LONG [01] *$/#define BFD_HOST_64BIT_LONG (__WORDSIZE == 64)/' \ + -e 's/^#define BFD_HOST_64_BIT \(long \)\?long *$/#if __WORDSIZE == 32\ #define BFD_HOST_64_BIT long long\ #else\ #define BFD_HOST_64_BIT long\ #endif/' \ - -e 's/^#define BFD_HOST_U_64_BIT unsigned \(long \)\?long *$/#define BFD_HOST_U_64_BIT unsigned BFD_HOST_64_BIT/' \ - %{buildroot}%{_prefix}/include/bfd.h + -e 's/^#define BFD_HOST_U_64_BIT unsigned \(long \)\?long *$/#define BFD_HOST_U_64_BIT unsigned BFD_HOST_64_BIT/' \ + $local_incdir/bfd.h %endif -touch -r bfd/bfd-in2.h %{buildroot}%{_prefix}/include/bfd.h -# Generate .so linker scripts for dependencies; imported from glibc/Makerules: + touch -r ../bfd/bfd-in2.h $local_incdir/bfd.h + + # Generate .so linker scripts for dependencies; imported from glibc/Makerules: -# This fragment of linker script gives the OUTPUT_FORMAT statement -# for the configuration we are building. -OUTPUT_FORMAT="\ + # This fragment of linker script gives the OUTPUT_FORMAT statement + # for the configuration we are building. + OUTPUT_FORMAT="\ /* Ensure this .so library will not be used by a link for a different format on a multi-architecture system. */ $(gcc $CFLAGS $LDFLAGS -shared -x c /dev/null -o /dev/null -Wl,--verbose -v 2>&1 | sed -n -f "%{SOURCE2}")" -tee %{buildroot}%{_libdir}/libbfd.so <> binutils.lang + cat bfd.lang >> binutils.lang + cat gas.lang >> binutils.lang + cat gprof.lang >> binutils.lang + + if [ -x ld/ld-new ]; then + %find_lang ld + cat ld.lang >> binutils.lang + fi + + if [ -x gold/ld-new ]; then + %find_lang gold + cat gold.lang >> binutils.lang + fi + + popd +} -# This one comes from gcc -rm -f %{buildroot}%{_infodir}/dir -rm -rf %{buildroot}%{_prefix}/%{binutils_target} - -%find_lang %{?cross}binutils -%find_lang %{?cross}opcodes -%find_lang %{?cross}bfd -%find_lang %{?cross}gas -%find_lang %{?cross}gprof -cat %{?cross}opcodes.lang >> %{?cross}binutils.lang -cat %{?cross}bfd.lang >> %{?cross}binutils.lang -cat %{?cross}gas.lang >> %{?cross}binutils.lang -cat %{?cross}gprof.lang >> %{?cross}binutils.lang - -if [ -x ld/ld-new ]; then - %find_lang %{?cross}ld - cat %{?cross}ld.lang >> %{?cross}binutils.lang -fi -if [ -x gold/ld-new ]; then - %find_lang %{?cross}gold - cat %{?cross}gold.lang >> %{?cross}binutils.lang -fi +#---------------------------------------------------------------------------- + +install_binutils %{_target_platform} 1 %{enable_shared} + +%if %{with crossbuilds} + +for f in %{cross_targets}; do + if test x$f != x%{_target_platform}; then + # We could improve the cross build's size by enabling shared libraries but + # the produced binaries may be less convenient in the embedded environment. + install_binutils $f 0 0 + fi +done + +%endif # Stop check-rpaths from complaining about standard runpaths. -export QA_RPATHS=0x0001 +export QA_RPATHS=0x0003 +#---------------------------------------------------------------------------- #---------------------------------------------------------------------------- %post -%__rm -f %{_bindir}/%{?cross}ld -%{_sbindir}/alternatives --install %{_bindir}/%{?cross}ld %{?cross}ld \ - %{_bindir}/%{?cross}ld.bfd %{ld_bfd_priority} +%__rm -f %{_bindir}/ld +%{_sbindir}/alternatives --install %{_bindir}/ld ld \ + %{_bindir}/ld.bfd %{ld_bfd_priority} %if %{with gold} -%{_sbindir}/alternatives --install %{_bindir}/%{?cross}ld %{?cross}ld \ - %{_bindir}/%{?cross}ld.gold %{ld_gold_priority} +%{_sbindir}/alternatives --install %{_bindir}/ld ld \ + %{_bindir}/ld.gold %{ld_gold_priority} %endif # Do not run "alternatives --auto ld" here. Leave the setting to # however the user previously had it set. See BZ 1592069 for more details. -%if %{isnative} %ldconfig_post -%endif exit 0 @@ -926,11 +1171,11 @@ exit 0 %preun if [ $1 = 0 ]; then - %{_sbindir}/alternatives --remove %{?cross}ld %{_bindir}/%{?cross}ld.bfd + %{_sbindir}/alternatives --remove ld %{_bindir}/ld.bfd fi %if %{with gold} if [ $1 = 0 ]; then - %{_sbindir}/alternatives --remove %{?cross}ld %{_bindir}/%{?cross}ld.gold + %{_sbindir}/alternatives --remove ld %{_bindir}/ld.gold fi %endif @@ -938,58 +1183,175 @@ exit 0 #---------------------------------------------------------------------------- -%if %{isnative} %postun %ldconfig_postun -%endif #---------------------------------------------------------------------------- -%files -f %{?cross}binutils.lang +%files -f build-%{_target_platform}/binutils.lang + +%if %{with crossbuilds} +%if "%{_target_platform}" != "aarch64-redhat-linux" +%exclude /usr/aarch64-redhat-linux/* +%exclude /usr/bin/aarch64-redhat-linux-* +%endif + +%if "%{_target_platform}" != "ppc64le-redhat-linux" +%exclude /usr/ppc64le-redhat-linux/* +%exclude /usr/bin/ppc64le-redhat-linux-* +%endif + +%if "%{_target_platform}" != "s390x-redhat-linux" +%exclude /usr/s390x-redhat-linux/* +%exclude /usr/bin/s390x-redhat-linux-* +%endif + +%if "%{_target_platform}" != "x86_64-redhat-linux" +%exclude /usr/x86_64-redhat-linux/* +%exclude /usr/bin/x86_64-redhat-linux-* +%endif +%endif + %license COPYING COPYING3 COPYING3.LIB COPYING.LIB %doc README -%{_bindir}/%{?cross}[!l]* +%{_bindir}/[!l]* # Strictly speaking ld is a symlink not a ghost file, but %%verify does not support symlinks -%ghost %{_bindir}/%{?cross}ld -%{_bindir}/%{?cross}ld.bfd +%ghost %{_bindir}/ld +%{_bindir}/ld.bfd %if %{with docs} %{_mandir}/man1/ -%if %{isnative} %{_infodir}/as.info.* %{_infodir}/binutils.info.* %{_infodir}/gprof.info.* %{_infodir}/ld.info.* %{_infodir}/bfd.info.* %endif -%endif %if %{enable_shared} -%{_libdir}/lib*.so -%{_libdir}/libctf* +%{_libdir}/lib*.so* +%{_libdir}/lib*.la %exclude %{_libdir}/libbfd.so %exclude %{_libdir}/libopcodes.so +%exclude %{_libdir}/libbfd.la +%exclude %{_libdir}/libopcodes.la %endif -%if %{isnative} +%if %{with gold} +%files gold +%{_bindir}/ld.gold +%endif %files devel %{_prefix}/include/* %{_libdir}/lib*.a %{_libdir}/libbfd.so %{_libdir}/libopcodes.so +%{_libdir}/libbfd.la +%{_libdir}/libopcodes.la + +%if %{with crossbuilds} +%if "%{_target_platform}" != "aarch64-redhat-linux" +%files -n cross-binutils-aarch64 +/usr/aarch64-redhat-linux/ +/usr/bin/aarch64-redhat-linux-* %endif -%if %{with gold} -%files gold -%{_bindir}/%{?cross}ld.gold +%if "%{_target_platform}" != "ppc64le-redhat-linux" +%files -n cross-binutils-ppc64le +/usr/ppc64le-redhat-linux/ +/usr/bin/ppc64le-redhat-linux-* +%endif + +%if "%{_target_platform}" != "s390x-redhat-linux" +%files -n cross-binutils-s390x +/usr/s390x-redhat-linux/ +/usr/bin/s390x-redhat-linux-* %endif -# %%ghost %%{_bindir}/%%{?cross}ld +%if "%{_target_platform}" != "x86_64-redhat-linux" +%files -n cross-binutils-x86_64 +/usr/x86_64-redhat-linux/ +/usr/bin/x86_64-redhat-linux-* +%endif + +%endif #---------------------------------------------------------------------------- %changelog +* Wed Apr 26 2023 Nick Clifton - 2.35.2-42 +- Add support for the AArch64 'flagm' extenstion to the assembler. (#2189304) + +* Wed Apr 19 2023 Nick Clifton - 2.35.2-41 +- Add DWARF-5 support to GOLD. (#2182587) + +* Thu Mar 16 2023 Yara Ahmad - 2.35.2-40 +- Fix an illegal memory access when parsing an ELF file containing corrupt symbol version information. (#2164701) + +* Thu Mar 09 2023 Nick Clifton - 2.35.2-39 +- NVR bump to allow rebuilding. + +* Fri Mar 03 2023 Nick Clifton - 2.35.2-38 +- Fix a potential seg-fault when dumping a corrupt ELF format file. (#2174205) + +* Fri Jan 20 2023 Nick Clifton - 2.35.2-37 +- Stop the cross binaries from leaking into the native packages. + +* Thu Jan 19 2023 Nick Clifton - 2.35.2-36 +- Ensure that x76_64 and i686 versions of bfd_stdint.h are the same. (#2162328) + +* Tue Jan 10 2023 Nick Clifton - 2.35.2-35 +- Extend fix handling symbol versioning with LTO plugins. (#2148469) + +* Mon Dec 19 2022 Nick Clifton - 2.35.2-33 +- Restore libiberty.a to the binutils-devel package. (#2154772) + +* Wed Dec 14 2022 Nick Clifton - 2.35.2-32 +- Fix special case of previous delta for s390x. (#2151938) + +* Mon Dec 12 2022 Yara Ahmamd -2.35.2-31 +- Increase the max number of open files to 20. (#2151938) + +* Mon Dec 12 2022 Nick Clifton - 2.35.2-30 +- Disable building GOLD for cross-binutils. + +* Wed Dec 07 2022 Nick Clifton - 2.35.2-29 +- Eliminate duplicates between sub-packages and add missing shared libraries. (#2149646) + +* Wed Nov 30 2022 Nick Clifton - 2.35.2-28 +- Eliminate duplicates between sub-packages. (#2149646) + +* Wed Nov 30 2022 Nick Clifton - 2.35.2-27 +- Create cross-binutils- sub-packages. (#2149646) + +* Mon Nov 28 2022 Nick Clifton - 2.35.2-26 +- Fix handling symbol versioning with LTO plugins. (#2148469) + +* Thu Sep 08 2022 Nick Clifton - 2.35.2-25 +- Fix the generation of unnecesaary CIE stack unwinding frames. (#2121123) + +* Mon Jun 13 2022 Nick Clifton - 2.35.2-24 +- Fix bogus linker warnings about references to undefined symbols. (#2095926) + +* Mon May 23 2022 Nick Clifton - 2.35.2-23 +- GAS: AArch64: Do not complain about unknown disabled architecture extensions. (#2071038) + +* Tue May 03 2022 Nick Clifton - 2.35.2-22 +- Add support for generating s390x static PIE binaries. (#2080164) + +* Mon Apr 11 2022 Nick Clifton - 2.35.2-21 +- Allow z16 to be used as an alias for the arch14 extenstions to the S390 architecture. (#2073383) + +* Tue Apr 05 2022 Nick Clifton - 2.35.2-20 +- Allow the AArch64 architecture's RNG extension to be used without ARMv8.5. (#2071038) + +* Wed Mar 30 2022 Nick Clifton - 2.35.2-19 +- NVR bump to allow rebuild. (#2057638) + +* Mon Mar 07 2022 Nick Clifton - 2.35.2-18 +- Do not export any windows tools (if they were built). (#2057638) + * Mon Jan 24 2022 Nick Clifton - 2.35.2-17 - Add upstream patch to use the directory name in .file 0, fixes ccache FTBFS (#2043970)