[arch-commits] Commit in binutils/trunk (3 files)

2018-12-26 Thread Anatol Pomozov via arch-commits
Date: Wednesday, December 26, 2018 @ 15:38:51
  Author: anatolik
Revision: 342744

upgpkg: binutils 2.31.1-4

FS#61151: Handle ELF compressed header alignment correctly

Added:
  binutils/trunk/0007-PR23919-Handle-ELF-compressed-header-alignment.patch
  binutils/trunk/0008-PR23919-gold-Get-alignment-of-uncompressed-section.patch
Modified:
  binutils/trunk/PKGBUILD

---+
 0007-PR23919-Handle-ELF-compressed-header-alignment.patch |  316 ++
 0008-PR23919-gold-Get-alignment-of-uncompressed-section.patch |  187 +
 PKGBUILD  |   16 
 3 files changed, 516 insertions(+), 3 deletions(-)

Added: 0007-PR23919-Handle-ELF-compressed-header-alignment.patch
===
--- 0007-PR23919-Handle-ELF-compressed-header-alignment.patch   
(rev 0)
+++ 0007-PR23919-Handle-ELF-compressed-header-alignment.patch   2018-12-26 
15:38:51 UTC (rev 342744)
@@ -0,0 +1,316 @@
+commit 4207142d6a5d2359170c5f9a140fc1a2351fbda9
+Author: Mark Wielaard 
+Date:   Tue Nov 27 11:59:10 2018 +
+
+Handle ELF compressed header alignment correctly by setting up the section 
alignment correctly for the Elf32_Chdr or Elf64_Chdr type and respect the 
ch_addralign field when decompressing the section data.
+
+PR binutils/23919
+binutils* readelf.c (dump_sections_as_strings): Remove bogus addralign 
check.
+(dump_sections_as_bytes): Likewise.
+(load_specific_debug_sections): Likewise.
+* testsuite/binutils-all/dw2-3.rS: Adjust alignment.
+* testsuite/binutils-all/dw2-3.rt: Likewise.
+
+bfd * bfd.c (bfd_update_compression_header): Explicitly set alignment.
+(bfd_check_compression_header): Add uncompressed_alignment_power
+argument. Check ch_addralign is a power of 2.
+* bfd-in2.h: Regenerated.
+* compress.c (bfd_compress_section_contents): Get and set
+orig_uncompressed_alignment_pow if section is decompressed.
+(bfd_is_section_compressed_with_header): Add and get
+uncompressed_align_pow_p argument.
+(bfd_is_section_compressed): Add uncompressed_align_power argument
+to bfd_is_section_compressed_with_header call.
+(bfd_init_section_decompress_status): Get and set
+uncompressed_alignment_power.
+* elf.c (_bfd_elf_make_section_from_shdr): Add
+uncompressed_align_power argument to
+bfd_is_section_compressed_with_header call.
+
+diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
+index ee8cd7ef0b..6d92c51cb9 100644
+--- a/bfd/bfd-in2.h
 b/bfd/bfd-in2.h
+@@ -7419,7 +7419,8 @@ void bfd_update_compression_header
+ 
+ bfd_boolean bfd_check_compression_header
+(bfd *abfd, bfd_byte *contents, asection *sec,
+-bfd_size_type *uncompressed_size);
++bfd_size_type *uncompressed_size,
++unsigned int *uncompressed_alignment_power);
+ 
+ int bfd_get_compression_header_size (bfd *abfd, asection *sec);
+ 
+@@ -8006,7 +8007,8 @@ void bfd_cache_section_contents
+ bfd_boolean bfd_is_section_compressed_with_header
+(bfd *abfd, asection *section,
+ int *compression_header_size_p,
+-bfd_size_type *uncompressed_size_p);
++bfd_size_type *uncompressed_size_p,
++unsigned int *uncompressed_alignment_power_p);
+ 
+ bfd_boolean bfd_is_section_compressed
+(bfd *abfd, asection *section);
+diff --git a/bfd/bfd.c b/bfd/bfd.c
+index 15becd7ae8..2b658298ea 100644
+--- a/bfd/bfd.c
 b/bfd/bfd.c
