From 71be1623505858052a5aaf76d72577c9d8d623a5 Mon Sep 17 00:00:00 2001 From: Nicholas Clifton Date: Mar 04 2010 16:51:03 +0000 Subject: - Do not set ELFOSABI_LINUX on binaries which just link to IFUNC using DSOs. (BZ 568941) - Copy the OSABI field in ELF headers, if set. (BZ 568921) --- diff --git a/binutils-2.20.51.0.2-copy-osabi.patch b/binutils-2.20.51.0.2-copy-osabi.patch new file mode 100644 index 0000000..c92a269 --- /dev/null +++ b/binutils-2.20.51.0.2-copy-osabi.patch @@ -0,0 +1,18 @@ +*** ../binutils-2.20.51.0.2.copy-patched/bfd/elf.c 2010-03-02 14:37:43.000000000 +0000 +--- bfd/elf.c 2010-03-02 14:39:27.000000000 +0000 +*************** _bfd_elf_copy_private_bfd_data (bfd *ibf +*** 1069,1074 **** +--- 1069,1081 ---- + /* Copy object attributes. */ + _bfd_elf_copy_obj_attributes (ibfd, obfd); + ++ /* If the input BFD has the OSABI field set and the ++ output BFD does not, then copy the value. */ ++ if (elf_elfheader (ibfd)->e_ident [EI_OSABI] != ELFOSABI_NONE ++ && elf_elfheader (obfd)->e_ident [EI_OSABI] == ELFOSABI_NONE) ++ elf_elfheader (obfd)->e_ident [EI_OSABI] = ++ elf_elfheader (ibfd)->e_ident [EI_OSABI]; ++ + return TRUE; + } + diff --git a/binutils-2.20.51.0.2-do-not-set-ifunc.patch b/binutils-2.20.51.0.2-do-not-set-ifunc.patch new file mode 100644 index 0000000..9e44d36 --- /dev/null +++ b/binutils-2.20.51.0.2-do-not-set-ifunc.patch @@ -0,0 +1,139 @@ +diff -rcp ../binutils-2.20.51.0.2.copy-patched/bfd/ChangeLog bfd/ChangeLog +*** ../binutils-2.20.51.0.2.copy-patched/bfd/ChangeLog 2010-03-04 09:15:22.000000000 +0000 +--- bfd/ChangeLog 2010-03-04 10:37:24.000000000 +0000 +*************** +*** 1,3 **** +--- 1,11 ---- ++ 2010-02-18 H.J. Lu ++ ++ * elf32-i386.c (elf_i386_add_symbol_hook): Don't set ++ has_ifunc_symbols if the symbol comes from a shared library. ++ * elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise. ++ * elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise. ++ * elf64-x86-64.c (elf64_x86_64_add_symbol_hook): Likewise. ++ + 2009-12-17 Alan Modra + + PR ld/11088 +diff -rcp ../binutils-2.20.51.0.2.copy-patched/bfd/elf32-i386.c bfd/elf32-i386.c +*** ../binutils-2.20.51.0.2.copy-patched/bfd/elf32-i386.c 2010-03-04 09:15:19.000000000 +0000 +--- bfd/elf32-i386.c 2010-03-04 10:37:39.000000000 +0000 +*************** elf_i386_add_symbol_hook (bfd * abfd ATT +*** 4613,4619 **** + asection ** secp ATTRIBUTE_UNUSED, + bfd_vma * valp ATTRIBUTE_UNUSED) + { +! if (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC) + elf_tdata (info->output_bfd)->has_ifunc_symbols = TRUE; + + return _bfd_elf_add_sharable_symbol (abfd, info, sym, namep, flagsp, +--- 4613,4620 ---- + asection ** secp ATTRIBUTE_UNUSED, + bfd_vma * valp ATTRIBUTE_UNUSED) + { +! if ((abfd->flags & DYNAMIC) == 0 +! && ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC) + elf_tdata (info->output_bfd)->has_ifunc_symbols = TRUE; + + return _bfd_elf_add_sharable_symbol (abfd, info, sym, namep, flagsp, +diff -rcp ../binutils-2.20.51.0.2.copy-patched/bfd/elf32-ppc.c bfd/elf32-ppc.c +*** ../binutils-2.20.51.0.2.copy-patched/bfd/elf32-ppc.c 2010-03-04 09:15:20.000000000 +0000 +--- bfd/elf32-ppc.c 2010-03-04 10:38:02.000000000 +0000 +*************** ppc_elf_add_symbol_hook (bfd *abfd, +*** 3133,3139 **** + *valp = sym->st_size; + } + +! if (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC) + elf_tdata (info->output_bfd)->has_ifunc_symbols = TRUE; + + return TRUE; +--- 3133,3140 ---- + *valp = sym->st_size; + } + +! if ((abfd->flags & DYNAMIC) == 0 +! && ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC) + elf_tdata (info->output_bfd)->has_ifunc_symbols = TRUE; + + return TRUE; +diff -rcp ../binutils-2.20.51.0.2.copy-patched/bfd/elf64-ppc.c bfd/elf64-ppc.c +*** ../binutils-2.20.51.0.2.copy-patched/bfd/elf64-ppc.c 2010-03-04 09:15:20.000000000 +0000 +--- bfd/elf64-ppc.c 2010-03-04 10:38:32.000000000 +0000 +*************** ppc64_elf_add_symbol_hook (bfd *ibfd ATT +*** 4531,4537 **** + bfd_vma *value ATTRIBUTE_UNUSED) + { + if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC) +! elf_tdata (info->output_bfd)->has_ifunc_symbols = TRUE; + else if (ELF_ST_TYPE (isym->st_info) == STT_FUNC) + ; + else if (*sec != NULL +--- 4531,4540 ---- + bfd_vma *value ATTRIBUTE_UNUSED) + { + if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC) +! { +! if ((ibfd->flags & DYNAMIC) == 0) +! elf_tdata (info->output_bfd)->has_ifunc_symbols = TRUE; +! } + else if (ELF_ST_TYPE (isym->st_info) == STT_FUNC) + ; + else if (*sec != NULL +diff -rcp ../binutils-2.20.51.0.2.copy-patched/bfd/elf64-x86-64.c bfd/elf64-x86-64.c +*** ../binutils-2.20.51.0.2.copy-patched/bfd/elf64-x86-64.c 2010-03-04 09:15:21.000000000 +0000 +--- bfd/elf64-x86-64.c 2010-03-04 10:38:50.000000000 +0000 +*************** elf64_x86_64_add_symbol_hook (bfd *abfd, +*** 4242,4248 **** + return TRUE; + } + +! if (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC) + elf_tdata (info->output_bfd)->has_ifunc_symbols = TRUE; + + return _bfd_elf_add_sharable_symbol (abfd, info, sym, namep, flagsp, +--- 4242,4249 ---- + return TRUE; + } + +! if ((abfd->flags & DYNAMIC) == 0 +! && ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC) + elf_tdata (info->output_bfd)->has_ifunc_symbols = TRUE; + + return _bfd_elf_add_sharable_symbol (abfd, info, sym, namep, flagsp, +diff -rcp ../binutils-2.20.51.0.2.copy-patched/ld/testsuite/ChangeLog ld/testsuite/ChangeLog +*** ../binutils-2.20.51.0.2.copy-patched/ld/testsuite/ChangeLog 2010-03-04 09:16:17.000000000 +0000 +--- ld/testsuite/ChangeLog 2010-03-04 11:43:29.000000000 +0000 +*************** +*** 1,3 **** +--- 1,8 ---- ++ 2010-02-18 H.J. Lu ++ ++ * ld-ifunc/ifunc.exp: Expect System V OSABI in dynamic ++ ifunc-using executable. ++ + 2009-10-09 H.J. Lu + + PR ld/10749 +diff -rcp ../binutils-2.20.51.0.2.copy-patched/ld/testsuite/ld-ifunc/ifunc.exp ld/testsuite/ld-ifunc/ifunc.exp +*** ../binutils-2.20.51.0.2.copy-patched/ld/testsuite/ld-ifunc/ifunc.exp 2010-03-04 09:16:08.000000000 +0000 +--- ld/testsuite/ld-ifunc/ifunc.exp 2010-03-04 11:44:15.000000000 +0000 +*************** if {! [check_osabi tmpdir/static_prog {U +*** 257,264 **** + fail "Static ifunc-using executable does not have an OS/ABI field of LINUX" + set fails [expr $fails + 1] + } +! if {! [check_osabi tmpdir/dynamic_prog {UNIX - Linux}]} { +! fail "Dynamic ifunc-using executable does not have an OS/ABI field of LINUX" + set fails [expr $fails + 1] + } + if {! [check_osabi tmpdir/static_nonifunc_prog {UNIX - System V}]} { +--- 257,264 ---- + fail "Static ifunc-using executable does not have an OS/ABI field of LINUX" + set fails [expr $fails + 1] + } +! if {! [check_osabi tmpdir/dynamic_prog {UNIX - System V}]} { +! fail "Dynamic ifunc-using executable does not have an OS/ABI field of System V" + set fails [expr $fails + 1] + } + if {! [check_osabi tmpdir/static_nonifunc_prog {UNIX - System V}]} { diff --git a/binutils.spec b/binutils.spec index 170de79..a4b47ed 100644 --- a/binutils.spec +++ b/binutils.spec @@ -17,7 +17,7 @@ Summary: A GNU collection of binary utilities Name: %{?cross}binutils%{?_with_debug:-debug} Version: 2.20.51.0.2 -Release: 15%{?dist} +Release: 17%{?dist} License: GPLv3+ Group: Development/Tools URL: http://sources.redhat.com/binutils @@ -37,6 +37,8 @@ Patch11: binutils-2.20.51.0.2-enable-gold.patch Patch12: binutils-2.20.51.0.2-gas-expr.patch Patch13: binutils-2.20.51.0.2-ppc-hidden-plt-relocs.patch Patch14: binutils-2.20.51.0.2-x86-hash-table.patch +Patch15: binutils-2.20.51.0.2-copy-osabi.patch +Patch16: binutils-2.20.51.0.2-do-not-set-ifunc.patch %define gold_arches %ix86 x86_64 @@ -143,6 +145,8 @@ libelf instead of BFD. %patch12 -p0 -b .gas-expr~ %patch13 -p0 -b .hidden-plt~ %patch14 -p0 -b .hash-table~ +%patch15 -p0 -b .copy-osabi~ +%patch16 -p0 -b .no-ifunc~ # We cannot run autotools as there is an exact requirement of autoconf-2.59. @@ -445,6 +449,12 @@ exit 0 %endif # %{isnative} %changelog +* Thu Mar 4 2010 Nick Clifton - 2.20.51.0.2-17 +- Do not set ELFOSABI_LINUX on binaries which just link to IFUNC using DSOs. (BZ 568941) + +* Tue Mar 2 2010 Nick Clifton - 2.20.51.0.2-16 +- Copy the OSABI field in ELF headers, if set. (BZ 568921) + * Fri Feb 12 2010 Nick Clifton - 2.20.51.0.2-15 - Create separate static and devel sub-packages. (BZ 556040)