Submitted By: Bruce Dubbs Date: 2016-02-16 Initial Package Version: 2.26 Origin: Upstream Description: Various patches including some security issues --- a/bfd/elf32-i386.c 2016-01-25 09:51:06.000000000 +0100 +++ b/bfd/elf32-i386.c 2016-02-16 14:47:00.724974874 +0100 @@ -4016,10 +4016,12 @@ /* It is relative to .got.plt section. */ if (h->got.offset != (bfd_vma) -1) - /* Use GOT entry. */ + /* Use GOT entry. Mask off the least significant bit in + GOT offset which may be set by R_386_GOT32 processing + below. */ relocation = (htab->elf.sgot->output_section->vma + htab->elf.sgot->output_offset - + h->got.offset - offplt); + + (h->got.offset & ~1) - offplt); else /* Use GOTPLT entry. */ relocation = (h->plt.offset / plt_entry_size - 1 + 3) * 4; --- a/bfd/elf64-x86-64.c 2016-01-25 09:51:06.000000000 +0100 +++ b/bfd/elf64-x86-64.c 2016-02-16 14:45:48.379450511 +0100 @@ -3190,35 +3190,43 @@ } else { - asection *asect; - bfd_size_type size; + bfd_signed_vma distance; /* At this point, we don't know the load addresses of TSEC section nor SEC section. We estimate the distrance between - SEC and TSEC. */ - size = 0; - for (asect = sec->output_section; - asect != NULL && asect != tsec->output_section; - asect = asect->next) + SEC and TSEC. We store the estimated distances in the + compressed_size field of the output section, which is only + used to decompress the compressed input section. */ + if (sec->output_section->compressed_size == 0) { - asection *i; - for (i = asect->output_section->map_head.s; - i != NULL; - i = i->map_head.s) + asection *asect; + bfd_size_type size = 0; + for (asect = link_info->output_bfd->sections; + asect != NULL; + asect = asect->next) { - size = align_power (size, i->alignment_power); - size += i->size; + asection *i; + for (i = asect->map_head.s; + i != NULL; + i = i->map_head.s) + { + size = align_power (size, i->alignment_power); + size += i->size; + } + asect->compressed_size = size; } } /* Don't convert GOTPCREL relocations if TSEC isn't placed after SEC. */ - if (asect == NULL) + distance = (tsec->output_section->compressed_size + - sec->output_section->compressed_size); + if (distance < 0) continue; /* Take PT_GNU_RELRO segment into account by adding maxpagesize. */ - if ((toff + size + maxpagesize - roff + 0x80000000) + if ((toff + distance + maxpagesize - roff + 0x80000000) > 0xffffffff) continue; } --- a/gas/config/tc-i386.c 2016-01-25 09:51:06.000000000 +0100 +++ b/gas/config/tc-i386.c 2016-02-16 14:46:28.557300128 +0100 @@ -552,6 +552,10 @@ specified explicitly. */ static int omit_lock_prefix = 0; +/* 1 if the assembler should generate relax relocations. */ +static int generate_relax_relocations + = DEFAULT_GENERATE_X86_RELAX_RELOCATIONS; + static enum check_kind { check_none = 0, @@ -7241,9 +7245,14 @@ /* Check for "call/jmp *mem", "mov mem, %reg", "test %reg, mem" and "binop mem, %reg" where binop is one of adc, add, and, cmp, or, sbb, sub, xor - instructions. */ - if ((i.rm.mode == 2 - || (i.rm.mode == 0 && i.rm.regmem == 5)) + instructions. Always generate R_386_GOT32X for + "sym*GOT" operand in 32-bit mode. */ + if ((generate_relax_relocations + || (!object_64bit + && i.rm.mode == 0 + && i.rm.regmem == 5)) + && (i.rm.mode == 2 + || (i.rm.mode == 0 && i.rm.regmem == 5)) && ((i.operands == 1 && i.tm.base_opcode == 0xff && (i.rm.reg == 2 || i.rm.reg == 4)) @@ -9616,6 +9625,7 @@ #define OPTION_MSHARED (OPTION_MD_BASE + 21) #define OPTION_MAMD64 (OPTION_MD_BASE + 22) #define OPTION_MINTEL64 (OPTION_MD_BASE + 23) +#define OPTION_MRELAX_RELOCATIONS (OPTION_MD_BASE + 24) struct option md_longopts[] = { @@ -9647,6 +9657,7 @@ {"mbig-obj", no_argument, NULL, OPTION_MBIG_OBJ}, #endif {"momit-lock-prefix", required_argument, NULL, OPTION_OMIT_LOCK_PREFIX}, + {"mrelax-relocations", required_argument, NULL, OPTION_MRELAX_RELOCATIONS}, {"mevexrcig", required_argument, NULL, OPTION_MEVEXRCIG}, {"mamd64", no_argument, NULL, OPTION_MAMD64}, {"mintel64", no_argument, NULL, OPTION_MINTEL64}, @@ -9966,6 +9977,15 @@ as_fatal (_("invalid -momit-lock-prefix= option: `%s'"), arg); break; + case OPTION_MRELAX_RELOCATIONS: + if (strcasecmp (arg, "yes") == 0) + generate_relax_relocations = 1; + else if (strcasecmp (arg, "no") == 0) + generate_relax_relocations = 0; + else + as_fatal (_("invalid -mrelax-relocations= option: `%s'"), arg); + break; + case OPTION_MAMD64: cpu_arch_flags.bitfield.cpuamd64 = 1; cpu_arch_flags.bitfield.cpuintel64 = 0; @@ -10146,6 +10166,9 @@ -momit-lock-prefix=[no|yes]\n\ strip all lock prefixes\n")); fprintf (stream, _("\ + -mrelax-relocations=[no|yes]\n\ + generate relax relocations\n")); + fprintf (stream, _("\ -mamd64 accept only AMD64 ISA\n")); fprintf (stream, _("\ -mintel64 accept only Intel64 ISA\n")); --- a/gas/config.in 2015-11-13 09:27:41.000000000 +0100 +++ b/gas/config.in 2016-02-16 14:46:28.556300107 +0100 @@ -39,6 +39,9 @@ /* Define if you want compressed debug sections by default. */ #undef DEFAULT_FLAG_COMPRESS_DEBUG +/* Define to 1 if you want to generate x86 relax relocations by default. */ +#undef DEFAULT_GENERATE_X86_RELAX_RELOCATIONS + /* Supported emulations. */ #undef EMULATIONS --- a/gas/configure 2016-01-25 09:54:08.000000000 +0100 +++ b/gas/configure 2016-02-16 14:46:28.560300191 +0100 @@ -765,6 +765,7 @@ enable_targets enable_checking enable_compressed_debug_sections +enable_x86_relax_relocations enable_werror enable_build_warnings enable_nls @@ -1415,6 +1416,8 @@ --enable-checking enable run-time checks --enable-compressed-debug-sections={all,gas,none} compress debug sections by default] + --enable-x86-relax-relocations + generate x86 relax relocations by default --enable-werror treat compile warnings as errors --enable-build-warnings enable build-time compiler warnings --disable-nls do not use Native Language Support @@ -10972,7 +10975,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10975 "configure" +#line 10978 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11078,7 +11081,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11081 "configure" +#line 11084 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11680,6 +11683,17 @@ esac fi +# PR gas/19520 +# Decide if x86 assembler should generate relax relocations. +ac_default_x86_relax_relocations=unset +# Provide a configure time option to override our default. +# Check whether --enable-x86_relax_relocations was given. +if test "${enable_x86_relax_relocations+set}" = set; then : + enableval=$enable_x86_relax_relocations; case "${enableval}" in + no) ac_default_x86_relax_relocations=0 ;; +esac +fi + using_cgen=no @@ -12085,6 +12099,17 @@ ;; + i386-*-solaris2 \ + | x86_64-*-solaris2 \ + | i386-*-solaris2.[0-9] \ + | i386-*-solaris2.1[01] \ + | x86_64-*-solaris2.1[01]) + if test ${this_target} = $target \ + && test ${ac_default_x86_relax_relocations} = unset; then + ac_default_x86_relax_relocations=0 + fi + ;; + i860-*-*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: GAS support for ${generic_target} is preliminary and a work in progress" >&5 $as_echo "$as_me: WARNING: GAS support for ${generic_target} is preliminary and a work in progress" >&2;} @@ -12505,7 +12530,16 @@ done -if test x$ac_default_compressed_debug_sections == xyes ; then +if test ${ac_default_x86_relax_relocations} = unset; then + ac_default_x86_relax_relocations=1 +fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_GENERATE_X86_RELAX_RELOCATIONS $ac_default_x86_relax_relocations +_ACEOF + + +if test x$ac_default_compressed_debug_sections = xyes ; then $as_echo "#define DEFAULT_FLAG_COMPRESS_DEBUG 1" >>confdefs.h --- a/gas/configure.ac 2016-01-25 09:51:06.000000000 +0100 +++ b/gas/configure.ac 2016-02-16 14:46:28.560300191 +0100 @@ -77,6 +77,17 @@ *) ac_default_compressed_debug_sections=unset ;; esac])dnl +# PR gas/19520 +# Decide if x86 assembler should generate relax relocations. +ac_default_x86_relax_relocations=unset +# Provide a configure time option to override our default. +AC_ARG_ENABLE(x86_relax_relocations, + AS_HELP_STRING([--enable-x86-relax-relocations], + [generate x86 relax relocations by default]), +[case "${enableval}" in + no) ac_default_x86_relax_relocations=0 ;; +esac])dnl + using_cgen=no AM_BINUTILS_WARNINGS @@ -168,6 +179,17 @@ AC_DEFINE(STRICTCOFF, 1, [Using strict COFF?]) ;; + i386-*-solaris2 \ + | x86_64-*-solaris2 \ + | i386-*-solaris2.[[0-9]] \ + | i386-*-solaris2.1[[01]] \ + | x86_64-*-solaris2.1[[01]]) + if test ${this_target} = $target \ + && test ${ac_default_x86_relax_relocations} = unset; then + ac_default_x86_relax_relocations=0 + fi + ;; + i860-*-*) AC_MSG_WARN(GAS support for ${generic_target} is preliminary and a work in progress) ;; @@ -549,7 +571,14 @@ done -if test x$ac_default_compressed_debug_sections == xyes ; then +if test ${ac_default_x86_relax_relocations} = unset; then + ac_default_x86_relax_relocations=1 +fi +AC_DEFINE_UNQUOTED(DEFAULT_GENERATE_X86_RELAX_RELOCATIONS, + $ac_default_x86_relax_relocations, + [Define to 1 if you want to generate x86 relax relocations by default.]) + +if test x$ac_default_compressed_debug_sections = xyes ; then AC_DEFINE(DEFAULT_FLAG_COMPRESS_DEBUG, 1, [Define if you want compressed debug sections by default.]) fi --- a/ld/configure 2016-01-25 09:54:11.000000000 +0100 +++ b/ld/configure 2016-02-16 14:43:18.377200561 +0100 @@ -17134,7 +17134,7 @@ fi done -if test x$ac_default_compressed_debug_sections == xyes ; then +if test x$ac_default_compressed_debug_sections = xyes ; then $as_echo "#define DEFAULT_FLAG_COMPRESS_DEBUG 1" >>confdefs.h --- a/ld/configure.ac 2015-11-13 09:27:42.000000000 +0100 +++ b/ld/configure.ac 2016-02-16 14:43:18.377200561 +0100 @@ -384,7 +384,7 @@ fi done -if test x$ac_default_compressed_debug_sections == xyes ; then +if test x$ac_default_compressed_debug_sections = xyes ; then AC_DEFINE(DEFAULT_FLAG_COMPRESS_DEBUG, 1, [Define if you want compressed debug sections by default.]) fi --- a/ld/lexsup.c 2015-11-13 09:27:42.000000000 +0100 +++ b/ld/lexsup.c 2016-02-16 14:47:32.165629964 +0100 @@ -1586,15 +1586,14 @@ /* We may have -Bsymbolic, -Bsymbolic-functions, --dynamic-list-data, --dynamic-list-cpp-new, --dynamic-list-cpp-typeinfo and --dynamic-list FILE. -Bsymbolic and -Bsymbolic-functions are - for shared libraries. -Bsymbolic overrides all others and vice - versa. */ + for PIC outputs. -Bsymbolic overrides all others and vice versa. */ switch (command_line.symbolic) { case symbolic_unset: break; case symbolic: - /* -Bsymbolic is for shared library only. */ - if (bfd_link_dll (&link_info)) + /* -Bsymbolic is for PIC output only. */ + if (bfd_link_pic (&link_info)) { link_info.symbolic = TRUE; /* Should we free the unused memory? */ @@ -1603,8 +1602,8 @@ } break; case symbolic_functions: - /* -Bsymbolic-functions is for shared library only. */ - if (bfd_link_dll (&link_info)) + /* -Bsymbolic-functions is for PIC output only. */ + if (bfd_link_pic (&link_info)) command_line.dynamic_list = dynamic_list_data; break; } --- a/opcodes/i386-dis.c 2016-01-25 09:51:06.000000000 +0100 +++ b/opcodes/i386-dis.c 2016-02-16 14:48:03.213272848 +0100 @@ -13644,7 +13644,7 @@ if (op_index[i] != -1 && op_riprel[i]) { (*info->fprintf_func) (info->stream, " # "); - (*info->print_address_func) ((bfd_vma) (start_pc + codep - start_codep + (*info->print_address_func) ((bfd_vma) (start_pc + (codep - start_codep) + op_address[op_index[i]]), info); break; } @@ -16158,7 +16158,7 @@ the displacement is added! */ mask = 0xffff; if ((prefixes & PREFIX_DATA) == 0) - segment = ((start_pc + codep - start_codep) + segment = ((start_pc + (codep - start_codep)) & ~((bfd_vma) 0xffff)); } if (address_mode != mode_64bit