import binutils-2.30-75.el8

This commit is contained in:
CentOS Sources 2020-07-28 08:52:06 -04:00 committed by Stepan Oksanichenko
parent 4f4503b4ea
commit b931a56fce
14 changed files with 5142 additions and 11 deletions

View File

@ -0,0 +1,62 @@
--- binutils.orig/bfd/dwarf2.c 2019-12-03 15:50:43.324118062 +0000
+++ binutils-2.30/bfd/dwarf2.c 2019-12-03 15:54:32.545489215 +0000
@@ -2803,8 +2803,8 @@ lookup_symbol_in_variable_table (struct
static bfd_boolean
find_abstract_instance_name (struct comp_unit *unit,
- bfd_byte *orig_info_ptr,
struct attribute *attr_ptr,
+ unsigned int recur_count,
const char **pname,
bfd_boolean *is_linkage)
{
@@ -2817,6 +2817,14 @@ find_abstract_instance_name (struct comp
struct attribute attr;
const char *name = NULL;
+ if (recur_count == 100)
+ {
+ _bfd_error_handler
+ (_("DWARF error: abstract instance recursion detected"));
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+
/* DW_FORM_ref_addr can reference an entry in a different CU. It
is an offset from the .debug_info section, not the current CU. */
if (attr_ptr->form == DW_FORM_ref_addr)
@@ -2934,15 +2942,7 @@ find_abstract_instance_name (struct comp
info_ptr, info_ptr_end);
if (info_ptr == NULL)
break;
- /* It doesn't ever make sense for DW_AT_specification to
- refer to the same DIE. Stop simple recursion. */
- if (info_ptr == orig_info_ptr)
- {
- _bfd_error_handler
- (_("Dwarf Error: Abstract instance recursion detected."));
- bfd_set_error (bfd_error_bad_value);
- return FALSE;
- }
+
switch (attr.name)
{
case DW_AT_name:
@@ -2956,7 +2956,7 @@ find_abstract_instance_name (struct comp
}
break;
case DW_AT_specification:
- if (!find_abstract_instance_name (unit, info_ptr, &attr,
+ if (!find_abstract_instance_name (unit, &attr, recur_count + 1,
pname, is_linkage))
return FALSE;
break;
@@ -3162,7 +3162,7 @@ scan_unit_for_symbols (struct comp_unit
case DW_AT_abstract_origin:
case DW_AT_specification:
- if (!find_abstract_instance_name (unit, info_ptr, &attr,
+ if (!find_abstract_instance_name (unit, &attr, 0,
&func->name,
&func->is_linkage))
goto fail;

View File

@ -0,0 +1,20 @@
--- binutils.orig/bfd/dwarf2.c 2019-11-13 11:32:09.395430104 +0000
+++ binutils-2.33.1/bfd/dwarf2.c 2019-11-13 11:33:17.272899503 +0000
@@ -4440,7 +4440,16 @@ _bfd_dwarf2_slurp_debug_info (bfd *abfd,
for (total_size = 0;
msec;
msec = find_debug_info (debug_bfd, debug_sections, msec))
- total_size += msec->size;
+ {
+ /* Catch PR25070 testcase overflowing size calculation here. */
+ if (total_size + msec->size < total_size
+ || total_size + msec->size < msec->size)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return FALSE;
+ }
+ total_size += msec->size;
+ }
stash->info_ptr_memory = (bfd_byte *) bfd_malloc (total_size);
if (stash->info_ptr_memory == NULL)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,122 @@
diff -rup binutils.orig/ld/testsuite/ld-aarch64/variant_pcs-now.d binutils-2.30/ld/testsuite/ld-aarch64/variant_pcs-now.d
--- binutils.orig/ld/testsuite/ld-aarch64/variant_pcs-now.d 2020-04-06 16:21:53.296852157 +0100
+++ binutils-2.30/ld/testsuite/ld-aarch64/variant_pcs-now.d 2020-04-06 16:28:56.733001935 +0100
@@ -5,28 +5,29 @@
Relocation section '\.rela\.plt' at offset 0x11000 contains 12 entries:
Offset Info Type Symbol's Value Symbol's Name \+ Addend
-0000000000009020 0000000100000402 R_AARCH64_JUMP_SLOT 0000000000000000 f_base_global_default_undef \+ 0
-0000000000009028 0000000200000402 R_AARCH64_JUMP_SLOT 0000000000000000 f_spec_global_default_undef \+ 0
-0000000000009030 0000000400000402 R_AARCH64_JUMP_SLOT 0000000000008000 f_base_global_default_def \+ 0
-0000000000009038 0000000500000402 R_AARCH64_JUMP_SLOT 0000000000008000 f_spec_global_default_def \+ 0
+0000000000009020 0000000.00000402 R_AARCH64_JUMP_SLOT 0000000000000000 f_base_global_default_undef \+ 0
+0000000000009028 0000000.00000402 R_AARCH64_JUMP_SLOT 0000000000000000 f_spec_global_default_undef \+ 0
+0000000000009030 0000000.00000402 R_AARCH64_JUMP_SLOT 0000000000008000 f_base_global_default_def \+ 0
+0000000000009038 0000000.00000402 R_AARCH64_JUMP_SLOT 0000000000008000 f_spec_global_default_def \+ 0
0000000000009040 0000000000000408 R_AARCH64_IRELATIVE 8000
-0000000000009048 0000000300000402 R_AARCH64_JUMP_SLOT f_spec_global_default_ifunc\(\) f_spec_global_default_ifunc \+ 0
+0000000000009048 0000000.00000402 R_AARCH64_JUMP_SLOT f_spec_global_default_ifunc\(\) f_spec_global_default_ifunc \+ 0
0000000000009050 0000000000000408 R_AARCH64_IRELATIVE 8000
-0000000000009058 0000000600000402 R_AARCH64_JUMP_SLOT f_base_global_default_ifunc\(\) f_base_global_default_ifunc \+ 0
+0000000000009058 0000000.00000402 R_AARCH64_JUMP_SLOT f_base_global_default_ifunc\(\) f_base_global_default_ifunc \+ 0
0000000000009060 0000000000000408 R_AARCH64_IRELATIVE 8038
0000000000009068 0000000000000408 R_AARCH64_IRELATIVE 8000
0000000000009070 0000000000000408 R_AARCH64_IRELATIVE 8000
0000000000009078 0000000000000408 R_AARCH64_IRELATIVE 8038
-Symbol table '\.dynsym' contains 7 entries:
+Symbol table '\.dynsym' contains . entries:
Num: Value Size Type Bind Vis Ndx Name
- 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
- 1: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_base_global_default_undef
- 2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_spec_global_default_undef \[VARIANT_PCS\]
- 3: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_spec_global_default_ifunc \[VARIANT_PCS\]
- 4: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_base_global_default_def
- 5: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_spec_global_default_def \[VARIANT_PCS\]
- 6: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_base_global_default_ifunc
+ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
+#...
+ .: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_base_global_default_undef
+ .: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_spec_global_default_undef \[VARIANT_PCS\]
+ .: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_spec_global_default_ifunc \[VARIANT_PCS\]
+ .: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_base_global_default_def
+ .: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_spec_global_default_def \[VARIANT_PCS\]
+ .: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_base_global_default_ifunc
Symbol table '\.symtab' contains 35 entries:
Num: Value Size Type Bind Vis Ndx Name
diff -rup binutils.orig/ld/testsuite/ld-aarch64/variant_pcs-shared.d binutils-2.30/ld/testsuite/ld-aarch64/variant_pcs-shared.d
--- binutils.orig/ld/testsuite/ld-aarch64/variant_pcs-shared.d 2020-04-06 16:21:53.296852157 +0100
+++ binutils-2.30/ld/testsuite/ld-aarch64/variant_pcs-shared.d 2020-04-06 16:28:35.565094429 +0100
@@ -5,28 +5,29 @@
Relocation section '\.rela\.plt' at offset 0x11000 contains 12 entries:
Offset Info Type Symbol's Value Symbol's Name \+ Addend
-0000000000009020 0000000100000402 R_AARCH64_JUMP_SLOT 0000000000000000 f_base_global_default_undef \+ 0
-0000000000009028 0000000200000402 R_AARCH64_JUMP_SLOT 0000000000000000 f_spec_global_default_undef \+ 0
-0000000000009030 0000000400000402 R_AARCH64_JUMP_SLOT 0000000000008000 f_base_global_default_def \+ 0
-0000000000009038 0000000500000402 R_AARCH64_JUMP_SLOT 0000000000008000 f_spec_global_default_def \+ 0
+0000000000009020 0000000.00000402 R_AARCH64_JUMP_SLOT 0000000000000000 f_base_global_default_undef \+ 0
+0000000000009028 0000000.00000402 R_AARCH64_JUMP_SLOT 0000000000000000 f_spec_global_default_undef \+ 0
+0000000000009030 0000000.00000402 R_AARCH64_JUMP_SLOT 0000000000008000 f_base_global_default_def \+ 0
+0000000000009038 0000000.00000402 R_AARCH64_JUMP_SLOT 0000000000008000 f_spec_global_default_def \+ 0
0000000000009040 0000000000000408 R_AARCH64_IRELATIVE 8000
-0000000000009048 0000000300000402 R_AARCH64_JUMP_SLOT f_spec_global_default_ifunc\(\) f_spec_global_default_ifunc \+ 0
+0000000000009048 0000000.00000402 R_AARCH64_JUMP_SLOT f_spec_global_default_ifunc\(\) f_spec_global_default_ifunc \+ 0
0000000000009050 0000000000000408 R_AARCH64_IRELATIVE 8000
-0000000000009058 0000000600000402 R_AARCH64_JUMP_SLOT f_base_global_default_ifunc\(\) f_base_global_default_ifunc \+ 0
+0000000000009058 0000000.00000402 R_AARCH64_JUMP_SLOT f_base_global_default_ifunc\(\) f_base_global_default_ifunc \+ 0
0000000000009060 0000000000000408 R_AARCH64_IRELATIVE 8038
0000000000009068 0000000000000408 R_AARCH64_IRELATIVE 8000
0000000000009070 0000000000000408 R_AARCH64_IRELATIVE 8000
0000000000009078 0000000000000408 R_AARCH64_IRELATIVE 8038
-Symbol table '\.dynsym' contains 7 entries:
+Symbol table '\.dynsym' contains . entries:
Num: Value Size Type Bind Vis Ndx Name
- 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
- 1: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_base_global_default_undef
- 2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_spec_global_default_undef \[VARIANT_PCS\]
- 3: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_spec_global_default_ifunc \[VARIANT_PCS\]
- 4: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_base_global_default_def
- 5: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_spec_global_default_def \[VARIANT_PCS\]
- 6: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_base_global_default_ifunc
+ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
+#...
+ .: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_base_global_default_undef
+ .: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_spec_global_default_undef \[VARIANT_PCS\]
+ .: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_spec_global_default_ifunc \[VARIANT_PCS\]
+ .: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_base_global_default_def
+ .: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_spec_global_default_def \[VARIANT_PCS\]
+ .: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_base_global_default_ifunc
Symbol table '\.symtab' contains 35 entries:
Num: Value Size Type Bind Vis Ndx Name
diff -rup binutils.orig/ld/testsuite/ld-aarch64/variant_pcs-now.d binutils-2.30/ld/testsuite/ld-aarch64/variant_pcs-now.d
--- binutils.orig/ld/testsuite/ld-aarch64/variant_pcs-now.d 2020-04-06 17:27:02.890275588 +0100
+++ binutils-2.30/ld/testsuite/ld-aarch64/variant_pcs-now.d 2020-04-06 17:33:51.136464165 +0100
@@ -38,8 +38,8 @@ Symbol table '\.symtab' contains 35 entr
4: 0000000000009080 0 SECTION LOCAL DEFAULT 4
5: 0000000000011000 0 SECTION LOCAL DEFAULT 5
6: 0000000000011120 0 SECTION LOCAL DEFAULT 6
- 7: 00000000000111c8 0 SECTION LOCAL DEFAULT 7
- 8: 0000000000011270 0 SECTION LOCAL DEFAULT 8
+ 7: 00000000000111.. 0 SECTION LOCAL DEFAULT 7
+ 8: 00000000000112.. 0 SECTION LOCAL DEFAULT 8
9: 0000000000000000 0 FILE LOCAL DEFAULT ABS .*variant_pcs-1\.o
10: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 f_spec_local \[VARIANT_PCS\]
11: 0000000000008000 0 IFUNC LOCAL DEFAULT 1 f_spec_local_ifunc \[VARIANT_PCS\]
diff -rup binutils.orig/ld/testsuite/ld-aarch64/variant_pcs-shared.d binutils-2.30/ld/testsuite/ld-aarch64/variant_pcs-shared.d
--- binutils.orig/ld/testsuite/ld-aarch64/variant_pcs-shared.d 2020-04-06 17:27:02.890275588 +0100
+++ binutils-2.30/ld/testsuite/ld-aarch64/variant_pcs-shared.d 2020-04-06 17:33:56.512440347 +0100
@@ -38,8 +38,8 @@ Symbol table '\.symtab' contains 35 entr
4: 0000000000009080 0 SECTION LOCAL DEFAULT 4
5: 0000000000011000 0 SECTION LOCAL DEFAULT 5
6: 0000000000011120 0 SECTION LOCAL DEFAULT 6
- 7: 00000000000111c8 0 SECTION LOCAL DEFAULT 7
- 8: 0000000000011270 0 SECTION LOCAL DEFAULT 8
+ 7: 00000000000111.. 0 SECTION LOCAL DEFAULT 7
+ 8: 00000000000112.. 0 SECTION LOCAL DEFAULT 8
9: 0000000000000000 0 FILE LOCAL DEFAULT ABS .*variant_pcs-1\.o
10: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 f_spec_local \[VARIANT_PCS\]
11: 0000000000008000 0 IFUNC LOCAL DEFAULT 1 f_spec_local_ifunc \[VARIANT_PCS\]

View File

@ -0,0 +1,591 @@
diff -rup binutils.orig/bfd/elf-bfd.h binutils-2.30/bfd/elf-bfd.h
--- binutils.orig/bfd/elf-bfd.h 2020-02-12 13:31:20.348605538 +0000
+++ binutils-2.30/bfd/elf-bfd.h 2020-02-12 13:31:33.831507582 +0000
@@ -1479,6 +1479,19 @@ struct elf_backend_data
/* Opcode representing no unwind. */
int (*cant_unwind_opcode) (struct bfd_link_info *);
+ /* Called when a section has extra reloc sections. */
+ bfd_boolean (*init_secondary_reloc_section) (bfd *, Elf_Internal_Shdr *, const char *, unsigned int);
+
+ /* Called when after loading the normal relocs for a section. */
+ bfd_boolean (*slurp_secondary_relocs) (bfd *, asection *, asymbol **);
+
+ /* Called after writing the normal relocs for a section. */
+ bfd_boolean (*write_secondary_relocs) (bfd *, asection *);
+
+ /* Called to return the value to set in the ST_SHNDX field of an ELF symbol
+ from an iternal symbol which does not map to any known section. */
+ unsigned int (*symbol_section_index) (bfd *, elf_symbol_type *);
+
/* This is non-zero if static TLS segments require a special alignment. */
unsigned static_tls_alignment;
@@ -2696,6 +2709,19 @@ extern bfd_vma elf64_r_sym (bfd_vma);
extern bfd_vma elf32_r_info (bfd_vma, bfd_vma);
extern bfd_vma elf32_r_sym (bfd_vma);
+
+extern bfd_boolean _bfd_elf_init_secondary_reloc_section
+ (bfd *, Elf_Internal_Shdr *, const char *, unsigned int);
+extern bfd_boolean _bfd_elf_slurp_secondary_reloc_section
+ (bfd *, asection *, asymbol **);
+extern bfd_boolean _bfd_elf_copy_special_section_fields
+ (const bfd *, bfd *, const Elf_Internal_Shdr *, Elf_Internal_Shdr *);
+extern bfd_boolean _bfd_elf_write_secondary_reloc_section
+ (bfd *, asection *);
+extern unsigned int _bfd_elf_symbol_section_index
+ (bfd *, elf_symbol_type *);
+
+
/* Large common section. */
extern asection _bfd_elf_large_com_section;
diff -rup binutils.orig/bfd/elf.c binutils-2.30/bfd/elf.c
--- binutils.orig/bfd/elf.c 2020-02-12 13:31:20.347605546 +0000
+++ binutils-2.30/bfd/elf.c 2020-02-12 13:33:19.635738944 +0000
@@ -1572,7 +1572,7 @@ _bfd_elf_copy_private_bfd_data (bfd *ibf
/* Final attempt. Call the backend copy function
with a NULL input section. */
if (bed->elf_backend_copy_special_section_fields != NULL)
- bed->elf_backend_copy_special_section_fields (ibfd, obfd, NULL, oheader);
+ (void) bed->elf_backend_copy_special_section_fields (ibfd, obfd, NULL, oheader);
}
}
@@ -2416,11 +2416,14 @@ bfd_section_from_shdr (bfd *abfd, unsign
sections. */
if (*p_hdr != NULL)
{
- _bfd_error_handler
- /* xgettext:c-format */
- (_("%B: warning: multiple relocation sections for section %A \
-found - ignoring all but the first"),
- abfd, target_sect);
+ if (bed->init_secondary_reloc_section == NULL
+ || ! bed->init_secondary_reloc_section (abfd, hdr, name, shindex))
+ {
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%pB: warning: secondary relocation section '%s' for section %pA found - ignoring"),
+ abfd, name, target_sect);
+ }
goto success;
}
hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, sizeof (*hdr2));
@@ -7948,9 +7951,20 @@ error_return:
if (elf_symtab_shndx_list (abfd))
shndx = elf_symtab_shndx_list (abfd)->ndx;
break;
- default:
+ case SHN_COMMON:
+ case SHN_ABS:
shndx = SHN_ABS;
break;
+ default:
+ if (bed->symbol_section_index)
+ shndx = bed->symbol_section_index (abfd, type_ptr);
+ else
+ {
+ _bfd_error_handler (_("%pB: Unable to handle section index %x in ELF symbol. Using ABS instead. (%x)"),
+ abfd, shndx, SHN_COMMON);
+ shndx = SHN_ABS;
+ }
+ break;
}
}
else
@@ -11556,3 +11570,354 @@ _bfd_elf_maybe_function_sym (const asymb
size = 1;
return size;
}
+
+/* Set to non-zero to enable some debug messages. */
+#define DEBUG_SECONDARY_RELOCS 0
+
+/* An internal-to-the-bfd-library only section type
+ used to indicate a cached secondary reloc section. */
+#define SHT_SECONDARY_RELOC (SHT_LOOS + SHT_RELA)
+
+/* Create a BFD section to hold a secondary reloc section. */
+
+bfd_boolean
+_bfd_elf_init_secondary_reloc_section (bfd * abfd,
+ Elf_Internal_Shdr *hdr,
+ const char * name,
+ unsigned int shindex)
+{
+ /* We only support RELA secondary relocs. */
+ if (hdr->sh_type != SHT_RELA)
+ return FALSE;
+
+#if DEBUG_SECONDARY_RELOCS
+ fprintf (stderr, "secondary reloc section %s encountered\n", name);
+#endif
+ hdr->sh_type = SHT_SECONDARY_RELOC;
+ return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
+}
+
+/* Read in any secondary relocs associated with SEC. */
+
+bfd_boolean
+_bfd_elf_slurp_secondary_reloc_section (bfd * abfd,
+ asection * sec,
+ asymbol ** symbols)
+{
+ const struct elf_backend_data * const ebd = get_elf_backend_data (abfd);
+ asection * relsec;
+ bfd_boolean result = TRUE;
+ bfd_vma (*r_sym) (bfd_vma);
+
+
+#ifdef BFD64
+ if (bfd_arch_bits_per_address (abfd) != 32)
+ r_sym = elf64_r_sym;
+ else
+#endif
+ r_sym = elf32_r_sym;
+
+ /* Discover if there are any secondary reloc sections
+ associated with SEC. */
+ for (relsec = abfd->sections; relsec != NULL; relsec = relsec->next)
+ {
+ Elf_Internal_Shdr * hdr = & elf_section_data (relsec)->this_hdr;
+
+ if (hdr->sh_type == SHT_SECONDARY_RELOC
+ && hdr->sh_info == (unsigned) elf_section_data (sec)->this_idx)
+ {
+ bfd_byte * native_relocs;
+ bfd_byte * native_reloc;
+ arelent * internal_relocs;
+ arelent * internal_reloc;
+ unsigned int i;
+ unsigned int entsize;
+ unsigned int symcount;
+ unsigned int reloc_count;
+
+#if DEBUG_SECONDARY_RELOCS
+ fprintf (stderr, "read secondary relocs for %s from %s\n", sec->name, relsec->name);
+#endif
+ entsize = hdr->sh_entsize;
+
+ native_relocs = bfd_malloc (hdr->sh_size);
+ if (native_relocs == NULL)
+ {
+ result = FALSE;
+ continue;
+ }
+
+ reloc_count = NUM_SHDR_ENTRIES (hdr);
+ internal_relocs = (arelent *) bfd_alloc2 (abfd, reloc_count, sizeof (arelent));
+ if (internal_relocs == NULL)
+ {
+ free (native_relocs);
+ result = FALSE;
+ continue;
+ }
+
+ if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0
+ || (bfd_bread (native_relocs, hdr->sh_size, abfd) != hdr->sh_size))
+ {
+ free (native_relocs);
+ free (internal_relocs);
+ result = FALSE;
+ continue;
+ }
+
+ symcount = bfd_get_symcount (abfd);
+
+ for (i = 0, internal_reloc = internal_relocs, native_reloc = native_relocs;
+ i < reloc_count;
+ i++, internal_reloc++, native_reloc += entsize)
+ {
+ ;
+ Elf_Internal_Rela rela;
+
+ ebd->s->swap_reloca_in (abfd, native_reloc, & rela);
+
+ /* The address of an ELF reloc is section relative for an object
+ file, and absolute for an executable file or shared library.
+ The address of a normal BFD reloc is always section relative,
+ and the address of a dynamic reloc is absolute.. */
+ if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
+ internal_reloc->address = rela.r_offset;
+ else
+ internal_reloc->address = rela.r_offset - sec->vma;
+
+ if (r_sym (rela.r_info) == STN_UNDEF)
+ {
+ /* FIXME: This and the error case below mean that we
+ have a symbol on relocs that is not elf_symbol_type. */
+ internal_reloc->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ }
+ else if (r_sym (rela.r_info) > symcount)
+ {
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%pB(%pA): relocation %d has invalid symbol index %ld"),
+ abfd, sec, i, (long) r_sym (rela.r_info));
+ bfd_set_error (bfd_error_bad_value);
+ internal_reloc->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+ result = FALSE;
+ }
+ else
+ {
+ asymbol **ps;
+
+ ps = symbols + r_sym (rela.r_info) - 1;
+
+ internal_reloc->sym_ptr_ptr = ps;
+ /* Make sure that this symbol is not removed by strip. */
+ (*ps)->flags |= BSF_KEEP;
+ }
+
+ internal_reloc->addend = rela.r_addend;
+
+ ebd->elf_info_to_howto (abfd, internal_reloc, & rela);
+ if (internal_reloc->howto == NULL)
+ {
+#if DEBUG_SECONDARY_RELOCS
+ fprintf (stderr, "there is no howto associated with reloc %lx\n", rela.r_info);
+#endif
+ result = FALSE;
+ }
+ }
+
+ free (native_relocs);
+ /* Store the internal relocs. */
+ elf_section_data (relsec)->sec_info = internal_relocs;
+ }
+ }
+
+ return result;
+}
+
+/* Set the ELF section header fields of an output secondary reloc section. */
+
+bfd_boolean
+_bfd_elf_copy_special_section_fields (const bfd * ibfd ATTRIBUTE_UNUSED,
+ bfd * obfd ATTRIBUTE_UNUSED,
+ const Elf_Internal_Shdr * isection,
+ Elf_Internal_Shdr * osection)
+{
+ if (isection == NULL)
+ return FALSE;
+
+ if (isection->sh_type != SHT_SECONDARY_RELOC)
+ return TRUE;
+
+ asection * isec = isection->bfd_section;
+ if (isec == NULL)
+ return FALSE;
+
+ asection * osec = osection->bfd_section;
+ if (osec == NULL)
+ return FALSE;
+
+ BFD_ASSERT (elf_section_data (osec)->sec_info == NULL);
+ elf_section_data (osec)->sec_info = elf_section_data (isec)->sec_info;
+ osection->sh_type = SHT_RELA;
+ osection->sh_link = elf_onesymtab (obfd);
+ if (osection->sh_link == 0)
+ {
+ /* There is no symbol table - we are hosed... */
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%pB(%pA): link section cannot be set because the output file does not have a symbol table"),
+ obfd, osec);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+
+ /* Find the output section that corresponds to the isection's sh_info link. */
+ BFD_ASSERT (isection->sh_info > 0 && isection->sh_info < elf_numsections (ibfd));
+ isection = elf_elfsections (ibfd)[isection->sh_info];
+
+ BFD_ASSERT (isection != NULL);
+ BFD_ASSERT (isection->bfd_section != NULL);
+ BFD_ASSERT (isection->bfd_section->output_section != NULL);
+ osection->sh_info = elf_section_data (isection->bfd_section->output_section)->this_idx;
+
+#if DEBUG_SECONDARY_RELOCS
+ fprintf (stderr, "update header of %s, sh_link = %u, sh_info = %u\n",
+ osec->name, osection->sh_link, osection->sh_info);
+#endif
+
+ return TRUE;
+}
+
+/* Write out a secondary reloc section. */
+
+bfd_boolean
+_bfd_elf_write_secondary_reloc_section (bfd *abfd, asection *sec)
+{
+ const struct elf_backend_data * const ebd = get_elf_backend_data (abfd);
+ bfd_vma addr_offset;
+ asection * relsec;
+ bfd_vma (*r_info) (bfd_vma, bfd_vma);
+
+#ifdef BFD64
+ if (bfd_arch_bits_per_address (abfd) != 32)
+ r_info = elf64_r_info;
+ else
+#endif
+ r_info = elf32_r_info;
+
+ if (sec == NULL)
+ return FALSE;
+
+ /* The address of an ELF reloc is section relative for an object
+ file, and absolute for an executable file or shared library.
+ The address of a BFD reloc is always section relative. */
+ addr_offset = 0;
+ if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
+ addr_offset = sec->vma;
+
+ /* Discover if there are any secondary reloc sections
+ associated with SEC. */
+ for (relsec = abfd->sections; relsec != NULL; relsec = relsec->next)
+ {
+ const struct bfd_elf_section_data * const esd = elf_section_data (relsec);
+ Elf_Internal_Shdr * const hdr = (Elf_Internal_Shdr *) & esd->this_hdr;
+
+ if (hdr->sh_type == SHT_RELA
+ && hdr->sh_info == (unsigned) elf_section_data (sec)->this_idx)
+ {
+ asymbol * last_sym;
+ int last_sym_idx;
+ unsigned int reloc_count;
+ unsigned int idx;
+ arelent * src_irel;
+ bfd_byte * dst_rela;
+
+ BFD_ASSERT (hdr->contents == NULL);
+
+ reloc_count = hdr->sh_size / hdr->sh_entsize;
+ BFD_ASSERT (reloc_count > 0);
+
+ hdr->contents = bfd_alloc (abfd, hdr->sh_size);
+ if (hdr->contents == NULL)
+ continue;
+
+#if DEBUG_SECONDARY_RELOCS
+ fprintf (stderr, "write %u secondary relocs for %s from %s\n", reloc_count, sec->name, relsec->name);
+#endif
+ last_sym = NULL;
+ last_sym_idx = 0;
+ dst_rela = hdr->contents;
+ src_irel = (arelent *) esd->sec_info;
+ BFD_ASSERT (src_irel != NULL);
+
+ for (idx = 0; idx < reloc_count; idx++, dst_rela += hdr->sh_entsize)
+ {
+ Elf_Internal_Rela src_rela;
+ arelent *ptr;
+ asymbol *sym;
+ int n;
+
+ ptr = src_irel + idx;
+ sym = *ptr->sym_ptr_ptr;
+
+ if (sym == last_sym)
+ n = last_sym_idx;
+ else
+ {
+ last_sym = sym;
+ n = _bfd_elf_symbol_from_bfd_symbol (abfd, & sym);
+ if (n < 0)
+ {
+#if DEBUG_SECONDARY_RELOCS
+ fprintf (stderr, "failed to find symbol %s whilst rewriting relocs\n",
+ sym->name);
+#endif
+ /* FIXME: Signal failure somehow. */
+ n = 0;
+ }
+ last_sym_idx = n;
+ }
+
+ if ((*ptr->sym_ptr_ptr)->the_bfd != NULL
+ && (*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
+ && ! _bfd_elf_validate_reloc (abfd, ptr))
+ {
+#if DEBUG_SECONDARY_RELOCS
+ fprintf (stderr, "symbol %s is not in the output bfd\n",
+ sym->name);
+#endif
+ /* FIXME: Signal failure somehow. */
+ n = 0;
+ }
+
+ if (ptr->howto == NULL)
+ {
+#if DEBUG_SECONDARY_RELOCS
+ fprintf (stderr, "reloc for symbol %s does not have a howto associated with it\n",
+ sym->name);
+#endif
+ /* FIXME: Signal failure somehow. */
+ n = 0;
+ }
+
+ src_rela.r_offset = ptr->address + addr_offset;
+ src_rela.r_info = r_info (n, ptr->howto->type);
+ src_rela.r_addend = ptr->addend;
+ ebd->s->swap_reloca_out (abfd, &src_rela, dst_rela);
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+/* Preserve any OS or PROCESSOR specific section indicies. */
+
+unsigned int
+_bfd_elf_symbol_section_index (bfd * abfd ATTRIBUTE_UNUSED,
+ elf_symbol_type * sym)
+{
+ unsigned int shndx = sym->internal_elf_sym.st_shndx;
+
+ /* Preserve special section indicies. */
+ return shndx >= SHN_LORESERVE ? shndx : SHN_ABS;
+}
diff -rup binutils.orig/bfd/elfcode.h binutils-2.30/bfd/elfcode.h
--- binutils.orig/bfd/elfcode.h 2020-02-12 13:31:20.334605640 +0000
+++ binutils-2.30/bfd/elfcode.h 2020-02-12 13:31:33.833507567 +0000
@@ -855,6 +855,7 @@ elf_object_p (bfd *abfd)
void
elf_write_relocs (bfd *abfd, asection *sec, void *data)
{
+ const struct elf_backend_data * const bed = get_elf_backend_data (abfd);
bfd_boolean *failedp = (bfd_boolean *) data;
Elf_Internal_Shdr *rela_hdr;
bfd_vma addr_offset;
@@ -969,6 +970,13 @@ elf_write_relocs (bfd *abfd, asection *s
src_rela.r_addend = ptr->addend;
(*swap_out) (abfd, &src_rela, dst_rela);
}
+
+ if (bed->write_secondary_relocs != NULL)
+ if (! bed->write_secondary_relocs (abfd, sec))
+ {
+ *failedp = TRUE;
+ return;
+ }
}
/* Write out the program headers. */
@@ -1271,7 +1279,10 @@ elf_slurp_symbol_table (bfd *abfd, asymb
{
/* This symbol is in a section for which we did not
create a BFD section. Just use bfd_abs_section,
- although it is wrong. FIXME. */
+ although it is wrong. FIXME. Note - there is
+ code in elf.c:swap_out_syms that calls
+ symbol_section_index() in the elf backend for
+ cases like this. */
sym->symbol.section = bfd_abs_section_ptr;
}
}
@@ -1501,6 +1512,7 @@ elf_slurp_reloc_table (bfd *abfd,
asymbol **symbols,
bfd_boolean dynamic)
{
+ const struct elf_backend_data * const bed = get_elf_backend_data (abfd);
struct bfd_elf_section_data * const d = elf_section_data (asect);
Elf_Internal_Shdr *rel_hdr;
Elf_Internal_Shdr *rel_hdr2;
@@ -1564,6 +1576,10 @@ elf_slurp_reloc_table (bfd *abfd,
symbols, dynamic))
return FALSE;
+ if (bed->slurp_secondary_relocs != NULL
+ && ! bed->slurp_secondary_relocs (abfd, asect, symbols))
+ return FALSE;
+
asect->relocation = relents;
return TRUE;
}
diff -rup binutils.orig/bfd/elflink.c binutils-2.30/bfd/elflink.c
--- binutils.orig/bfd/elflink.c 2020-02-12 13:31:20.338605611 +0000
+++ binutils-2.30/bfd/elflink.c 2020-02-12 13:31:33.834507560 +0000
@@ -11514,6 +11514,10 @@ elf_final_link_free (bfd *obfd, struct e
}
}
+#define is_reloc_section(ESDO) \
+ ( (ESDO)->this_hdr.sh_type == SHT_REL \
+ || (ESDO)->this_hdr.sh_type == SHT_RELA)
+
/* Do the final step of an ELF link. */
bfd_boolean
@@ -11685,8 +11689,7 @@ bfd_elf_final_link (bfd *abfd, struct bf
&& elf_symtab_shndx_list (sec->owner) != NULL)
max_sym_shndx_count = sym_count;
- if (esdo->this_hdr.sh_type == SHT_REL
- || esdo->this_hdr.sh_type == SHT_RELA)
+ if (is_reloc_section (esdo))
/* Some backends use reloc_count in relocation sections
to count particular types of relocs. Of course,
reloc sections themselves can't have relocations. */
@@ -12290,6 +12293,9 @@ bfd_elf_final_link (bfd *abfd, struct bf
struct bfd_elf_section_data *esdo = elf_section_data (o);
bfd_boolean sort;
+ if (esdo == NULL)
+ continue;
+
if ((o->flags & SEC_RELOC) == 0)
continue;
diff -rup binutils.orig/bfd/elfxx-target.h binutils-2.30/bfd/elfxx-target.h
--- binutils.orig/bfd/elfxx-target.h 2020-02-12 13:31:20.338605611 +0000
+++ binutils-2.30/bfd/elfxx-target.h 2020-02-12 13:31:33.834507560 +0000
@@ -737,7 +737,7 @@
#endif
#ifndef elf_backend_copy_special_section_fields
-#define elf_backend_copy_special_section_fields NULL
+#define elf_backend_copy_special_section_fields _bfd_elf_copy_special_section_fields
#endif
#ifndef elf_backend_compact_eh_encoding
@@ -745,7 +745,23 @@
#endif
#ifndef elf_backend_cant_unwind_opcode
-#define elf_backend_cant_unwind_opcode 0
+#define elf_backend_cant_unwind_opcode NULL
+#endif
+
+#ifndef elf_backend_init_secondary_reloc_section
+#define elf_backend_init_secondary_reloc_section _bfd_elf_init_secondary_reloc_section
+#endif
+
+#ifndef elf_backend_slurp_secondary_reloc_section
+#define elf_backend_slurp_secondary_reloc_section _bfd_elf_slurp_secondary_reloc_section
+#endif
+
+#ifndef elf_backend_write_secondary_reloc_section
+#define elf_backend_write_secondary_reloc_section _bfd_elf_write_secondary_reloc_section
+#endif
+
+#ifndef elf_backend_symbol_section_index
+#define elf_backend_symbol_section_index _bfd_elf_symbol_section_index
#endif
#ifndef elf_match_priority
@@ -870,6 +886,10 @@ static struct elf_backend_data elfNN_bed
elf_backend_setup_gnu_properties,
elf_backend_compact_eh_encoding,
elf_backend_cant_unwind_opcode,
+ elf_backend_init_secondary_reloc_section,
+ elf_backend_slurp_secondary_reloc_section,
+ elf_backend_write_secondary_reloc_section,
+ elf_backend_symbol_section_index,
elf_backend_static_tls_alignment,
elf_backend_stack_align,
elf_backend_strtab_flags,
Only in binutils-2.30/bfd: elfxx-target.h.orig

View File

@ -0,0 +1,68 @@
diff -rup binutils.orig/bfd/elf-bfd.h binutils-2.30/bfd/elf-bfd.h
--- binutils.orig/bfd/elf-bfd.h 2020-04-06 13:08:43.081659992 +0100
+++ binutils-2.30/bfd/elf-bfd.h 2020-04-06 13:09:17.040517295 +0100
@@ -2722,6 +2722,8 @@ extern unsigned int _bfd_elf_symbol_sect
(bfd *, elf_symbol_type *);
+extern bfd_boolean is_debuginfo_file (bfd *);
+
/* Large common section. */
extern asection _bfd_elf_large_com_section;
Only in binutils-2.30/bfd: elf-bfd.h.orig
diff -rup binutils.orig/bfd/elf.c binutils-2.30/bfd/elf.c
--- binutils.orig/bfd/elf.c 2020-04-06 13:08:43.104659896 +0100
+++ binutils-2.30/bfd/elf.c 2020-04-06 13:09:17.042517287 +0100
@@ -5749,6 +5749,35 @@ assign_file_positions_for_load_sections
#define IS_TBSS(s) \
((s->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) == SEC_THREAD_LOCAL)
+/* Determine if a bfd is a debuginfo file. Unfortunately there
+ is no defined method for detecting such files, so we have to
+ use heuristics instead. */
+
+bfd_boolean
+is_debuginfo_file (bfd *abfd)
+{
+ if (abfd == NULL || bfd_get_flavour (abfd) != bfd_target_elf_flavour)
+ return FALSE;
+
+ Elf_Internal_Shdr **start_headers = elf_elfsections (abfd);
+ Elf_Internal_Shdr **end_headers = start_headers + elf_numsections (abfd);
+ Elf_Internal_Shdr **headerp;
+
+ for (headerp = start_headers; headerp < end_headers; headerp ++)
+ {
+ Elf_Internal_Shdr *header = * headerp;
+
+ /* Debuginfo files do not have any allocated SHT_PROGBITS sections.
+ The only allocated sections are SHT_NOBITS or SHT_NOTES. */
+ if ((header->sh_flags & SHF_ALLOC) == SHF_ALLOC
+ && header->sh_type != SHT_NOBITS
+ && header->sh_type != SHT_NOTE)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
/* Assign file positions for the other sections. */
static bfd_boolean
@@ -5782,7 +5811,13 @@ assign_file_positions_for_non_load_secti
BFD_ASSERT (hdr->sh_offset == hdr->bfd_section->filepos);
else if ((hdr->sh_flags & SHF_ALLOC) != 0)
{
- if (hdr->sh_size != 0)
+ if (hdr->sh_size != 0
+ /* PR 24717 - debuginfo files are known to be not strictly
+ compliant with the ELF standard. In particular they often
+ have .note.gnu.property sections that are outside of any
+ loadable segment. This is not a problem for such files,
+ so do not warn about them. */
+ && ! is_debuginfo_file (abfd))
_bfd_error_handler
/* xgettext:c-format */
(_("%B: warning: allocated section `%s' not in segment"),
Only in binutils-2.30/bfd: elf.c.orig

View File

@ -753,3 +753,16 @@ diff -rup binutils.orig/ld/testsuite/ld-x86-64/x86-64.exp binutils-2.30/ld/tests
run_cc_link_tests [list \
[list \
"Build plt-lib.so" \
--- binutils.orig/ld/testsuite/ld-plugin/lto.exp 2019-12-02 10:22:47.019526080 +0000
+++ binutils-2.30/ld/testsuite/ld-plugin/lto.exp 2019-12-02 10:28:11.413354928 +0000
@@ -33,8 +33,8 @@ global CFLAGS
global CXXFLAGS
set saved_CFLAGS "$CFLAGS"
set saved_CXXFLAGS "$CXXFLAGS"
-regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CFLAGS "" CFLAGS
-regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CXXFLAGS "" CXXFLAGS
+# regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CFLAGS "" CFLAGS
+# regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CXXFLAGS "" CXXFLAGS
proc restore_notify { } {
global saved_CFLAGS

View File

@ -0,0 +1,36 @@
diff -rup binutils.orig/gold/layout.cc binutils-2.32/gold/layout.cc
--- binutils.orig/gold/layout.cc 2019-06-24 14:37:36.013086899 +0100
+++ binutils-2.32/gold/layout.cc 2019-06-24 14:41:40.054517479 +0100
@@ -868,6 +868,7 @@ Layout::get_output_section(const char* n
&& (same_name->flags() & elfcpp::SHF_TLS) == 0)
os = same_name;
}
+#if 0 /* BZ 1722715, PR 17556. */
else if ((flags & elfcpp::SHF_TLS) == 0)
{
elfcpp::Elf_Xword zero_flags = 0;
@@ -878,6 +879,7 @@ Layout::get_output_section(const char* n
if (p != this->section_name_map_.end())
os = p->second;
}
+#endif
}
if (os == NULL)
diff -rup binutils.orig/gold/object.cc binutils-2.32/gold/object.cc
--- binutils.orig/gold/object.cc 2019-06-24 14:37:36.012086906 +0100
+++ binutils-2.32/gold/object.cc 2019-06-24 14:39:59.287165501 +0100
@@ -1644,6 +1644,13 @@ Sized_relobj_file<size, big_endian>::do_
omit[i] = true;
}
+ // Skip empty sections without flags.
+ if (!(shdr.get_sh_flags() & ~elfcpp::SHF_GROUP)
+ && !shdr.get_sh_size())
+ {
+ omit[i] = true;
+ }
+
bool discard = omit[i];
if (!discard)
{

View File

@ -1948,15 +1948,6 @@ diff -rupN binutils.orig/binutils/testsuite/binutils-all/objcopy.exp binutils-2.
free (merged);
continue;
}
@@ -4519,7 +4519,7 @@ strip_main (int argc, char *argv[])
int i;
char *output_file = NULL;
- merge_notes = TRUE;
+ /* merge_notes = TRUE; */
while ((c = getopt_long (argc, argv, "I:O:F:K:MN:R:o:sSpdgxXHhVvwDU",
strip_options, (int *) 0)) != EOF)
--- binutils.orig/binutils/objcopy.c 2019-11-06 16:37:57.018843494 +0000
+++ binutils-2.30/binutils/objcopy.c 2019-11-06 16:40:52.669564222 +0000
@@ -2845,7 +2845,13 @@ copy_object (bfd *ibfd, bfd *obfd, const

View File

@ -0,0 +1,97 @@
diff -rup binutils.orig/binutils/doc/binutils.texi binutils-2.30/binutils/doc/binutils.texi
--- binutils.orig/binutils/doc/binutils.texi 2020-04-07 16:11:52.164358203 +0100
+++ binutils-2.30/binutils/doc/binutils.texi 2020-04-07 16:14:37.759171936 +0100
@@ -1586,7 +1586,9 @@ recognized names are @samp{alloc}, @samp
for a section which does not have contents, but it is not meaningful
to clear the @samp{contents} flag of a section which does have
contents--just remove the section instead. Not all flags are
-meaningful for all object file formats.
+meaningful for all object file formats. In particular the
+@samp{share} flag is only meaningful for COFF format files and not for
+ELF format files.
@item --add-section @var{sectionname}=@var{filename}
Add a new section named @var{sectionname} while copying the file. The
@@ -1637,7 +1639,8 @@ Rename a section from @var{oldname} to @
changing the section's flags to @var{flags} in the process. This has
the advantage over using a linker script to perform the rename in that
the output stays as an object file and does not become a linked
-executable.
+executable. This option accepts the same set of flags as the
+@option{--sect-section-flags} option.
This option is particularly helpful when the input format is binary,
since this will always create a section called .data. If for example,
diff -rup binutils.orig/binutils/objcopy.c binutils-2.30/binutils/objcopy.c
--- binutils.orig/binutils/objcopy.c 2020-04-07 16:11:52.177358110 +0100
+++ binutils-2.30/binutils/objcopy.c 2020-04-07 16:16:15.736470047 +0100
@@ -2514,6 +2514,23 @@ merge_gnu_build_notes (bfd * ab
return size;
}
+static flagword
+check_new_section_flags (flagword flags, bfd * abfd, const char * secname)
+{
+ /* Only set the SEC_COFF_SHARED flag on COFF files.
+ The same bit value is used by ELF targets to indicate
+ compressed sections, and setting that flag here breaks
+ things. */
+ if ((flags & SEC_COFF_SHARED)
+ && bfd_get_flavour (abfd) != bfd_target_coff_flavour)
+ {
+ non_fatal (_("%s[%s]: Note - dropping 'share' flag as output format is not COFF"),
+ bfd_get_filename (abfd), secname);
+ flags &= ~ SEC_COFF_SHARED;
+ }
+ return flags;
+}
+
/* Copy object file IBFD onto OBFD.
Returns TRUE upon success, FALSE otherwise. */
@@ -2755,7 +2772,10 @@ copy_object (bfd *ibfd, bfd *obfd, const
pset = find_section_list (padd->name, FALSE,
SECTION_CONTEXT_SET_FLAGS);
if (pset != NULL)
- flags = pset->flags | SEC_HAS_CONTENTS;
+ {
+ flags = pset->flags | SEC_HAS_CONTENTS;
+ flags = check_new_section_flags (flags, obfd, padd->name);
+ }
else
flags = SEC_HAS_CONTENTS | SEC_READONLY | SEC_DATA;
@@ -3867,6 +3887,7 @@ setup_section (bfd *ibfd, sec_ptr isecti
flagword flags;
const char *err;
const char * name;
+ const char * new_name;
char *prefix = NULL;
bfd_boolean make_nobits;
@@ -3876,7 +3897,12 @@ setup_section (bfd *ibfd, sec_ptr isecti
/* Get the, possibly new, name of the output section. */
name = bfd_section_name (ibfd, isection);
flags = bfd_get_section_flags (ibfd, isection);
- name = find_section_rename (name, &flags);
+ new_name = find_section_rename (name, &flags);
+ if (new_name != name)
+ {
+ name = new_name;
+ flags = check_new_section_flags (flags, obfd, name);
+ }
/* Prefix sections. */
if ((prefix_alloc_sections_string)
@@ -3900,7 +3926,10 @@ setup_section (bfd *ibfd, sec_ptr isecti
p = find_section_list (bfd_section_name (ibfd, isection), FALSE,
SECTION_CONTEXT_SET_FLAGS);
if (p != NULL)
- flags = p->flags | (flags & (SEC_HAS_CONTENTS | SEC_RELOC));
+ {
+ flags = p->flags | (flags & (SEC_HAS_CONTENTS | SEC_RELOC));
+ flags = check_new_section_flags (flags, obfd, bfd_section_name (ibfd, isection));
+ }
else if (strip_symbols == STRIP_NONDEBUG
&& (flags & (SEC_ALLOC | SEC_GROUP)) != 0
&& !is_nondebug_keep_contents_section (ibfd, isection))

View File

@ -0,0 +1,427 @@
diff -rup binutils.orig/ld/testsuite/ld-elfvsb/elfvsb.exp binutils-2.30/ld/testsuite/ld-elfvsb/elfvsb.exp
--- binutils.orig/ld/testsuite/ld-elfvsb/elfvsb.exp 2020-04-06 13:46:34.057525248 +0100
+++ binutils-2.30/ld/testsuite/ld-elfvsb/elfvsb.exp 2020-04-06 14:06:44.964203913 +0100
@@ -315,7 +315,6 @@ proc visibility_run {visibility} {
&& ![ string match $visibility "hidden_undef" ]
&& ![ string match $visibility "hidden_undef_def" ]
&& ![ string match $visibility "protected_undef" ] } {
- setup_xfail "s390x-*-linux*"
if { [istarget sparc*-*-linux*] && [is_elf64 $tmpdir/mainnp.o] } {
setup_xfail "sparc*-*-linux*"
}
@@ -353,7 +352,6 @@ proc visibility_run {visibility} {
|| [ string match $visibility "protected_weak" ]
|| [ string match $visibility "normal" ] } {
setup_xfail "powerpc-*-linux*"
- setup_xfail "s390x-*-linux*"
if { [istarget sparc*-*-linux*] && [is_elf64 $tmpdir/mainnp.o] } {
setup_xfail "sparc*-*-linux*"
}
diff -rup binutils.orig/ld/testsuite/ld-plugin/lto.exp binutils-2.30/ld/testsuite/ld-plugin/lto.exp
--- binutils.orig/ld/testsuite/ld-plugin/lto.exp 2020-04-06 13:46:34.063525222 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/lto.exp 2020-04-06 14:10:02.634343536 +0100
@@ -222,7 +222,7 @@ if { [at_least_gcc_version 4 7] } {
"" "-flto -O2" \
{pr12942a.cc pr12942c.cc} {} "" "c++"] \
[list "Compile PR ld/12942 (2)" \
- "" "-O0" \
+ "" "-O2" \
{pr12942b.cc} {} "" "c++"] \
]]
}
@@ -547,13 +547,16 @@ if { [at_least_gcc_version 4 7] } {
}
# Run "ld -r" to generate inputs for complex LTO tests.
+setup_xfail "*-*-*"
run_dump_test "lto-3r"
remote_exec host "mv" "tmpdir/dump tmpdir/lto-3.o"
+setup_xfail "*-*-*"
run_dump_test "lto-5r"
remote_exec host "mv" "tmpdir/dump tmpdir/lto-5.o"
run_cc_link_tests $lto_link_symbol_tests
+setup_xfail "*-*-*"
run_ld_link_tests [list \
[list "PR ld/19317 (2)" \
"-r tmpdir/pr19317.o" "" "" \
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-10.d binutils-2.30/ld/testsuite/ld-plugin/plugin-10.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-10.d 2020-04-06 13:46:34.060525235 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-10.d 2020-04-06 14:22:06.280196979 +0100
@@ -34,5 +34,4 @@ hook called: claim_file tmpdir/libtext.a
hook called: all symbols read.
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
-hook called: cleanup.
#...
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-11.d binutils-2.30/ld/testsuite/ld-plugin/plugin-11.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-11.d 2020-04-06 13:46:34.063525222 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-11.d 2020-04-06 14:22:24.789116715 +0100
@@ -38,5 +38,4 @@ hook called: all symbols read.
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
Sym: '_?text' Resolution: LDPR_PREVAILING_DEF
-hook called: cleanup.
#...
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-12.d binutils-2.30/ld/testsuite/ld-plugin/plugin-12.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-12.d 2020-04-06 13:46:34.060525235 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-12.d 2020-04-06 14:21:20.373396053 +0100
@@ -1,5 +1,5 @@
#...
-.*: symbol `.*unc' definition: 0, visibility: 0, resolution: 2
+.*: symbol `.*unc' definition: 0, visibility: 0, resolution: .
.*: symbol `.*unc1' definition: 0, visibility: 1, resolution: 3
.*: symbol `.*unc2' definition: 0, visibility: 2, resolution: 3
.*: symbol `.*unc3' definition: 0, visibility: 3, resolution: 3
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-13.d binutils-2.30/ld/testsuite/ld-plugin/plugin-13.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-13.d 2020-04-06 13:46:34.061525231 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-13.d 2020-04-06 14:17:17.134452335 +0100
@@ -23,5 +23,4 @@ hook called: claim_file tmpdir/main.o \[
hook called: claim_file .*/ld/testsuite/ld-plugin/func.c \[@0/.* CLAIMED
hook called: claim_file tmpdir/text.o \[@0/.* not claimed
#...
-.*main.c.*: undefined reference to `\.?func'
-#...
+
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-14.d binutils-2.30/ld/testsuite/ld-plugin/plugin-14.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-14.d 2020-04-06 13:46:34.062525226 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-14.d 2020-04-06 14:17:47.544319974 +0100
@@ -27,7 +27,4 @@ hook called: claim_file .*/ld/testsuite/
hook called: claim_file tmpdir/text.o \[@0/.* not claimed
#...
hook called: all symbols read.
-tmpdir/main.o: In function `main':
-.*main.c.*: undefined reference to `\.?func'
-hook called: cleanup.
-#...
+#pass
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-15.d binutils-2.30/ld/testsuite/ld-plugin/plugin-15.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-15.d 2020-04-06 13:46:34.060525235 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-15.d 2020-04-06 14:18:24.091160900 +0100
@@ -28,7 +28,4 @@ hook called: claim_file .*/ld/testsuite/
hook called: claim_file tmpdir/text.o \[@0/.* not claimed
#...
hook called: all symbols read.
-tmpdir/main.o: In function `main':
-.*main.c.*: undefined reference to `\.?func'
-hook called: cleanup.
-#...
+#pass
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-16.d binutils-2.30/ld/testsuite/ld-plugin/plugin-16.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-16.d 2020-04-06 13:46:34.062525226 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-16.d 2020-04-06 14:18:50.780044764 +0100
@@ -32,7 +32,4 @@ hook called: claim_file tmpdir/text.o \[
hook called: all symbols read.
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
-tmpdir/main.o: In function `main':
-.*main.c.*: undefined reference to `\.?func'
-hook called: cleanup.
-#...
+#pass
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-17.d binutils-2.30/ld/testsuite/ld-plugin/plugin-17.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-17.d 2020-04-06 13:46:34.061525231 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-17.d 2020-04-06 14:19:16.601932787 +0100
@@ -33,5 +33,4 @@ hook called: claim_file tmpdir/text.o \[
hook called: all symbols read.
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
-hook called: cleanup.
#...
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-18.d binutils-2.30/ld/testsuite/ld-plugin/plugin-18.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-18.d 2020-04-06 13:46:34.060525235 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-18.d 2020-04-06 14:23:32.887821405 +0100
@@ -32,7 +32,6 @@ hook called: claim_file .*/ld/testsuite/
hook called: claim_file tmpdir/libtext.a \[@.* not claimed
#...
hook called: all symbols read.
-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
+Sym: '_?func' Resolution: LDPR_PREVAILING_DE.*
Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
-hook called: cleanup.
#...
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-19.d binutils-2.30/ld/testsuite/ld-plugin/plugin-19.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-19.d 2020-04-06 13:46:34.063525222 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-19.d 2020-04-06 14:24:41.828522444 +0100
@@ -35,8 +35,7 @@ hook called: claim_file .*/ld/testsuite/
hook called: claim_file tmpdir/libtext.a \[@.* CLAIMED
#...
hook called: all symbols read.
-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
+Sym: '_?func' Resolution: LDPR_PREVAILING_DE.*
Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
-Sym: '_?text' Resolution: LDPR_PREVAILING_DEF
-hook called: cleanup.
+Sym: '_?text' Resolution: LDPR_PREVAILING_DE.*
#...
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-20.d binutils-2.30/ld/testsuite/ld-plugin/plugin-20.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-20.d 2020-04-06 13:46:34.063525222 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-20.d 2020-04-06 14:26:04.548163731 +0100
@@ -2,6 +2,5 @@ hook called: all symbols read.
Input: func.c \(tmpdir/libfunc.a\)
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
-tmpdir/main.o: In function `main':
-.*main.c.*: undefined reference to `\.?func'
-hook called: cleanup.
+#pass
+
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-21.d binutils-2.30/ld/testsuite/ld-plugin/plugin-21.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-21.d 2020-04-06 13:46:34.061525231 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-21.d 2020-04-06 14:26:21.497090232 +0100
@@ -2,6 +2,4 @@ hook called: all symbols read.
Input: .*/ld/testsuite/ld-plugin/func.c \(.*/ld/testsuite/ld-plugin/func.c\)
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
-tmpdir/main.o: In function `main':
-.*main.c.*: undefined reference to `\.?func'
-hook called: cleanup.
+#pass
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-22.d binutils-2.30/ld/testsuite/ld-plugin/plugin-22.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-22.d 2020-04-06 13:46:34.062525226 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-22.d 2020-04-06 14:27:04.766902593 +0100
@@ -2,6 +2,5 @@ Claimed: tmpdir/libfunc.a \[@.*
hook called: all symbols read.
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
-tmpdir/main.o: In function `main':
-.*main.c.*: undefined reference to `\.?func'
-hook called: cleanup.
+#pass
+
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-23.d binutils-2.30/ld/testsuite/ld-plugin/plugin-23.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-23.d 2020-04-06 13:46:34.061525231 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-23.d 2020-04-06 14:27:21.482830104 +0100
@@ -2,6 +2,4 @@ Claimed: .*/ld/testsuite/ld-plugin/func.
hook called: all symbols read.
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
-tmpdir/main.o: In function `main':
-.*main.c.*: undefined reference to `\.?func'
-hook called: cleanup.
+#pass
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-24.d binutils-2.30/ld/testsuite/ld-plugin/plugin-24.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-24.d 2020-04-06 13:46:34.060525235 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-24.d 2020-04-06 14:26:45.650985489 +0100
@@ -2,4 +2,4 @@ hook called: all symbols read.
Input: .*/ld/testsuite/ld-plugin/func.c \(.*/ld/testsuite/ld-plugin/func.c\)
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
-hook called: cleanup.
+#...
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-25.d binutils-2.30/ld/testsuite/ld-plugin/plugin-25.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-25.d 2020-04-06 13:46:34.063525222 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-25.d 2020-04-06 14:27:37.112762325 +0100
@@ -2,4 +2,4 @@ Claimed: .*/ld/testsuite/ld-plugin/func.
hook called: all symbols read.
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
-hook called: cleanup.
+#pass
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-28.d binutils-2.30/ld/testsuite/ld-plugin/plugin-28.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-28.d 2020-04-06 13:46:34.062525226 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-28.d 2020-04-06 14:19:48.822793062 +0100
@@ -1 +1,2 @@
.*: error: Error
+#pass
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-29.d binutils-2.30/ld/testsuite/ld-plugin/plugin-29.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-29.d 2020-04-06 13:46:34.063525222 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-29.d 2020-04-06 14:20:03.559729155 +0100
@@ -1 +1,2 @@
.*: warning: Warning
+#pass
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-30.d binutils-2.30/ld/testsuite/ld-plugin/plugin-30.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-30.d 2020-04-06 13:46:34.062525226 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-30.d 2020-04-06 14:25:11.872392159 +0100
@@ -24,3 +24,4 @@ hook called: claim_file tmpdir/main.o \[
hook called: claim_file tmpdir/func.o \[@0/.* not claimed
hook called: claim_file tmpdir/text.o \[@0/.* not claimed
hook called: claim_file tmpdir/libempty.a \[@.* not claimed
+#pass
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-6.d binutils-2.30/ld/testsuite/ld-plugin/plugin-6.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-6.d 2020-04-06 13:46:34.063525222 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-6.d 2020-04-06 14:13:00.297570240 +0100
@@ -27,7 +27,4 @@ hook called: claim_file tmpdir/func.o \[
hook called: claim_file tmpdir/text.o \[@0/.* not claimed
#...
hook called: all symbols read.
-tmpdir/main.o: In function `main':
-.*main.c.*: undefined reference to `\.?func'
-hook called: cleanup.
-#...
+#pass
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-7.d binutils-2.30/ld/testsuite/ld-plugin/plugin-7.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-7.d 2020-04-06 13:46:34.060525235 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-7.d 2020-04-06 14:13:51.209348643 +0100
@@ -28,7 +28,4 @@ hook called: claim_file tmpdir/func.o \[
hook called: claim_file tmpdir/text.o \[@0/.* not claimed
#...
hook called: all symbols read.
-tmpdir/main.o: In function `main':
-.*main.c.*: undefined reference to `\.?func'
-hook called: cleanup.
-#...
+#pass
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-8.d binutils-2.30/ld/testsuite/ld-plugin/plugin-8.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-8.d 2020-04-06 13:46:34.061525231 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-8.d 2020-04-06 14:14:12.827254549 +0100
@@ -32,7 +32,4 @@ hook called: claim_file tmpdir/text.o \[
hook called: all symbols read.
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
-tmpdir/main.o: In function `main':
-.*main.c.*: undefined reference to `\.?func'
-hook called: cleanup.
-#...
+#pass
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-9.d binutils-2.30/ld/testsuite/ld-plugin/plugin-9.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-9.d 2020-04-06 13:46:34.063525222 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-9.d 2020-04-06 14:16:35.548633342 +0100
@@ -33,5 +33,4 @@ hook called: claim_file tmpdir/text.o \[
hook called: all symbols read.
Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
-hook called: cleanup.
#...
diff -rup binutils.orig/ld/testsuite/ld-plugin/pr20070.d binutils-2.30/ld/testsuite/ld-plugin/pr20070.d
--- binutils.orig/ld/testsuite/ld-plugin/pr20070.d 2020-04-06 13:46:34.061525231 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/pr20070.d 2020-04-06 14:28:01.634655986 +0100
@@ -5,5 +5,4 @@ Sym: 'weakdef' Resolution: LDPR_PREVAILI
Sym: 'undef' Resolution: LDPR_UNDEF
Sym: 'weakundef' Resolution: LDPR_UNDEF
Sym: 'common' Resolution: LDPR_PREVAILING_DEF_IRONLY
-hook called: cleanup.
#...
diff -rup binutils.orig/ld/testsuite/ld-elfvsb/elfvsb.exp binutils-2.30/ld/testsuite/ld-elfvsb/elfvsb.exp
--- binutils.orig/ld/testsuite/ld-elfvsb/elfvsb.exp 2020-04-06 15:33:40.650512019 +0100
+++ binutils-2.30/ld/testsuite/ld-elfvsb/elfvsb.exp 2020-04-06 15:40:03.806845232 +0100
@@ -323,6 +323,7 @@ proc visibility_run {visibility} {
setup_xfail "x86_64-*-linux*"
}
setup_xfail "x86_64-*-linux-gnux32"
+ setup_xfail "s390x-*-linux*"
if { ![istarget hppa*64*-*-linux*] } {
setup_xfail "hppa*-*-linux*"
}
diff -rup binutils.orig/ld/testsuite/ld-plugin/lto.exp binutils-2.30/ld/testsuite/ld-plugin/lto.exp
--- binutils.orig/ld/testsuite/ld-plugin/lto.exp 2020-04-06 15:33:40.653512005 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/lto.exp 2020-04-06 15:41:32.348460063 +0100
@@ -538,6 +538,7 @@ if { [at_least_gcc_version 4 7] } {
]
}
set testname "PR ld/12942 (3)"
+ setup_xfail "*-*-*"
set exec_output [run_host_cmd "$CXX" "-O2 -flto -fuse-linker-plugin tmpdir/pr12942b.o tmpdir/pr12942a.o"]
if { [ regexp "undefined reference to `\\.?link_error\\(\\)'" $exec_output ] } {
pass $testname
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-10.d binutils-2.30/ld/testsuite/ld-plugin/plugin-10.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-10.d 2020-04-06 15:33:40.656511992 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-10.d 2020-04-06 15:47:31.619894007 +0100
@@ -32,6 +32,6 @@ hook called: claim_file tmpdir/func.o \[
hook called: claim_file tmpdir/libtext.a \[@.* not claimed
#...
hook called: all symbols read.
-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
+Sym: '_?func' Resolution: LDPR_PREVAILING_DE.*
Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
#...
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-11.d binutils-2.30/ld/testsuite/ld-plugin/plugin-11.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-11.d 2020-04-06 15:33:40.653512005 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-11.d 2020-04-06 15:48:31.738631248 +0100
@@ -35,7 +35,7 @@ hook called: claim_file tmpdir/func.o \[
hook called: claim_file tmpdir/libtext.a \[@.* CLAIMED
#...
hook called: all symbols read.
-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
+Sym: '_?func' Resolution: LDPR_PREVAILING_DE.*
Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
-Sym: '_?text' Resolution: LDPR_PREVAILING_DEF
+Sym: '_?text' Resolution: LDPR_PREVAILING_DE.*
#...
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-13.d binutils-2.30/ld/testsuite/ld-plugin/plugin-13.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-13.d 2020-04-06 15:33:40.653512005 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-13.d 2020-04-06 15:43:46.962874471 +0100
@@ -22,5 +22,4 @@ Hello from testplugin.
hook called: claim_file tmpdir/main.o \[@0/.* not claimed
hook called: claim_file .*/ld/testsuite/ld-plugin/func.c \[@0/.* CLAIMED
hook called: claim_file tmpdir/text.o \[@0/.* not claimed
-#...
-
+#pass
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-16.d binutils-2.30/ld/testsuite/ld-plugin/plugin-16.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-16.d 2020-04-06 15:33:40.653512005 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-16.d 2020-04-06 15:44:31.918678908 +0100
@@ -30,6 +30,6 @@ hook called: claim_file .*/ld/testsuite/
hook called: claim_file tmpdir/text.o \[@0/.* not claimed
#...
hook called: all symbols read.
-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
+Sym: '_?func' Resolution: LDPR_PREVAILING_DE.*
Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
#pass
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-17.d binutils-2.30/ld/testsuite/ld-plugin/plugin-17.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-17.d 2020-04-06 15:33:40.655511997 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-17.d 2020-04-06 15:45:08.899517790 +0100
@@ -31,6 +31,6 @@ hook called: claim_file .*/ld/testsuite/
hook called: claim_file tmpdir/text.o \[@0/.* not claimed
#...
hook called: all symbols read.
-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
+Sym: '_?func' Resolution: LDPR_PREVAILING_DE.*
Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
#...
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-8.d binutils-2.30/ld/testsuite/ld-plugin/plugin-8.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-8.d 2020-04-06 15:33:40.653512005 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-8.d 2020-04-06 15:42:26.081226318 +0100
@@ -30,6 +30,6 @@ hook called: claim_file tmpdir/func.o \[
hook called: claim_file tmpdir/text.o \[@0/.* not claimed
#...
hook called: all symbols read.
-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
+Sym: '_?func' Resolution: LDPR_PREVAILING_DE.*
Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
#pass
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin-9.d binutils-2.30/ld/testsuite/ld-plugin/plugin-9.d
--- binutils.orig/ld/testsuite/ld-plugin/plugin-9.d 2020-04-06 15:33:40.654512001 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin-9.d 2020-04-06 15:43:01.761071105 +0100
@@ -31,6 +31,6 @@ hook called: claim_file tmpdir/func.o \[
hook called: claim_file tmpdir/text.o \[@0/.* not claimed
#...
hook called: all symbols read.
-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
+Sym: '_?func' Resolution: LDPR_PREVAILING_DE.*
Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
#...
diff -rup binutils.orig/ld/testsuite/ld-plugin/plugin.exp binutils-2.30/ld/testsuite/ld-plugin/plugin.exp
--- binutils.orig/ld/testsuite/ld-plugin/plugin.exp 2020-04-06 15:33:40.655511997 +0100
+++ binutils-2.30/ld/testsuite/ld-plugin/plugin.exp 2020-04-06 15:46:30.704160249 +0100
@@ -268,7 +268,7 @@ set plugin_extra_elf_tests [list \
-plugin-opt add:tmpdir/func2i.o \
-plugin-opt add:tmpdir/func3h.o \
$testobjfiles $libs --verbose=2" "" "" "" {{ld plugin-12.d} \
- {readelf -s plugin-vis-1.d}} "main.x" ] \
+ } "main.x" ] \
[list "plugin set symbol visibility with source" \
"-plugin $plugin_path $regclm $regas $regcln \
-plugin-opt claim:$srcdir/$subdir/func.c \
@@ -282,7 +282,7 @@ set plugin_extra_elf_tests [list \
-plugin-opt add:tmpdir/func2i.o \
-plugin-opt add:tmpdir/func3h.o \
$testsrcfiles $libs --verbose=2" "" "" "" {{ld plugin-12.d} \
- {readelf -s plugin-vis-1.d}} "main.x" ] \
+ } "main.x" ] \
]
if { !$can_compile || $failed_compile } {
diff -rup binutils.orig/ld/testsuite/ld-shared/shared.exp binutils-2.30/ld/testsuite/ld-shared/shared.exp
--- binutils.orig/ld/testsuite/ld-shared/shared.exp 2020-04-06 15:33:40.688511853 +0100
+++ binutils-2.30/ld/testsuite/ld-shared/shared.exp 2020-04-06 15:34:38.645259733 +0100
@@ -275,7 +275,6 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $
setup_xfail "x86_64-*-linux*"
}
setup_xfail "x86_64-*-linux-gnux32"
- setup_xfail "s390x-*-linux*"
if [ string match $shared_needs_pic "yes" ] {
setup_xfail "arm*-*-linux*"
}

View File

@ -0,0 +1,43 @@
--- binutils.orig/bfd/elf64-s390.c 2020-06-15 11:01:54.671940830 +0100
+++ binutils-2.30/bfd/elf64-s390.c 2020-06-15 11:04:44.663343784 +0100
@@ -2335,6 +2335,9 @@ elf_s390_relocate_section (bfd *output_b
&& SYMBOL_REFERENCES_LOCAL (info, h))
|| resolved_to_zero)
{
+ Elf_Internal_Sym *isym;
+ asection *sym_sec;
+
/* This is actually a static link, or it is a
-Bsymbolic link and the symbol is defined
locally, or the symbol was forced to be local
@@ -2356,6 +2359,10 @@ elf_s390_relocate_section (bfd *output_b
h->got.offset |= 1;
}
+ /* When turning a GOT slot dereference into a direct
+ reference using larl we have to make sure that
+ the symbol is 1. properly aligned and 2. it is no
+ ABS symbol or will become one. */
if ((h->def_regular
&& bfd_link_pic (info)
&& SYMBOL_REFERENCES_LOCAL (info, h))
@@ -2370,8 +2377,17 @@ elf_s390_relocate_section (bfd *output_b
contents + rel->r_offset - 2)
& 0xff00f000) == 0xe300c000
&& bfd_get_8 (input_bfd,
- contents + rel->r_offset + 3) == 0x04)))
-
+ contents + rel->r_offset + 3) == 0x04))
+ && (isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+ input_bfd, r_symndx))
+ && isym->st_shndx != SHN_ABS
+ && h != htab->elf.hdynamic
+ && h != htab->elf.hgot
+ && h != htab->elf.hplt
+ && !(isym->st_value & 1)
+ && (sym_sec = bfd_section_from_elf_index (input_bfd,
+ isym->st_shndx))
+ && sym_sec->alignment_power)
{
unsigned short new_insn =
(0xc000 | (bfd_get_8 (input_bfd,

View File

@ -0,0 +1,11 @@
diff -rup binutils.orig/config/plugins.m4 binutils-2.30/config/plugins.m4
--- binutils.orig/config/plugins.m4 2019-02-18 16:11:38.392440473 +0000
+++ binutils-2.30/config/plugins.m4 2019-02-18 16:11:44.715393846 +0000
@@ -16,6 +16,6 @@ AC_DEFUN([AC_PLUGINS],
[plugins=$maybe_plugins]
)
if test "$plugins" = "yes"; then
- AC_SEARCH_LIBS([dlopen], [dl])
+ AC_SEARCH_LIBS([dlsym], [dl])
fi
])

View File

@ -69,7 +69,7 @@
Summary: A GNU collection of binary utilities
Name: %{?cross}binutils%{?_with_debug:-debug}
Version: 2.30
Release: 68%{?dist}
Release: 75%{?dist}
License: GPLv3+
URL: https://sourceware.org/binutils
@ -416,6 +416,58 @@ Patch63: binutils-CVE-2019-1010204.patch
# Lifetime: Fixed in 2.34
Patch64: binutils-x86_JCC_Erratum.patch
# Purpose: Fix a potential seg-fault in the BFD library when parsing
# pathalogical debug_info sections.
# Lifetime: Fixed in 2.34
Patch65: binutils-CVE-2019-17451.patch
# Purpose: Fix a memory exhaustion bug in the BFD library when parsing
# corrupt DWARF debug information.
# Lifetime: Fixed in 2.34
Patch66: binutils-CVE-2019-17450.patch
# Purpose: Allow the BFD library to handle the copying of files which
# contain secondary reloc sections.
# Lifetime: Fixed in 2.35
Patch67: binutils-copy-multiple-relocs.patch
# Purpose: Stop the BFD library from issueing warning messages about allocated
# sections being found outside of loadable segments, if they are
# found inside debuginfo files.
# Lifetime: Fixed in 2.33
Patch68: binutils-do-not-warn-about-debuginfo-files.patch
# Purpose: Fix failures in the linker testsuite for the s390-linux target.
# Lifetime: Fixed in 2.33
Patch69: binutils-s390-ld-test-fixes.patch
# Purpose: Fix failures in the linker testsuite for the s390-linux target.
# Lifetime: Fixed in 2.33
Patch70: binutils-aarch64-ld-test-fixes.patch
# Purpose: Fix building the binutils with address sanitization enabled.
# Lifetime: Fixed in 2.33
Patch71: binutils-sanitize-uses-dlsym.patch
# Purpose: Fix building the binutils with address sanitization enabled.
# Lifetime: Fixed in 2.33
Patch72: binutils-PT_GNU_PROPERTY-segment.patch
# Purpose: Stop gold from aborting when input sections with the same name
# have different flags.
# Lifetime: 2.33 (probably)
Patch73: binutils-gold-mismatched-section-flags.patch
# Purpose: Stop objcopy's --set-section-flag option from accepting the
# 'shared' flag on non-COFF binaries.
# Lifetime: Fixed in 2.34
Patch74: binutils-objcopy-set-section-flags-shared.patch
# Purpose: Prevent the s/390 linker from rewriting the GOT access
# for certain symbols.
# Lifetime: Fixed in 2.32
Patch75: binutils-s390x-prevent-GOT-rewrite.patch
#----------------------------------------------------------------------------
Provides: bundled(libiberty)
@ -604,6 +656,17 @@ using libelf instead of BFD.
%patch62 -p1
%patch63 -p1
%patch64 -p1
%patch65 -p1
%patch66 -p1
%patch67 -p1
%patch68 -p1
%patch69 -p1
%patch70 -p1
%patch71 -p1
%patch72 -p1
%patch73 -p1
%patch74 -p1
%patch75 -p1
# We cannot run autotools as there is an exact requirement of autoconf-2.59.
# FIXME - this is no longer true. Maybe try reinstating autotool use ?
@ -1041,7 +1104,36 @@ exit 0
#----------------------------------------------------------------------------
%changelog
* Thu Nov 27 2019 Nick Clifton <nickc@redhat.com> - 2.30-68
* Mon Jun 15 2020 Nick Clifton <nickc@redhat.com> - 2.30-75
- Prevent the s/390 linker from rewriting the GOT access for certain symbol types. (#1846972)
* Tue Apr 07 2020 Nick Clifton <nickc@redhat.com> - 2.30-74
- Stop the BFD library from issueing warning messages about allocated sections being found outside of loadable segments. (#1630115)
- Fix linker testsuite failures for the aarch64 and s390x targets. (#1632775, #1809101)
- Fix building the binutils with address sanitization enabled. (#1678323)
- Add support for the PT_GNU_PROPERTY segment. (#1721606)
- Fix an internal error in the GOLD linker. (#1722715)
- Fix the generation of corrupt .note.gnu.property notes. (#1723533)
- Stop objcopy's --set-section-flags option from setting the 'shared' flag on non-COFF binaries. (#1807308)
- Fix a bug in the secondary reloc processing code. (#1809186)
* Wed Feb 12 2020 Nick Clifton <nickc@redhat.com> - 2.30-73
- Remove bogus assertion. (#1801879)
* Wed Feb 12 2020 Nick Clifton <nickc@redhat.com> - 2.30-72
- Allow the BFD library to handle the copying of files containing secondary reloc sections. (#1801879)
* Tue Dec 03 2019 Nick Clifton <nickc@redhat.com> - 2.30-71
- Fix a potential seg-fault in the BFD library when parsing pathalogical debug_info sections. (#1779245)
- Fix a potential memory exhaustion in the BFD library when parsing corrupt DWARF debug information.
* Mon Dec 02 2019 Nick Clifton <nickc@redhat.com> - 2.30-70
- Re-enable strip merging build notes. (#1777760)
* Mon Dec 02 2019 Nick Clifton <nickc@redhat.com> - 2.30-69
- Fix linker testsuite failures triggered by annobin update.
* Thu Nov 28 2019 Nick Clifton <nickc@redhat.com> - 2.30-68
- Backport H.J.Lu's patch to add a workaround for the JCC Errata to the assembler. (#1777002)
* Thu Nov 21 2019 Nick Clifton <nickc@redhat.com> - 2.30-67