Rebase to GNU Binutils 2.31.1 release.

This commit is contained in:
Nick Clifton 2018-07-19 10:27:52 +01:00
parent 762e415bc4
commit b3e6223124
32 changed files with 38 additions and 2924 deletions

1
.gitignore vendored
View File

@ -14,3 +14,4 @@ build-sources
/binutils-2.19.50.0.1-output-format.sed
/binutils-2.30.tar.xz
/binutils-2.30.90.tar.xz
/binutils-2.31.1.tar.xz

View File

@ -1,21 +0,0 @@
--- a/bfd/Makefile.am 2012-03-06 14:00:33.229957572 +0000
+++ b/bfd/Makefile.am 2012-04-27 16:46:05.410974817 +0100
@@ -18,7 +18,7 @@
bfdlibdir = @bfdlibdir@
bfdincludedir = @bfdincludedir@
bfdlib_LTLIBRARIES = libbfd.la
-bfdinclude_HEADERS = $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h
+bfdinclude_HEADERS = $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h $(INCDIR)/demangle.h
else !INSTALL_LIBBFD
# Empty these so that the respective installation directories will not be created.
bfdlibdir =
--- binutils-2.26.orig/bfd/Makefile.in 2016-01-25 10:23:35.054721634 +0000
+++ binutils-2.26/bfd/Makefile.in 2016-01-25 10:25:59.292607840 +0000
@@ -350,6 +350,7 @@ libbfd_la_LDFLAGS = $(am__append_1) -rel
@INSTALL_LIBBFD_FALSE@bfdinclude_HEADERS = $(am__append_2)
@INSTALL_LIBBFD_TRUE@bfdinclude_HEADERS = $(BFD_H) \
@INSTALL_LIBBFD_TRUE@ $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \
+@INSTALL_LIBBFD_TRUE@ $(INCDIR)/demangle.h \
@INSTALL_LIBBFD_TRUE@ $(INCDIR)/bfdlink.h $(am__append_2)
@INSTALL_LIBBFD_FALSE@rpath_bfdlibdir = @bfdlibdir@
@INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libbfd.la

View File