+@@ -2332,6 +2332,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte 
*contents,
+ bfd_put_32 (abfd, sec->size, &echdr->ch_size);
+ bfd_put_32 (abfd, 1 << sec->alignment_power,
+ &echdr->ch_addralign);
++/* bfd_log2 (alignof (Elf32_Chdr)) */
++bfd_set_section_alignment (abfd, sec, 2);
+   }
+ else
+   {
+@@ -2342,6 +2344,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte 
*contents,
+ bfd_put_64 (abfd, sec->size, &echdr->ch_size);
+ bfd_put_64 (abfd, 1 << sec->alignment_power,
+ &echdr->ch_addralign);
++/* bfd_log2 (alignof (Elf64_Chdr)) */
++bfd_set_section_alignment (abfd, sec, 3);
+   }
+   }
+ else
+@@ -2354,6 +2358,8 @@ bfd_update_compression_header (bfd *abfd, bfd_byte 
*contents,
+order.  */
+ memcpy (contents, "ZLIB", 4);
+ bfd_putb64 (sec->size, contents + 4);
++/* No way to keep the original alignment, just use 1 always. */
++bfd_set_section_alignment (abfd, sec, 0);
+   }
+   }
+ }
+@@ -2368,12 +2374,14 @@ bfd_update_compression_header (bfd *abfd, bfd_byte 
*contents,

[arch-commits] Commit in binutils/trunk (3 files)

2018-04-10 Thread Bartłomiej Piotrowski via arch-commits
Date: Tuesday, April 10, 2018 @ 21:55:03
  Author: bpiotrowski
Revision: 321517

2.30-2: apply patches added in 2.29.1-3

Added:
  binutils/trunk/0002-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch
Modified:
  binutils/trunk/PKGBUILD
Deleted:
  binutils/trunk/0001-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch

-+
 0001-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch |  145 
--
 0002-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch |  145 
++
 PKGBUILD|   13 
 3 files changed, 153 insertions(+), 150 deletions(-)

Deleted: 0001-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch
===
--- 0001-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch 
2018-04-10 21:38:53 UTC (rev 321516)
+++ 0001-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch 
2018-04-10 21:55:03 UTC (rev 321517)
@@ -1,145 +0,0 @@
-From 3b56a1358768563d9cf320559ebdedfb30f122dd Mon Sep 17 00:00:00 2001
-From: Alan Modra 
-Date: Mon, 12 Feb 2018 13:06:07 +1030
-Subject: [PATCH] PR22829, objcopy/strip removes PT_GNU_RELRO from lld binaries
-
-lld lays out the relro segment differently to GNU ld, not bothering to
-include the first few bytes of .got.plt and padding out to a page at
-the end of the segment.  This patch teaches binutils to recognize the
-different (and somewhat inferior) layout as valid.
-
-bfd/
-   PR 22829
-   * elf.c (assign_file_positions_for_non_load_sections): Rewrite
-   PT_GNU_RELRO setup.
-ld/
-   * testsuite/ld-x86-64/pr14207.d: Adjust relro p_filesz.
-
-(cherry picked from commit f2731e0c374e5323ce4cdae2bcc7b7fe22da1a6f)

- bfd/elf.c| 78 ++--
- ld/testsuite/ld-x86-64/pr14207.d |  2 +-
- 2 files changed, 52 insertions(+), 28 deletions(-)
-
-diff --git a/bfd/elf.c b/bfd/elf.c
-index bbaab26918..f5a230cd77 100644
 a/bfd/elf.c
-+++ b/bfd/elf.c
-@@ -5826,50 +5826,74 @@ assign_file_positions_for_non_load_sections (bfd *abfd,
- {
-   if (p->p_type == PT_GNU_RELRO)
-   {
--const Elf_Internal_Phdr *lp;
--struct elf_segment_map *lm;
-+bfd_vma start, end;
- 
- 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;
-+  }
-+
-+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 >= 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)
-+
-+/* Find the section starting the RELRO segment.  */
-+for (i = 0; i < lm->count; i++)
-   {
--if (lp->p_type == PT_LOAD
--&& lp->p_paddr == p->p_paddr)
-+asection *s = lm->sections[i];
-+if (s->vma >= start
-+&& s->vma < end
-+&& s->size != 0)
-   break;
-   }
--  }
-+BFD_ASSERT (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
-+

[arch-commits] Commit in binutils/trunk (3 files)

2018-03-14 Thread Evangelos Foutras via arch-commits
Date: Thursday, March 15, 2018 @ 06:06:46
  Author: foutrelis
Revision: 319155

upgpkg: binutils 2.29.1-3

- Prevent tools such as objcopy/strip from incorrectly removing
  the PT_GNU_RELRO program segment from binaries linked with LLD
- Fix CVE-2018-7208: missing bounds check in coff_pointerize_aux()

Added:
  binutils/trunk/0001-PR22741-objcopy-segfault-on-fuzzed-COFF-object.patch
  binutils/trunk/0001-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch
Modified:
  binutils/trunk/PKGBUILD

-+
 0001-PR22741-objcopy-segfault-on-fuzzed-COFF-object.patch   |   29 ++
 0001-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch |  145 
++
 PKGBUILD|   16 -
 3 files changed, 187 insertions(+), 3 deletions(-)

Added: 0001-PR22741-objcopy-segfault-on-fuzzed-COFF-object.patch
===
--- 0001-PR22741-objcopy-segfault-on-fuzzed-COFF-object.patch   
(rev 0)
+++ 0001-PR22741-objcopy-segfault-on-fuzzed-COFF-object.patch   2018-03-15 
06:06:46 UTC (rev 319155)
@@ -0,0 +1,29 @@
+From eb77f6a4621795367a39cdd30957903af9dbb815 Mon Sep 17 00:00:00 2001
+From: Alan Modra 
+Date: Sat, 27 Jan 2018 08:19:33 +1030
+Subject: [PATCH] PR22741, objcopy segfault on fuzzed COFF object
+
+   PR 22741
+   * coffgen.c (coff_pointerize_aux): Ensure auxent tagndx is in
+   range before converting to a symbol table pointer.
+---
+ bfd/coffgen.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/bfd/coffgen.c b/bfd/coffgen.c
+index b2410873d0..4f90eaddd9 100644
+--- a/bfd/coffgen.c
 b/bfd/coffgen.c
+@@ -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;
+-- 
+2.16.2
+

Added: 0001-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch
===
--- 0001-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch 
(rev 0)
+++ 0001-PR22829-objcopy-strip-removes-PT_GNU_RELRO-from-lld-.patch 
2018-03-15 06:06:46 UTC (rev 319155)
@@ -0,0 +1,145 @@
+From 3b56a1358768563d9cf320559ebdedfb30f122dd Mon Sep 17 00:00:00 2001
+From: Alan Modra 
+Date: Mon, 12 Feb 2018 13:06:07 +1030
+Subject: [PATCH] PR22829, objcopy/strip removes PT_GNU_RELRO from lld binaries
+
+lld lays out the relro segment differently to GNU ld, not bothering to
+include the first few bytes of .got.plt and padding out to a page at
+the end of the segment.  This patch teaches binutils to recognize the
+different (and somewhat inferior) layout as valid.
+
+bfd/
+   PR 22829
+   * elf.c (assign_file_positions_for_non_load_sections): Rewrite
+   PT_GNU_RELRO setup.
+ld/
+   * testsuite/ld-x86-64/pr14207.d: Adjust relro p_filesz.
+
+(cherry picked from commit f2731e0c374e5323ce4cdae2bcc7b7fe22da1a6f)
+---
+ bfd/elf.c| 78 ++--
+ ld/testsuite/ld-x86-64/pr14207.d |  2 +-
+ 2 files changed, 52 insertions(+), 28 deletions(-)
+
+diff --git a/bfd/elf.c b/bfd/elf.c
+index bbaab26918..f5a230cd77 100644
+--- a/bfd/elf.c
 b/bfd/elf.c
+@@ -5826,50 +5826,74 @@ assign_file_positions_for_non_load_sections (bfd *abfd,
+ {
+   if (p->p_type == PT_GNU_RELRO)
+   {
+-const Elf_Internal_Phdr *lp;
+-struct elf_segment_map *lm;
++bfd_vma start, end;
+ 
+ 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;
++  }
++
++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 == 

[arch-commits] Commit in binutils/trunk (3 files)

2014-06-12 Thread Allan McRae
Date: Thursday, June 12, 2014 @ 16:07:15
  Author: allan
Revision: 215066

upgpkg: binutils 2.24-6

old patch had been reverted upstream, use replacement upstream patch

Added:
  binutils/trunk/binutils-2.24-shared-pie.patch
Modified:
  binutils/trunk/PKGBUILD
Deleted:
  binutils/trunk/binutils-2.24-static-pie-hang.patch

-+
 PKGBUILD|   10 +--
 binutils-2.24-shared-pie.patch  |   99 ++
 binutils-2.24-static-pie-hang.patch |   78 --
 3 files changed, 104 insertions(+), 83 deletions(-)

Modified: PKGBUILD
===
--- PKGBUILD2014-06-12 14:01:53 UTC (rev 215065)
+++ PKGBUILD2014-06-12 14:07:15 UTC (rev 215066)
@@ -5,7 +5,7 @@
 
 pkgname=binutils
 pkgver=2.24
-pkgrel=5
+pkgrel=6
 pkgdesc="A set of programs to assemble and manipulate binary and object files"
 arch=('i686' 'x86_64')
 url="http://www.gnu.org/software/binutils/";
@@ -19,11 +19,11 @@
 install=binutils.install
 source=(ftp://ftp.gnu.org/gnu/binutils/binutils-${pkgver}.tar.bz2{,.sig}
 binutils-2.24-lto-testsuite.patch
-binutils-2.24-static-pie-hang.patch)
+binutils-2.24-shared-pie.patch)
 md5sums=('e0f71a7b2ddab0f8612336ac81d9636b'
  'SKIP'
  'b16e895c24ff80acd98a21021eccefad'
- '4d2cf591560c3d25265778146bbe1941')
+ 'ec59461c4febab9cfe1c1ef33326bc50')
 validpgpkeys=('EAF1C276A747E9ED86210CBAC3126D3B4AE55E93')
 
 prepare() {
@@ -35,8 +35,8 @@
   # fix lto testsuite with gcc-4.9 - commit b35d44f1
   patch -p1 -i $srcdir/binutils-2.24-lto-testsuite.patch
 
-  # fix autoconf hang with -static -fPIE -pie - commits d1ec1e40 and 818d220a
-  patch -p1 -i $srcdir/binutils-2.24-static-pie-hang.patch
+  # fix issues with -static -fPIE -pie - commit 4199e3b8
+  patch -p1 -i $srcdir/binutils-2.24-shared-pie.patch
 
   mkdir ${srcdir}/binutils-build
 }

Added: binutils-2.24-shared-pie.patch
===
--- binutils-2.24-shared-pie.patch  (rev 0)
+++ binutils-2.24-shared-pie.patch  2014-06-12 14:07:15 UTC (rev 215066)
@@ -0,0 +1,99 @@
+diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
+index 9a2fe89..13f86f0 100644
+--- a/ld/emultempl/elf32.em
 b/ld/emultempl/elf32.em
+@@ -1480,6 +1480,8 @@ gld${EMULATION_NAME}_before_allocation (void)
+   const char *rpath;
+   asection *sinterp;
+   bfd *abfd;
++  struct elf_link_hash_entry *ehdr_start = NULL;
++  struct bfd_link_hash_entry ehdr_start_save;
+ 
+   if (is_elf_hash_table (link_info.hash))
+ {
+@@ -1504,6 +1506,16 @@ gld${EMULATION_NAME}_before_allocation (void)
+  _bfd_elf_link_hash_hide_symbol (&link_info, h, TRUE);
+  if (ELF_ST_VISIBILITY (h->other) != STV_INTERNAL)
+h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;
++   /* Don't leave the symbol undefined.  Undefined hidden
++  symbols typically won't have dynamic relocations, but
++  we most likely will need dynamic relocations for
++  __ehdr_start if we are building a PIE or shared
++  library.  */
++   ehdr_start = h;
++   ehdr_start_save = h->root;
++   h->root.type = bfd_link_hash_defined;
++   h->root.u.def.section = bfd_abs_section_ptr;
++   h->root.u.def.value = 0;
+}
+}
+ 
+@@ -1620,6 +1632,14 @@ ${ELF_INTERPRETER_SET_DEFAULT}
+ 
+   if (!bfd_elf_size_dynsym_hash_dynstr (link_info.output_bfd, &link_info))
+ einfo ("%P%F: failed to set dynamic section sizes: %E\n");
++
++  if (ehdr_start != NULL)
++{
++  /* If we twiddled __ehdr_start to defined earlier, put it back
++   as it was.  */
++  ehdr_start->root.type = ehdr_start_save.type;
++  ehdr_start->root.u = ehdr_start_save.u;
++}
+ }
+ 
+ EOF
+diff --git a/ld/testsuite/ld-elf/ehdr_start-shared.d 
b/ld/testsuite/ld-elf/ehdr_start-shared.d
+new file mode 100644
+index 000..c17516a
+--- /dev/null
 b/ld/testsuite/ld-elf/ehdr_start-shared.d
