mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2025-01-27 23:44:04 +00:00
core/binutils to 2.25-1
This commit is contained in:
parent
e8318ca61a
commit
426653ae2e
14 changed files with 6 additions and 2179 deletions
|
@ -10,8 +10,8 @@
|
|||
noautobuild=1
|
||||
|
||||
pkgname=binutils
|
||||
pkgver=2.24
|
||||
pkgrel=8
|
||||
pkgver=2.25
|
||||
pkgrel=1
|
||||
pkgdesc="A set of programs to assemble and manipulate binary and object files"
|
||||
arch=('i686' 'x86_64')
|
||||
url="http://www.gnu.org/software/binutils/"
|
||||
|
@ -21,33 +21,10 @@ depends=('glibc>=2.20' 'zlib')
|
|||
checkdepends=('dejagnu')
|
||||
options=('staticlibs' '!distcc' '!ccache')
|
||||
install=binutils.install
|
||||
source=(ftp://ftp.gnu.org/gnu/binutils/binutils-${pkgver}.tar.bz2{,.sig}
|
||||
binutils-2.24-lto-testsuite.patch
|
||||
binutils-2.24-gold-testsuite-plugin.patch
|
||||
binutils-2.24-shared-pie.patch
|
||||
binutils-2.24-CVE-2014-8484.patch
|
||||
binutils-2.24-CVE-2014-8485.patch
|
||||
binutils-2.24-CVE-2014-8501.patch
|
||||
binutils-2.24-CVE-2014-8502.patch
|
||||
binutils-2.24-CVE-2014-8503.patch
|
||||
binutils-2.24-CVE-2014-8504.patch
|
||||
binutils-2.24-CVE-2014-8737.patch
|
||||
binutils-2.24-CVE-2014-8738.patch
|
||||
binutils-2.24-strings-all-default.patch)
|
||||
md5sums=('e0f71a7b2ddab0f8612336ac81d9636b'
|
||||
'SKIP'
|
||||
'e68a1f221545f082baa5bd417cd077af'
|
||||
'e46bbb03abaa5db58c12247644dc4857'
|
||||
'ec59461c4febab9cfe1c1ef33326bc50'
|
||||
'125d8ce675ced84814d5f068106dbaa3'
|
||||
'6923e5279a84cb7134b07e2cf6686434'
|
||||
'4c590dc70829d8f4fc190f0fe7e3add8'
|
||||
'64efddd24d5628437cc457b468df8de3'
|
||||
'70540e2c6418a54ad88ab9c6b988d075'
|
||||
'acce1f1d28db6bdb84b430a05f331366'
|
||||
'12fb3e860203a06b5d1f4b023c06dcec'
|
||||
'd35b0ccb79d565757821b3e0206f3873'
|
||||
'99445d528110543d88b59a1ec7677592')
|
||||
source=(ftp://ftp.gnu.org/gnu/binutils/binutils-${pkgver}.tar.bz2{,.sig})
|
||||
md5sums=('d9f3303f802a5b6b0bb73a335ab89d66'
|
||||
'SKIP')
|
||||
validpgpkeys=('EAF1C276A747E9ED86210CBAC3126D3B4AE55E93') # Tristan Gingold
|
||||
|
||||
prepare() {
|
||||
cd ${srcdir}/binutils-${pkgver}
|
||||
|
@ -55,42 +32,6 @@ prepare() {
|
|||
# hack! - libiberty configure tests for header files using "$CPP $CPPFLAGS"
|
||||
sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" libiberty/configure
|
||||
|
||||
# fix lto testsuite with gcc-4.9 - commits b35d44f1 and 37a6ac44
|
||||
patch -p1 -i $srcdir/binutils-2.24-lto-testsuite.patch
|
||||
|
||||
# fix gold testsuite with gcc-4.9 - commit ae447ddd
|
||||
patch -p1 -i $srcdir/binutils-2.24-gold-testsuite-plugin.patch
|
||||
|
||||
# fix issues with -static -fPIE -pie - commit 4199e3b8
|
||||
patch -p1 -i $srcdir/binutils-2.24-shared-pie.patch
|
||||
|
||||
# CVE-2014-8484 - backport of commit bd25671c
|
||||
patch -p1 -i $srcdir/binutils-2.24-CVE-2014-8484.patch
|
||||
|
||||
# CVE-2014-8485 - commit 493a3386
|
||||
patch -p1 -i $srcdir/binutils-2.24-CVE-2014-8485.patch
|
||||
|
||||
# CVE-2014-8501 - commit 7e1e1988
|
||||
patch -p1 -i $srcdir/binutils-2.24-CVE-2014-8501.patch
|
||||
|
||||
# CVE-2014-8502 - commits bf67003b and 5a4b0ccc
|
||||
patch -p1 -i $srcdir/binutils-2.24-CVE-2014-8502.patch
|
||||
|
||||
# CVE-2014-8503 - commit 0102ea8c
|
||||
patch -p1 -i $srcdir/binutils-2.24-CVE-2014-8503.patch
|
||||
|
||||
# CVE-2014-8504 - commit 708d7d0d
|
||||
patch -p1 -i $srcdir/binutils-2.24-CVE-2014-8504.patch
|
||||
|
||||
# CVE-2014-8737 - commit dd9b91de
|
||||
patch -p1 -i $srcdir/binutils-2.24-CVE-2014-8737.patch
|
||||
|
||||
# CVE-2014-8738 - commit bb0d8671
|
||||
patch -p1 -i $srcdir/binutils-2.24-CVE-2014-8738.patch
|
||||
|
||||
# strings -a default - commit 7fac9594 (fedora backport)
|
||||
patch -p0 -i $srcdir/binutils-2.24-strings-all-default.patch
|
||||
|
||||
mkdir ${srcdir}/binutils-build
|
||||
}
|
||||
|
||||
|
@ -131,7 +72,6 @@ package() {
|
|||
|
||||
# Remove unwanted files
|
||||
rm -f ${pkgdir}/usr/share/man/man1/{dlltool,nlmconv,windres,windmc}*
|
||||
rm ${pkgdir}/usr/share/info/{configure,standards}.info
|
||||
|
||||
# No shared linking to these files outside binutils
|
||||
rm -f ${pkgdir}/usr/lib/lib{bfd,opcodes}.so
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
--- binutils-2.24/bfd/srec.c 2013-11-04 16:33:37.000000000 +0100
|
||||
+++ binutils-2.24-1/bfd/srec.c 2014-10-24 21:46:38.973046641 +0200
|
||||
@@ -455,7 +455,7 @@
|
||||
{
|
||||
file_ptr pos;
|
||||
char hdr[3];
|
||||
- unsigned int bytes;
|
||||
+ unsigned int bytes, min_bytes;
|
||||
bfd_vma address;
|
||||
bfd_byte *data;
|
||||
unsigned char check_sum;
|
||||
@@ -478,6 +478,19 @@
|
||||
}
|
||||
|
||||
check_sum = bytes = HEX (hdr + 1);
|
||||
+ min_bytes = 3;
|
||||
+ if (hdr[0] == '2' || hdr[0] == '8')
|
||||
+ min_bytes = 4;
|
||||
+ else if (hdr[0] == '3' || hdr[0] == '7')
|
||||
+ min_bytes = 5;
|
||||
+ if (bytes < min_bytes)
|
||||
+ {
|
||||
+ (*_bfd_error_handler) (_("%B:%d: byte count %d too small\n"),
|
||||
+ abfd, lineno, bytes);
|
||||
+ bfd_set_error (bfd_error_bad_value);
|
||||
+ goto error_return;
|
||||
+ }
|
||||
+
|
||||
if (bytes * 2 > bufsize)
|
||||
{
|
||||
if (buf != NULL)
|
|
@ -1,70 +0,0 @@
|
|||
diff --git a/bfd/elf.c b/bfd/elf.c
|
||||
index c884d1d..c8ac826 100644
|
||||
--- a/bfd/elf.c
|
||||
+++ b/bfd/elf.c
|
||||
@@ -608,9 +608,10 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
|
||||
if (shdr->contents == NULL)
|
||||
{
|
||||
_bfd_error_handler
|
||||
- (_("%B: Corrupt size field in group section header: 0x%lx"), abfd, shdr->sh_size);
|
||||
+ (_("%B: corrupt size field in group section header: 0x%lx"), abfd, shdr->sh_size);
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
- return FALSE;
|
||||
+ -- num_group;
|
||||
+ continue;
|
||||
}
|
||||
|
||||
memset (shdr->contents, 0, amt);
|
||||
@@ -618,8 +619,17 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
|
||||
if (bfd_seek (abfd, shdr->sh_offset, SEEK_SET) != 0
|
||||
|| (bfd_bread (shdr->contents, shdr->sh_size, abfd)
|
||||
!= shdr->sh_size))
|
||||
- return FALSE;
|
||||
-
|
||||
+ {
|
||||
+ _bfd_error_handler
|
||||
+ (_("%B: invalid size field in group section header: 0x%lx"), abfd, shdr->sh_size);
|
||||
+ bfd_set_error (bfd_error_bad_value);
|
||||
+ -- num_group;
|
||||
+ /* PR 17510: If the group contents are even partially
|
||||
+ corrupt, do not allow any of the contents to be used. */
|
||||
+ memset (shdr->contents, 0, amt);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
/* Translate raw contents, a flag word followed by an
|
||||
array of elf section indices all in target byte order,
|
||||
to the flag word followed by an array of elf section
|
||||
@@ -651,6 +661,21 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
|
||||
}
|
||||
}
|
||||
}
|
||||
+
|
||||
+ /* PR 17510: Corrupt binaries might contain invalid groups. */
|
||||
+ if (num_group != (unsigned) elf_tdata (abfd)->num_group)
|
||||
+ {
|
||||
+ elf_tdata (abfd)->num_group = num_group;
|
||||
+
|
||||
+ /* If all groups are invalid then fail. */
|
||||
+ if (num_group == 0)
|
||||
+ {
|
||||
+ elf_tdata (abfd)->group_sect_ptr = NULL;
|
||||
+ elf_tdata (abfd)->num_group = num_group = -1;
|
||||
+ (*_bfd_error_handler) (_("%B: no valid group sections found"), abfd);
|
||||
+ bfd_set_error (bfd_error_bad_value);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -716,6 +741,7 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
|
||||
{
|
||||
(*_bfd_error_handler) (_("%B: no group info for section %A"),
|
||||
abfd, newsect);
|
||||
+ return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
--
|
||||
1.7.1
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
|
||||
index 2fb631c..987be40 100644
|
||||
--- a/bfd/peXXigen.c
|
||||
+++ b/bfd/peXXigen.c
|
||||
@@ -504,6 +504,18 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd,
|
||||
{
|
||||
int idx;
|
||||
|
||||
+ /* PR 17512: Corrupt PE binaries can cause seg-faults. */
|
||||
+ if (a->NumberOfRvaAndSizes > 16)
|
||||
+ {
|
||||
+ (*_bfd_error_handler)
|
||||
+ (_("%B: aout header specifies an invalid number of data-directory entries: %d"),
|
||||
+ abfd, a->NumberOfRvaAndSizes);
|
||||
+ /* Paranoia: If the number is corrupt, then assume that the
|
||||
+ actual entries themselves might be corrupt as well. */
|
||||
+ a->NumberOfRvaAndSizes = 0;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
for (idx = 0; idx < a->NumberOfRvaAndSizes; idx++)
|
||||
{
|
||||
/* If data directory is empty, rva also should be 0. */
|
||||
--
|
||||
1.7.1
|
||||
|
|
@ -1,481 +0,0 @@
|
|||
diff --git a/bfd/elf.c b/bfd/elf.c
|
||||
index c8ac826..3fcf2d8 100644
|
||||
--- a/bfd/elf.c
|
||||
+++ b/bfd/elf.c
|
||||
@@ -1578,38 +1578,67 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
Elf_Internal_Ehdr *ehdr;
|
||||
const struct elf_backend_data *bed;
|
||||
const char *name;
|
||||
+ bfd_boolean ret = TRUE;
|
||||
+ static bfd_boolean * sections_being_created = NULL;
|
||||
+ static unsigned int nesting = 0;
|
||||
|
||||
if (shindex >= elf_numsections (abfd))
|
||||
return FALSE;
|
||||
|
||||
+ if (++ nesting > 3)
|
||||
+ {
|
||||
+ /* PR17512: A corrupt ELF binary might contain a recursive group of
|
||||
+ sections, each the string indicies pointing to the next in the
|
||||
+ loop. Detect this here, by refusing to load a section that we are
|
||||
+ already in the process of loading. We only trigger this test if
|
||||
+ we have nested at least three sections deep as normal ELF binaries
|
||||
+ can expect to recurse at least once. */
|
||||
+
|
||||
+ if (sections_being_created == NULL)
|
||||
+ {
|
||||
+ /* FIXME: It would be more efficient to attach this array to the bfd somehow. */
|
||||
+ sections_being_created = (bfd_boolean *)
|
||||
+ bfd_zalloc (abfd, elf_numsections (abfd) * sizeof (bfd_boolean));
|
||||
+ }
|
||||
+ if (sections_being_created [shindex])
|
||||
+ {
|
||||
+ (*_bfd_error_handler)
|
||||
+ (_("%B: warning: loop in section dependencies detected"), abfd);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ sections_being_created [shindex] = TRUE;
|
||||
+ }
|
||||
+
|
||||
hdr = elf_elfsections (abfd)[shindex];
|
||||
ehdr = elf_elfheader (abfd);
|
||||
name = bfd_elf_string_from_elf_section (abfd, ehdr->e_shstrndx,
|
||||
hdr->sh_name);
|
||||
if (name == NULL)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
bed = get_elf_backend_data (abfd);
|
||||
switch (hdr->sh_type)
|
||||
{
|
||||
case SHT_NULL:
|
||||
/* Inactive section. Throw it away. */
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
- case SHT_PROGBITS: /* Normal section with contents. */
|
||||
- case SHT_NOBITS: /* .bss section. */
|
||||
- case SHT_HASH: /* .hash section. */
|
||||
- case SHT_NOTE: /* .note section. */
|
||||
+ case SHT_PROGBITS: /* Normal section with contents. */
|
||||
+ case SHT_NOBITS: /* .bss section. */
|
||||
+ case SHT_HASH: /* .hash section. */
|
||||
+ case SHT_NOTE: /* .note section. */
|
||||
case SHT_INIT_ARRAY: /* .init_array section. */
|
||||
case SHT_FINI_ARRAY: /* .fini_array section. */
|
||||
case SHT_PREINIT_ARRAY: /* .preinit_array section. */
|
||||
case SHT_GNU_LIBLIST: /* .gnu.liblist section. */
|
||||
case SHT_GNU_HASH: /* .gnu.hash section. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_DYNAMIC: /* Dynamic linking information. */
|
||||
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (hdr->sh_link > elf_numsections (abfd))
|
||||
{
|
||||
/* PR 10478: Accept Solaris binaries with a sh_link
|
||||
@@ -1623,11 +1652,11 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
break;
|
||||
/* Otherwise fall through. */
|
||||
default:
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
}
|
||||
}
|
||||
else if (elf_elfsections (abfd)[hdr->sh_link] == NULL)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
else if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB)
|
||||
{
|
||||
Elf_Internal_Shdr *dynsymhdr;
|
||||
@@ -1656,24 +1685,26 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
}
|
||||
}
|
||||
}
|
||||
- break;
|
||||
+ goto success;
|
||||
|
||||
- case SHT_SYMTAB: /* A symbol table */
|
||||
+ case SHT_SYMTAB: /* A symbol table. */
|
||||
if (elf_onesymtab (abfd) == shindex)
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
if (hdr->sh_entsize != bed->s->sizeof_sym)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size)
|
||||
{
|
||||
if (hdr->sh_size != 0)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
/* Some assemblers erroneously set sh_info to one with a
|
||||
zero sh_size. ld sees this as a global symbol count
|
||||
of (unsigned) -1. Fix it here. */
|
||||
hdr->sh_info = 0;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
+
|
||||
BFD_ASSERT (elf_onesymtab (abfd) == 0);
|
||||
elf_onesymtab (abfd) = shindex;
|
||||
elf_tdata (abfd)->symtab_hdr = *hdr;
|
||||
@@ -1690,7 +1721,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
&& (abfd->flags & DYNAMIC) != 0
|
||||
&& ! _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
shindex))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
/* Go looking for SHT_SYMTAB_SHNDX too, since if there is one we
|
||||
can't read symbols without that section loaded as well. It
|
||||
@@ -1716,26 +1747,29 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
break;
|
||||
}
|
||||
if (i != shindex)
|
||||
- return bfd_section_from_shdr (abfd, i);
|
||||
+ ret = bfd_section_from_shdr (abfd, i);
|
||||
}
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
- case SHT_DYNSYM: /* A dynamic symbol table */
|
||||
+ case SHT_DYNSYM: /* A dynamic symbol table. */
|
||||
if (elf_dynsymtab (abfd) == shindex)
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
if (hdr->sh_entsize != bed->s->sizeof_sym)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size)
|
||||
{
|
||||
if (hdr->sh_size != 0)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
/* Some linkers erroneously set sh_info to one with a
|
||||
zero sh_size. ld sees this as a global symbol count
|
||||
of (unsigned) -1. Fix it here. */
|
||||
hdr->sh_info = 0;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
+
|
||||
BFD_ASSERT (elf_dynsymtab (abfd) == 0);
|
||||
elf_dynsymtab (abfd) = shindex;
|
||||
elf_tdata (abfd)->dynsymtab_hdr = *hdr;
|
||||
@@ -1744,34 +1778,38 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
|
||||
/* Besides being a symbol table, we also treat this as a regular
|
||||
section, so that objcopy can handle it. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
- case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections */
|
||||
+ case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections. */
|
||||
if (elf_symtab_shndx (abfd) == shindex)
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
BFD_ASSERT (elf_symtab_shndx (abfd) == 0);
|
||||
elf_symtab_shndx (abfd) = shindex;
|
||||
elf_tdata (abfd)->symtab_shndx_hdr = *hdr;
|
||||
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->symtab_shndx_hdr;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
- case SHT_STRTAB: /* A string table */
|
||||
+ case SHT_STRTAB: /* A string table. */
|
||||
if (hdr->bfd_section != NULL)
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
+
|
||||
if (ehdr->e_shstrndx == shindex)
|
||||
{
|
||||
elf_tdata (abfd)->shstrtab_hdr = *hdr;
|
||||
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->shstrtab_hdr;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
+
|
||||
if (elf_elfsections (abfd)[elf_onesymtab (abfd)]->sh_link == shindex)
|
||||
{
|
||||
symtab_strtab:
|
||||
elf_tdata (abfd)->strtab_hdr = *hdr;
|
||||
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->strtab_hdr;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
+
|
||||
if (elf_elfsections (abfd)[elf_dynsymtab (abfd)]->sh_link == shindex)
|
||||
{
|
||||
dynsymtab_strtab:
|
||||
@@ -1780,8 +1818,9 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
elf_elfsections (abfd)[shindex] = hdr;
|
||||
/* We also treat this as a regular section, so that objcopy
|
||||
can handle it. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
- shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
+ shindex);
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
/* If the string table isn't one of the above, then treat it as a
|
||||
@@ -1799,9 +1838,9 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
{
|
||||
/* Prevent endless recursion on broken objects. */
|
||||
if (i == shindex)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
if (! bfd_section_from_shdr (abfd, i))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
if (elf_onesymtab (abfd) == i)
|
||||
goto symtab_strtab;
|
||||
if (elf_dynsymtab (abfd) == i)
|
||||
@@ -1809,7 +1848,8 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
}
|
||||
}
|
||||
}
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_REL:
|
||||
case SHT_RELA:
|
||||
@@ -1824,7 +1864,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
if (hdr->sh_entsize
|
||||
!= (bfd_size_type) (hdr->sh_type == SHT_REL
|
||||
? bed->s->sizeof_rel : bed->s->sizeof_rela))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
/* Check for a bogus link to avoid crashing. */
|
||||
if (hdr->sh_link >= num_sec)
|
||||
@@ -1832,8 +1872,9 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
((*_bfd_error_handler)
|
||||
(_("%B: invalid link %lu for reloc section %s (index %u)"),
|
||||
abfd, hdr->sh_link, name, shindex));
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
- shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
+ shindex);
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
/* For some incomprehensible reason Oracle distributes
|
||||
@@ -1874,7 +1915,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
if ((elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB
|
||||
|| elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_DYNSYM)
|
||||
&& ! bfd_section_from_shdr (abfd, hdr->sh_link))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
/* If this reloc section does not use the main symbol table we
|
||||
don't treat it as a reloc section. BFD can't adequately
|
||||
@@ -1889,14 +1930,18 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
|| hdr->sh_info >= num_sec
|
||||
|| elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_REL
|
||||
|| elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_RELA)
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
- shindex);
|
||||
+ {
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
+ shindex);
|
||||
+ goto success;
|
||||
+ }
|
||||
|
||||
if (! bfd_section_from_shdr (abfd, hdr->sh_info))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
target_sect = bfd_section_from_elf_index (abfd, hdr->sh_info);
|
||||
if (target_sect == NULL)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
esdt = elf_section_data (target_sect);
|
||||
if (hdr->sh_type == SHT_RELA)
|
||||
@@ -1908,7 +1953,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
amt = sizeof (*hdr2);
|
||||
hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt);
|
||||
if (hdr2 == NULL)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
*hdr2 = *hdr;
|
||||
*p_hdr = hdr2;
|
||||
elf_elfsections (abfd)[shindex] = hdr2;
|
||||
@@ -1924,34 +1969,40 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
target_sect->use_rela_p = 1;
|
||||
}
|
||||
abfd->flags |= HAS_RELOC;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
case SHT_GNU_verdef:
|
||||
elf_dynverdef (abfd) = shindex;
|
||||
elf_tdata (abfd)->dynverdef_hdr = *hdr;
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_GNU_versym:
|
||||
if (hdr->sh_entsize != sizeof (Elf_External_Versym))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
elf_dynversym (abfd) = shindex;
|
||||
elf_tdata (abfd)->dynversym_hdr = *hdr;
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_GNU_verneed:
|
||||
elf_dynverref (abfd) = shindex;
|
||||
elf_tdata (abfd)->dynverref_hdr = *hdr;
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_SHLIB:
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
case SHT_GROUP:
|
||||
if (! IS_VALID_GROUP_SECTION_HEADER (hdr, GRP_ENTRY_SIZE))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (hdr->contents != NULL)
|
||||
{
|
||||
Elf_Internal_Group *idx = (Elf_Internal_Group *) hdr->contents;
|
||||
@@ -1977,7 +2028,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
}
|
||||
}
|
||||
}
|
||||
- break;
|
||||
+ goto success;
|
||||
|
||||
default:
|
||||
/* Possibly an attributes section. */
|
||||
@@ -1985,14 +2036,14 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
|| hdr->sh_type == bed->obj_attrs_section_type)
|
||||
{
|
||||
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
_bfd_elf_parse_attributes (abfd, hdr);
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
/* Check for any processor-specific section types. */
|
||||
if (bed->elf_backend_section_from_shdr (abfd, hdr, name, shindex))
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
if (hdr->sh_type >= SHT_LOUSER && hdr->sh_type <= SHT_HIUSER)
|
||||
{
|
||||
@@ -2004,9 +2055,12 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
"specific section `%s' [0x%8x]"),
|
||||
abfd, name, hdr->sh_type);
|
||||
else
|
||||
- /* Allow sections reserved for applications. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
- shindex);
|
||||
+ {
|
||||
+ /* Allow sections reserved for applications. */
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
+ shindex);
|
||||
+ goto success;
|
||||
+ }
|
||||
}
|
||||
else if (hdr->sh_type >= SHT_LOPROC
|
||||
&& hdr->sh_type <= SHT_HIPROC)
|
||||
@@ -2027,8 +2081,11 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
"`%s' [0x%8x]"),
|
||||
abfd, name, hdr->sh_type);
|
||||
else
|
||||
- /* Otherwise it should be processed. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ {
|
||||
+ /* Otherwise it should be processed. */
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
+ }
|
||||
}
|
||||
else
|
||||
/* FIXME: We should handle this section. */
|
||||
@@ -2036,10 +2093,17 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
(_("%B: don't know how to handle section `%s' [0x%8x]"),
|
||||
abfd, name, hdr->sh_type);
|
||||
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
- return TRUE;
|
||||
+ fail:
|
||||
+ ret = FALSE;
|
||||
+ success:
|
||||
+ if (sections_being_created)
|
||||
+ sections_being_created [shindex] = FALSE;
|
||||
+ if (-- nesting == 0)
|
||||
+ sections_being_created = NULL;
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
/* Return the local symbol specified by ABFD, R_SYMNDX. */
|
||||
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
|
||||
index 987be40..c7d6067 100644
|
||||
--- a/bfd/peXXigen.c
|
||||
+++ b/bfd/peXXigen.c
|
||||
@@ -1705,7 +1705,12 @@ pe_print_edata (bfd * abfd, void * vfile)
|
||||
_("\nExport Address Table -- Ordinal Base %ld\n"),
|
||||
edt.base);
|
||||
|
||||
- for (i = 0; i < edt.num_functions; ++i)
|
||||
+ /* PR 17512: Handle corrupt PE binaries. */
|
||||
+ if (edt.eat_addr + (edt.num_functions * 4) - adj >= datasize)
|
||||
+ fprintf (file, _("\tInvalid Export Address Table rva (0x%lx) or entry count (0x%lx)\n"),
|
||||
+ (long) edt.eat_addr,
|
||||
+ (long) edt.num_functions);
|
||||
+ else for (i = 0; i < edt.num_functions; ++i)
|
||||
{
|
||||
bfd_vma eat_member = bfd_get_32 (abfd,
|
||||
data + edt.eat_addr + (i * 4) - adj);
|
||||
@@ -1741,7 +1746,16 @@ pe_print_edata (bfd * abfd, void * vfile)
|
||||
fprintf (file,
|
||||
_("\n[Ordinal/Name Pointer] Table\n"));
|
||||
|
||||
- for (i = 0; i < edt.num_names; ++i)
|
||||
+ /* PR 17512: Handle corrupt PE binaries. */
|
||||
+ if (edt.npt_addr + (edt.num_names * 4) - adj >= datasize)
|
||||
+ fprintf (file, _("\tInvalid Name Pointer Table rva (0x%lx) or entry count (0x%lx)\n"),
|
||||
+ (long) edt.npt_addr,
|
||||
+ (long) edt.num_names);
|
||||
+ else if (edt.ot_addr + (edt.num_names * 2) - adj >= datasize)
|
||||
+ fprintf (file, _("\tInvalid Ordinal Table rva (0x%lx) or entry count (0x%lx)\n"),
|
||||
+ (long) edt.ot_addr,
|
||||
+ (long) edt.num_names);
|
||||
+ else for (i = 0; i < edt.num_names; ++i)
|
||||
{
|
||||
bfd_vma name_ptr = bfd_get_32 (abfd,
|
||||
data +
|
||||
--
|
||||
1.7.1
|
||||
|
|
@ -1,547 +0,0 @@
|
|||
diff --git a/bfd/elf.c b/bfd/elf.c
|
||||
index c8ac826..3fcf2d8 100644
|
||||
--- a/bfd/elf.c
|
||||
+++ b/bfd/elf.c
|
||||
@@ -1578,38 +1578,67 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
Elf_Internal_Ehdr *ehdr;
|
||||
const struct elf_backend_data *bed;
|
||||
const char *name;
|
||||
+ bfd_boolean ret = TRUE;
|
||||
+ static bfd_boolean * sections_being_created = NULL;
|
||||
+ static unsigned int nesting = 0;
|
||||
|
||||
if (shindex >= elf_numsections (abfd))
|
||||
return FALSE;
|
||||
|
||||
+ if (++ nesting > 3)
|
||||
+ {
|
||||
+ /* PR17512: A corrupt ELF binary might contain a recursive group of
|
||||
+ sections, each the string indicies pointing to the next in the
|
||||
+ loop. Detect this here, by refusing to load a section that we are
|
||||
+ already in the process of loading. We only trigger this test if
|
||||
+ we have nested at least three sections deep as normal ELF binaries
|
||||
+ can expect to recurse at least once. */
|
||||
+
|
||||
+ if (sections_being_created == NULL)
|
||||
+ {
|
||||
+ /* FIXME: It would be more efficient to attach this array to the bfd somehow. */
|
||||
+ sections_being_created = (bfd_boolean *)
|
||||
+ bfd_zalloc (abfd, elf_numsections (abfd) * sizeof (bfd_boolean));
|
||||
+ }
|
||||
+ if (sections_being_created [shindex])
|
||||
+ {
|
||||
+ (*_bfd_error_handler)
|
||||
+ (_("%B: warning: loop in section dependencies detected"), abfd);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ sections_being_created [shindex] = TRUE;
|
||||
+ }
|
||||
+
|
||||
hdr = elf_elfsections (abfd)[shindex];
|
||||
ehdr = elf_elfheader (abfd);
|
||||
name = bfd_elf_string_from_elf_section (abfd, ehdr->e_shstrndx,
|
||||
hdr->sh_name);
|
||||
if (name == NULL)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
bed = get_elf_backend_data (abfd);
|
||||
switch (hdr->sh_type)
|
||||
{
|
||||
case SHT_NULL:
|
||||
/* Inactive section. Throw it away. */
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
- case SHT_PROGBITS: /* Normal section with contents. */
|
||||
- case SHT_NOBITS: /* .bss section. */
|
||||
- case SHT_HASH: /* .hash section. */
|
||||
- case SHT_NOTE: /* .note section. */
|
||||
+ case SHT_PROGBITS: /* Normal section with contents. */
|
||||
+ case SHT_NOBITS: /* .bss section. */
|
||||
+ case SHT_HASH: /* .hash section. */
|
||||
+ case SHT_NOTE: /* .note section. */
|
||||
case SHT_INIT_ARRAY: /* .init_array section. */
|
||||
case SHT_FINI_ARRAY: /* .fini_array section. */
|
||||
case SHT_PREINIT_ARRAY: /* .preinit_array section. */
|
||||
case SHT_GNU_LIBLIST: /* .gnu.liblist section. */
|
||||
case SHT_GNU_HASH: /* .gnu.hash section. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_DYNAMIC: /* Dynamic linking information. */
|
||||
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (hdr->sh_link > elf_numsections (abfd))
|
||||
{
|
||||
/* PR 10478: Accept Solaris binaries with a sh_link
|
||||
@@ -1623,11 +1652,11 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
break;
|
||||
/* Otherwise fall through. */
|
||||
default:
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
}
|
||||
}
|
||||
else if (elf_elfsections (abfd)[hdr->sh_link] == NULL)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
else if (elf_elfsections (abfd)[hdr->sh_link]->sh_type != SHT_STRTAB)
|
||||
{
|
||||
Elf_Internal_Shdr *dynsymhdr;
|
||||
@@ -1656,24 +1685,26 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
}
|
||||
}
|
||||
}
|
||||
- break;
|
||||
+ goto success;
|
||||
|
||||
- case SHT_SYMTAB: /* A symbol table */
|
||||
+ case SHT_SYMTAB: /* A symbol table. */
|
||||
if (elf_onesymtab (abfd) == shindex)
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
if (hdr->sh_entsize != bed->s->sizeof_sym)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size)
|
||||
{
|
||||
if (hdr->sh_size != 0)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
/* Some assemblers erroneously set sh_info to one with a
|
||||
zero sh_size. ld sees this as a global symbol count
|
||||
of (unsigned) -1. Fix it here. */
|
||||
hdr->sh_info = 0;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
+
|
||||
BFD_ASSERT (elf_onesymtab (abfd) == 0);
|
||||
elf_onesymtab (abfd) = shindex;
|
||||
elf_tdata (abfd)->symtab_hdr = *hdr;
|
||||
@@ -1690,7 +1721,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
&& (abfd->flags & DYNAMIC) != 0
|
||||
&& ! _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
shindex))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
/* Go looking for SHT_SYMTAB_SHNDX too, since if there is one we
|
||||
can't read symbols without that section loaded as well. It
|
||||
@@ -1716,26 +1747,29 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
break;
|
||||
}
|
||||
if (i != shindex)
|
||||
- return bfd_section_from_shdr (abfd, i);
|
||||
+ ret = bfd_section_from_shdr (abfd, i);
|
||||
}
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
- case SHT_DYNSYM: /* A dynamic symbol table */
|
||||
+ case SHT_DYNSYM: /* A dynamic symbol table. */
|
||||
if (elf_dynsymtab (abfd) == shindex)
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
if (hdr->sh_entsize != bed->s->sizeof_sym)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size)
|
||||
{
|
||||
if (hdr->sh_size != 0)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
/* Some linkers erroneously set sh_info to one with a
|
||||
zero sh_size. ld sees this as a global symbol count
|
||||
of (unsigned) -1. Fix it here. */
|
||||
hdr->sh_info = 0;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
+
|
||||
BFD_ASSERT (elf_dynsymtab (abfd) == 0);
|
||||
elf_dynsymtab (abfd) = shindex;
|
||||
elf_tdata (abfd)->dynsymtab_hdr = *hdr;
|
||||
@@ -1744,34 +1778,38 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
|
||||
/* Besides being a symbol table, we also treat this as a regular
|
||||
section, so that objcopy can handle it. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
- case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections */
|
||||
+ case SHT_SYMTAB_SHNDX: /* Symbol section indices when >64k sections. */
|
||||
if (elf_symtab_shndx (abfd) == shindex)
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
BFD_ASSERT (elf_symtab_shndx (abfd) == 0);
|
||||
elf_symtab_shndx (abfd) = shindex;
|
||||
elf_tdata (abfd)->symtab_shndx_hdr = *hdr;
|
||||
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->symtab_shndx_hdr;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
- case SHT_STRTAB: /* A string table */
|
||||
+ case SHT_STRTAB: /* A string table. */
|
||||
if (hdr->bfd_section != NULL)
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
+
|
||||
if (ehdr->e_shstrndx == shindex)
|
||||
{
|
||||
elf_tdata (abfd)->shstrtab_hdr = *hdr;
|
||||
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->shstrtab_hdr;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
+
|
||||
if (elf_elfsections (abfd)[elf_onesymtab (abfd)]->sh_link == shindex)
|
||||
{
|
||||
symtab_strtab:
|
||||
elf_tdata (abfd)->strtab_hdr = *hdr;
|
||||
elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->strtab_hdr;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
+
|
||||
if (elf_elfsections (abfd)[elf_dynsymtab (abfd)]->sh_link == shindex)
|
||||
{
|
||||
dynsymtab_strtab:
|
||||
@@ -1780,8 +1818,9 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
elf_elfsections (abfd)[shindex] = hdr;
|
||||
/* We also treat this as a regular section, so that objcopy
|
||||
can handle it. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
- shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
+ shindex);
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
/* If the string table isn't one of the above, then treat it as a
|
||||
@@ -1799,9 +1838,9 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
{
|
||||
/* Prevent endless recursion on broken objects. */
|
||||
if (i == shindex)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
if (! bfd_section_from_shdr (abfd, i))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
if (elf_onesymtab (abfd) == i)
|
||||
goto symtab_strtab;
|
||||
if (elf_dynsymtab (abfd) == i)
|
||||
@@ -1809,7 +1848,8 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
}
|
||||
}
|
||||
}
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_REL:
|
||||
case SHT_RELA:
|
||||
@@ -1824,7 +1864,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
if (hdr->sh_entsize
|
||||
!= (bfd_size_type) (hdr->sh_type == SHT_REL
|
||||
? bed->s->sizeof_rel : bed->s->sizeof_rela))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
/* Check for a bogus link to avoid crashing. */
|
||||
if (hdr->sh_link >= num_sec)
|
||||
@@ -1832,8 +1872,9 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
((*_bfd_error_handler)
|
||||
(_("%B: invalid link %lu for reloc section %s (index %u)"),
|
||||
abfd, hdr->sh_link, name, shindex));
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
- shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
+ shindex);
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
/* For some incomprehensible reason Oracle distributes
|
||||
@@ -1874,7 +1915,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
if ((elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB
|
||||
|| elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_DYNSYM)
|
||||
&& ! bfd_section_from_shdr (abfd, hdr->sh_link))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
/* If this reloc section does not use the main symbol table we
|
||||
don't treat it as a reloc section. BFD can't adequately
|
||||
@@ -1889,14 +1930,18 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
|| hdr->sh_info >= num_sec
|
||||
|| elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_REL
|
||||
|| elf_elfsections (abfd)[hdr->sh_info]->sh_type == SHT_RELA)
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
- shindex);
|
||||
+ {
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
+ shindex);
|
||||
+ goto success;
|
||||
+ }
|
||||
|
||||
if (! bfd_section_from_shdr (abfd, hdr->sh_info))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
target_sect = bfd_section_from_elf_index (abfd, hdr->sh_info);
|
||||
if (target_sect == NULL)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
|
||||
esdt = elf_section_data (target_sect);
|
||||
if (hdr->sh_type == SHT_RELA)
|
||||
@@ -1908,7 +1953,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
amt = sizeof (*hdr2);
|
||||
hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt);
|
||||
if (hdr2 == NULL)
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
*hdr2 = *hdr;
|
||||
*p_hdr = hdr2;
|
||||
elf_elfsections (abfd)[shindex] = hdr2;
|
||||
@@ -1924,34 +1969,40 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
target_sect->use_rela_p = 1;
|
||||
}
|
||||
abfd->flags |= HAS_RELOC;
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
case SHT_GNU_verdef:
|
||||
elf_dynverdef (abfd) = shindex;
|
||||
elf_tdata (abfd)->dynverdef_hdr = *hdr;
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_GNU_versym:
|
||||
if (hdr->sh_entsize != sizeof (Elf_External_Versym))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
elf_dynversym (abfd) = shindex;
|
||||
elf_tdata (abfd)->dynversym_hdr = *hdr;
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_GNU_verneed:
|
||||
elf_dynverref (abfd) = shindex;
|
||||
elf_tdata (abfd)->dynverref_hdr = *hdr;
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
|
||||
case SHT_SHLIB:
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
case SHT_GROUP:
|
||||
if (! IS_VALID_GROUP_SECTION_HEADER (hdr, GRP_ENTRY_SIZE))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
+
|
||||
if (hdr->contents != NULL)
|
||||
{
|
||||
Elf_Internal_Group *idx = (Elf_Internal_Group *) hdr->contents;
|
||||
@@ -1977,7 +2028,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
}
|
||||
}
|
||||
}
|
||||
- break;
|
||||
+ goto success;
|
||||
|
||||
default:
|
||||
/* Possibly an attributes section. */
|
||||
@@ -1985,14 +2036,14 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
|| hdr->sh_type == bed->obj_attrs_section_type)
|
||||
{
|
||||
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
_bfd_elf_parse_attributes (abfd, hdr);
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
}
|
||||
|
||||
/* Check for any processor-specific section types. */
|
||||
if (bed->elf_backend_section_from_shdr (abfd, hdr, name, shindex))
|
||||
- return TRUE;
|
||||
+ goto success;
|
||||
|
||||
if (hdr->sh_type >= SHT_LOUSER && hdr->sh_type <= SHT_HIUSER)
|
||||
{
|
||||
@@ -2004,9 +2055,12 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
"specific section `%s' [0x%8x]"),
|
||||
abfd, name, hdr->sh_type);
|
||||
else
|
||||
- /* Allow sections reserved for applications. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
- shindex);
|
||||
+ {
|
||||
+ /* Allow sections reserved for applications. */
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name,
|
||||
+ shindex);
|
||||
+ goto success;
|
||||
+ }
|
||||
}
|
||||
else if (hdr->sh_type >= SHT_LOPROC
|
||||
&& hdr->sh_type <= SHT_HIPROC)
|
||||
@@ -2027,8 +2081,11 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
"`%s' [0x%8x]"),
|
||||
abfd, name, hdr->sh_type);
|
||||
else
|
||||
- /* Otherwise it should be processed. */
|
||||
- return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ {
|
||||
+ /* Otherwise it should be processed. */
|
||||
+ ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
|
||||
+ goto success;
|
||||
+ }
|
||||
}
|
||||
else
|
||||
/* FIXME: We should handle this section. */
|
||||
@@ -2036,10 +2093,17 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
(_("%B: don't know how to handle section `%s' [0x%8x]"),
|
||||
abfd, name, hdr->sh_type);
|
||||
|
||||
- return FALSE;
|
||||
+ goto fail;
|
||||
}
|
||||
|
||||
- return TRUE;
|
||||
+ fail:
|
||||
+ ret = FALSE;
|
||||
+ success:
|
||||
+ if (sections_being_created)
|
||||
+ sections_being_created [shindex] = FALSE;
|
||||
+ if (-- nesting == 0)
|
||||
+ sections_being_created = NULL;
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
/* Return the local symbol specified by ABFD, R_SYMNDX. */
|
||||
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
|
||||
index 987be40..c7d6067 100644
|
||||
--- a/bfd/peXXigen.c
|
||||
+++ b/bfd/peXXigen.c
|
||||
@@ -1705,7 +1705,12 @@ pe_print_edata (bfd * abfd, void * vfile)
|
||||
_("\nExport Address Table -- Ordinal Base %ld\n"),
|
||||
edt.base);
|
||||
|
||||
- for (i = 0; i < edt.num_functions; ++i)
|
||||
+ /* PR 17512: Handle corrupt PE binaries. */
|
||||
+ if (edt.eat_addr + (edt.num_functions * 4) - adj >= datasize)
|
||||
+ fprintf (file, _("\tInvalid Export Address Table rva (0x%lx) or entry count (0x%lx)\n"),
|
||||
+ (long) edt.eat_addr,
|
||||
+ (long) edt.num_functions);
|
||||
+ else for (i = 0; i < edt.num_functions; ++i)
|
||||
{
|
||||
bfd_vma eat_member = bfd_get_32 (abfd,
|
||||
data + edt.eat_addr + (i * 4) - adj);
|
||||
@@ -1741,7 +1746,16 @@ pe_print_edata (bfd * abfd, void * vfile)
|
||||
fprintf (file,
|
||||
_("\n[Ordinal/Name Pointer] Table\n"));
|
||||
|
||||
- for (i = 0; i < edt.num_names; ++i)
|
||||
+ /* PR 17512: Handle corrupt PE binaries. */
|
||||
+ if (edt.npt_addr + (edt.num_names * 4) - adj >= datasize)
|
||||
+ fprintf (file, _("\tInvalid Name Pointer Table rva (0x%lx) or entry count (0x%lx)\n"),
|
||||
+ (long) edt.npt_addr,
|
||||
+ (long) edt.num_names);
|
||||
+ else if (edt.ot_addr + (edt.num_names * 2) - adj >= datasize)
|
||||
+ fprintf (file, _("\tInvalid Ordinal Table rva (0x%lx) or entry count (0x%lx)\n"),
|
||||
+ (long) edt.ot_addr,
|
||||
+ (long) edt.num_names);
|
||||
+ else for (i = 0; i < edt.num_names; ++i)
|
||||
{
|
||||
bfd_vma name_ptr = bfd_get_32 (abfd,
|
||||
data +
|
||||
diff --git a/bfd/elf.c b/bfd/elf.c
|
||||
index 949221f..b5fc84b 100644
|
||||
--- a/bfd/elf.c
|
||||
+++ b/bfd/elf.c
|
||||
@@ -1580,6 +1580,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
const char *name;
|
||||
bfd_boolean ret = TRUE;
|
||||
static bfd_boolean * sections_being_created = NULL;
|
||||
+ static bfd * sections_being_created_abfd = NULL;
|
||||
static unsigned int nesting = 0;
|
||||
|
||||
if (shindex >= elf_numsections (abfd))
|
||||
@@ -1592,13 +1593,19 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
loop. Detect this here, by refusing to load a section that we are
|
||||
already in the process of loading. We only trigger this test if
|
||||
we have nested at least three sections deep as normal ELF binaries
|
||||
- can expect to recurse at least once. */
|
||||
-
|
||||
+ can expect to recurse at least once.
|
||||
+
|
||||
+ FIXME: It would be better if this array was attached to the bfd,
|
||||
+ rather than being held in a static pointer. */
|
||||
+
|
||||
+ if (sections_being_created_abfd != abfd)
|
||||
+ sections_being_created = NULL;
|
||||
if (sections_being_created == NULL)
|
||||
{
|
||||
/* FIXME: It would be more efficient to attach this array to the bfd somehow. */
|
||||
sections_being_created = (bfd_boolean *)
|
||||
bfd_zalloc (abfd, elf_numsections (abfd) * sizeof (bfd_boolean));
|
||||
+ sections_being_created_abfd = abfd;
|
||||
}
|
||||
if (sections_being_created [shindex])
|
||||
{
|
||||
@@ -2102,7 +2109,10 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
|
||||
if (sections_being_created)
|
||||
sections_being_created [shindex] = FALSE;
|
||||
if (-- nesting == 0)
|
||||
- sections_being_created = NULL;
|
||||
+ {
|
||||
+ sections_being_created = NULL;
|
||||
+ sections_being_created_abfd = abfd;
|
||||
+ }
|
||||
return ret;
|
||||
}
|
||||
|
||||
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
|
||||
index 6129085..1a5cb31 100644
|
||||
--- a/bfd/peXXigen.c
|
||||
+++ b/bfd/peXXigen.c
|
||||
@@ -1611,6 +1611,15 @@ pe_print_edata (bfd * abfd, void * vfile)
|
||||
}
|
||||
}
|
||||
|
||||
+ /* PR 17512: Handle corrupt PE binaries. */
|
||||
+ if (datasize < 36)
|
||||
+ {
|
||||
+ fprintf (file,
|
||||
+ _("\nThere is an export table in %s, but it is too small (%d)\n"),
|
||||
+ section->name, (int) datasize);
|
||||
+ return TRUE;
|
||||
+ }
|
||||
+
|
||||
fprintf (file, _("\nThere is an export table in %s at 0x%lx\n"),
|
||||
section->name, (unsigned long) addr);
|
||||
|
||||
--
|
||||
1.7.1
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
diff --git a/bfd/ihex.c b/bfd/ihex.c
|
||||
index 8d3590d..9b3b813 100644
|
||||
--- a/bfd/ihex.c
|
||||
+++ b/bfd/ihex.c
|
||||
@@ -321,7 +321,7 @@ ihex_scan (bfd *abfd)
|
||||
{
|
||||
if (! ISHEX (buf[i]))
|
||||
{
|
||||
- ihex_bad_byte (abfd, lineno, hdr[i], error);
|
||||
+ ihex_bad_byte (abfd, lineno, buf[i], error);
|
||||
goto error_return;
|
||||
}
|
||||
}
|
||||
--
|
||||
1.7.1
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
diff --git a/bfd/elf.c b/bfd/elf.c
|
||||
index 3fcf2d8..949221f 100644
|
||||
--- a/bfd/elf.c
|
||||
+++ b/bfd/elf.c
|
||||
@@ -629,7 +629,7 @@ setup_group (bfd *abfd, Elf_Internal_Shdr *hdr, asection *newsect)
|
||||
memset (shdr->contents, 0, amt);
|
||||
continue;
|
||||
}
|
||||
-
|
||||
+
|
||||
/* Translate raw contents, a flag word followed by an
|
||||
array of elf section indices all in target byte order,
|
||||
to the flag word followed by an array of elf section
|
||||
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
|
||||
index c7d6067..6129085 100644
|
||||
--- a/bfd/peXXigen.c
|
||||
+++ b/bfd/peXXigen.c
|
||||
@@ -515,7 +515,6 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd,
|
||||
a->NumberOfRvaAndSizes = 0;
|
||||
}
|
||||
|
||||
-
|
||||
for (idx = 0; idx < a->NumberOfRvaAndSizes; idx++)
|
||||
{
|
||||
/* If data directory is empty, rva also should be 0. */
|
||||
diff --git a/bfd/srec.c b/bfd/srec.c
|
||||
index 9ed2080..5f9a546 100644
|
||||
--- a/bfd/srec.c
|
||||
+++ b/bfd/srec.c
|
||||
@@ -246,7 +246,7 @@ srec_bad_byte (bfd *abfd,
|
||||
}
|
||||
else
|
||||
{
|
||||
- char buf[10];
|
||||
+ char buf[40];
|
||||
|
||||
if (! ISPRINT (c))
|
||||
sprintf (buf, "\\%03o", (unsigned int) c);
|
||||
@@ -452,7 +452,7 @@ srec_scan (bfd *abfd)
|
||||
case 'S':
|
||||
{
|
||||
file_ptr pos;
|
||||
- char hdr[3];
|
||||
+ unsigned char hdr[3];
|
||||
unsigned int bytes, min_bytes;
|
||||
bfd_vma address;
|
||||
bfd_byte *data;
|
||||
--
|
||||
1.7.1
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
diff --git a/binutils/ar.c b/binutils/ar.c
|
||||
index ebd9528..117826d 100644
|
||||
--- a/binutils/ar.c
|
||||
+++ b/binutils/ar.c
|
||||
@@ -1034,6 +1034,15 @@ extract_file (bfd *abfd)
|
||||
bfd_size_type size;
|
||||
struct stat buf;
|
||||
|
||||
+ /* PR binutils/17533: Do not allow directory traversal
|
||||
+ outside of the current directory tree. */
|
||||
+ if (! is_valid_archive_path (bfd_get_filename (abfd)))
|
||||
+ {
|
||||
+ non_fatal (_("illegal pathname found in archive member: %s"),
|
||||
+ bfd_get_filename (abfd));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
if (bfd_stat_arch_elt (abfd, &buf) != 0)
|
||||
/* xgettext:c-format */
|
||||
fatal (_("internal stat error on %s"), bfd_get_filename (abfd));
|
||||
diff --git a/binutils/bucomm.c b/binutils/bucomm.c
|
||||
index fd73070..b8deff5 100644
|
||||
--- a/binutils/bucomm.c
|
||||
+++ b/binutils/bucomm.c
|
||||
@@ -624,3 +624,29 @@ bfd_get_archive_filename (const bfd *abfd)
|
||||
bfd_get_filename (abfd));
|
||||
return buf;
|
||||
}
|
||||
+
|
||||
+/* Returns TRUE iff PATHNAME, a filename of an archive member,
|
||||
+ is valid for writing. For security reasons absolute paths
|
||||
+ and paths containing /../ are not allowed. See PR 17533. */
|
||||
+
|
||||
+bfd_boolean
|
||||
+is_valid_archive_path (char const * pathname)
|
||||
+{
|
||||
+ const char * n = pathname;
|
||||
+
|
||||
+ if (IS_ABSOLUTE_PATH (n))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ while (*n)
|
||||
+ {
|
||||
+ if (*n == '.' && *++n == '.' && ( ! *++n || IS_DIR_SEPARATOR (*n)))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ while (*n && ! IS_DIR_SEPARATOR (*n))
|
||||
+ n++;
|
||||
+ while (IS_DIR_SEPARATOR (*n))
|
||||
+ n++;
|
||||
+ }
|
||||
+
|
||||
+ return TRUE;
|
||||
+}
|
||||
diff --git a/binutils/bucomm.h b/binutils/bucomm.h
|
||||
index a93c378..a71a8fb 100644
|
||||
--- a/binutils/bucomm.h
|
||||
+++ b/binutils/bucomm.h
|
||||
@@ -21,6 +21,8 @@
|
||||
#ifndef _BUCOMM_H
|
||||
#define _BUCOMM_H
|
||||
|
||||
+/* In bucomm.c. */
|
||||
+
|
||||
/* Return the filename in a static buffer. */
|
||||
const char *bfd_get_archive_filename (const bfd *);
|
||||
|
||||
@@ -56,20 +58,22 @@ bfd_vma parse_vma (const char *, const char *);
|
||||
|
||||
off_t get_file_size (const char *);
|
||||
|
||||
+bfd_boolean is_valid_archive_path (char const *);
|
||||
+
|
||||
extern char *program_name;
|
||||
|
||||
-/* filemode.c */
|
||||
+/* In filemode.c. */
|
||||
void mode_string (unsigned long, char *);
|
||||
|
||||
-/* version.c */
|
||||
+/* In version.c. */
|
||||
extern void print_version (const char *);
|
||||
|
||||
-/* rename.c */
|
||||
+/* In rename.c. */
|
||||
extern void set_times (const char *, const struct stat *);
|
||||
|
||||
extern int smart_rename (const char *, const char *, int);
|
||||
|
||||
-/* libiberty. */
|
||||
+/* In libiberty. */
|
||||
void *xmalloc (size_t);
|
||||
|
||||
void *xrealloc (void *, size_t);
|
||||
diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
|
||||
index eee77b1..39eb1d2 100644
|
||||
--- a/binutils/doc/binutils.texi
|
||||
+++ b/binutils/doc/binutils.texi
|
||||
@@ -234,7 +234,8 @@ a normal archive. Instead the elements of the first archive are added
|
||||
individually to the second archive.
|
||||
|
||||
The paths to the elements of the archive are stored relative to the
|
||||
-archive itself.
|
||||
+archive itself. For security reasons absolute paths and paths with a
|
||||
+@code{/../} component are not allowed.
|
||||
|
||||
@cindex compatibility, @command{ar}
|
||||
@cindex @command{ar} compatibility
|
||||
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
|
||||
index 3b353ad..8454bc6 100644
|
||||
--- a/binutils/objcopy.c
|
||||
+++ b/binutils/objcopy.c
|
||||
@@ -2295,6 +2295,12 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target,
|
||||
bfd_boolean del = TRUE;
|
||||
bfd_boolean ok_object;
|
||||
|
||||
+ /* PR binutils/17533: Do not allow directory traversal
|
||||
+ outside of the current directory tree by archive members. */
|
||||
+ if (! is_valid_archive_path (bfd_get_filename (this_element)))
|
||||
+ fatal (_("illegal pathname found in archive member: %s"),
|
||||
+ bfd_get_filename (this_element));
|
||||
+
|
||||
/* Create an output file for this member. */
|
||||
output_name = concat (dir, "/",
|
||||
bfd_get_filename (this_element), (char *) 0);
|
||||
--
|
||||
1.7.1
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
diff --git a/bfd/archive.c b/bfd/archive.c
|
||||
index 40a3395..b905213 100644
|
||||
--- a/bfd/archive.c
|
||||
+++ b/bfd/archive.c
|
||||
@@ -1293,6 +1293,9 @@ _bfd_slurp_extended_name_table (bfd *abfd)
|
||||
amt = namedata->parsed_size;
|
||||
if (amt + 1 == 0)
|
||||
goto byebye;
|
||||
+ /* PR binutils/17533: A corrupt archive can contain an invalid size. */
|
||||
+ if (amt > (bfd_size_type) bfd_get_size (abfd))
|
||||
+ goto byebye;
|
||||
|
||||
bfd_ardata (abfd)->extended_names_size = amt;
|
||||
bfd_ardata (abfd)->extended_names = (char *) bfd_zalloc (abfd, amt + 1);
|
||||
@@ -1300,6 +1303,8 @@ _bfd_slurp_extended_name_table (bfd *abfd)
|
||||
{
|
||||
byebye:
|
||||
free (namedata);
|
||||
+ bfd_ardata (abfd)->extended_names = NULL;
|
||||
+ bfd_ardata (abfd)->extended_names_size = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1308,7 +1313,6 @@ _bfd_slurp_extended_name_table (bfd *abfd)
|
||||
if (bfd_get_error () != bfd_error_system_call)
|
||||
bfd_set_error (bfd_error_malformed_archive);
|
||||
bfd_release (abfd, (bfd_ardata (abfd)->extended_names));
|
||||
- bfd_ardata (abfd)->extended_names = NULL;
|
||||
goto byebye;
|
||||
}
|
||||
|
||||
@@ -1316,11 +1320,12 @@ _bfd_slurp_extended_name_table (bfd *abfd)
|
||||
text, the entries in the list are newline-padded, not null
|
||||
padded. In SVR4-style archives, the names also have a
|
||||
trailing '/'. DOS/NT created archive often have \ in them
|
||||
- We'll fix all problems here.. */
|
||||
+ We'll fix all problems here. */
|
||||
{
|
||||
char *ext_names = bfd_ardata (abfd)->extended_names;
|
||||
char *temp = ext_names;
|
||||
char *limit = temp + namedata->parsed_size;
|
||||
+
|
||||
for (; temp < limit; ++temp)
|
||||
{
|
||||
if (*temp == ARFMAG[1])
|
||||
--
|
||||
1.7.1
|
||||
|
|
@ -1,229 +0,0 @@
|
|||
diff --git a/gold/configure b/gold/configure
|
||||
index 2257324..f61307b 100755
|
||||
--- a/gold/configure
|
||||
+++ b/gold/configure
|
||||
@@ -594,10 +594,12 @@ LTLIBOBJS
|
||||
MAINT
|
||||
MAINTAINER_MODE_FALSE
|
||||
MAINTAINER_MODE_TRUE
|
||||
-HAVE_PUBNAMES_FALSE
|
||||
-HAVE_PUBNAMES_TRUE
|
||||
DLOPEN_LIBS
|
||||
CXXCPP
|
||||
+HAVE_NO_USE_LINKER_PLUGIN_FALSE
|
||||
+HAVE_NO_USE_LINKER_PLUGIN_TRUE
|
||||
+HAVE_PUBNAMES_FALSE
|
||||
+HAVE_PUBNAMES_TRUE
|
||||
HAVE_ZLIB_FALSE
|
||||
HAVE_ZLIB_TRUE
|
||||
LIBOBJS
|
||||
@@ -6991,6 +6993,50 @@ cat >>confdefs.h <<_ACEOF
|
||||
_ACEOF
|
||||
|
||||
|
||||
+save_CFLAGS="$CFLAGS"
|
||||
+CFLAGS="$CFLAGS -Werror -gpubnames"
|
||||
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
+/* end confdefs.h. */
|
||||
+int i;
|
||||
+_ACEOF
|
||||
+if ac_fn_c_try_compile "$LINENO"; then :
|
||||
+ have_pubnames=yes
|
||||
+else
|
||||
+ have_pubnames=no
|
||||
+fi
|
||||
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
+CFLAGS="$save_CFLAGS"
|
||||
+ if test "$have_pubnames" = "yes"; then
|
||||
+ HAVE_PUBNAMES_TRUE=
|
||||
+ HAVE_PUBNAMES_FALSE='#'
|
||||
+else
|
||||
+ HAVE_PUBNAMES_TRUE='#'
|
||||
+ HAVE_PUBNAMES_FALSE=
|
||||
+fi
|
||||
+
|
||||
+
|
||||
+save_CFLAGS="$CFLAGS"
|
||||
+CFLAGS="$CFLAGS -Werror -fno-use-linker-plugin"
|
||||
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
+/* end confdefs.h. */
|
||||
+int i;
|
||||
+_ACEOF
|
||||
+if ac_fn_c_try_compile "$LINENO"; then :
|
||||
+ have_no_use_linker_plugin=yes
|
||||
+else
|
||||
+ have_no_use_linker_plugin=no
|
||||
+fi
|
||||
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
+CFLAGS="$save_CFLAGS"
|
||||
+ if test "$have_no_use_linker_plugin" = "yes"; then
|
||||
+ HAVE_NO_USE_LINKER_PLUGIN_TRUE=
|
||||
+ HAVE_NO_USE_LINKER_PLUGIN_FALSE='#'
|
||||
+else
|
||||
+ HAVE_NO_USE_LINKER_PLUGIN_TRUE='#'
|
||||
+ HAVE_NO_USE_LINKER_PLUGIN_FALSE=
|
||||
+fi
|
||||
+
|
||||
+
|
||||
ac_ext=cpp
|
||||
ac_cpp='$CXXCPP $CPPFLAGS'
|
||||
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
|
||||
@@ -7515,28 +7561,6 @@ $as_echo "#define HAVE_STAT_ST_MTIM 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
-save_CXXFLAGS="$CXXFLAGS"
|
||||
-CXXFLAGS="$CXXFLAGS -Werror -gpubnames"
|
||||
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
-/* end confdefs.h. */
|
||||
-int i;
|
||||
-_ACEOF
|
||||
-if ac_fn_cxx_try_compile "$LINENO"; then :
|
||||
- have_pubnames=yes
|
||||
-else
|
||||
- have_pubnames=no
|
||||
-fi
|
||||
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
-CXXFLAGS="$save_CXXFLAGS"
|
||||
- if test "$have_pubnames" = "yes"; then
|
||||
- HAVE_PUBNAMES_TRUE=
|
||||
- HAVE_PUBNAMES_FALSE='#'
|
||||
-else
|
||||
- HAVE_PUBNAMES_TRUE='#'
|
||||
- HAVE_PUBNAMES_FALSE=
|
||||
-fi
|
||||
-
|
||||
-
|
||||
ac_ext=c
|
||||
ac_cpp='$CPP $CPPFLAGS'
|
||||
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
|
||||
@@ -7837,6 +7861,10 @@ if test -z "${HAVE_PUBNAMES_TRUE}" && test -z "${HAVE_PUBNAMES_FALSE}"; then
|
||||
as_fn_error "conditional \"HAVE_PUBNAMES\" was never defined.
|
||||
Usually this means the macro was only invoked conditionally." "$LINENO" 5
|
||||
fi
|
||||
+if test -z "${HAVE_NO_USE_LINKER_PLUGIN_TRUE}" && test -z "${HAVE_NO_USE_LINKER_PLUGIN_FALSE}"; then
|
||||
+ as_fn_error "conditional \"HAVE_NO_USE_LINKER_PLUGIN\" was never defined.
|
||||
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
|
||||
+fi
|
||||
if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
|
||||
as_fn_error "conditional \"MAINTAINER_MODE\" was never defined.
|
||||
Usually this means the macro was only invoked conditionally." "$LINENO" 5
|
||||
diff --git a/gold/configure.ac b/gold/configure.ac
|
||||
index 803cf46..7ad7302 100644
|
||||
--- a/gold/configure.ac
|
||||
+++ b/gold/configure.ac
|
||||
@@ -520,6 +520,25 @@ dnl multiple declarations of functions like basename when compiling
|
||||
dnl with C++.
|
||||
AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp])
|
||||
|
||||
+dnl Check if gcc supports the -gpubnames option.
|
||||
+dnl Use -Werror in case of compilers that make unknown -g options warnings.
|
||||
+dnl They would pass the test here, but fail in actual use when $WARN_CFLAGS
|
||||
+dnl gets set later by default Autoconf magic to include -Werror. (We are
|
||||
+dnl assuming here that there is no compiler that groks -gpubnames
|
||||
+dnl but does not grok -Werror.)
|
||||
+save_CFLAGS="$CFLAGS"
|
||||
+CFLAGS="$CFLAGS -Werror -gpubnames"
|
||||
+AC_COMPILE_IFELSE([int i;], [have_pubnames=yes], [have_pubnames=no])
|
||||
+CFLAGS="$save_CFLAGS"
|
||||
+AM_CONDITIONAL(HAVE_PUBNAMES, test "$have_pubnames" = "yes")
|
||||
+
|
||||
+dnl Check if gcc supports the -fno-use-linker-plugin option.
|
||||
+save_CFLAGS="$CFLAGS"
|
||||
+CFLAGS="$CFLAGS -Werror -fno-use-linker-plugin"
|
||||
+AC_COMPILE_IFELSE([int i;], [have_no_use_linker_plugin=yes], [have_no_use_linker_plugin=no])
|
||||
+CFLAGS="$save_CFLAGS"
|
||||
+AM_CONDITIONAL(HAVE_NO_USE_LINKER_PLUGIN, test "$have_no_use_linker_plugin" = "yes")
|
||||
+
|
||||
AC_LANG_PUSH(C++)
|
||||
|
||||
AC_CHECK_HEADERS(unordered_set unordered_map)
|
||||
@@ -601,18 +620,6 @@ if test "$gold_cv_stat_st_mtim" = "yes"; then
|
||||
[Define if struct stat has a field st_mtim with timespec for mtime])
|
||||
fi
|
||||
|
||||
-dnl Check if gcc supports the -gpubnames option.
|
||||
-dnl Use -Werror in case of compilers that make unknown -g options warnings.
|
||||
-dnl They would pass the test here, but fail in actual use when $WARN_CFLAGS
|
||||
-dnl gets set later by default Autoconf magic to include -Werror. (We are
|
||||
-dnl assuming here that there is no compiler that groks -gpubnames
|
||||
-dnl but does not grok -Werror.)
|
||||
-save_CXXFLAGS="$CXXFLAGS"
|
||||
-CXXFLAGS="$CXXFLAGS -Werror -gpubnames"
|
||||
-AC_COMPILE_IFELSE([int i;], [have_pubnames=yes], [have_pubnames=no])
|
||||
-CXXFLAGS="$save_CXXFLAGS"
|
||||
-AM_CONDITIONAL(HAVE_PUBNAMES, test "$have_pubnames" = "yes")
|
||||
-
|
||||
AC_LANG_POP(C++)
|
||||
|
||||
AC_CHECK_HEADERS(locale.h)
|
||||
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
|
||||
index aa41290..52cc05e 100644
|
||||
--- a/gold/testsuite/Makefile.am
|
||||
+++ b/gold/testsuite/Makefile.am
|
||||
@@ -19,18 +19,25 @@ AM_CPPFLAGS = \
|
||||
-DLOCALEDIR="\"$(datadir)/locale\"" \
|
||||
@INCINTL@
|
||||
|
||||
+# Some versions of GCC now automatically enable linker plugins,
|
||||
+# but we want to run our tests without GCC's plugins.
|
||||
+if HAVE_NO_USE_LINKER_PLUGIN
|
||||
+OPT_NO_PLUGINS = -fno-use-linker-plugin
|
||||
+endif
|
||||
+
|
||||
# COMPILE1, LINK1, CXXCOMPILE1, CXXLINK1 are renamed from COMPILE, LINK,
|
||||
# CXXCOMPILE and CXXLINK generated by automake 1.11.1. FIXME: they should
|
||||
# be updated if they are different from automake used by gold.
|
||||
COMPILE1 = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
-LINK1 = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
+LINK1 = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(OPT_NO_PLUGINS) \
|
||||
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
CXXCOMPILE1 = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
-CXXLINK1 = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
|
||||
- -o $@
|
||||
+CXXLINK1 = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(OPT_NO_PLUGINS) \
|
||||
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
-# Strip out -Wp,-D_FORTIFY_SOURCE=, which is rrelevant for the gold
|
||||
+# Strip out -Wp,-D_FORTIFY_SOURCE=, which is irrelevant for the gold
|
||||
# testsuite and incompatible with -O0 used in gold tests, from
|
||||
# COMPILE, LINK, CXXCOMPILE and CXXLINK.
|
||||
COMPILE = `echo $(COMPILE1) | sed -e 's/-Wp,-D_FORTIFY_SOURCE=[0-9[0-9]]*//'`
|
||||
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
|
||||
index 60c2c10..da0a338 100644
|
||||
--- a/gold/testsuite/Makefile.in
|
||||
+++ b/gold/testsuite/Makefile.in
|
||||
@@ -2096,21 +2096,27 @@ AM_CPPFLAGS = \
|
||||
@INCINTL@
|
||||
|
||||
|
||||
+# Some versions of GCC now automatically enable linker plugins,
|
||||
+# but we want to run our tests without GCC's plugins.
|
||||
+@HAVE_NO_USE_LINKER_PLUGIN_TRUE@OPT_NO_PLUGINS = -fno-use-linker-plugin
|
||||
+
|
||||
# COMPILE1, LINK1, CXXCOMPILE1, CXXLINK1 are renamed from COMPILE, LINK,
|
||||
# CXXCOMPILE and CXXLINK generated by automake 1.11.1. FIXME: they should
|
||||
# be updated if they are different from automake used by gold.
|
||||
COMPILE1 = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
|
||||
-LINK1 = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
+LINK1 = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(OPT_NO_PLUGINS) \
|
||||
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
+
|
||||
CXXCOMPILE1 = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
|
||||
-CXXLINK1 = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
|
||||
- -o $@
|
||||
+CXXLINK1 = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(OPT_NO_PLUGINS) \
|
||||
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
|
||||
-# Strip out -Wp,-D_FORTIFY_SOURCE=, which is rrelevant for the gold
|
||||
+# Strip out -Wp,-D_FORTIFY_SOURCE=, which is irrelevant for the gold
|
||||
# testsuite and incompatible with -O0 used in gold tests, from
|
||||
# COMPILE, LINK, CXXCOMPILE and CXXLINK.
|
||||
COMPILE = `echo $(COMPILE1) | sed -e 's/-Wp,-D_FORTIFY_SOURCE=[0-9[0-9]]*//'`
|
|
@ -1,78 +0,0 @@
|
|||
index c5249f0..69946de 100644
|
||||
--- a/ld/testsuite/ld-plugin/lto.exp
|
||||
+++ b/ld/testsuite/ld-plugin/lto.exp
|
||||
@@ -57,7 +57,7 @@ set lto_link_tests {
|
||||
"" "-O2"
|
||||
{lto-3c.c} {} "libdummy.a"}
|
||||
{"Build liblto-3.a"
|
||||
- "" "-flto"
|
||||
+ "" "-flto -ffat-lto-objects"
|
||||
{lto-3b.c} {} "liblto-3.a"}
|
||||
{"Build libdummy.a 5a"
|
||||
"" "-flto"
|
||||
@@ -111,7 +111,7 @@ set lto_link_tests {
|
||||
"" ""
|
||||
{pr12758a.s} {} "libdummy.a"}
|
||||
{"Build libpr12758.a"
|
||||
- "" "-flto -O2"
|
||||
+ "" "-flto -O2 -ffat-lto-objects"
|
||||
{pr12758b.c} {} "libpr12758.a"}
|
||||
{"PR ld/12758"
|
||||
"-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12758a.o -Wl,--start-group tmpdir/libpr12758.a -Wl,--end-group" ""
|
||||
@@ -120,13 +120,13 @@ set lto_link_tests {
|
||||
"" ""
|
||||
{pr12760a.c} {} "libdummy.a"}
|
||||
{"Build libpr12760.a"
|
||||
- "" "-flto -O2"
|
||||
+ "" "-flto -O2 -ffat-lto-objects"
|
||||
{pr12760b.c} {} "libpr12760.a"}
|
||||
{"PR ld/12760"
|
||||
"-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12760a.o -Wl,--start-group tmpdir/libpr12760.a -Wl,--end-group" ""
|
||||
{dummy.c} {} "pr12760.exe" "c" "warning: Bad bar"}
|
||||
{"Build libpr13183.a"
|
||||
- "-T" "-flto -O2"
|
||||
+ "-T" "-flto -O2 -ffat-lto-objects"
|
||||
{pr13183a.c} {} "libpr13183.a"}
|
||||
{"Build libdummy.a PR ld/13183"
|
||||
"" "-flto -O2"
|
||||
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
|
||||
index 8df42ae..175449a 100644
|
||||
--- a/ld/testsuite/lib/ld-lib.exp
|
||||
+++ b/ld/testsuite/lib/ld-lib.exp
|
||||
@@ -1643,7 +1643,7 @@ proc check_lto_available { } {
|
||||
set f [open $src "w"]
|
||||
puts $f ""
|
||||
close $f
|
||||
- set status [remote_exec host $CC "-shared -B[pwd]/tmpdir/ld/ -flto -fuse-linker-plugin $src -o $output"]
|
||||
+ set status [remote_exec host $CC "-shared -B[pwd]/tmpdir/ld/ -flto -ffat-lto-objects -fuse-linker-plugin $src -o $output"]
|
||||
if { [lindex $status 0] == 0 } {
|
||||
set lto_available_saved 1
|
||||
} else {
|
||||
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
|
||||
index b14f13c..765d85f 100644
|
||||
--- a/ld/testsuite/ld-plugin/lto.exp
|
||||
+++ b/ld/testsuite/ld-plugin/lto.exp
|
||||
@@ -324,7 +324,20 @@ if { [is_elf_format] && [check_lto_shared_available] } {
|
||||
|
||||
set testname "Build liblto-11.a"
|
||||
remote_file host delete "tmpdir/liblto-11.a"
|
||||
-set catch_output [run_host_cmd "$ar" "rc tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"]
|
||||
+set plugin_names {
|
||||
+ liblto_plugin.so
|
||||
+ liblto_plugin-0.dll
|
||||
+ cyglto_plugin-0.dll
|
||||
+}
|
||||
+set plug_opt ""
|
||||
+foreach plug $plugin_names {
|
||||
+ set plug_so [run_host_cmd $CC "--print-prog-name $plug"]
|
||||
+ if { $plug_so ne $plug } then {
|
||||
+ set plug_opt "--plugin $plug_so"
|
||||
+ break
|
||||
+ }
|
||||
+}
|
||||
+set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"]
|
||||
if {![string match "" $catch_output]} {
|
||||
unresolved $testname
|
||||
restore_notify
|
||||
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
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 0000000..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.d
|
||||
@@ -2,6 +2,7 @@
|
||||
#ld: -e _start -T ehdr_start-missing.t
|
||||
#nm: -n
|
||||
#target: *-*-linux* *-*-gnu* *-*-nacl*
|
||||
+#xfail: frv-*-*
|
||||
|
||||
#...
|
||||
\s+[wU] __ehdr_start
|
||||
diff --git a/ld/testsuite/ld-elf/ehdr_start.d b/ld/testsuite/ld-elf/ehdr_start.d
|
||||
index 52e5b54..d538b66 100644
|
||||
--- a/ld/testsuite/ld-elf/ehdr_start.d
|
||||
+++ b/ld/testsuite/ld-elf/ehdr_start.d
|
||||
@@ -2,6 +2,7 @@
|
||||
#ld: -e _start
|
||||
#nm: -n
|
||||
#target: *-*-linux* *-*-gnu* *-*-nacl*
|
||||
+#xfail: frv-*-*
|
||||
|
||||
#...
|
||||
[0-9a-f]*000 [Adrt] __ehdr_start
|
||||
--
|
||||
1.7.1
|
||||
|
|
@ -1,310 +0,0 @@
|
|||
diff -cpr ../binutils-2.24.orig/binutils/config.in binutils/config.in
|
||||
*** ../binutils-2.24.orig/binutils/config.in 2014-10-31 11:50:20.455222877 +0000
|
||||
--- binutils/config.in 2014-10-31 11:59:05.021241036 +0000
|
||||
***************
|
||||
*** 18,23 ****
|
||||
--- 18,26 ----
|
||||
/* Should ar and ranlib use -D behavior by default? */
|
||||
#undef DEFAULT_AR_DETERMINISTIC
|
||||
|
||||
+ /* Should strings use -a behavior by default? */
|
||||
+ #undef DEFAULT_STRINGS_ALL
|
||||
+
|
||||
/* Define to 1 if translation of program messages to the user's native
|
||||
language is requested. */
|
||||
#undef ENABLE_NLS
|
||||
diff -cpr ../binutils-2.24.orig/binutils/configure binutils/configure
|
||||
*** ../binutils-2.24.orig/binutils/configure 2014-10-31 11:50:20.590223736 +0000
|
||||
--- binutils/configure 2014-10-31 12:01:46.570102643 +0000
|
||||
*************** with_gnu_ld
|
||||
*** 772,777 ****
|
||||
--- 772,778 ----
|
||||
enable_libtool_lock
|
||||
enable_targets
|
||||
enable_deterministic_archives
|
||||
+ enable_default_strings_all
|
||||
enable_werror
|
||||
enable_build_warnings
|
||||
enable_nls
|
||||
*************** Optional Features:
|
||||
*** 1421,1426 ****
|
||||
--- 1422,1429 ----
|
||||
--enable-targets alternative target configurations
|
||||
--enable-deterministic-archives
|
||||
ar and ranlib default to -D behavior
|
||||
+ --disable-default-strings-all
|
||||
+ strings defaults to --data behavior
|
||||
--enable-werror treat compile warnings as errors
|
||||
--enable-build-warnings enable build-time compiler warnings
|
||||
--disable-nls do not use Native Language Support
|
||||
*************** cat >>confdefs.h <<_ACEOF
|
||||
*** 11615,11620 ****
|
||||
--- 11594,11618 ----
|
||||
_ACEOF
|
||||
|
||||
|
||||
+ # Check whether --enable-default-strings-all was given.
|
||||
+ if test "${enable_default_strings_all+set}" = set; then :
|
||||
+ enableval=$enable_default_strings_all;
|
||||
+ if test "${enableval}" = no; then
|
||||
+ default_strings_all=0
|
||||
+ else
|
||||
+ default_strings_all=1
|
||||
+ fi
|
||||
+ else
|
||||
+ default_strings_all=1
|
||||
+ fi
|
||||
+
|
||||
+
|
||||
+
|
||||
+ cat >>confdefs.h <<_ACEOF
|
||||
+ #define DEFAULT_STRINGS_ALL $default_strings_all
|
||||
+ _ACEOF
|
||||
+
|
||||
+
|
||||
|
||||
GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
diff -cpr ../binutils-2.24.orig/binutils/configure.in binutils/configure.in
|
||||
*** ../binutils-2.24.orig/binutils/configure.in 2014-10-31 11:50:20.430222717 +0000
|
||||
--- binutils/configure.in 2014-10-31 12:00:48.092790946 +0000
|
||||
*************** fi], [default_ar_deterministic=0])
|
||||
*** 57,62 ****
|
||||
--- 57,74 ----
|
||||
AC_DEFINE_UNQUOTED(DEFAULT_AR_DETERMINISTIC, $default_ar_deterministic,
|
||||
[Should ar and ranlib use -D behavior by default?])
|
||||
|
||||
+ AC_ARG_ENABLE(default-strings-all,
|
||||
+ [AS_HELP_STRING([--disable-default-strings-all],
|
||||
+ [strings defaults to --data behavior])], [
|
||||
+ if test "${enableval}" = no; then
|
||||
+ default_strings_all=0
|
||||
+ else
|
||||
+ default_strings_all=1
|
||||
+ fi], [default_strings_all=1])
|
||||
+
|
||||
+ AC_DEFINE_UNQUOTED(DEFAULT_STRINGS_ALL, $default_strings_all,
|
||||
+ [Should strings use -a behavior by default?])
|
||||
+
|
||||
AM_BINUTILS_WARNINGS
|
||||
|
||||
AC_CONFIG_HEADERS(config.h:config.in)
|
||||
diff -cpr ../binutils-2.24.orig/binutils/doc/binutils.texi binutils/doc/binutils.texi
|
||||
*** ../binutils-2.24.orig/binutils/doc/binutils.texi 2014-10-31 11:50:20.579223666 +0000
|
||||
--- binutils/doc/binutils.texi 2014-10-31 11:59:23.052339164 +0000
|
||||
*************** strings [@option{-afovV}] [@option{-}@va
|
||||
*** 2653,2667 ****
|
||||
|
||||
@c man begin DESCRIPTION strings
|
||||
|
||||
! For each @var{file} given, @sc{gnu} @command{strings} prints the printable
|
||||
! character sequences that are at least 4 characters long (or the number
|
||||
! given with the options below) and are followed by an unprintable
|
||||
! character. By default, it only prints the strings from the initialized
|
||||
! and loaded sections of object files; for other types of files, it prints
|
||||
! the strings from the whole file.
|
||||
|
||||
! @command{strings} is mainly useful for determining the contents of non-text
|
||||
! files.
|
||||
|
||||
@c man end
|
||||
|
||||
--- 2653,2676 ----
|
||||
|
||||
@c man begin DESCRIPTION strings
|
||||
|
||||
! For each @var{file} given, @sc{gnu} @command{strings} prints the
|
||||
! printable character sequences that are at least 4 characters long (or
|
||||
! the number given with the options below) and are followed by an
|
||||
! unprintable character.
|
||||
!
|
||||
! Depending upon how the strings program was configured it will default
|
||||
! to either displaying all the printable sequences that it can find in
|
||||
! each file, or only those sequences that are in loadable, initialized
|
||||
! data sections. If the file type in unrecognizable, or if strings is
|
||||
! reading from stdin then it will always display all of the printable
|
||||
! sequences that it can find.
|
||||
!
|
||||
! For backwards compatibility any file that occurs after a command line
|
||||
! option of just @option{-} will also be scanned in full, regardless of
|
||||
! the presence of any @option{-d} option.
|
||||
|
||||
! @command{strings} is mainly useful for determining the contents of
|
||||
! non-text files.
|
||||
|
||||
@c man end
|
||||
|
||||
*************** files.
|
||||
*** 2671,2678 ****
|
||||
@item -a
|
||||
@itemx --all
|
||||
@itemx -
|
||||
! Do not scan only the initialized and loaded sections of object files;
|
||||
! scan the whole files.
|
||||
|
||||
@item -f
|
||||
@itemx --print-file-name
|
||||
--- 2680,2704 ----
|
||||
@item -a
|
||||
@itemx --all
|
||||
@itemx -
|
||||
! Scan the whole file, regardless of what sections it contains or
|
||||
! whether those sections are loaded or initialized. Normally this is
|
||||
! the default behaviour, but strings can be configured so that the
|
||||
! @option{-d} is the default instead.
|
||||
!
|
||||
! The @option{-} option is position dependent and forces strings to
|
||||
! perform full scans of any file that is mentioned after the @option{-}
|
||||
! on the command line, even if the @option{-d} option has been
|
||||
! specified.
|
||||
!
|
||||
! @item -d
|
||||
! @itemx --data
|
||||
! Only print strings from initialized, loaded data sections in the
|
||||
! file. This may reduce the amount of garbage in the output, but it
|
||||
! also exposes the strings program to any security flaws that may be
|
||||
! present in the BFD library used to scan and load sections. Strings
|
||||
! can be configured so that this option is the default behaviour. In
|
||||
! such cases the @option{-a} option can be used to avoid using the BFD
|
||||
! library and instead just print all of the strings found in the file.
|
||||
|
||||
@item -f
|
||||
@itemx --print-file-name
|
||||
diff -cpr ../binutils-2.24.orig/binutils/NEWS binutils/NEWS
|
||||
*** ../binutils-2.24.orig/binutils/NEWS 2014-10-31 11:50:20.338222131 +0000
|
||||
--- binutils/NEWS 2014-10-31 11:59:52.315493579 +0000
|
||||
***************
|
||||
*** 1,5 ****
|
||||
--- 1,10 ----
|
||||
-*- text -*-
|
||||
|
||||
+ * Add --data option to strings to only print strings in loadable, initialized
|
||||
+ data sections. Change the default behaviour to be --all, but add a new
|
||||
+ configure time option of --disable-default-strings-all to restore the old
|
||||
+ default behaviour.
|
||||
+
|
||||
Changes in 2.24:
|
||||
|
||||
* Objcopy now supports wildcard characters in command line options that take
|
||||
diff -cpr ../binutils-2.24.orig/binutils/strings.c binutils/strings.c
|
||||
*** ../binutils-2.24.orig/binutils/strings.c 2014-10-31 11:50:20.464222934 +0000
|
||||
--- binutils/strings.c 2014-10-31 12:01:33.901035485 +0000
|
||||
***************
|
||||
*** 23,29 ****
|
||||
Options:
|
||||
--all
|
||||
-a
|
||||
! - Do not scan only the initialized data section of object files.
|
||||
|
||||
--print-file-name
|
||||
-f Print the name of the file before each string.
|
||||
--- 23,32 ----
|
||||
Options:
|
||||
--all
|
||||
-a
|
||||
! - Scan each file in its entirety.
|
||||
!
|
||||
! --data
|
||||
! -d Scan only the initialized data section(s) of object files.
|
||||
|
||||
--print-file-name
|
||||
-f Print the name of the file before each string.
|
||||
*************** static int encoding_bytes;
|
||||
*** 107,112 ****
|
||||
--- 110,116 ----
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"all", no_argument, NULL, 'a'},
|
||||
+ {"data", no_argument, NULL, 'd'},
|
||||
{"print-file-name", no_argument, NULL, 'f'},
|
||||
{"bytes", required_argument, NULL, 'n'},
|
||||
{"radix", required_argument, NULL, 't'},
|
||||
*************** typedef struct
|
||||
*** 128,134 ****
|
||||
|
||||
static void strings_a_section (bfd *, asection *, void *);
|
||||
static bfd_boolean strings_object_file (const char *);
|
||||
! static bfd_boolean strings_file (char *file);
|
||||
static void print_strings (const char *, FILE *, file_ptr, int, int, char *);
|
||||
static void usage (FILE *, int);
|
||||
static long get_char (FILE *, file_ptr *, int *, char **);
|
||||
--- 132,138 ----
|
||||
|
||||
static void strings_a_section (bfd *, asection *, void *);
|
||||
static bfd_boolean strings_object_file (const char *);
|
||||
! static bfd_boolean strings_file (char *);
|
||||
static void print_strings (const char *, FILE *, file_ptr, int, int, char *);
|
||||
static void usage (FILE *, int);
|
||||
static long get_char (FILE *, file_ptr *, int *, char **);
|
||||
*************** main (int argc, char **argv)
|
||||
*** 158,168 ****
|
||||
string_min = 4;
|
||||
print_addresses = FALSE;
|
||||
print_filenames = FALSE;
|
||||
! datasection_only = TRUE;
|
||||
target = NULL;
|
||||
encoding = 's';
|
||||
|
||||
! while ((optc = getopt_long (argc, argv, "afhHn:ot:e:T:Vv0123456789",
|
||||
long_options, (int *) 0)) != EOF)
|
||||
{
|
||||
switch (optc)
|
||||
--- 162,175 ----
|
||||
string_min = 4;
|
||||
print_addresses = FALSE;
|
||||
print_filenames = FALSE;
|
||||
! if (DEFAULT_STRINGS_ALL)
|
||||
! datasection_only = FALSE;
|
||||
! else
|
||||
! datasection_only = TRUE;
|
||||
target = NULL;
|
||||
encoding = 's';
|
||||
|
||||
! while ((optc = getopt_long (argc, argv, "adfhHn:ot:e:T:Vv0123456789",
|
||||
long_options, (int *) 0)) != EOF)
|
||||
{
|
||||
switch (optc)
|
||||
*************** main (int argc, char **argv)
|
||||
*** 171,176 ****
|
||||
--- 178,187 ----
|
||||
datasection_only = FALSE;
|
||||
break;
|
||||
|
||||
+ case 'd':
|
||||
+ datasection_only = TRUE;
|
||||
+ break;
|
||||
+
|
||||
case 'f':
|
||||
print_filenames = TRUE;
|
||||
break;
|
||||
*************** usage (FILE *stream, int status)
|
||||
*** 635,642 ****
|
||||
{
|
||||
fprintf (stream, _("Usage: %s [option(s)] [file(s)]\n"), program_name);
|
||||
fprintf (stream, _(" Display printable strings in [file(s)] (stdin by default)\n"));
|
||||
! fprintf (stream, _(" The options are:\n\
|
||||
-a - --all Scan the entire file, not just the data section\n\
|
||||
-f --print-file-name Print the name of the file before each string\n\
|
||||
-n --bytes=[number] Locate & print any NUL-terminated sequence of at\n\
|
||||
-<number> least [number] characters (default 4).\n\
|
||||
--- 646,663 ----
|
||||
{
|
||||
fprintf (stream, _("Usage: %s [option(s)] [file(s)]\n"), program_name);
|
||||
fprintf (stream, _(" Display printable strings in [file(s)] (stdin by default)\n"));
|
||||
! fprintf (stream, _(" The options are:\n"));
|
||||
!
|
||||
! if (DEFAULT_STRINGS_ALL)
|
||||
! fprintf (stream, _("\
|
||||
! -a - --all Scan the entire file, not just the data section [default]\n\
|
||||
! -d --data Only scan the data sections in the file\n"));
|
||||
! else
|
||||
! fprintf (stream, _("\
|
||||
-a - --all Scan the entire file, not just the data section\n\
|
||||
+ -d --data Only scan the data sections in the file [default]\n"));
|
||||
+
|
||||
+ fprintf (stream, _("\
|
||||
-f --print-file-name Print the name of the file before each string\n\
|
||||
-n --bytes=[number] Locate & print any NUL-terminated sequence of at\n\
|
||||
-<number> least [number] characters (default 4).\n\
|
||||
|
||||
Only in binutils: strings.c.rej
|
Loading…
Reference in a new issue