@ -1,147 +0,0 @@
From 279b2f94168ee91e02ccd070d27c983fc001fe12 Mon Sep 17 00:00:00 2001
From: Renlin Li <renlin.li@arm.com>
Date: Sat, 3 Feb 2018 13:18:17 +0000
Subject: [PATCH] [PR22764][LD][AARCH64]Allow R_AARCH64_ABS16 and
R_AARCH64_ABS32 against absolution symbol or undefine symbol in shared
object.
The assumption that R_AARCH64_ABS16 and R_AARCH64_ABS32 relocation in LP64 abi
will be used to generate an address does not hold for absolute symbol.
In this case, it is a value fixed at static linking time.
The condition to check the relocations is relax to allow absolute symbol and
undefined symbol case.
bfd/
2018-02-05 Renlin Li <renlin.li@arm.com>
PR ld/22764
* elfnn-aarch64.c (elfNN_aarch64_check_relocs): Relax the
R_AARCH64_ABS32 and R_AARCH64_ABS16 for absolute symbol. Apply the
check for writeable section as well.
ld/
2018-02-05 Renlin Li <renlin.li@arm.com>
PR ld/22764
* testsuite/ld-aarch64/emit-relocs-258.s: Define symbol as an address.
* testsuite/ld-aarch64/emit-relocs-259.s: Likewise.
* testsuite/ld-aarch64/aarch64-elf.exp: Run new test.
* testsuite/ld-aarch64/pr22764.s: New.
* testsuite/ld-aarch64/pr22764.d: New.
---
bfd/ChangeLog | 7 +++++++
bfd/elfnn-aarch64.c | 15 ++++++++++++---
ld/ChangeLog | 8 ++++++++
ld/testsuite/ld-aarch64/aarch64-elf.exp | 1 +
ld/testsuite/ld-aarch64/emit-relocs-258.s | 3 ++-
ld/testsuite/ld-aarch64/emit-relocs-259.s | 3 ++-
ld/testsuite/ld-aarch64/pr22764.d | 18 ++++++++++++++++++
ld/testsuite/ld-aarch64/pr22764.s | 6 ++++++
8 files changed, 56 insertions(+), 5 deletions(-)
create mode 100644 ld/testsuite/ld-aarch64/pr22764.d
create mode 100644 ld/testsuite/ld-aarch64/pr22764.s
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index af448f9..2737773 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -7189,10 +7189,19 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
#if ARCH_SIZE == 64
case BFD_RELOC_AARCH64_32:
#endif
- if (bfd_link_pic (info)
- && (sec->flags & SEC_ALLOC) != 0
- && (sec->flags & SEC_READONLY) != 0)
+ if (bfd_link_pic (info) && (sec->flags & SEC_ALLOC) != 0)
{
+ if (h != NULL
+ /* This is an absolute symbol. It represents a value instead
+ of an address. */
+ && ((h->root.type == bfd_link_hash_defined
+ && bfd_is_abs_section (h->root.u.def.section))
+ /* This is an undefined symbol. */
+ || h->root.type == bfd_link_hash_undefined))
+ break;
+
+ /* For local symbols, defined global symbols in a non-ABS section,
+ it is assumed that the value is an address. */
int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START;
_bfd_error_handler
/* xgettext:c-format */
diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp
index 2602a43..c67ffb1 100644
--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp
+++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp
@@ -285,6 +285,7 @@ run_dump_test "pr17415"
run_dump_test_lp64 "tprel_g2_overflow"
run_dump_test "tprel_add_lo12_overflow"
run_dump_test "protected-data"
+run_dump_test_lp64 "pr22764"
# ifunc tests
run_dump_test "ifunc-1"
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-258.s b/ld/testsuite/ld-aarch64/emit-relocs-258.s
index f724776..87bb657 100644
--- a/ld/testsuite/ld-aarch64/emit-relocs-258.s
+++ b/ld/testsuite/ld-aarch64/emit-relocs-258.s
@@ -1,5 +1,6 @@
+.global dummy
.text
-
+dummy:
ldr x0, .L1
.L1:
diff --git a/ld/testsuite/ld-aarch64/emit-relocs-259.s b/ld/testsuite/ld-aarch64/emit-relocs-259.s
index 7e1ba3c..0977c9d 100644
--- a/ld/testsuite/ld-aarch64/emit-relocs-259.s
+++ b/ld/testsuite/ld-aarch64/emit-relocs-259.s
@@ -1,5 +1,6 @@
+.global dummy
.text
-
+dummy:
ldr x0, .L1
.L1:
diff --git a/ld/testsuite/ld-aarch64/pr22764.d b/ld/testsuite/ld-aarch64/pr22764.d
new file mode 100644
index 0000000..997519f
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/pr22764.d
@@ -0,0 +1,18 @@
+#source: pr22764.s
+#ld: -shared -T relocs.ld -defsym sym_abs1=0x1 -defsym sym_abs2=0x2 -defsym sym_abs3=0x3 -e0 --emit-relocs
+#notarget: aarch64_be-*-*
+#objdump: -dr
+#...
+
+Disassembly of section \.text:
+
+0000000000010000 \<\.text\>:
+ 10000: d503201f nop
+ ...
+ 10004: R_AARCH64_ABS64 sym_abs1
+ 1000c: 00000002 \.word 0x00000002
+ 1000c: R_AARCH64_ABS32 sym_abs2
+ 10010: 0003 \.short 0x0003
+ 10010: R_AARCH64_ABS16 sym_abs3
+ 10012: 0000 \.short 0x0000
+ 10014: d503201f nop
diff --git a/ld/testsuite/ld-aarch64/pr22764.s b/ld/testsuite/ld-aarch64/pr22764.s
new file mode 100644
index 0000000..25e36b4
--- /dev/null
+++ b/ld/testsuite/ld-aarch64/pr22764.s
@@ -0,0 +1,6 @@
+ .text
+ nop
+ .xword sym_abs1
+ .word sym_abs2
+ .short sym_abs3
+ nop
--
2.9.3

View File

@ -1,22 +0,0 @@
--- binutils.orig/binutils/dwarf.c 2018-05-01 11:42:02.656431736 +0100
+++ binutils-2.30/binutils/dwarf.c 2018-05-01 11:43:24.210383020 +0100
@@ -9244,7 +9244,18 @@ process_cu_tu_index (struct dwarf_sectio
}
if (!do_display)
- memcpy (&this_set[row - 1].signature, ph, sizeof (uint64_t));
+ {
+ size_t num_copy = sizeof (uint64_t);
+
+ /* PR 23064: Beware of buffer overflow. */
+ if (ph + num_copy < limit)
+ memcpy (&this_set[row - 1].signature, ph, num_copy);
+ else
+ {
+ warn (_("Signature (%p) extends beyond end of space in section\n"), ph);
+ return 0;
+ }
+ }
prow = poffsets + (row - 1) * ncols * 4;
/* PR 17531: file: b8ce60a8. */

View File

@ -1,11 +0,0 @@
--- binutils.orig/bfd/dwarf2.c 2018-05-01 11:42:03.152425647 +0100
+++ binutils-2.30/bfd/dwarf2.c 2018-05-01 12:03:27.533735710 +0100
@@ -1559,7 +1559,7 @@ concat_filename (struct line_info_table
{
char *filename;
- if (file - 1 >= table->num_files)
+ if (table == NULL || file - 1 >= table->num_files)
{
/* FILE == 0 means unknown. */
if (file)

View File

@ -1,18 +0,0 @@
--- binutils.orig/bfd/peXXigen.c 2018-05-10 10:09:03.619147342 +0100
+++ binutils-2.30/bfd/peXXigen.c 2018-05-10 10:20:20.884883540 +0100
@@ -2991,6 +2991,15 @@ _bfd_XX_bfd_copy_private_bfd_data_common
bfd_get_section_size (section) - (addr - section->vma));
return FALSE;
}
+ /* PR 23110. */
+ else if (ope->pe_opthdr.DataDirectory[PE_DEBUG_DATA].Size < 0)
+ {
+ /* xgettext:c-format */
+ _bfd_error_handler
+ (_("%pB: Data Directory size (%#lx) is negative"),
+ obfd, ope->pe_opthdr.DataDirectory[PE_DEBUG_DATA].Size);
+ return FALSE;
+ }
for (i = 0; i < ope->pe_opthdr.DataDirectory[PE_DEBUG_DATA].Size
/ sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++)

View File

@ -1,28 +0,0 @@
--- binutils.orig/bfd/elf.c 2018-05-10 10:09:03.622147305 +0100
+++ binutils-2.30/bfd/elf.c 2018-05-10 10:29:09.895577234 +0100
@@ -4021,16 +4021,23 @@ ignore_section_sym (bfd *abfd, asymbol *
{
elf_symbol_type *type_ptr;
+ if (sym == NULL)
+ return FALSE;
+
if ((sym->flags & BSF_SECTION_SYM) == 0)
return FALSE;
+ if (sym->section == NULL)
+ return TRUE;
+
type_ptr = elf_symbol_from (abfd, sym);
return ((type_ptr != NULL
&& type_ptr->internal_elf_sym.st_shndx != 0
&& bfd_is_abs_section (sym->section))
|| !(sym->section->owner == abfd
- || (sym->section->output_section->owner == abfd
- && sym->section->output_offset == 0)
+ || (sym->section->output_section != NULL
+ && sym->section->output_section->owner == abfd
+ && sym->section->output_offset == 0)
|| bfd_is_abs_section (sym->section)));
}

View File

@ -1,20 +0,0 @@
--- binutils.orig/bfd/elfcode.h 2018-05-01 11:42:03.250424443 +0100
+++ binutils-2.30/bfd/elfcode.h 2018-05-01 12:41:00.745780026 +0100
@@ -680,7 +680,7 @@ elf_object_p (bfd *abfd)
if (i_ehdrp->e_shnum > ((bfd_size_type) -1) / sizeof (*i_shdrp))
goto got_wrong_format_error;
#endif
- amt = sizeof (*i_shdrp) * i_ehdrp->e_shnum;
+ amt = sizeof (*i_shdrp) * (bfd_size_type) i_ehdrp->e_shnum;
i_shdrp = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt);
if (!i_shdrp)
goto got_no_match;
@@ -776,7 +776,7 @@ elf_object_p (bfd *abfd)
if (i_ehdrp->e_phnum > ((bfd_size_type) -1) / sizeof (*i_phdr))
goto got_wrong_format_error;
#endif
- amt = i_ehdrp->e_phnum * sizeof (*i_phdr);
+ amt = (bfd_size_type) i_ehdrp->e_phnum * sizeof (*i_phdr);
elf_tdata (abfd)->phdr = (Elf_Internal_Phdr *) bfd_alloc (abfd, amt);
if (elf_tdata (abfd)->phdr == NULL)
goto got_no_match;

View File

@ -1,69 +0,0 @@
--- binutils.orig/bfd/opncls.c 2018-05-01 11:42:03.266424248 +0100
+++ binutils-2.30/bfd/opncls.c 2018-05-01 12:52:36.792579838 +0100
@@ -1179,6 +1179,7 @@ bfd_get_debug_link_info_1 (bfd *abfd, vo
bfd_byte *contents;
unsigned int crc_offset;
char *name;
+ bfd_size_type size;
BFD_ASSERT (abfd);
BFD_ASSERT (crc32_out);
@@ -1188,6 +1189,12 @@ bfd_get_debug_link_info_1 (bfd *abfd, vo
if (sect == NULL)
return NULL;
+ size = bfd_get_section_size (sect);
+
+ /* PR 22794: Make sure that the section has a reasonable size. */
+ if (size < 8 || size >= bfd_get_size (abfd))
+ return NULL;
+
if (!bfd_malloc_and_get_section (abfd, sect, &contents))
{
if (contents != NULL)
@@ -1198,9 +1205,9 @@ bfd_get_debug_link_info_1 (bfd *abfd, vo
/* CRC value is stored after the filename, aligned up to 4 bytes. */
name = (char *) contents;
/* PR 17597: avoid reading off the end of the buffer. */
- crc_offset = strnlen (name, bfd_get_section_size (sect)) + 1;
+ crc_offset = strnlen (name, size) + 1;
crc_offset = (crc_offset + 3) & ~3;
- if (crc_offset + 4 > bfd_get_section_size (sect))
+ if (crc_offset + 4 > size)
return NULL;
*crc32 = bfd_get_32 (abfd, contents + crc_offset);
@@ -1261,6 +1268,7 @@ bfd_get_alt_debug_link_info (bfd * abfd,
bfd_byte *contents;
unsigned int buildid_offset;
char *name;
+ bfd_size_type size;
BFD_ASSERT (abfd);
BFD_ASSERT (buildid_len);
@@ -1271,6 +1279,10 @@ bfd_get_alt_debug_link_info (bfd * abfd,
if (sect == NULL)
return NULL;
+ size = bfd_get_section_size (sect);
+ if (size < 8 || size >= bfd_get_size (abfd))
+ return NULL;
+
if (!bfd_malloc_and_get_section (abfd, sect, & contents))
{
if (contents != NULL)
@@ -1280,11 +1292,11 @@ bfd_get_alt_debug_link_info (bfd * abfd,
/* BuildID value is stored after the filename. */
name = (char *) contents;
- buildid_offset = strnlen (name, bfd_get_section_size (sect)) + 1;
- if (buildid_offset >= bfd_get_section_size (sect))
+ buildid_offset = strnlen (name, size) + 1;
+ if (buildid_offset >= size)
return NULL;
- *buildid_len = bfd_get_section_size (sect) - buildid_offset;
+ *buildid_len = size - buildid_offset;
*buildid_out = bfd_malloc (*buildid_len);
memcpy (*buildid_out, contents + buildid_offset, *buildid_len);

View File

@ -1,12 +0,0 @@
--- binutils.orig/bfd/coffgen.c 2018-04-27 09:23:33.449859052 +0100
+++ binutils-2.30/bfd/coffgen.c 2018-04-27 09:34:34.530135122 +0100
@@ -1555,7 +1555,8 @@ coff_pointerize_aux (bfd *abfd,
}
/* A negative tagndx is meaningless, but the SCO 3.2v4 cc can
generate one, so we must be careful to ignore it. */
- if (auxent->u.auxent.x_sym.x_tagndx.l > 0)
+ if ((unsigned long) auxent->u.auxent.x_sym.x_tagndx.l
+ < obj_raw_syment_count (abfd))
{
auxent->u.auxent.x_sym.x_tagndx.p =
table_base + auxent->u.auxent.x_sym.x_tagndx.l;

View File

@ -1,37 +0,0 @@
--- binutils.orig/bfd/dwarf1.c 2018-05-01 13:04:35.060041875 +0100
+++ binutils-2.30/bfd/dwarf1.c 2018-05-01 13:24:17.943833855 +0100
@@ -213,6 +213,7 @@ parse_die (bfd * abfd,
/* Then the attributes. */
while (xptr + 2 <= aDiePtrEnd)
{
+ unsigned int block_len;
unsigned short attr;
/* Parse the attribute based on its form. This section
@@ -255,12 +256,24 @@ parse_die (bfd * abfd,
break;
case FORM_BLOCK2:
if (xptr + 2 <= aDiePtrEnd)
- xptr += bfd_get_16 (abfd, xptr);
+ {
+ block_len = bfd_get_16 (abfd, xptr);
+ if (xptr + block_len > aDiePtrEnd
+ || xptr + block_len < xptr)
+ return FALSE;
+ xptr += block_len;
+ }
xptr += 2;
break;
case FORM_BLOCK4:
if (xptr + 4 <= aDiePtrEnd)
- xptr += bfd_get_32 (abfd, xptr);
+ {
+ block_len = bfd_get_32 (abfd, xptr);
+ if (xptr + block_len > aDiePtrEnd
+ || xptr + block_len < xptr)
+ return FALSE;
+ xptr += block_len;
+ }
xptr += 4;
break;
case FORM_STRING:

View File

@ -1,75 +0,0 @@
--- binutils.orig/bfd/dwarf2.c 2018-05-01 13:04:35.055041935 +0100
+++ binutils-2.30/bfd/dwarf2.c 2018-05-01 13:31:32.882624448 +0100
@@ -622,14 +622,24 @@ read_8_bytes (bfd *abfd, bfd_byte *buf,
}
static bfd_byte *
-read_n_bytes (bfd *abfd ATTRIBUTE_UNUSED,
- bfd_byte *buf,
- bfd_byte *end,
- unsigned int size ATTRIBUTE_UNUSED)
-{
- if (buf + size > end)
- return NULL;
- return buf;
+read_n_bytes (bfd_byte * buf,
+ bfd_byte * end,
+ struct dwarf_block * block)
+{
+ unsigned int size = block->size;
+ bfd_byte * block_end = buf + size;
+
+ if (block_end > end || block_end < buf)
+ {
+ block->data = NULL;
+ block->size = 0;
+ return end;
+ }
+ else
+ {
+ block->data = buf;
+ return block_end;
+ }
}
/* Scans a NUL terminated string starting at BUF, returning a pointer to it.
@@ -1127,8 +1137,7 @@ read_attribute_value (struct attribute *
return NULL;
blk->size = read_2_bytes (abfd, info_ptr, info_ptr_end);
info_ptr += 2;
- blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size);
- info_ptr += blk->size;
+ info_ptr = read_n_bytes (info_ptr, info_ptr_end, blk);
attr->u.blk = blk;
break;
case DW_FORM_block4:
@@ -1138,8 +1147,7 @@ read_attribute_value (struct attribute *
return NULL;
blk->size = read_4_bytes (abfd, info_ptr, info_ptr_end);
info_ptr += 4;
- blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size);
- info_ptr += blk->size;
+ info_ptr = read_n_bytes (info_ptr, info_ptr_end, blk);
attr->u.blk = blk;
break;
case DW_FORM_data2:
@@ -1179,8 +1187,7 @@ read_attribute_value (struct attribute *
blk->size = _bfd_safe_read_leb128 (abfd, info_ptr, &bytes_read,
FALSE, info_ptr_end);
info_ptr += bytes_read;
- blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size);
- info_ptr += blk->size;
+ info_ptr = read_n_bytes (info_ptr, info_ptr_end, blk);
attr->u.blk = blk;
break;
case DW_FORM_block1:
@@ -1190,8 +1197,7 @@ read_attribute_value (struct attribute *
return NULL;
blk->size = read_1_byte (abfd, info_ptr, info_ptr_end);
info_ptr += 1;
- blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size);
- info_ptr += blk->size;
+ info_ptr = read_n_bytes (info_ptr, info_ptr_end, blk);
attr->u.blk = blk;
break;
case DW_FORM_data1:

View File

@ -1,156 +0,0 @@
--- binutils.orig/bfd/elf.c 2018-05-01 11:42:03.151425659 +0100
+++ binutils-2.30/bfd/elf.c 2018-05-01 12:30:42.129206856 +0100
@@ -5713,6 +5713,9 @@ assign_file_positions_for_load_sections
return TRUE;
}
+#define IS_TBSS(s) \
+ ((s->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) == SEC_THREAD_LOCAL)
+
/* Assign file positions for the other sections. */
static bfd_boolean
@@ -5862,65 +5865,100 @@ assign_file_positions_for_non_load_secti
{
if (p->p_type == PT_GNU_RELRO)
{
- const Elf_Internal_Phdr *lp;
- struct elf_segment_map *lm;
+ bfd_vma start, end;
+ bfd_boolean ok;
if (link_info != NULL)
{
/* During linking the range of the RELRO segment is passed
- in link_info. */
+ in link_info. Note that there may be padding between
+ relro_start and the first RELRO section. */
+ start = link_info->relro_start;
+ end = link_info->relro_end;
+ }
+ else if (m->count != 0)
+ {
+ if (!m->p_size_valid)
+ abort ();
+ start = m->sections[0]->vma;
+ end = start + m->p_size;
+ }
+ else
+ {
+ start = 0;
+ end = 0;
+ }
+
+ ok = FALSE;
+ if (start < end)
+ {
+ struct elf_segment_map *lm;
+ const Elf_Internal_Phdr *lp;
+ unsigned int i;
+
+ /* Find a LOAD segment containing a section in the RELRO
+ segment. */
for (lm = elf_seg_map (abfd), lp = phdrs;
lm != NULL;
lm = lm->next, lp++)
{
if (lp->p_type == PT_LOAD
- && lp->p_vaddr < link_info->relro_end
&& lm->count != 0
- && lm->sections[0]->vma >= link_info->relro_start)
+ && (lm->sections[lm->count - 1]->vma
+ + (!IS_TBSS (lm->sections[lm->count - 1])
+ ? lm->sections[lm->count - 1]->size
+ : 0)) > start
+ && lm->sections[0]->vma < end)
break;
}
- BFD_ASSERT (lm != NULL);
- }
- else
- {
- /* Otherwise we are copying an executable or shared
- library, but we need to use the same linker logic. */
- for (lp = phdrs; lp < phdrs + count; ++lp)
+ if (lm != NULL)
{
- if (lp->p_type == PT_LOAD
- && lp->p_paddr == p->p_paddr)
- break;
+ /* Find the section starting the RELRO segment. */
+ for (i = 0; i < lm->count; i++)
+ {
+ asection *s = lm->sections[i];
+ if (s->vma >= start
+ && s->vma < end
+ && s->size != 0)
+ break;
+ }
+
+ if (i < lm->count)
+ {
+ p->p_vaddr = lm->sections[i]->vma;
+ p->p_paddr = lm->sections[i]->lma;
+ p->p_offset = lm->sections[i]->filepos;
+ p->p_memsz = end - p->p_vaddr;
+ p->p_filesz = p->p_memsz;
+
+ /* The RELRO segment typically ends a few bytes
+ into .got.plt but other layouts are possible.
+ In cases where the end does not match any
+ loaded section (for instance is in file
+ padding), trim p_filesz back to correspond to
+ the end of loaded section contents. */
+ if (p->p_filesz > lp->p_vaddr + lp->p_filesz - p->p_vaddr)
+ p->p_filesz = lp->p_vaddr + lp->p_filesz - p->p_vaddr;
+
+ /* Preserve the alignment and flags if they are
+ valid. The gold linker generates RW/4 for
+ the PT_GNU_RELRO section. It is better for
+ objcopy/strip to honor these attributes
+ otherwise gdb will choke when using separate
+ debug files. */
+ if (!m->p_align_valid)
+ p->p_align = 1;
+ if (!m->p_flags_valid)
+ p->p_flags = PF_R;
+ ok = TRUE;
+ }
}
}
-
- if (lp < phdrs + count)
- {
- p->p_vaddr = lp->p_vaddr;
- p->p_paddr = lp->p_paddr;
- p->p_offset = lp->p_offset;
- if (link_info != NULL)
- p->p_filesz = link_info->relro_end - lp->p_vaddr;
- else if (m->p_size_valid)
- p->p_filesz = m->p_size;
- else
- abort ();
- p->p_memsz = p->p_filesz;
- /* Preserve the alignment and flags if they are valid. The
- gold linker generates RW/4 for the PT_GNU_RELRO section.
- It is better for objcopy/strip to honor these attributes
- otherwise gdb will choke when using separate debug files.
- */
- if (!m->p_align_valid)
- p->p_align = 1;
- if (!m->p_flags_valid)
- p->p_flags = PF_R;
- }
- else
- {
- memset (p, 0, sizeof *p);
- p->p_type = PT_NULL;
- }
+ if (link_info != NULL)
+ BFD_ASSERT (ok);
+ if (!ok)
+ memset (p, 0, sizeof *p);
}
else if (p->p_type == PT_GNU_STACK)
{

View File

@ -1,17 +0,0 @@
--- binutils.orig/bfd/aoutx.h 2018-04-26 15:14:18.411450291 +0100
+++ binutils-2.30/bfd/aoutx.h 2018-04-26 17:22:38.328770529 +0100
@@ -2283,10 +2283,12 @@ NAME (aout, swap_std_reloc_in) (bfd *abf
if (r_baserel)
r_extern = 1;
- if (r_extern && r_index > symcount)
+ if (r_extern && r_index >= symcount)
{
/* We could arrange to return an error, but it might be useful
- to see the file even if it is bad. */
+ to see the file even if it is bad. FIXME: Of course this
+ means that objdump -r *doesn't* see the actual reloc, and
+ objcopy silently writes a different reloc. */
r_extern = 0;
r_index = N_ABS;
}

View File

@ -1,16 +0,0 @@
--- binutils.orig/binutils/dwarf.c 2018-04-27 09:22:07.402864408 +0100
+++ binutils-2.30/binutils/dwarf.c 2018-04-27 09:24:26.794235786 +0100
@@ -6810,6 +6810,13 @@ display_debug_ranges (struct dwarf_secti
continue;
}
+ if (next < section_begin || next >= finish)
+ {
+ warn (_("Corrupt offset (%#8.8lx) in range entry %u\n"),
+ (unsigned long) offset, i);
+ continue;
+ }
+
if (dwarf_check != 0 && i > 0)
{
if (start < next)

View File

@ -1,29 +0,0 @@
diff -rup binutils.orig/bfd/elf-attrs.c binutils-2.30/bfd/elf-attrs.c
--- binutils.orig/bfd/elf-attrs.c 2018-05-17 14:14:04.341805666 +0100
+++ binutils-2.30/bfd/elf-attrs.c 2018-05-17 14:15:19.729952453 +0100
@@ -438,6 +438,14 @@ _bfd_elf_parse_attributes (bfd *abfd, El
/* PR 17512: file: 2844a11d. */
if (hdr->sh_size == 0)
return;
+ if (hdr->sh_size > bfd_get_file_size (abfd))
+ {
+ _bfd_error_handler (_("%pB: error: attribute section '%pA' too big: %#llx"),
+ abfd, hdr->bfd_section, (long long) hdr->sh_size);
+ bfd_set_error (bfd_error_invalid_operation);
+ return;
+ }
+
contents = (bfd_byte *) bfd_malloc (hdr->sh_size + 1);
if (!contents)
return;
diff -rup binutils.orig/bfd/elf.c binutils-2.30/bfd/elf.c
--- binutils.orig/bfd/elf.c 2018-05-17 14:14:04.326805836 +0100
+++ binutils-2.30/bfd/elf.c 2018-05-17 14:15:59.412503342 +0100
@@ -298,6 +298,7 @@ bfd_elf_get_str_section (bfd *abfd, unsi
/* Allocate and clear an extra byte at the end, to prevent crashes
in case the string table is not terminated. */
if (shstrtabsize + 1 <= 1
+ || shstrtabsize > bfd_get_file_size (abfd)
|| bfd_seek (abfd, offset, SEEK_SET) != 0
|| (shstrtab = (bfd_byte *) bfd_alloc (abfd, shstrtabsize + 1)) == NULL)
shstrtab = NULL;

View File

@ -1,17 +0,0 @@
--- binutils.orig/bfd/elf32-ppc.c 2018-06-12 17:35:40.931551297 +0100
+++ binutils-2.30/bfd/elf32-ppc.c 2018-06-12 17:37:22.252441292 +0100
@@ -4677,12 +4677,12 @@ _bfd_elf_ppc_merge_fp_attributes (bfd *i
_bfd_error_handler
/* xgettext:c-format */
(_("Warning: %B uses IBM long double, "
- "%B uses IEEE long double"), ibfd, obfd);
+ "%B uses IEEE long double"), obfd, ibfd);
else if (out_fp == 3 * 4 && in_fp == 1 * 4)
_bfd_error_handler
/* xgettext:c-format */
(_("Warning: %B uses IBM long double, "
- "%B uses IEEE long double"), obfd, ibfd);
+ "%B uses IEEE long double"), ibfd, obfd);
}
}

View File

@ -1,39 +0,0 @@
--- binutils.orig/bfd/elflink.c 2018-03-14 10:14:49.729271271 +0000
+++ binutils-2.30/bfd/elflink.c 2018-03-14 10:15:15.748967793 +0000
@@ -12785,7 +12785,7 @@ _bfd_elf_gc_mark_hook (asection *sec,
return NULL;
}
-/* Return the global debug definition section. */
+/* Return the debug definition section. */
static asection *
elf_gc_mark_debug_section (asection *sec ATTRIBUTE_UNUSED,
@@ -12794,11 +12794,22 @@ elf_gc_mark_debug_section (asection *sec
struct elf_link_hash_entry *h,
Elf_Internal_Sym *sym ATTRIBUTE_UNUSED)
{
- if (h != NULL
- && (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- && (h->root.u.def.section->flags & SEC_DEBUGGING) != 0)
- return h->root.u.def.section;
+ if (h != NULL)
+ {
+ /* Return the global debug definition section. */
+ if ((h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && (h->root.u.def.section->flags & SEC_DEBUGGING) != 0)
+ return h->root.u.def.section;
+ }
+ else
+ {
+ /* Return the local debug definition section. */
+ asection *isec = bfd_section_from_elf_index (sec->owner,
+ sym->st_shndx);
+ if ((isec->flags & SEC_DEBUGGING) != 0)
+ return isec;
+ }
return NULL;
}

View File

@ -1,555 +0,0 @@
diff -rup binutils.orig/binutils/readelf.c binutils-2.30/binutils/readelf.c
--- binutils.orig/binutils/readelf.c 2018-04-26 15:14:17.220464639 +0100
+++ binutils-2.30/binutils/readelf.c 2018-04-26 15:14:31.927287474 +0100
@@ -12294,7 +12294,8 @@ is_32bit_abs_reloc (Filedata * filedata,
case EM_OR1K:
return reloc_type == 1; /* R_OR1K_32. */
case EM_PARISC:
- return (reloc_type == 1 /* R_PARISC_DIR32. */
+ return (reloc_type == 1 /* R_PARISC_DIR32. */
+ || reloc_type == 2 /* R_PARISC_DIR21L. */
|| reloc_type == 41); /* R_PARISC_SECREL32. */
case EM_PJ:
case EM_PJ_OLD:
Only in binutils-2.30/binutils: readelf.c.orig
diff -rup binutils.orig/binutils/testsuite/binutils-all/objcopy.exp binutils-2.30/binutils/testsuite/binutils-all/objcopy.exp
--- binutils.orig/binutils/testsuite/binutils-all/objcopy.exp 2018-04-26 15:14:17.215464699 +0100
+++ binutils-2.30/binutils/testsuite/binutils-all/objcopy.exp 2018-04-26 15:14:31.927287474 +0100
@@ -1062,6 +1062,7 @@ if [is_elf_format] {
run_dump_test "note-3-32"
run_dump_test "note-4-32"
}
+ run_dump_test "note-5"
}
run_dump_test "copy-2"
Only in binutils-2.30/binutils/testsuite/binutils-all: objcopy.exp.orig
diff -rup binutils.orig/gas/as.c binutils-2.30/gas/as.c
--- binutils.orig/gas/as.c 2018-04-26 15:14:17.646459507 +0100
+++ binutils-2.30/gas/as.c 2018-04-26 15:14:31.927287474 +0100
@@ -97,6 +97,7 @@ int verbose = 0;
#if defined OBJ_ELF || defined OBJ_MAYBE_ELF
int flag_use_elf_stt_common = DEFAULT_GENERATE_ELF_STT_COMMON;
+bfd_boolean flag_generate_build_notes = DEFAULT_GENERATE_BUILD_NOTES;
#endif
/* Keep the output file. */
@@ -304,8 +305,19 @@ Options:\n\
generate ELF common symbols with STT_COMMON type\n"));
fprintf (stream, _("\
--sectname-subst enable section name substitution sequences\n"));
+
+ fprintf (stream, _("\
+ --generate-missing-build-notes=[no|yes] "));
+#if DEFAULT_GENERATE_BUILD_NOTES
+ fprintf (stream, _("(default: yes)\n"));
+#else
+ fprintf (stream, _("(default: no)\n"));
#endif
fprintf (stream, _("\
+ generate GNU Build notes if none are present in the input\n"));
+#endif /* OBJ_ELF */
+
+ fprintf (stream, _("\
-f skip whitespace and comment preprocessing\n"));
fprintf (stream, _("\
-g --gen-debug generate debugging information\n"));
@@ -470,6 +482,7 @@ parse_args (int * pargc, char *** pargv)
OPTION_NOEXECSTACK,
OPTION_SIZE_CHECK,
OPTION_ELF_STT_COMMON,
+ OPTION_ELF_BUILD_NOTES,
OPTION_SECTNAME_SUBST,
OPTION_ALTERNATE,
OPTION_AL,
@@ -508,6 +521,7 @@ parse_args (int * pargc, char *** pargv)
,{"size-check", required_argument, NULL, OPTION_SIZE_CHECK}
,{"elf-stt-common", required_argument, NULL, OPTION_ELF_STT_COMMON}
,{"sectname-subst", no_argument, NULL, OPTION_SECTNAME_SUBST}
+ ,{"generate-missing-build-notes", required_argument, NULL, OPTION_ELF_BUILD_NOTES}
#endif
,{"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
,{"gdwarf-2", no_argument, NULL, OPTION_GDWARF2}
@@ -900,7 +914,19 @@ This program has absolutely no warranty.
case OPTION_SECTNAME_SUBST:
flag_sectname_subst = 1;
break;
-#endif
+
+ case OPTION_ELF_BUILD_NOTES:
+ if (strcasecmp (optarg, "no") == 0)
+ flag_generate_build_notes = FALSE;
+ else if (strcasecmp (optarg, "yes") == 0)
+ flag_generate_build_notes = TRUE;
+ else
+ as_fatal (_("Invalid --generate-missing-build-notes option: `%s'"),
+ optarg);
+ break;
+
+#endif /* OBJ_ELF */
+
case 'Z':
flag_always_generate_output = 1;
break;
diff -rup binutils.orig/gas/as.h binutils-2.30/gas/as.h
--- binutils.orig/gas/as.h 2018-04-26 15:14:17.654459410 +0100
+++ binutils-2.30/gas/as.h 2018-04-26 15:14:31.927287474 +0100
@@ -585,6 +585,10 @@ COMMON int flag_allow_nonconst_size;
/* If we should generate ELF common symbols with the STT_COMMON type. */
extern int flag_use_elf_stt_common;
+/* TRUE iff GNU Build attribute notes should
+ be generated if none are in the input files. */
+extern bfd_boolean flag_generate_build_notes;
+
/* If section name substitution sequences should be honored */
COMMON int flag_sectname_subst;
#endif
Only in binutils-2.30/gas: as.h.orig
diff -rup binutils.orig/gas/config.in binutils-2.30/gas/config.in
--- binutils.orig/gas/config.in 2018-04-26 15:14:17.645459519 +0100
+++ binutils-2.30/gas/config.in 2018-04-26 15:14:31.927287474 +0100
@@ -39,6 +39,10 @@
/* Define if you want compressed debug sections by default. */
#undef DEFAULT_FLAG_COMPRESS_DEBUG
+/* Define to 1 if you want to generate GNU Build attribute notes by default,
+ if none are contained in the input. */
+#undef DEFAULT_GENERATE_BUILD_NOTES
+
/* Define to 1 if you want to generate ELF common symbols with the STT_COMMON
type by default. */
#undef DEFAULT_GENERATE_ELF_STT_COMMON
diff -rup binutils.orig/gas/configure binutils-2.30/gas/configure
--- binutils.orig/gas/configure 2018-04-26 15:14:17.645459519 +0100
+++ binutils-2.30/gas/configure 2018-04-26 15:14:31.928287462 +0100
@@ -771,6 +771,7 @@ enable_checking
enable_compressed_debug_sections
enable_x86_relax_relocations
enable_elf_stt_common
+enable_generate_build_notes
enable_werror
enable_build_warnings
with_cpu
@@ -1426,6 +1427,9 @@ Optional Features:
generate x86 relax relocations by default
--enable-elf-stt-common generate ELF common symbols with STT_COMMON type by
default
+ --enable-generate-build-notes
+ generate GNU Build notes if none are provided by the
+ input
--enable-werror treat compile warnings as errors
--enable-build-warnings enable build-time compiler warnings
--disable-nls do not use Native Language Support
@@ -11011,7 +11015,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10990 "configure"
+#line 10994 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11117,7 +11121,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11096 "configure"
+#line 11100 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11771,6 +11775,20 @@ if test "${enable_elf_stt_common+set}" =
esac
fi
+
+# Decide if the ELF assembler should default to generating
+# GNU Build notes if none are provided by the input.
+ac_default_generate_build_notes=0
+# Provide a configuration option to override the default.
+# Check whether --enable-generate_build_notes was given.
+if test "${enable_generate_build_notes+set}" = set; then :
+ enableval=$enable_generate_build_notes; case "${enableval}" in
+ yes) ac_default_generate_build_notes=1 ;;
+ no) ac_default_generate_build_notes=0 ;;
+esac
+fi
+
+
using_cgen=no
@@ -12713,6 +12731,12 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_GENERATE_BUILD_NOTES $ac_default_generate_build_notes
+_ACEOF
+
+
if test x$ac_default_compressed_debug_sections = xyes ; then
$as_echo "#define DEFAULT_FLAG_COMPRESS_DEBUG 1" >>confdefs.h
diff -rup binutils.orig/gas/configure.ac binutils-2.30/gas/configure.ac
--- binutils.orig/gas/configure.ac 2018-04-26 15:14:17.645459519 +0100
+++ binutils-2.30/gas/configure.ac 2018-04-26 15:14:31.928287462 +0100
@@ -100,6 +100,20 @@ AC_ARG_ENABLE(elf_stt_common,
yes) ac_default_elf_stt_common=1 ;;
esac])dnl
+
+# Decide if the ELF assembler should default to generating
+# GNU Build notes if none are provided by the input.
+ac_default_generate_build_notes=0
+# Provide a configuration option to override the default.
+AC_ARG_ENABLE(generate_build_notes,
+ AS_HELP_STRING([--enable-generate-build-notes],
+ [generate GNU Build notes if none are provided by the input]),
+[case "${enableval}" in
+ yes) ac_default_generate_build_notes=1 ;;
+ no) ac_default_generate_build_notes=0 ;;
+esac])dnl
+
+
using_cgen=no
AM_BINUTILS_WARNINGS
@@ -610,6 +624,11 @@ AC_DEFINE_UNQUOTED(DEFAULT_GENERATE_ELF_
[Define to 1 if you want to generate ELF common symbols with the
STT_COMMON type by default.])
+AC_DEFINE_UNQUOTED(DEFAULT_GENERATE_BUILD_NOTES,
+ $ac_default_generate_build_notes,
+ [Define to 1 if you want to generate GNU Build attribute notes
+ by default, if none are contained in the input.])
+
if test x$ac_default_compressed_debug_sections = xyes ; then
AC_DEFINE(DEFAULT_FLAG_COMPRESS_DEBUG, 1, [Define if you want compressed debug sections by default.])
fi
Only in binutils-2.30/gas: configure.ac.orig
Only in binutils-2.30/gas: configure.orig
diff -rup binutils.orig/gas/doc/as.texinfo binutils-2.30/gas/doc/as.texinfo
--- binutils.orig/gas/doc/as.texinfo 2018-04-26 15:14:17.665459278 +0100
+++ binutils-2.30/gas/doc/as.texinfo 2018-04-26 15:14:31.929287450 +0100
@@ -244,6 +244,7 @@ gcc(1), ld(1), and the Info entries for
[@b{-Z}] [@b{@@@var{FILE}}]
[@b{--sectname-subst}] [@b{--size-check=[error|warning]}]
[@b{--elf-stt-common=[no|yes]}]
+ [@b{--generate-missing-build-notes=[no|yes]}]
[@b{--target-help}] [@var{target-options}]
[@b{--}|@var{files} @dots{}]
@c
@@ -754,6 +755,14 @@ Issue an error or warning for invalid EL
These options control whether the ELF assembler should generate common
symbols with the @code{STT_COMMON} type. The default can be controlled
by a configure option @option{--enable-elf-stt-common}.
+
+@item --generate-missing-build-notes=yes
+@itemx --generate-missing-build-notes=no
+These options control whether the ELF assembler should generate GNU Build
+attribute notes if none are present in the input sources.
+The default can be controlled by the @option{--enable-generate-build-notes}
+configure option.
+
@end ifset
@item --help
Only in binutils-2.30/gas/doc: as.texinfo.orig
diff -rup binutils.orig/gas/NEWS binutils-2.30/gas/NEWS
--- binutils.orig/gas/NEWS 2018-04-26 15:14:17.646459507 +0100
+++ binutils-2.30/gas/NEWS 2018-04-26 15:15:32.276560482 +0100
@@ -1,5 +1,11 @@
-*- text -*-
+* Add --generate-missing-build-notes=[yes|no] option to create (or not) GNU
+ Build Attribute notes if none are present in the input sources. Add a
+ --enable-generate-build-notes=[yes|no] configure time option to set the
+ default behaviour. Set the default if the configure option is not used
+ to "no".
+
Changes in 2.30:
* Add support for loaction views in DWARF debug line information.
Only in binutils-2.30/gas: NEWS.orig
Only in binutils-2.30/gas: NEWS.rej
diff -rup binutils.orig/gas/symbols.c binutils-2.30/gas/symbols.c
--- binutils.orig/gas/symbols.c 2018-04-26 15:14:17.667459254 +0100
+++ binutils-2.30/gas/symbols.c 2018-04-26 15:14:31.929287450 +0100
@@ -108,6 +108,7 @@ save_symbol_name (const char *name)
size_t name_length;
char *ret;
+ gas_assert (name != NULL);
name_length = strlen (name) + 1; /* +1 for \0. */
obstack_grow (&notes, name, name_length);
ret = (char *) obstack_finish (&notes);
diff -rup binutils.orig/gas/write.c binutils-2.30/gas/write.c
--- binutils.orig/gas/write.c 2018-04-26 15:14:18.296451677 +0100
+++ binutils-2.30/gas/write.c 2018-04-26 15:14:31.929287450 +0100
@@ -1822,25 +1822,200 @@ create_obj_attrs_section (void)
const char *name;
size = bfd_elf_obj_attr_size (stdoutput);
- if (size)
+ if (size == 0)
+ return;
+
+ name = get_elf_backend_data (stdoutput)->obj_attrs_section;
+ if (!name)
+ name = ".gnu.attributes";
+ s = subseg_new (name, 0);
+ elf_section_type (s)
+ = get_elf_backend_data (stdoutput)->obj_attrs_section_type;
+ bfd_set_section_flags (stdoutput, s, SEC_READONLY | SEC_DATA);
+ frag_now_fix ();
+ p = frag_more (size);
+ bfd_elf_set_obj_attr_contents (stdoutput, (bfd_byte *)p, size);
+
+ subsegs_finish_section (s);
+ relax_segment (seg_info (s)->frchainP->frch_root, s, 0);
+ size_seg (stdoutput, s, NULL);
+}
+
+#include "struc-symbol.h"
+
+/* Create a relocation against an entry in a GNU Build attribute section. */
+
+static void
+create_note_reloc (segT sec,
+ symbolS * sym,
+ bfd_size_type offset,
+ int reloc_type,
+ bfd_vma addend,
+ char * note)
+{
+ struct reloc_list * reloc;
+
+ reloc = XNEW (struct reloc_list);
+
+ /* We create a .b type reloc as resolve_reloc_expr_symbols() has already been called. */
+ reloc->u.b.sec = sec;
+ reloc->u.b.s = sym->bsym;
+ reloc->u.b.r.sym_ptr_ptr = & reloc->u.b.s;
+ reloc->u.b.r.address = offset;
+ reloc->u.b.r.addend = addend;
+ reloc->u.b.r.howto = bfd_reloc_type_lookup (stdoutput, reloc_type);
+
+ if (reloc->u.b.r.howto == NULL)
{
- name = get_elf_backend_data (stdoutput)->obj_attrs_section;
- if (!name)
- name = ".gnu.attributes";
- s = subseg_new (name, 0);
- elf_section_type (s)
- = get_elf_backend_data (stdoutput)->obj_attrs_section_type;
- bfd_set_section_flags (stdoutput, s, SEC_READONLY | SEC_DATA);
- frag_now_fix ();
- p = frag_more (size);
- bfd_elf_set_obj_attr_contents (stdoutput, (bfd_byte *)p, size);
-
- subsegs_finish_section (s);
- relax_segment (seg_info (s)->frchainP->frch_root, s, 0);
- size_seg (stdoutput, s, NULL);
+ as_bad (_("unable to create reloc for build note"));
+ return;
+ }
+
+ reloc->file = N_("<gnu build note>");
+ reloc->line = 0;
+
+ reloc->next = reloc_list;
+ reloc_list = reloc;
+
+ /* For REL relocs, store the addend in the section. */
+ if (! sec->use_rela_p
+ /* The SH target is a special case that uses RELA relocs
+ but still stores the addend in the word being relocated. */
+ || strstr (bfd_get_target (stdoutput), "-sh") != NULL)
+ {
+ if (target_big_endian)
+ {
+ if (bfd_arch_bits_per_address (stdoutput) <= 32)
+ note[offset + 3] = addend;
+ else
+ note[offset + 7] = addend;
+ }
+ else
+ note[offset] = addend;
}
}
-#endif
+
+static void
+maybe_generate_build_notes (void)
+{
+ segT sec;
+ char * note;
+ offsetT note_size;
+ offsetT desc_size;
+ offsetT desc2_offset;
+ int desc_reloc;
+ symbolS * sym;
+
+ if (! flag_generate_build_notes
+ || bfd_get_section_by_name (stdoutput,
+ GNU_BUILD_ATTRS_SECTION_NAME) != NULL)
+ return;
+
+ /* Create a GNU Build Attribute section. */
+ sec = subseg_new (GNU_BUILD_ATTRS_SECTION_NAME, FALSE);
+ elf_section_type (sec) = SHT_NOTE;
+ bfd_set_section_flags (stdoutput, sec,
+ SEC_READONLY | SEC_HAS_CONTENTS | SEC_DATA);
+ bfd_set_section_alignment (stdoutput, sec, 2);
+
+ /* Create a version note. */
+ if (bfd_arch_bits_per_address (stdoutput) <= 32)
+ {
+ note_size = 28;
+ desc_size = 8; /* Two 4-byte offsets. */
+ desc2_offset = 24;
+
+ /* FIXME: The BFD backend for the CRX target does not support the
+ BFD_RELOC_32, even though it really should. Likewise for the
+ CR16 target. So we have special case code here... */
+ if (strstr (bfd_get_target (stdoutput), "-crx") != NULL)
+ desc_reloc = BFD_RELOC_CRX_NUM32;
+ else if (strstr (bfd_get_target (stdoutput), "-cr16") != NULL)
+ desc_reloc = BFD_RELOC_CR16_NUM32;
+ else
+ desc_reloc = BFD_RELOC_32;
+ }
+ else
+ {
+ note_size = 36;
+ desc_size = 16; /* Two 8-byte offsets. */
+ desc2_offset = 28;
+ /* FIXME: The BFD backend for the IA64 target does not support the
+ BFD_RELOC_64, even though it really should. The HPPA backend
+ has a similar issue, although it does not support BFD_RELOCs at
+ all! So we have special case code to handle these targets. */
+ if (strstr (bfd_get_target (stdoutput), "-ia64") != NULL)
+ desc_reloc = target_big_endian ? BFD_RELOC_IA64_DIR32MSB : BFD_RELOC_IA64_DIR32LSB;
+ else if (strstr (bfd_get_target (stdoutput), "-hppa") != NULL)
+ desc_reloc = 80; /* R_PARISC_DIR64. */
+ else
+ desc_reloc = BFD_RELOC_64;
+ }
+
+ frag_now_fix ();
+ note = frag_more (note_size);
+ memset (note, 0, note_size);
+
+ if (target_big_endian)
+ {
+ note[3] = 8; /* strlen (name) + 1. */
+ note[7] = desc_size; /* Two 8-byte offsets. */
+ note[10] = NT_GNU_BUILD_ATTRIBUTE_OPEN >> 8;
+ note[11] = NT_GNU_BUILD_ATTRIBUTE_OPEN & 0xff;
+ }
+ else
+ {
+ note[0] = 8; /* strlen (name) + 1. */
+ note[4] = desc_size; /* Two 8-byte offsets. */
+ note[8] = NT_GNU_BUILD_ATTRIBUTE_OPEN & 0xff;
+ note[9] = NT_GNU_BUILD_ATTRIBUTE_OPEN >> 8;
+ }
+
+ /* The a1 version number indicates that this note was
+ generated by the assembler and not the gcc annobin plugin. */
+ memcpy (note + 12, "GA$3a1", 8);
+
+ /* Find the first code section symbol. */
+ for (sym = symbol_rootP; sym != NULL; sym = sym->sy_next)
+ if (sym->bsym != NULL
+ && sym->bsym->flags & BSF_SECTION_SYM
+ && sym->bsym->section != NULL
+ && sym->bsym->section->flags & SEC_CODE)
+ {
+ /* Found one - now create a relocation against this symbol. */
+ create_note_reloc (sec, sym, 20, desc_reloc, 0, note);
+ break;
+ }
+
+ /* Find the last code section symbol. */
+ if (sym)
+ {
+ for (sym = symbol_lastP; sym != NULL; sym = sym->sy_previous)
+ if (sym->bsym != NULL
+ && sym->bsym->flags & BSF_SECTION_SYM
+ && sym->bsym->section != NULL
+ && sym->bsym->section->flags & SEC_CODE)
+ {
+ /* Create a relocation against the end of this symbol. */
+ create_note_reloc (sec, sym, desc2_offset, desc_reloc,
+ bfd_get_section_size (sym->bsym->section),
+ note);
+ break;
+ }
+ }
+ /* else - if we were unable to find any code section symbols then
+ probably there is no code in the output. So leaving the start
+ and end values as zero in the note is OK. */
+
+ /* FIXME: Maybe add a note recording the assembler command line and version ? */
+
+ /* Install the note(s) into the section. */
+ bfd_set_section_contents (stdoutput, sec, (bfd_byte *) note, 0, note_size);
+ subsegs_finish_section (sec);
+ relax_segment (seg_info (sec)->frchainP->frch_root, sec, 0);
+ size_seg (stdoutput, sec, NULL);
+}
+#endif /* OBJ_ELF */
/* Write the object file. */
@@ -2052,6 +2227,11 @@ write_object_file (void)
resolve_local_symbol_values ();
resolve_reloc_expr_symbols ();
+#ifdef OBJ_ELF
+ if (IS_ELF)
+ maybe_generate_build_notes ();
+#endif
+
PROGRESS (1);
#ifdef tc_frob_file_before_adjust
Only in binutils-2.30/gas: write.c.orig
Only in binutils-2.30: testsuite
--- /dev/null 2018-04-26 08:07:19.307057583 +0100
+++ binutils-2.30/binutils/testsuite/binutils-all/note-5.d 2018-04-26 15:17:06.318427614 +0100
@@ -0,0 +1,11 @@
+#PROG: objcopy
+#as: --generate-missing-build-notes=yes
+#readelf: --notes --wide
+#name: assembler generated build notes
+#source: note-5.s
+
+#...
+Displaying notes found in: .gnu.build.attributes
+[ ]+Owner[ ]+Data size[ ]+Description
+[ ]+GA\$<version>3a1[ ]+0x000000(08|10)[ ]+OPEN[ ]+Applies to region from 0 to 0x.. \(note_5.s\)
+#...
--- /dev/null 2018-04-26 08:07:19.307057583 +0100
+++ binutils-2.30/binutils/testsuite/binutils-all/note-5.s 2018-04-26 15:17:06.318427614 +0100
@@ -0,0 +1,14 @@
+ .text
+ .global note_5.s
+note_5.s:
+ .dc.l 2
+ .dc.l 4
+ .dc.l 6
+ .dc.l 8
+ .dc.l 8
+ .dc.l 8
+ .dc.l 8
+ .dc.l 8
+ .dc.l 8
+ .dc.l 8
+
\ No newline at end of file

View File

@ -1,16 +0,0 @@
--- binutils.orig/gold/resolve.cc 2018-03-22 16:52:11.746513638 +0000
+++ binutils-2.30/gold/resolve.cc 2018-03-22 16:53:58.038192419 +0000
@@ -265,10 +265,13 @@ Symbol_table::resolve(Sized_symbol<size>
return;
// Likewise for an absolute symbol defined twice with the same value.
+ // Plugin-symbols are always absolute with same value here, so ignore those.
if (!is_ordinary
&& st_shndx == elfcpp::SHN_ABS
&& !to_is_ordinary
&& to_shndx == elfcpp::SHN_ABS
+ && object->pluginobj() == NULL
+ && to->object()->pluginobj() == NULL
&& to->value() == sym.get_st_value())
return;

View File

@ -1,296 +0,0 @@
diff -rup binutils.orig/bfd/elf32-i386.c binutils-2.30/bfd/elf32-i386.c
--- binutils.orig/bfd/elf32-i386.c 2018-03-09 14:43:05.324208873 +0000
+++ binutils-2.30/bfd/elf32-i386.c 2018-03-09 14:43:23.158000456 +0000
@@ -2202,12 +2202,19 @@ elf_i386_relocate_section (bfd *output_b
if ((input_section->flags & SEC_ALLOC) == 0)
{
+ /* If this is a SHT_NOTE section without SHF_ALLOC, treat
+ STT_GNU_IFUNC symbol as STT_FUNC. */
+ if (elf_section_type (input_section) == SHT_NOTE)
+ goto skip_ifunc;
/* Dynamic relocs are not propagated for SEC_DEBUGGING
sections because such sections are not SEC_ALLOC and
thus ld.so will not process them. */
if ((input_section->flags & SEC_DEBUGGING) != 0)
continue;
- abort ();
+ _bfd_error_handler (_("%B: error: relocation againt ifunc symbol in non-alloc section %A"),
+ input_bfd, input_section);
+ bfd_set_error (bfd_error_invalid_operation);
+ return FALSE;
}
/* STT_GNU_IFUNC symbol must go through PLT. */
@@ -2421,6 +2428,7 @@ do_ifunc_pointer:
}
}
+ skip_ifunc:
resolved_to_zero = (eh != NULL
&& UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
diff -rup binutils.orig/bfd/elf32-s390.c binutils-2.30/bfd/elf32-s390.c
--- binutils.orig/bfd/elf32-s390.c 2018-03-09 14:43:05.325208861 +0000
+++ binutils-2.30/bfd/elf32-s390.c 2018-03-09 14:43:31.353904647 +0000
@@ -2601,6 +2601,9 @@ elf_s390_relocate_section (bfd *output_b
case R_390_8:
case R_390_16:
case R_390_32:
+ if ((input_section->flags & SEC_ALLOC) == 0)
+ break;
+
if (h != NULL
&& s390_is_ifunc_symbol_p (h)
&& h->def_regular)
@@ -2662,9 +2665,6 @@ elf_s390_relocate_section (bfd *output_b
}
}
- if ((input_section->flags & SEC_ALLOC) == 0)
- break;
-
if ((bfd_link_pic (info)
&& (h == NULL
|| (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
Only in binutils-2.30/bfd: elf32-s390.c.orig
diff -rup binutils.orig/bfd/elf64-s390.c binutils-2.30/bfd/elf64-s390.c
--- binutils.orig/bfd/elf64-s390.c 2018-03-09 14:43:05.341208674 +0000
+++ binutils-2.30/bfd/elf64-s390.c 2018-03-09 14:43:31.354904635 +0000
@@ -2559,6 +2559,9 @@ elf_s390_relocate_section (bfd *output_b
case R_390_32:
case R_390_64:
+ if ((input_section->flags & SEC_ALLOC) == 0)
+ break;
+
if (h != NULL
&& s390_is_ifunc_symbol_p (h)
&& h->def_regular)
@@ -2621,9 +2624,6 @@ elf_s390_relocate_section (bfd *output_b
}
}
- if ((input_section->flags & SEC_ALLOC) == 0)
- break;
-
if ((bfd_link_pic (info)
&& (h == NULL
|| (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
Only in binutils-2.30/bfd: elf64-s390.c.orig
diff -rup binutils.orig/bfd/elf64-x86-64.c binutils-2.30/bfd/elf64-x86-64.c
--- binutils.orig/bfd/elf64-x86-64.c 2018-03-09 14:43:05.344208639 +0000
+++ binutils-2.30/bfd/elf64-x86-64.c 2018-03-09 14:43:23.161000420 +0000
@@ -2499,12 +2499,19 @@ elf_x86_64_relocate_section (bfd *output
if ((input_section->flags & SEC_ALLOC) == 0)
{
+ /* If this is a SHT_NOTE section without SHF_ALLOC, treat
+ STT_GNU_IFUNC symbol as STT_FUNC. */
+ if (elf_section_type (input_section) == SHT_NOTE)
+ goto skip_ifunc;
/* Dynamic relocs are not propagated for SEC_DEBUGGING
sections because such sections are not SEC_ALLOC and
thus ld.so will not process them. */
if ((input_section->flags & SEC_DEBUGGING) != 0)
continue;
- abort ();
+ _bfd_error_handler (_("%B: error: relocation againt ifunc symbol in non-alloc section %A"),
+ input_bfd, input_section);
+ bfd_set_error (bfd_error_invalid_operation);
+ return FALSE;
}
switch (r_type)
@@ -2722,6 +2729,7 @@ do_ifunc_pointer:
}
}
+ skip_ifunc:
resolved_to_zero = (eh != NULL
&& UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
diff -rup binutils.orig/bfd/elfnn-aarch64.c binutils-2.30/bfd/elfnn-aarch64.c
--- binutils.orig/bfd/elfnn-aarch64.c 2018-03-09 14:43:05.337208721 +0000
+++ binutils-2.30/bfd/elfnn-aarch64.c 2018-03-09 14:43:31.355904624 +0000
@@ -4987,6 +4987,11 @@ elfNN_aarch64_final_link_relocate (reloc
if ((input_section->flags & SEC_ALLOC) == 0)
{
+ /* If this is a SHT_NOTE section without SHF_ALLOC, treat
+ STT_GNU_IFUNC symbol as STT_FUNC. */
+ if (elf_section_type (input_section) == SHT_NOTE)
+ goto skip_ifunc;
+
/* Dynamic relocs are not propagated for SEC_DEBUGGING
sections because such sections are not SEC_ALLOC and
thus ld.so will not process them. */
@@ -5180,6 +5185,7 @@ bad_ifunc_reloc:
}
}
+ skip_ifunc:
resolved_to_zero = (h != NULL
&& UNDEFWEAK_NO_DYNAMIC_RELOC (info, h));
Only in binutils-2.30/bfd: elfnn-aarch64.c.orig
diff -rup binutils.orig/bfd/elfxx-sparc.c binutils-2.30/bfd/elfxx-sparc.c
--- binutils.orig/bfd/elfxx-sparc.c 2018-03-09 14:43:05.333208768 +0000
+++ binutils-2.30/bfd/elfxx-sparc.c 2018-03-09 14:43:31.355904624 +0000
@@ -3026,7 +3026,13 @@ _bfd_sparc_elf_relocate_section (bfd *ou
if ((input_section->flags & SEC_ALLOC) == 0
|| h->plt.offset == (bfd_vma) -1)
- abort ();
+ {
+ /* If this is a SHT_NOTE section without SHF_ALLOC, treat
+ STT_GNU_IFUNC symbol as STT_FUNC. */
+ if (elf_section_type (input_section) == SHT_NOTE)
+ goto skip_ifunc;
+ abort ();
+ }
plt_sec = htab->elf.splt;
if (! plt_sec)
@@ -3130,6 +3136,7 @@ _bfd_sparc_elf_relocate_section (bfd *ou
}
}
+ skip_ifunc:
eh = (struct _bfd_sparc_elf_link_hash_entry *) h;
resolved_to_zero = (eh != NULL
&& UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
Only in binutils-2.30/bfd: elfxx-sparc.c.orig
diff -rup binutils.orig/ld/testsuite/ld-ifunc/ifunc.exp binutils-2.30/ld/testsuite/ld-ifunc/ifunc.exp
--- binutils.orig/ld/testsuite/ld-ifunc/ifunc.exp 2018-03-09 14:43:04.844214486 +0000
+++ binutils-2.30/ld/testsuite/ld-ifunc/ifunc.exp 2018-03-09 14:43:31.355904624 +0000
@@ -47,6 +47,9 @@ if ![check_shared_lib_support] {
return
}
+# This test does not need a compiler...
+run_dump_test "ifuncmod5"
+
# We need a working compiler. (Strictly speaking this is
# not true, we could use target specific assembler files).
if { [which $CC] == 0 } {
Only in binutils-2.30: testsuite
--- /dev/null 2018-03-09 07:59:09.608015200 +0000
+++ binutils-2.30/ld/testsuite/ld-ifunc/ifuncmod5.s 2018-03-09 14:45:45.698334500 +0000
@@ -0,0 +1,105 @@
+ .file "ifuncmod5.c"
+
+ .text
+ .type ifuncmod5.c, STT_NOTYPE
+ifuncmod5.c:
+ .size ifuncmod5.c, 0
+
+ .pushsection .gnu.build.attributes, "", %note
+ .balign 4
+ .dc.l 8
+ .dc.l 16
+ .dc.l 0x100
+ .asciz "GA$3p4"
+ .dc.a ifuncmod5.c
+ .dc.a ifuncmod5.c_end
+ .popsection
+
+.Ltext0:
+#APP
+ .protected global
+ .type foo, %gnu_indirect_function
+ .type foo_hidden, %gnu_indirect_function
+ .type foo_protected, %gnu_indirect_function
+ .hidden foo_hidden
+ .protected foo_protected
+#NO_APP
+ .align 8
+ .type one, %function
+one:
+ .dc.l 0
+ .size one, .-one
+ .align 8
+
+.globl foo
+ .type foo, %function
+foo:
+ .dc.l 0
+ .size foo, .-foo
+
+ .pushsection .gnu.build.attributes
+ .dc.l 6
+ .dc.l 16
+ .dc.l 0x101
+ .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0
+ .dc.b 0, 0
+ .dc.a foo
+ .dc.a foo_end
+ .popsection
+
+foo_end:
+ .align 8
+.globl foo_hidden
+ .type foo_hidden, %function
+foo_hidden:
+ .dc.l 0
+ .size foo_hidden, .-foo_hidden
+
+ .pushsection .gnu.build.attributes
+ .dc.l 6
+ .dc.l 16
+ .dc.l 0x101
+ .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0
+ .dc.b 0, 0
+ .dc.a foo_hidden
+ .dc.a foo_hidden_end
+ .popsection
+
+foo_hidden_end:
+ .align 8
+
+ .globl foo_protected
+ .type foo_protected, %function
+foo_protected:
+ .dc.l 0
+
+ .size foo_protected, .-foo_protected
+
+ .pushsection .gnu.build.attributes
+ .dc.l 6
+ .dc.l 16
+ .dc.l 0x101
+ .dc.b 0x47, 0x41, 0x2a, 0x2, 0, 0
+ .dc.b 0, 0
+ .dc.a foo_protected
+ .dc.a foo_protected_end
+ .popsection
+
+foo_protected_end:
+ .globl global
+
+ .data
+ .align 4
+ .type global, %object
+ .size global, 4
+global:
+ .long -1
+
+ .text
+ .Letext0:
+
+ifuncmod5.c_end:
+ .type ifuncmod5.c_end, STT_NOTYPE
+ .size ifuncmod5.c_end, 0
+
+
--- /dev/null 2018-03-09 07:59:09.608015200 +0000
+++ binutils-2.30/ld/testsuite/ld-ifunc/ifuncmod5.d 2018-03-09 14:45:45.698334500 +0000
@@ -0,0 +1,8 @@
+# name: Reloc against IFUNC symbol in NOTE section
+# ld: -shared
+# nm: -p
+
+# We do not actually care about the notes at the moment.
+# The purpose of this test is to make sure that the link completes successfully.
+#pass
+

View File

@ -1,127 +0,0 @@
--- binutils.orig/gas/write.c 2018-05-14 12:22:27.893671804 +0100
+++ binutils-2.30/gas/write.c 2018-05-14 15:39:03.900509629 +0100
@@ -1901,6 +1901,7 @@ maybe_generate_build_notes (void)
segT sec;
char * note;
offsetT note_size;
+ offsetT total_size;
offsetT desc_size;
offsetT desc2_offset;
int desc_reloc;
@@ -1918,7 +1919,8 @@ maybe_generate_build_notes (void)
SEC_READONLY | SEC_HAS_CONTENTS | SEC_DATA);
bfd_set_section_alignment (stdoutput, sec, 2);
- /* Create a version note. */
+ /* Work out the size of the notes that we will create,
+ and the relocation we should use. */
if (bfd_arch_bits_per_address (stdoutput) <= 32)
{
note_size = 28;
@@ -1952,65 +1954,59 @@ maybe_generate_build_notes (void)
desc_reloc = BFD_RELOC_64;
}
- frag_now_fix ();
- note = frag_more (note_size);
- memset (note, 0, note_size);
+ /* We have to create a note for *each* code section.
+ Linker garbage collection might discard some. */
+ total_size = 0;
+ note = NULL;
- if (target_big_endian)
- {
- note[3] = 8; /* strlen (name) + 1. */
- note[7] = desc_size; /* Two 8-byte offsets. */
- note[10] = NT_GNU_BUILD_ATTRIBUTE_OPEN >> 8;
- note[11] = NT_GNU_BUILD_ATTRIBUTE_OPEN & 0xff;
- }
- else
- {
- note[0] = 8; /* strlen (name) + 1. */
- note[4] = desc_size; /* Two 8-byte offsets. */
- note[8] = NT_GNU_BUILD_ATTRIBUTE_OPEN & 0xff;
- note[9] = NT_GNU_BUILD_ATTRIBUTE_OPEN >> 8;
- }
-
- /* The a1 version number indicates that this note was
- generated by the assembler and not the gcc annobin plugin. */
- memcpy (note + 12, "GA$3a1", 8);
-
- /* Find the first code section symbol. */
for (sym = symbol_rootP; sym != NULL; sym = sym->sy_next)
if (sym->bsym != NULL
&& sym->bsym->flags & BSF_SECTION_SYM
&& sym->bsym->section != NULL
- && sym->bsym->section->flags & SEC_CODE)
+ /* Skip linkonce sections - we cannot these section symbols as they may disappear. */
+ && (sym->bsym->section->flags & (SEC_CODE | SEC_LINK_ONCE)) == SEC_CODE
+ /* Not all linkonce sections are flagged... */
+ && strncmp (S_GET_NAME (sym), ".gnu.linkonce", sizeof ".gnu.linkonce" - 1) != 0)
{
- /* Found one - now create a relocation against this symbol. */
- create_note_reloc (sec, sym, 20, desc_reloc, 0, note);
- break;
- }
+ /* Create a version note. */
+ frag_now_fix ();
+ note = frag_more (note_size);
+ memset (note, 0, note_size);
- /* Find the last code section symbol. */
- if (sym)
- {
- for (sym = symbol_lastP; sym != NULL; sym = sym->sy_previous)
- if (sym->bsym != NULL
- && sym->bsym->flags & BSF_SECTION_SYM
- && sym->bsym->section != NULL
- && sym->bsym->section->flags & SEC_CODE)
+ if (target_big_endian)
{
- /* Create a relocation against the end of this symbol. */
- create_note_reloc (sec, sym, desc2_offset, desc_reloc,
- bfd_get_section_size (sym->bsym->section),
- note);
- break;
+ note[3] = 8; /* strlen (name) + 1. */
+ note[7] = desc_size; /* Two 8-byte offsets. */
+ note[10] = NT_GNU_BUILD_ATTRIBUTE_OPEN >> 8;
+ note[11] = NT_GNU_BUILD_ATTRIBUTE_OPEN & 0xff;
}
- }
- /* else - if we were unable to find any code section symbols then
- probably there is no code in the output. So leaving the start
- and end values as zero in the note is OK. */
+ else
+ {
+ note[0] = 8; /* strlen (name) + 1. */
+ note[4] = desc_size; /* Two 8-byte offsets. */
+ note[8] = NT_GNU_BUILD_ATTRIBUTE_OPEN & 0xff;
+ note[9] = NT_GNU_BUILD_ATTRIBUTE_OPEN >> 8;
+ }
+
+ /* The a1 version number indicates that this note was
+ generated by the assembler and not the gcc annobin plugin. */
+ memcpy (note + 12, "GA$3a1", 8);
- /* FIXME: Maybe add a note recording the assembler command line and version ? */
+ /* Create a relocation to install the start address of the note... */
+ create_note_reloc (sec, sym, 20, desc_reloc, 0, note);
+
+ /* ...and another one to install the end address. */
+ create_note_reloc (sec, sym, desc2_offset, desc_reloc,
+ bfd_get_section_size (sym->bsym->section),
+ note);
+
+ total_size += note_size;
+ /* FIXME: Maybe add a note recording the assembler command line and version ? */
+ }
/* Install the note(s) into the section. */
- bfd_set_section_contents (stdoutput, sec, (bfd_byte *) note, 0, note_size);
+ if (total_size)
+ bfd_set_section_contents (stdoutput, sec, (bfd_byte *) note, 0, total_size);
subsegs_finish_section (sec);
relax_segment (seg_info (sec)->frchainP->frch_root, sec, 0);
size_seg (stdoutput, sec, NULL);

View File

@ -1,24 +0,0 @@
--- binutils.orig/gas/write.c 2018-07-06 11:49:29.149532896 +0100
+++ binutils-2.30/gas/write.c 2018-07-06 11:49:37.550441810 +0100
@@ -1963,7 +1963,7 @@ maybe_generate_build_notes (void)
if (sym->bsym != NULL
&& sym->bsym->flags & BSF_SECTION_SYM
&& sym->bsym->section != NULL
- /* Skip linkonce sections - we cannot these section symbols as they may disappear. */
+ /* Skip linkonce sections - we cannot use these section symbols as they may disappear. */
&& (sym->bsym->section->flags & (SEC_CODE | SEC_LINK_ONCE)) == SEC_CODE
/* Not all linkonce sections are flagged... */
&& strncmp (S_GET_NAME (sym), ".gnu.linkonce", sizeof ".gnu.linkonce" - 1) != 0)
@@ -1993,10 +1993,10 @@ maybe_generate_build_notes (void)
memcpy (note + 12, "GA$3a1", 8);
/* Create a relocation to install the start address of the note... */
- create_note_reloc (sec, sym, 20, desc_reloc, 0, note);
+ create_note_reloc (sec, sym, total_size + 20, desc_reloc, 0, note);
/* ...and another one to install the end address. */
- create_note_reloc (sec, sym, desc2_offset, desc_reloc,
+ create_note_reloc (sec, sym, total_size + desc2_offset, desc_reloc,
bfd_get_section_size (sym->bsym->section),
note);

View File

@ -1,77 +0,0 @@
diff --git a/bfd/elf.c b/bfd/elf.c
index c132098558..325bdd545a 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4727,33 +4727,35 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info)
the previous section, then we need a new segment. */
new_segment = TRUE;
}
+ else if ((abfd->flags & D_PAGED) != 0
+ && (((last_hdr->lma + last_size - 1) & -maxpagesize)
+ == (hdr->lma & -maxpagesize)))
+ {
+ /* If we are demand paged then we can't map two disk
+ pages onto the same memory page. */
+ new_segment = FALSE;
+ }
/* In the next test we have to be careful when last_hdr->lma is close
to the end of the address space. If the aligned address wraps
around to the start of the address space, then there are no more
pages left in memory and it is OK to assume that the current
section can be included in the current segment. */
- else if ((BFD_ALIGN (last_hdr->lma + last_size, maxpagesize) + maxpagesize
- > last_hdr->lma)
- && (BFD_ALIGN (last_hdr->lma + last_size, maxpagesize) + maxpagesize
- <= hdr->lma))
+ else if ((BFD_ALIGN (last_hdr->lma + last_size, maxpagesize)
+ + maxpagesize > last_hdr->lma)
+ && (BFD_ALIGN (last_hdr->lma + last_size, maxpagesize)
+ + maxpagesize <= hdr->lma))
{
/* If putting this section in this segment would force us to
skip a page in the segment, then we need a new segment. */
new_segment = TRUE;
}
else if ((last_hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) == 0
- && (hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) != 0
- && ((abfd->flags & D_PAGED) == 0
- || (((last_hdr->lma + last_size - 1) & -maxpagesize)
- != (hdr->lma & -maxpagesize))))
+ && (hdr->flags & (SEC_LOAD | SEC_THREAD_LOCAL)) != 0)
{
/* We don't want to put a loaded section after a
nonloaded (ie. bss style) section in the same segment
as that will force the non-loaded section to be loaded.
- Consider .tbss sections as loaded for this purpose.
- However, like the writable/non-writable case below,
- if they are on the same page then they must be put
- in the same segment. */
+ Consider .tbss sections as loaded for this purpose. */
new_segment = TRUE;
}
else if ((abfd->flags & D_PAGED) == 0)
@@ -4769,21 +4771,11 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info)
{
new_segment = TRUE;
}
- else if (! writable
- && (hdr->flags & SEC_READONLY) == 0
- && ((info != NULL
- && info->relro_end > info->relro_start)
- || (((last_hdr->lma + last_size - 1) & -maxpagesize)
- != (hdr->lma & -maxpagesize))))
+ else if (! writable
+ && (hdr->flags & SEC_READONLY) == 0)
{
/* We don't want to put a writable section in a read only
- segment, unless they are on the same page in memory
- anyhow and there is no RELRO segment. We already
- know that the last section does not bring us past the
- current section on the page, so the only case in which
- the new section is not on the same page as the previous
- section is when the previous section ends precisely on
- a page boundary. */
+ segment. */
new_segment = TRUE;
}
else

View File

@ -1,749 +0,0 @@
diff -rup binutils.orig/bfd/elf32-ppc.c binutils-2.30/bfd/elf32-ppc.c
--- binutils.orig/bfd/elf32-ppc.c 2018-02-08 10:49:07.649185371 +0000
+++ binutils-2.30/bfd/elf32-ppc.c 2018-02-08 10:50:11.058395459 +0000
@@ -69,7 +69,7 @@ static bfd_reloc_status_type ppc_elf_unh
/* For new-style .glink and .plt. */
#define GLINK_PLTRESOLVE 16*4
#define GLINK_ENTRY_SIZE(htab, h) \
- (((!htab->params->speculate_indirect_jumps ? 6*4 : 4*4) \
+ ((4*4 \
+ (h != NULL \
&& h == htab->tls_get_addr \
&& !htab->params->no_tls_get_addr_opt ? 8*4 : 0) \
@@ -155,8 +155,6 @@ static const bfd_vma ppc_elf_vxworks_pic
#define BA 0x48000002
#define BCL_20_31 0x429f0005
#define BCTR 0x4e800420
-#define CRSETEQ 0x4c421242
-#define BEQCTRM 0x4dc20420
#define BEQLR 0x4d820020
#define CMPWI_11_0 0x2c0b0000
#define LIS_11 0x3d600000
@@ -2880,14 +2878,15 @@ ppc_elf_final_write_processing (bfd *abf
static bfd_boolean
is_nonpic_glink_stub (bfd *abfd, asection *glink, bfd_vma off)
{
- bfd_byte buf[3 * 4];
+ bfd_byte buf[4 * 4];
if (!bfd_get_section_contents (abfd, glink, buf, off, sizeof buf))
return FALSE;
return ((bfd_get_32 (abfd, buf + 0) & 0xffff0000) == LIS_11
&& (bfd_get_32 (abfd, buf + 4) & 0xffff0000) == LWZ_11_11
- && bfd_get_32 (abfd, buf + 8) == MTCTR_11);
+ && bfd_get_32 (abfd, buf + 8) == MTCTR_11
+ && bfd_get_32 (abfd, buf + 12) == BCTR);
}
static bfd_boolean
@@ -3366,7 +3365,7 @@ ppc_elf_link_hash_table_create (bfd *abf
{
struct ppc_elf_link_hash_table *ret;
static struct ppc_elf_params default_params
- = { PLT_OLD, 0, 1, 0, 1, 0, 0, 12, 0, 0, 0 };
+ = { PLT_OLD, 0, 0, 1, 0, 0, 12, 0, 0, 0 };
ret = bfd_zmalloc (sizeof (struct ppc_elf_link_hash_table));
if (ret == NULL)
@@ -7171,8 +7170,6 @@ ppc_elf_relax_section (bfd *abfd,
size = 4 * ARRAY_SIZE (stub_entry);
insn_offset = 0;
}
- if (!htab->params->speculate_indirect_jumps)
- size += 8;
stub_rtype = R_PPC_RELAX;
if (tsec == htab->elf.splt
|| tsec == htab->glink)
@@ -7454,26 +7451,6 @@ elf_finish_pointer_linker_section (bfd *
#define PPC_HI(v) (((v) >> 16) & 0xffff)
#define PPC_HA(v) PPC_HI ((v) + 0x8000)
-static inline bfd_byte *
-output_bctr (struct ppc_elf_link_hash_table *htab, bfd *obfd, bfd_byte *p)
-{
- if (!htab->params->speculate_indirect_jumps)
- {
- bfd_put_32 (obfd, CRSETEQ, p);
- p += 4;
- bfd_put_32 (obfd, BEQCTRM, p);
- p += 4;
- bfd_put_32 (obfd, B, p);
- p += 4;
- }
- else
- {
- bfd_put_32 (obfd, BCTR, p);
- p += 4;
- }
- return p;
-}
-
static void
write_glink_stub (struct elf_link_hash_entry *h, struct plt_entry *ent,
asection *plt_sec, unsigned char *p,
@@ -7541,7 +7518,8 @@ write_glink_stub (struct elf_link_hash_e
p += 4;
bfd_put_32 (output_bfd, MTCTR_11, p);
p += 4;
- p = output_bctr (htab, output_bfd, p);
+ bfd_put_32 (output_bfd, BCTR, p);
+ p += 4;
while (p < end)
{
bfd_put_32 (output_bfd, htab->params->ppc476_workaround ? BA : NOP, p);
@@ -8979,7 +8957,6 @@ ppc_elf_relocate_section (bfd *output_bf
stub = stub_entry;
size = ARRAY_SIZE (stub_entry);
}
- --size;
relocation += addend;
if (bfd_link_relocatable (info))
@@ -9004,7 +8981,6 @@ ppc_elf_relocate_section (bfd *output_bf
bfd_put_32 (input_bfd, insn, contents + insn_offset);
insn_offset += 4;
}
- output_bctr (htab, input_bfd, contents + insn_offset);
/* Rewrite the reloc and convert one of the trailing nop
relocs to describe this relocation. */
@@ -10713,7 +10689,8 @@ ppc_elf_finish_dynamic_sections (bfd *ou
p += 4;
bfd_put_32 (output_bfd, ADD_11_0_11, p);
p += 4;
- p = output_bctr (htab, output_bfd, p);
+ bfd_put_32 (output_bfd, BCTR, p);
+ p += 4;
while (p < endp)
{
bfd_put_32 (output_bfd,
diff -rup binutils.orig/bfd/elf32-ppc.h binutils-2.30/bfd/elf32-ppc.h
--- binutils.orig/bfd/elf32-ppc.h 2018-02-08 10:49:07.644185433 +0000
+++ binutils-2.30/bfd/elf32-ppc.h 2018-02-08 10:50:11.058395459 +0000
@@ -35,9 +35,6 @@ struct ppc_elf_params
/* Set if individual PLT call stubs should be aligned. */
int plt_stub_align;
- /* Clear if PLT call stubs should use a speculative execution barrier. */
- int speculate_indirect_jumps;
-
/* Whether to emit symbols for stubs. */
int emit_stub_syms;
diff -rup binutils.orig/bfd/elf64-ppc.c binutils-2.30/bfd/elf64-ppc.c
--- binutils.orig/bfd/elf64-ppc.c 2018-02-08 10:49:07.645185421 +0000
+++ binutils-2.30/bfd/elf64-ppc.c 2018-02-08 10:50:11.060395434 +0000
@@ -161,10 +161,6 @@ static bfd_vma opd_entry_value
#define LD_R11_0R11 0xe96b0000 /* ld %r11,xxx+16@l(%r11) */
#define BCTR 0x4e800420 /* bctr */
-#define CRSETEQ 0x4c421242 /* crset 4*%cr0+%eq */
-#define BEQCTRM 0x4dc20420 /* beqctr- */
-#define BEQCTRLM 0x4dc20421 /* beqctrl- */
-
#define ADDI_R11_R11 0x396b0000 /* addi %r11,%r11,off@l */
#define ADDIS_R2_R2 0x3c420000 /* addis %r2,%r2,off@ha */
#define ADDI_R2_R2 0x38420000 /* addi %r2,%r2,off@l */
@@ -193,8 +189,7 @@ static bfd_vma opd_entry_value
/* __glink_PLTresolve stub instructions. We enter with the index in R0. */
#define GLINK_PLTRESOLVE_SIZE(htab) \
- (8u + (htab->opd_abi ? 11 * 4 : 14 * 4) \
- + (!htab->params->speculate_indirect_jumps ? 2 * 4 : 0))
+ (8u + (htab->opd_abi ? 11 * 4 : 14 * 4))
/* 0: */
/* .quad plt0-1f */
/* __glink: */
@@ -9886,8 +9881,6 @@ size_global_entry_stubs (struct elf_link
unsigned int align_power;
stub_size = 16;
- if (!htab->params->speculate_indirect_jumps)
- stub_size += 8;
stub_off = s->size;
if (htab->params->plt_stub_align >= 0)
align_power = htab->params->plt_stub_align;
@@ -10453,8 +10446,6 @@ plt_stub_size (struct ppc_link_hash_tabl
size += 4;
if (PPC_HA (off) != 0)
size += 4;
- if (!htab->params->speculate_indirect_jumps)
- size += 8;
if (htab->opd_abi)
{
size += 4;
@@ -10476,11 +10467,7 @@ plt_stub_size (struct ppc_link_hash_tabl
size += 7 * 4;
if (ALWAYS_EMIT_R2SAVE
|| stub_entry->stub_type == ppc_stub_plt_call_r2save)
- {
- size += 6 * 4;
- if (!htab->params->speculate_indirect_jumps)
- size -= 4;
- }
+ size += 6 * 4;
}
return size;
}
@@ -10515,26 +10502,6 @@ plt_stub_pad (struct ppc_link_hash_table
return 0;
}
-static inline bfd_byte *
-output_bctr (struct ppc_link_hash_table *htab, bfd *obfd, bfd_byte *p)
-{
- if (!htab->params->speculate_indirect_jumps)
- {
- bfd_put_32 (obfd, CRSETEQ, p);
- p += 4;
- bfd_put_32 (obfd, BEQCTRM, p);
- p += 4;
- bfd_put_32 (obfd, B_DOT, p);
- p += 4;
- }
- else
- {
- bfd_put_32 (obfd, BCTR, p);
- p += 4;
- }
- return p;
-}
-
/* Build a .plt call stub. */
static inline bfd_byte *
@@ -10555,7 +10522,6 @@ build_plt_stub (struct ppc_link_hash_tab
if (!ALWAYS_USE_FAKE_DEP
&& plt_load_toc
&& plt_thread_safe
- && htab->params->speculate_indirect_jumps
&& !((stub_entry->h == htab->tls_get_addr_fd
|| stub_entry->h == htab->tls_get_addr)
&& htab->params->tls_get_addr_opt))
@@ -10710,7 +10676,7 @@ build_plt_stub (struct ppc_link_hash_tab
bfd_put_32 (obfd, B_DOT | (cmp_branch_off & 0x3fffffc), p), p += 4;
}
else
- p = output_bctr (htab, obfd, p);
+ bfd_put_32 (obfd, BCTR, p), p += 4;
return p;
}
@@ -10754,13 +10720,7 @@ build_tls_get_addr_stub (struct ppc_link
if (r != NULL)
r[0].r_offset += 2 * 4;
p = build_plt_stub (htab, stub_entry, p, offset, r);
- if (!htab->params->speculate_indirect_jumps)
- {
- p -= 4;
- bfd_put_32 (obfd, BEQCTRLM, p - 4);
- }
- else
- bfd_put_32 (obfd, BCTRL, p - 4);
+ bfd_put_32 (obfd, BCTRL, p - 4);
bfd_put_32 (obfd, LD_R2_0R1 + STK_TOC (htab), p), p += 4;
bfd_put_32 (obfd, LD_R11_0R1 + STK_LINKER (htab), p), p += 4;
@@ -11113,7 +11073,8 @@ ppc_build_one_stub (struct bfd_hash_entr
p += 4;
bfd_put_32 (htab->params->stub_bfd, MTCTR_R12, p);
p += 4;
- p = output_bctr (htab, htab->params->stub_bfd, p);
+ bfd_put_32 (htab->params->stub_bfd, BCTR, p);
+ p += 4;
break;
case ppc_stub_plt_call:
@@ -11446,8 +11407,6 @@ ppc_size_one_stub (struct bfd_hash_entry
if (PPC_LO (r2off) != 0)
size += 4;
}
- if (!htab->params->speculate_indirect_jumps)
- size += 8;
}
else if (info->emitrelocations)
{
@@ -13089,7 +13048,7 @@ build_global_entry_stubs (struct elf_lin
p += 4;
bfd_put_32 (s->owner, MTCTR_R12, p);
p += 4;
- output_bctr (htab, s->owner, p);
+ bfd_put_32 (s->owner, BCTR, p);
break;
}
return TRUE;
@@ -13218,7 +13177,8 @@ ppc64_elf_build_stubs (struct bfd_link_i
bfd_put_32 (htab->glink->owner, LD_R11_0R11 | 8, p);
p += 4;
}
- p = output_bctr (htab, htab->glink->owner, p);
+ bfd_put_32 (htab->glink->owner, BCTR, p);
+ p += 4;
BFD_ASSERT (p == htab->glink->contents + GLINK_PLTRESOLVE_SIZE (htab));
/* Build the .glink lazy link call stubs. */
diff -rup binutils.orig/bfd/elf64-ppc.h binutils-2.30/bfd/elf64-ppc.h
--- binutils.orig/bfd/elf64-ppc.h 2018-02-08 10:49:07.637185520 +0000
+++ binutils-2.30/bfd/elf64-ppc.h 2018-02-08 10:50:11.060395434 +0000
@@ -51,9 +51,6 @@ struct ppc64_elf_params
/* Set if PLT call stubs for localentry:0 functions should omit r2 save. */
int plt_localentry0;
- /* Clear if PLT call stubs should use a speculative execution barrier. */
- int speculate_indirect_jumps;
-
/* Whether to canonicalize .opd so that there are no overlapping
.opd entries. */
int non_overlapping_opd;
diff -rup binutils.orig/gold/options.h binutils-2.30/gold/options.h
--- binutils.orig/gold/options.h 2018-02-08 10:49:07.354189045 +0000
+++ binutils-2.30/gold/options.h 2018-02-08 10:50:11.060395434 +0000
@@ -1108,10 +1108,6 @@ class General_options
N_("(PowerPC64 only) Optimize calls to ELFv2 localentry:0 functions"),
N_("(PowerPC64 only) Don't optimize ELFv2 calls"));
- DEFINE_bool(speculate_indirect_jumps, options::TWO_DASHES, '\0', true,
- N_("(PowerPC only) PLT call stubs without speculation barrier"),
- N_("(PowerPC only) PLT call stubs with speculation barrier"));
-
DEFINE_bool(plt_static_chain, options::TWO_DASHES, '\0', false,
N_("(PowerPC64 only) PLT call stubs should load r11"),
N_("(PowerPC64 only) PLT call stubs should not load r11"));
diff -rup binutils.orig/gold/powerpc.cc binutils-2.30/gold/powerpc.cc
--- binutils.orig/gold/powerpc.cc 2018-02-08 10:49:07.355189033 +0000
+++ binutils-2.30/gold/powerpc.cc 2018-02-08 10:50:11.061395422 +0000
@@ -3781,8 +3781,6 @@ static const uint32_t b = 0x48000000;
static const uint32_t bcl_20_31 = 0x429f0005;
static const uint32_t bctr = 0x4e800420;
static const uint32_t bctrl = 0x4e800421;
-static const uint32_t beqctrm = 0x4dc20420;
-static const uint32_t beqctrlm = 0x4dc20421;
static const uint32_t beqlr = 0x4d820020;
static const uint32_t blr = 0x4e800020;
static const uint32_t bnectr_p4 = 0x4ce20420;
@@ -3792,7 +3790,6 @@ static const uint32_t cmpdi_11_0 = 0x2c2
static const uint32_t cmpwi_11_0 = 0x2c0b0000;
static const uint32_t cror_15_15_15 = 0x4def7b82;
static const uint32_t cror_31_31_31 = 0x4ffffb82;
-static const uint32_t crseteq = 0x4c421242;
static const uint32_t ld_0_1 = 0xe8010000;
static const uint32_t ld_0_12 = 0xe80c0000;
static const uint32_t ld_2_1 = 0xe8410000;
@@ -4168,24 +4165,6 @@ write_insn(unsigned char* p, uint32_t v)
elfcpp::Swap<32, big_endian>::writeval(p, v);
}
-template<bool big_endian>
-static unsigned char*
-output_bctr(unsigned char* p)
-{
- if (!parameters->options().speculate_indirect_jumps())
- {
- write_insn<big_endian>(p, crseteq);
- p += 4;
- write_insn<big_endian>(p, beqctrm);
- p += 4;
- write_insn<big_endian>(p, b);
- }
- else
- write_insn<big_endian>(p, bctr);
- p += 4;
- return p;
-}
-
template<int size>
static inline unsigned int
param_plt_align()
@@ -4454,7 +4433,6 @@ class Stub_table : public Output_relaxed
{
const Symbol* gsym = p->first.sym_;
return (4 * 4
- + (!parameters->options().speculate_indirect_jumps() ? 2 * 4 : 0)
+ (this->targ_->is_tls_get_addr_opt(gsym) ? 8 * 4 : 0));
}
@@ -4470,8 +4448,6 @@ class Stub_table : public Output_relaxed
got_addr += ppcobj->toc_base_offset();
Address off = plt_addr - got_addr;
unsigned int bytes = 4 * 4 + 4 * (ha(off) != 0);
- if (!parameters->options().speculate_indirect_jumps())
- bytes += 2 * 4;
const Symbol* gsym = p->first.sym_;
if (this->targ_->is_tls_get_addr_opt(gsym))
bytes += 13 * 4;
@@ -4502,8 +4478,6 @@ class Stub_table : public Output_relaxed
if (p->first.dest_ - loc + (1 << 25) < 2 << 25)
return 4;
unsigned int bytes = 16;
- if (!parameters->options().speculate_indirect_jumps())
- bytes += 8;
if (size == 32 && parameters->options().output_is_position_independent())
bytes += 16;
return bytes;
@@ -4955,8 +4929,7 @@ class Output_data_glink : public Output_
{
if (size == 64)
return (8
- + (this->targ_->abiversion() < 2 ? 11 * 4 : 14 * 4)
- + (!parameters->options().speculate_indirect_jumps() ? 2 * 4 : 0));
+ + (this->targ_->abiversion() < 2 ? 11 * 4 : 14 * 4));
return 16 * 4;
}
@@ -5033,8 +5006,7 @@ Output_data_glink<size, big_endian>::add
std::pair<typename Global_entry_stub_entries::iterator, bool> p
= this->global_entry_stubs_.insert(std::make_pair(gsym, off));
if (p.second)
- this->ge_size_
- = off + 16 + (!parameters->options().speculate_indirect_jumps() ? 8 : 0);
+ this->ge_size_ = off + 16;
}
template<int size, bool big_endian>
@@ -5223,10 +5195,7 @@ Stub_table<size, big_endian>::do_write(O
= plt_load_toc && this->targ_->plt_thread_safe();
bool use_fake_dep = false;
Address cmp_branch_off = 0;
- if (thread_safe
- && !parameters->options().speculate_indirect_jumps())
- use_fake_dep = true;
- else if (thread_safe)
+ if (thread_safe)
{
unsigned int pltindex
= ((pltoff - this->targ_->first_plt_entry_offset())
@@ -5274,7 +5243,7 @@ Stub_table<size, big_endian>::do_write(O
+ this->targ_->stk_linker()));
p += 4;
}
- use_fake_dep |= thread_safe;
+ use_fake_dep = thread_safe;
}
if (ha(off) != 0)
{
@@ -5365,14 +5334,7 @@ Stub_table<size, big_endian>::do_write(O
if (!cs->second.localentry0_
&& this->targ_->is_tls_get_addr_opt(gsym))
{
- if (!parameters->options().speculate_indirect_jumps())
- {
- write_insn<big_endian>(p, crseteq);
- p += 4;
- write_insn<big_endian>(p, beqctrlm);
- }
- else
- write_insn<big_endian>(p, bctrl);
+ write_insn<big_endian>(p, bctrl);
p += 4;
write_insn<big_endian>(p, ld_2_1 + this->targ_->stk_toc());
p += 4;
@@ -5391,7 +5353,7 @@ Stub_table<size, big_endian>::do_write(O
write_insn<big_endian>(p, b | (cmp_branch_off & 0x3fffffc));
}
else
- output_bctr<big_endian>(p);
+ write_insn<big_endian>(p, bctr);
}
}
@@ -5426,7 +5388,7 @@ Stub_table<size, big_endian>::do_write(O
write_insn<big_endian>(p, ld_12_12 + l(brltoff)), p += 4;
}
write_insn<big_endian>(p, mtctr_12), p += 4;
- output_bctr<big_endian>(p);
+ write_insn<big_endian>(p, bctr);
}
}
}
@@ -5522,7 +5484,7 @@ Stub_table<size, big_endian>::do_write(O
p += 4;
write_insn<big_endian>(p, mtctr_11);
p += 4;
- output_bctr<big_endian>(p);
+ write_insn<big_endian>(p, bctr);
}
}
@@ -5563,7 +5525,7 @@ Stub_table<size, big_endian>::do_write(O
p += 4;
write_insn<big_endian>(p, mtctr_12);
p += 4;
- output_bctr<big_endian>(p);
+ write_insn<big_endian>(p, bctr);
}
}
if (this->need_save_res_)
@@ -5630,7 +5592,7 @@ Output_data_glink<size, big_endian>::do_
write_insn<big_endian>(p, mtctr_12), p += 4;
write_insn<big_endian>(p, ld_11_11 + 8), p += 4;
}
- p = output_bctr<big_endian>(p);
+ write_insn<big_endian>(p, bctr), p += 4;
gold_assert(p == oview + this->pltresolve_size());
// Write lazy link call stubs.
@@ -5686,7 +5648,7 @@ Output_data_glink<size, big_endian>::do_
write_insn<big_endian>(p, addis_12_12 + ha(off)), p += 4;
write_insn<big_endian>(p, ld_12_12 + l(off)), p += 4;
write_insn<big_endian>(p, mtctr_12), p += 4;
- output_bctr<big_endian>(p);
+ write_insn<big_endian>(p, bctr);
}
}
else
@@ -5778,7 +5740,8 @@ Output_data_glink<size, big_endian>::do_
write_insn<big_endian>(p, add_11_0_11);
}
p += 4;
- p = output_bctr<big_endian>(p);
+ write_insn<big_endian>(p, bctr);
+ p += 4;
while (p < end_p)
{
write_insn<big_endian>(p, nop);
diff -rup binutils.orig/ld/emultempl/ppc32elf.em binutils-2.30/ld/emultempl/ppc32elf.em
--- binutils.orig/ld/emultempl/ppc32elf.em 2018-02-08 10:49:07.192191063 +0000
+++ binutils-2.30/ld/emultempl/ppc32elf.em 2018-02-08 10:50:11.062395410 +0000
@@ -38,7 +38,7 @@ static int notlsopt = 0;
/* Choose the correct place for .got. */
static int old_got = 0;
-static struct ppc_elf_params params = { PLT_UNSET, 0, 1, -1,
+static struct ppc_elf_params params = { PLT_UNSET, 0, -1,
0, 0, 0, 0, 0, 0, 0 };
static void
@@ -246,8 +246,6 @@ enum ppc32_opt
OPTION_NO_TLS_GET_ADDR_OPT,
OPTION_NEW_PLT,
OPTION_OLD_PLT,
- OPTION_SPECULATE_INDIRECT_JUMPS,
- OPTION_NO_SPECULATE_INDIRECT_JUMPS,
OPTION_PLT_ALIGN,
OPTION_NO_PLT_ALIGN,
OPTION_OLD_GOT,
@@ -269,8 +267,6 @@ if test -z "$VXWORKS_BASE_EM_FILE" ; the
PARSE_AND_LIST_LONGOPTS=${PARSE_AND_LIST_LONGOPTS}'
{ "secure-plt", no_argument, NULL, OPTION_NEW_PLT },
{ "bss-plt", no_argument, NULL, OPTION_OLD_PLT },
- { "speculate-indirect-jumps", no_argument, NULL, OPTION_SPECULATE_INDIRECT_JUMPS },
- { "no-speculate-indirect-jumps", no_argument, NULL, OPTION_NO_SPECULATE_INDIRECT_JUMPS },
{ "plt-align", optional_argument, NULL, OPTION_PLT_ALIGN },
{ "no-plt-align", no_argument, NULL, OPTION_NO_PLT_ALIGN },
{ "sdata-got", no_argument, NULL, OPTION_OLD_GOT },'
@@ -304,12 +300,6 @@ if test -z "$VXWORKS_BASE_EM_FILE" ; the
--bss-plt Force old-style BSS PLT.\n"
));
fprintf (file, _("\
- --speculate-indirect-jumps PLT call stubs without speculation barrier.\n"
- ));
- fprintf (file, _("\
- --no-speculate-indirect-jumps PLT call stubs with speculation barrier.\n"
- ));
- fprintf (file, _("\
--plt-align Align PLT call stubs to fit cache lines.\n"
));
fprintf (file, _("\
@@ -360,14 +350,6 @@ PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LI
params.plt_style = PLT_OLD;
break;
- case OPTION_SPECULATE_INDIRECT_JUMPS:
- params.speculate_indirect_jumps = 1;
- break;
-
- case OPTION_NO_SPECULATE_INDIRECT_JUMPS:
- params.speculate_indirect_jumps = 0;
- break;
-
case OPTION_PLT_ALIGN:
if (optarg != NULL)
{
diff -rup binutils.orig/ld/emultempl/ppc64elf.em binutils-2.30/ld/emultempl/ppc64elf.em
--- binutils.orig/ld/emultempl/ppc64elf.em 2018-02-08 10:49:07.192191063 +0000
+++ binutils-2.30/ld/emultempl/ppc64elf.em 2018-02-08 10:50:11.062395410 +0000
@@ -38,7 +38,7 @@ static struct ppc64_elf_params params =
&ppc_layout_sections_again,
1, -1, 0,
${DEFAULT_PLT_STATIC_CHAIN-0}, -1, 5,
- -1, 1, 0, -1, -1, 0};
+ -1, 0, -1, -1, 0};
/* Fake input file for stubs. */
static lang_input_statement_type *stub_file;
@@ -692,8 +692,6 @@ enum ppc64_opt
OPTION_NO_PLT_STATIC_CHAIN,
OPTION_PLT_THREAD_SAFE,
OPTION_NO_PLT_THREAD_SAFE,
- OPTION_SPECULATE_INDIRECT_JUMPS,
- OPTION_NO_SPECULATE_INDIRECT_JUMPS,
OPTION_PLT_ALIGN,
OPTION_NO_PLT_ALIGN,
OPTION_PLT_LOCALENTRY,
@@ -721,8 +719,6 @@ PARSE_AND_LIST_LONGOPTS=${PARSE_AND_LIST
{ "no-plt-static-chain", no_argument, NULL, OPTION_NO_PLT_STATIC_CHAIN },
{ "plt-thread-safe", no_argument, NULL, OPTION_PLT_THREAD_SAFE },
{ "no-plt-thread-safe", no_argument, NULL, OPTION_NO_PLT_THREAD_SAFE },
- { "speculate-indirect-jumps", no_argument, NULL, OPTION_SPECULATE_INDIRECT_JUMPS },
- { "no-speculate-indirect-jumps", no_argument, NULL, OPTION_NO_SPECULATE_INDIRECT_JUMPS },
{ "plt-align", optional_argument, NULL, OPTION_PLT_ALIGN },
{ "no-plt-align", no_argument, NULL, OPTION_NO_PLT_ALIGN },
{ "plt-localentry", optional_argument, NULL, OPTION_PLT_LOCALENTRY },
@@ -764,13 +760,7 @@ PARSE_AND_LIST_OPTIONS=${PARSE_AND_LIST_
--plt-thread-safe PLT call stubs with load-load barrier.\n"
));
fprintf (file, _("\
- --no-plt-thread-safe PLT call stubs without load-load barrier.\n"
- ));
- fprintf (file, _("\
- --speculate-indirect-jumps PLT call stubs without speculation barrier.\n"
- ));
- fprintf (file, _("\
- --no-speculate-indirect-jumps PLT call stubs with speculation barrier.\n"
+ --no-plt-thread-safe PLT call stubs without barrier.\n"
));
fprintf (file, _("\
--plt-align [=<align>] Align PLT call stubs to fit cache lines.\n"
@@ -860,14 +850,6 @@ PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LI
params.plt_thread_safe = 0;
break;
- case OPTION_SPECULATE_INDIRECT_JUMPS:
- params.speculate_indirect_jumps = 1;
- break;
-
- case OPTION_NO_SPECULATE_INDIRECT_JUMPS:
- params.speculate_indirect_jumps = 0;
- break;
-
case OPTION_PLT_ALIGN:
if (optarg != NULL)
{
diff -rup binutils.orig/ld/ld.texinfo binutils-2.30/ld/ld.texinfo
--- binutils.orig/ld/ld.texinfo 2018-02-08 10:49:07.203190926 +0000
+++ binutils-2.30/ld/ld.texinfo 2018-02-08 10:50:11.063395397 +0000
@@ -7646,15 +7646,6 @@ looks for calls to commonly used functio
seen, adds the necessary barriers. Use these options to change the
default behaviour.
-@cindex PowerPC64 PLT call stub speculative execution barrier
-@kindex --speculate-indirect-jumps
-@kindex --no-speculate-indirect-jumps
-@item --speculate-indirect-jumps
-@itemx --no-speculate-indirect-jumps
-Use these options to control whether all indirect branch instructions
-emitted by @code{ld}, such as those in the PLT, have a speculative
-execution barrier to mitigate Spectre variant 2 attacks.
-
@cindex PowerPC64 ELFv2 PLT localentry optimization
@kindex --plt-localentry
@kindex --no-plt-localentry
diff -rup binutils.orig/ld/testsuite/ld-powerpc/elfv2exe.d binutils-2.30/ld/testsuite/ld-powerpc/elfv2exe.d
--- binutils.orig/ld/testsuite/ld-powerpc/elfv2exe.d 2018-02-08 10:49:07.261190203 +0000
+++ binutils-2.30/ld/testsuite/ld-powerpc/elfv2exe.d 2018-02-08 10:50:11.063395397 +0000
@@ -1,6 +1,6 @@
#source: elfv2.s
#as: -a64
-#ld: -melf64ppc --speculate-indirect-jumps --defsym f2=0x1234 --defsym f3=0x10008888 --defsym f4=0x1200000 --defsym _start=f1
+#ld: -melf64ppc --defsym f2=0x1234 --defsym f3=0x10008888 --defsym f4=0x1200000 --defsym _start=f1
#objdump: -dr
.*
diff -rup binutils.orig/ld/testsuite/ld-powerpc/elfv2so.d binutils-2.30/ld/testsuite/ld-powerpc/elfv2so.d
--- binutils.orig/ld/testsuite/ld-powerpc/elfv2so.d 2018-02-08 10:49:07.264190166 +0000
+++ binutils-2.30/ld/testsuite/ld-powerpc/elfv2so.d 2018-02-08 10:50:11.063395397 +0000
@@ -1,6 +1,6 @@
#source: elfv2.s
#as: -a64
-#ld: -melf64ppc -shared --speculate-indirect-jumps
+#ld: -melf64ppc -shared
#objdump: -dr
.*
diff -rup binutils.orig/ld/testsuite/ld-powerpc/powerpc.exp binutils-2.30/ld/testsuite/ld-powerpc/powerpc.exp
--- binutils.orig/ld/testsuite/ld-powerpc/powerpc.exp 2018-02-08 10:49:07.261190203 +0000
+++ binutils-2.30/ld/testsuite/ld-powerpc/powerpc.exp 2018-02-08 10:50:11.063395397 +0000
@@ -121,11 +121,11 @@ set ppcelftests {
"tls32"}
{"TLS32 helper shared library" "-shared -melf32ppc tmpdir/tlslib32.o" "" "" {}
{} "libtlslib32.so"}
- {"TLS32 dynamic exec" "-melf32ppc --no-plt-align --speculate-indirect-jumps --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tls32.o tmpdir/libtlslib32.so" "" "" {}
+ {"TLS32 dynamic exec" "-melf32ppc --no-plt-align --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tls32.o tmpdir/libtlslib32.so" "" "" {}
{{readelf -WSsrl tlsexe32.r} {objdump -dr tlsexe32.d}
{objdump -sj.got tlsexe32.g} {objdump -sj.tdata tlsexe32.t}}
"tlsexe32"}
- {"TLS32 shared" "-shared -melf32ppc --no-plt-align --speculate-indirect-jumps --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tls32.o" "" "" {}
+ {"TLS32 shared" "-shared -melf32ppc --no-plt-align --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tls32.o" "" "" {}
{{readelf -WSsrl tlsso32.r} {objdump -dr tlsso32.d}
{objdump -sj.got tlsso32.g} {objdump -sj.tdata tlsso32.t}}
"tls32.so"}
@@ -147,7 +147,7 @@ set ppcelftests {
{"TLS32 DLL" "-shared -melf32ppc --version-script tlsdll.ver" ""
"-a32" {tlsdll_32.s}
{} "tlsdll32.so"}
- {"TLS32 opt 5" "-melf32ppc -shared --gc-sections --secure-plt --no-plt-align --speculate-indirect-jumps tmpdir/tlsdll32.so" "" "-a32" {tlsopt5_32.s}
+ {"TLS32 opt 5" "-melf32ppc -shared --gc-sections --secure-plt --no-plt-align tmpdir/tlsdll32.so" "" "-a32" {tlsopt5_32.s}
{{objdump -dr tlsopt5_32.d}}
"tlsopt5_32"}
{"Shared library with global symbol" "-shared -melf32ppc" "" "-a32" {sdalib.s}
@@ -174,15 +174,15 @@ set ppc64elftests {
{} "libtlslib.so"}
{"TLS helper old shared lib" "-shared -melf64ppc" "" "-a64" {oldtlslib.s}
{} "liboldlib.so"}
- {"TLS dynamic exec" "-melf64ppc --no-plt-align --speculate-indirect-jumps --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tls.o tmpdir/libtlslib.so" "" "" {}
+ {"TLS dynamic exec" "-melf64ppc --no-plt-align --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tls.o tmpdir/libtlslib.so" "" "" {}
{{readelf -WSsrl tlsexe.r} {objdump -dr tlsexe.d}
{objdump -sj.got tlsexe.g} {objdump -sj.tdata tlsexe.t}}
"tlsexe"}
- {"TLS dynamic old" "-melf64ppc --no-plt-align --speculate-indirect-jumps --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tls.o tmpdir/liboldlib.so" "" "" {}
+ {"TLS dynamic old" "-melf64ppc --no-plt-align --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tls.o tmpdir/liboldlib.so" "" "" {}
{{readelf -WSsrl tlsexe.r} {objdump -dr tlsexe.d}
{objdump -sj.got tlsexe.g} {objdump -sj.tdata tlsexe.t}}
"tlsexeold"}
- {"TLS shared" "-shared -melf64ppc --no-plt-align --speculate-indirect-jumps --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tls.o" "" "" {}
+ {"TLS shared" "-shared -melf64ppc --no-plt-align --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tls.o" "" "" {}
{{readelf -WSsrl tlsso.r} {objdump -dr tlsso.d}
{objdump -sj.got tlsso.g} {objdump -sj.tdata tlsso.t}}
"tls.so"}
@@ -190,17 +190,17 @@ set ppc64elftests {
{{objdump -dr tlstoc.d} {objdump -sj.got tlstoc.g}
{objdump -sj.tdata tlstoc.t}}
"tlstoc"}
- {"TLSTOC dynamic exec" "-melf64ppc --no-plt-align --speculate-indirect-jumps --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tlstoc.o tmpdir/libtlslib.so" ""
+ {"TLSTOC dynamic exec" "-melf64ppc --no-plt-align --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tlstoc.o tmpdir/libtlslib.so" ""
"" {}
{{readelf -WSsrl tlsexetoc.r} {objdump -dr tlsexetoc.d}
{objdump -sj.got tlsexetoc.g} {objdump -sj.tdata tlsexetoc.t}}
"tlsexetoc"}
- {"TLSTOC dynamic old" "-melf64ppc --no-plt-align --speculate-indirect-jumps --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tlstoc.o tmpdir/liboldlib.so" ""
+ {"TLSTOC dynamic old" "-melf64ppc --no-plt-align --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tlstoc.o tmpdir/liboldlib.so" ""
"" {}
{{readelf -WSsrl tlsexetoc.r} {objdump -dr tlsexetoc.d}
{objdump -sj.got tlsexetoc.g} {objdump -sj.tdata tlsexetoc.t}}
"tlsexetocold"}
- {"TLSTOC shared" "-shared -melf64ppc --no-plt-align --speculate-indirect-jumps --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tlstoc.o" "" "" {}
+ {"TLSTOC shared" "-shared -melf64ppc --no-plt-align --no-ld-generated-unwind-info --hash-style=sysv tmpdir/tlstoc.o" "" "" {}
{{readelf -WSsrl tlstocso.r} {objdump -dr tlstocso.d}
{objdump -sj.got tlstocso.g} {objdump -sj.tdata tlstocso.t}}
"tlstoc.so"}
@@ -221,7 +221,7 @@ set ppc64elftests {
"tlsopt4"}
{"TLS DLL" "-shared -melf64ppc --version-script tlsdll.ver" "" "-a64" {tlsdll.s}
{} "tlsdll.so"}
- {"TLS opt 5" "-melf64ppc --no-plt-align --speculate-indirect-jumps -shared --gc-sections --no-plt-localentry tmpdir/tlsdll.so" "" "-a64" {tlsopt5.s}
+ {"TLS opt 5" "-melf64ppc --no-plt-align -shared --gc-sections --no-plt-localentry tmpdir/tlsdll.so" "" "-a64" {tlsopt5.s}
{{objdump -dr tlsopt5.d} {readelf -wf tlsopt5.wf}}
"tlsopt5"}
{"sym@tocbase" "-shared -melf64ppc" "" "-a64" {symtocbase-1.s symtocbase-2.s}
diff -rup binutils.orig/ld/testsuite/ld-powerpc/relbrlt.d binutils-2.30/ld/testsuite/ld-powerpc/relbrlt.d
--- binutils.orig/ld/testsuite/ld-powerpc/relbrlt.d 2018-02-08 10:49:07.262190191 +0000
+++ binutils-2.30/ld/testsuite/ld-powerpc/relbrlt.d 2018-02-08 10:50:11.063395397 +0000
@@ -1,6 +1,6 @@
#source: relbrlt.s
#as: -a64
-#ld: -melf64ppc --no-plt-align --speculate-indirect-jumps --no-ld-generated-unwind-info --emit-relocs
+#ld: -melf64ppc --no-plt-align --no-ld-generated-unwind-info --emit-relocs
#objdump: -Dr
.*

View File

@ -1,13 +0,0 @@
--- binutils.orig/binutils/dwarf.c 2018-02-08 10:49:07.154191536 +0000
+++ binutils-2.30/binutils/dwarf.c 2018-02-08 12:53:32.649380368 +0000
@@ -9851,6 +9851,10 @@ load_dwo_file (const char * main_filenam
void *
load_separate_debug_file (void * file, const char * filename)
{
+ /* Skip this operation if we are not interested in debug links. */
+ if (! do_follow_links && ! do_debug_links)
+ return NULL;
+
/* See if there is a dwo link. */
if (load_debug_section (str, file)
&& load_debug_section (abbrev, file)

View File

@ -1,97 +0,0 @@
--- binutils.orig/binutils/objdump.c 2018-03-05 17:04:19.901619738 +0000
+++ binutils-2.29/binutils/objdump.c 2018-03-05 17:10:08.334643096 +0000
@@ -664,9 +664,7 @@ slurp_dynamic_symtab (bfd *abfd)
static bfd_boolean
is_significant_symbol_name (const char * name)
{
- return strcmp (name, ".plt") == 0
- || strcmp (name, ".got") == 0
- || strcmp (name, ".plt.got") == 0;
+ return strncmp (name, ".plt", 4) == 0 || strcmp (name, ".got") == 0;
}
/* Filter out (in place) symbols that are useless for disassembly.
@@ -937,6 +935,7 @@ find_symbol_for_address (bfd_vma vma,
asection *sec;
unsigned int opb;
bfd_boolean want_section;
+ long rel_count;
if (sorted_symcount < 1)
return NULL;
@@ -1065,33 +1064,59 @@ find_symbol_for_address (bfd_vma vma,
and we have dynamic relocations available, then we can produce
a better result by matching a relocation to the address and
using the symbol associated with that relocation. */
+ rel_count = aux->dynrelcount;
if (!want_section
- && aux->dynrelbuf != NULL
&& sorted_syms[thisplace]->value != vma
+ && rel_count > 0
+ && aux->dynrelbuf != NULL
+ && aux->dynrelbuf[0]->address <= vma
+ && aux->dynrelbuf[rel_count - 1]->address >= vma
/* If we have matched a synthetic symbol, then stick with that. */
&& (sorted_syms[thisplace]->flags & BSF_SYNTHETIC) == 0)
{
- long rel_count;
- arelent ** rel_pp;
+ arelent ** rel_low;
+ arelent ** rel_high;
- for (rel_count = aux->dynrelcount, rel_pp = aux->dynrelbuf;
- rel_count--;)
+ rel_low = aux->dynrelbuf;
+ rel_high = rel_low + rel_count - 1;
+ while (rel_low <= rel_high)
{
- arelent * rel = rel_pp[rel_count];
+ arelent ** rel_mid = &rel_low[(rel_high - rel_low) / 2];
+ arelent * rel = *rel_mid;
- if (rel->address == vma
- && rel->sym_ptr_ptr != NULL
- /* Absolute relocations do not provide a more helpful symbolic address. */
- && ! bfd_is_abs_section ((* rel->sym_ptr_ptr)->section))
+ if (rel->address == vma)
{
- if (place != NULL)
- * place = thisplace;
- return * rel->sym_ptr_ptr;
+ /* Absolute relocations do not provide a more helpful
+ symbolic address. Find a non-absolute relocation
+ with the same address. */
+
+ arelent **rel_vma = rel_mid;
+
+ for (rel_mid--;
+ rel_mid >= rel_low && rel_mid[0]->address == vma;
+ rel_mid--)
+ rel_vma = rel_mid;
+
+ for (; rel_vma <= rel_high && rel_vma[0]->address == vma;
+ rel_vma++)
+ {
+ rel = *rel_vma;
+ if (rel->sym_ptr_ptr != NULL
+ && ! bfd_is_abs_section ((* rel->sym_ptr_ptr)->section))
+ {
+ if (place != NULL)
+ * place = thisplace;
+ return * rel->sym_ptr_ptr;
+ }
+ }
+ break;
}
- /* We are scanning backwards, so if we go below the target address
- we have failed. */
- if (rel_pp[rel_count]->address < vma)
+ if (vma < rel->address)
+ rel_high = rel_mid;
+ else if (vma >= rel_mid[1]->address)
+ rel_low = rel_mid + 1;
+ else
break;
}
}

View File

@ -1,107 +0,0 @@
diff -rup binutils.orig/bfd/elf32-i386.c binutils-2.30/bfd/elf32-i386.c
--- binutils.orig/bfd/elf32-i386.c 2018-02-27 17:25:53.961140597 +0000
+++ binutils-2.30/bfd/elf32-i386.c 2018-02-27 17:27:14.115133477 +0000
@@ -383,7 +383,7 @@ elf_i386_rtype_to_howto (bfd *abfd, unsi
/* xgettext:c-format */
_bfd_error_handler (_("%B: invalid relocation type %d"),
abfd, (int) r_type);
- indx = R_386_NONE;
+ return NULL;
}
/* PR 17512: file: 0f67f69d. */
if (elf_howto_table [indx].type != r_type)
diff -rup binutils.orig/bfd/elf64-ppc.c binutils-2.30/bfd/elf64-ppc.c
--- binutils.orig/bfd/elf64-ppc.c 2018-02-27 17:25:53.969140496 +0000
+++ binutils-2.30/bfd/elf64-ppc.c 2018-02-27 17:27:56.213604518 +0000
@@ -2516,9 +2516,10 @@ ppc64_elf_info_to_howto (bfd *abfd, arel
/* xgettext:c-format */
_bfd_error_handler (_("%B: invalid relocation type %d"),
abfd, (int) type);
- type = R_PPC64_NONE;
+ cache_ptr->howto = NULL;
}
- cache_ptr->howto = ppc64_elf_howto_table[type];
+ else
+ cache_ptr->howto = ppc64_elf_howto_table[type];
}
/* Handle the R_PPC64_ADDR16_HA and similar relocs. */
diff -rup binutils.orig/bfd/elf64-s390.c binutils-2.30/bfd/elf64-s390.c
--- binutils.orig/bfd/elf64-s390.c 2018-02-27 17:25:53.968140509 +0000
+++ binutils-2.30/bfd/elf64-s390.c 2018-02-27 17:28:24.632247443 +0000
@@ -372,9 +372,10 @@ elf_s390_info_to_howto (bfd *abfd ATTRIB
/* xgettext:c-format */
_bfd_error_handler (_("%B: invalid relocation type %d"),
abfd, (int) r_type);
- r_type = R_390_NONE;
+ cache_ptr->howto = NULL;
}
- cache_ptr->howto = &elf_howto_table[r_type];
+ else
+ cache_ptr->howto = &elf_howto_table[r_type];
}
}
diff -rup binutils.orig/bfd/elf64-x86-64.c binutils-2.30/bfd/elf64-x86-64.c
--- binutils.orig/bfd/elf64-x86-64.c 2018-02-27 17:25:53.964140559 +0000
+++ binutils-2.30/bfd/elf64-x86-64.c 2018-02-27 17:29:12.554645307 +0000
@@ -284,7 +284,7 @@ elf_x86_64_rtype_to_howto (bfd *abfd, un
/* xgettext:c-format */
_bfd_error_handler (_("%B: invalid relocation type %d"),
abfd, (int) r_type);
- r_type = R_X86_64_NONE;
+ return NULL;
}
i = r_type;
}
@@ -347,8 +347,6 @@ elf_x86_64_info_to_howto (bfd *abfd ATTR
&& r_type != (unsigned int) R_X86_64_GNU_VTENTRY)
r_type &= ~R_X86_64_converted_reloc_bit;
cache_ptr->howto = elf_x86_64_rtype_to_howto (abfd, r_type);
-
- BFD_ASSERT (r_type == cache_ptr->howto->type || cache_ptr->howto->type == R_X86_64_NONE);
}
/* Support for core dump NOTE sections. */
diff -rup binutils.orig/bfd/elfcode.h binutils-2.30/bfd/elfcode.h
--- binutils.orig/bfd/elfcode.h 2018-02-27 17:25:53.964140559 +0000
+++ binutils-2.30/bfd/elfcode.h 2018-02-27 17:26:57.234345581 +0000
@@ -1474,6 +1474,12 @@ elf_slurp_reloc_table_from_section (bfd
(*ebd->elf_info_to_howto) (abfd, relent, &rela);
else
(*ebd->elf_info_to_howto_rel) (abfd, relent, &rela);
+
+ if (relent->howto == NULL)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
}
if (allocated != NULL)
diff -rup binutils.orig/binutils/objcopy.c binutils-2.30/binutils/objcopy.c
--- binutils.orig/binutils/objcopy.c 2018-02-27 17:25:53.185150347 +0000
+++ binutils-2.30/binutils/objcopy.c 2018-02-27 17:30:05.806976202 +0000
@@ -3022,10 +3022,19 @@ copy_object (bfd *ibfd, bfd *obfd, const
haven't been set yet. mark_symbols_used_in_relocations will
ignore input sections which have no corresponding output
section. */
+ bfd_set_error (bfd_error_no_error);
if (strip_symbols != STRIP_ALL)
- bfd_map_over_sections (ibfd,
- mark_symbols_used_in_relocations,
- isympp);
+ {
+ bfd_map_over_sections (ibfd,
+ mark_symbols_used_in_relocations,
+ isympp);
+ if (bfd_get_error () != bfd_error_no_error)
+ {
+ status = 1;
+ return FALSE;
+ }
+ }
+
osympp = (asymbol **) xmalloc ((symcount + add_symbols + 1) * sizeof (asymbol *));
symcount = filter_symbols (ibfd, obfd, osympp, isympp, symcount);
}

View File

@ -1,64 +0,0 @@
--- binutils.orig/bfd/elfxx-x86.c 2018-05-14 12:22:29.149657093 +0100
+++ binutils-2.30/bfd/elfxx-x86.c 2018-05-14 12:25:16.244700009 +0100
@@ -839,6 +839,33 @@ _bfd_x86_elf_compare_relocs (const void
return 0;
}
+/* Mark symbol, NAME, as locally defined by linker if it is referenced
+ and not defined in a relocatable object file. */
+
+static void
+elf_x86_linker_defined (struct bfd_link_info *info, const char *name)
+{
+ struct elf_link_hash_entry *h;
+
+ h = elf_link_hash_lookup (elf_hash_table (info), name,
+ FALSE, FALSE, FALSE);
+ if (h == NULL)
+ return;
+
+ while (h->root.type == bfd_link_hash_indirect)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+ if (h->root.type == bfd_link_hash_new
+ || h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak
+ || h->root.type == bfd_link_hash_common
+ || (!h->def_regular && h->def_dynamic))
+ {
+ elf_x86_hash_entry (h)->local_ref = 2;
+ elf_x86_hash_entry (h)->linker_def = 1;
+ }
+}
+
bfd_boolean
_bfd_x86_elf_link_check_relocs (bfd *abfd, struct bfd_link_info *info)
{
@@ -869,18 +896,16 @@ _bfd_x86_elf_link_check_relocs (bfd *abf
/* "__ehdr_start" will be defined by linker as a hidden symbol
later if it is referenced and not defined. */
- h = elf_link_hash_lookup (elf_hash_table (info),
- "__ehdr_start",
- FALSE, FALSE, FALSE);
- if (h != NULL
- && (h->root.type == bfd_link_hash_new
- || h->root.type == bfd_link_hash_undefined
- || h->root.type == bfd_link_hash_undefweak
- || h->root.type == bfd_link_hash_common))
+ elf_x86_linker_defined (info, "__ehdr_start");
+
+ if (bfd_link_executable (info))
{
- elf_x86_hash_entry (h)->local_ref = 2;
- elf_x86_hash_entry (h)->linker_def = 1;
- }
+ /* References to __bss_start, _end and _edata should be
+ locally resolved within executables. */
+ elf_x86_linker_defined (info, "__bss_start");
+ elf_x86_linker_defined (info, "_end");
+ elf_x86_linker_defined (info, "_edata");
+ }
}
}

View File

@ -1,58 +0,0 @@
diff -rup binutils.orig/bfd/elf.c binutils-2.30/bfd/elf.c
--- binutils.orig/bfd/elf.c 2018-06-01 09:10:37.866552789 +0100
+++ binutils-2.30/bfd/elf.c 2018-06-01 09:16:23.159605609 +0100
@@ -707,11 +707,23 @@ setup_group (bfd *abfd, Elf_Internal_Shd
|= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
break;
}
- if (idx >= shnum)
+ if (idx < shnum)
+ {
+ dest->shdr = elf_elfsections (abfd)[idx];
+ /* PR binutils/23199: All sections in a
+ section group should be marked with
+ SHF_GROUP. But some tools generate
+ broken objects without SHF_GROUP. Fix
+ them up here. */
+ dest->shdr->sh_flags |= SHF_GROUP;
+ }
+ if (idx >= shnum
+ || dest->shdr->sh_type == SHT_GROUP)
{
_bfd_error_handler
- (_("%B: invalid SHT_GROUP entry"), abfd);
- idx = 0;
+ (_("%B: invalid entry in SHT_GROUP section [%u]"),
+ abfd, i);
+ dest->shdr = NULL;
}
dest->shdr = elf_elfsections (abfd)[idx];
}
@@ -779,7 +791,8 @@ setup_group (bfd *abfd, Elf_Internal_Shd
idx = (Elf_Internal_Group *) shdr->contents;
n_elt = shdr->sh_size / 4;
while (--n_elt != 0)
- if ((s = (++idx)->shdr->bfd_section) != NULL
+ if ((++idx)->shdr != NULL
+ && (s = idx->shdr->bfd_section) != NULL
&& elf_next_in_group (s) != NULL)
break;
if (n_elt != 0)
diff -rup binutils.orig/bfd/elfxx-x86.c binutils-2.30/bfd/elfxx-x86.c
--- binutils.orig/bfd/elfxx-x86.c 2018-06-01 09:10:37.854552926 +0100
+++ binutils-2.30/bfd/elfxx-x86.c 2018-06-01 09:21:10.570323575 +0100
@@ -1976,7 +1976,13 @@ _bfd_x86_elf_link_symbol_references_loca
return TRUE;
}
- eh->local_ref = 1;
+ /* Symbols created by HIDDEN and PROVIDE_HIDDEN assignments in linker
+ script aren't forced local here yet. bfd_hide_sym_by_version
+ can't be used to check if a versioned symbol is hidden. It has to
+ be syncd with _bfd_elf_link_assign_sym_version to get the correct
+ answer. */
+ if (!h->root.ldscript_def && h->versioned == unversioned)
+ eh->local_ref = 1;
return FALSE;
}

View File

@ -46,7 +46,7 @@
%if %{with debug}
%undefine with_testsuite
%endif
%endif1599521)
%if 0%{!?binutils_target:1}
%define binutils_target %{_target_platform}
@ -68,8 +68,8 @@
Summary: A GNU collection of binary utilities
Name: %{?cross}binutils%{?_with_debug:-debug}
Version: 2.30.90
Release: 4%{?dist}
Version: 2.31.1
Release: 1%{?dist}
License: GPLv3+
URL: https://sourceware.org/binutils
@ -77,9 +77,7 @@ URL: https://sourceware.org/binutils
# too many controversial patches so we stick with the official FSF version
# instead.
# Source: http://ftp.gnu.org/gnu/binutils/binutils-% {version}.tar.xz
Source: https://sourceware.org/pub/binutils/snapshots/binutils-%{version}.tar.xz
Source: https://ftp.gnu.org/gnu/binutils/binutils-%{version}.tar.xz
Source2: binutils-2.19.50.0.1-output-format.sed
@ -708,6 +706,38 @@ exit 0
#----------------------------------------------------------------------------
%changelog
* Thu Jul 19 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.31.1-1
- Rebase to official 2.31.1 GNU Binutils release.
- Retire: binutils-2.22.52.0.1-export-demangle.h.patch
- Retire: binutils-2.30-allow_R_AARCH64-symbols.patch
- Retire: binutils-CVE-2018-10372.patch
- Retire: binutils-CVE-2018-10373.patch
- Retire: binutils-CVE-2018-10534.patch
- Retire: binutils-CVE-2018-10535.patch
- Retire: binutils-CVE-2018-6323.patch
- Retire: binutils-CVE-2018-6759.patch
- Retire: binutils-CVE-2018-7208.patch
- Retire: binutils-CVE-2018-7568.patch
- Retire: binutils-CVE-2018-7569.patch
- Retire: binutils-CVE-2018-7570.patch
- Retire: binutils-CVE-2018-7642.patch
- Retire: binutils-CVE-2018-7643.patch
- Retire: binutils-CVE-2018-8945.patch
- Retire: binutils-PowerPC-IEEE-long-double-warnings.patch
- Retire: binutils-debug-section-marking.patch
- Retire: binutils-gas-build-notes.patch
- Retire: binutils-gold-llvm-plugin.patch
- Retire: binutils-ifunc-relocs-in-notes.patch
- Retire: binutils-linkonce-notes.patch
- Retire: binutils-missing-notes.patch
- Retire: binutils-page-to-segment-assignment.patch
- Retire: binutils-revert-PowerPC-speculation-barriers.patch
- Retire: binutils-skip-dwo-search-if-not-needed.patch
- Retire: binutils-speed-up-objdump.patch
- Retire: binutils-strip-unknown-relocs.patch
- Retire: binutils-x86-local-relocs.patch
- Retire: binutils-x86-local-version.patch
* Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.30.90-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

View File

@ -1 +1 @@
SHA512 (binutils-2.30.90.tar.xz) = 927ffb2bf771d93e58f482521ed31e94cecf5e5257adbc7e279ef24d1b0cd230f2c2254934520d99c2dbeab89e9d1471ca58bc0872a2d150dc2cee39c7df3527
SHA512 (binutils-2.31.1.tar.xz) = 0fca326feb1d5f5fe505a827b20237fe3ec9c13eaf7ec7e35847fd71184f605ba1cefe1314b1b8f8a29c0aa9d88162849ee1c1a3e70c2f7407d88339b17edb30