+@@ -0,0 +1,9 @@
++#source: ehdr_start.s
++#ld: -e _start -shared
++#nm: -n
++#target: *-*-linux* *-*-gnu* *-*-nacl*
++#xfail: cris*-*-* frv-*-*
++
++#...
++[0-9a-f]*000 [Adrt] __ehdr_start
++#pass
+diff --git a/ld/testsuite/ld-elf/ehdr_start-userdef.d 
b/ld/testsuite/ld-elf/ehdr_start-userdef.d
+index 2a88e98..b58ae3f 100644
+--- a/ld/testsuite/ld-elf/ehdr_start-userdef.d
 b/ld/testsuite/ld-elf/ehdr_start-userdef.d
+@@ -2,6 +2,7 @@
+ #ld: -e _start -T ehdr_start-userdef.t
+ #readelf: -Ws
+ #target: *-*-linux* *-*-gnu* *-*-nacl*
++#xfail: frv-*-*
+ 
+ #...
+ Symbol table '\.symtab' contains [0-9]+ entries:
+diff --git a/ld/testsuite/ld-elf/ehdr_start-weak.d 
b/ld/testsuite/ld-elf/ehdr_start-weak.d
+index 8bd9035..24ae34c 100644
+--- a/ld/testsuite/ld-elf/ehdr_start-weak.d
 b/ld/testsuite/ld-elf/ehdr_start-weak.