Assemble this file .type a, @gnu_unique_object a: .long 0 .size a, .-a and the result will have on Linux/x86-64 a header which has an ELF header with no special OSABI marker. But STB_GNU_UNIQUE requires that. gas should also notice the STB_GNU_UNIQUE binding and change the OSABI to ELFOSABI_LINUX, just as ld does.
Created attachment 4149 [details] Set elf_osabi field when processing a gnu_unique_object
Hi Uli, The uploaded patch should do what you want. But - are you sure that the linker is setting the ELFOSABI field to ELFOSABI_LINUX for binaries containing STB_GBU_UNIQUE symbols ? In my tests it did not (and just left the field as ELFOSABI_NONE). Cheers Nick
Posted a patch for the ld part: http://sourceware.org/ml/binutils/2011-04/msg00107.html
CVSROOT: /cvs/src Module name: src Changes by: nickc@sourceware.org 2011-04-11 08:13:22 Modified files: bfd : ChangeLog elf-bfd.h elf.c elf32-arm.c elf32-i386.c elf32-ppc.c elf32-sparc.c elf64-ppc.c elf64-sparc.c elf64-x86-64.c ld/testsuite : ChangeLog Added files: ld/testsuite/ld-unique: unique.exp unique.s unique_empty.s unique_shared.s Log message: PR 10549 * elf-bfd.h (has_ifunc_symbols): Renamed to has_gnu_symbols. (has_gnu_symbols): Renamed from has_ifunc_symbols. * elf.c (_bfd_elf_set_osabi): Use new has_gnu_symbols name. * elf32-arm.c (elf32_arm_add_symbol_hook): Set has_gnu_symbols also if STB_GNU_UNIQUE symbol binding was seen. * elf32-i386.c (elf_i386_add_symbol_hook): Likewise. * elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise. * elf32-sparc.c (elf32_sparc_add_symbol_hook): Likewise. * elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise. * elf64-sparc.c (elf64_sparc_add_symbol_hook): Likewise. * elf64-x86-64.c (elf_x86_64_add_symbol_hook): Likewise. * ld-unique: New directory. * ld-unique/unique.exp: New file: Run the UNIQUE tests. * ld-unique/unique.s: New test file. * ld-unique/unique_empty.s: Likewise. * ld-unique/unique_shared.s: Likewise. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5300&r2=1.5301 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf-bfd.h.diff?cvsroot=src&r1=1.315&r2=1.316 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf.c.diff?cvsroot=src&r1=1.530&r2=1.531 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-arm.c.diff?cvsroot=src&r1=1.262&r2=1.263 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-i386.c.diff?cvsroot=src&r1=1.246&r2=1.247 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-ppc.c.diff?cvsroot=src&r1=1.292&r2=1.293 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-sparc.c.diff?cvsroot=src&r1=1.94&r2=1.95 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-ppc.c.diff?cvsroot=src&r1=1.346&r2=1.347 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-sparc.c.diff?cvsroot=src&r1=1.125&r2=1.126 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-x86-64.c.diff?cvsroot=src&r1=1.219&r2=1.220 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1384&r2=1.1385 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-unique/unique.exp.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-unique/unique.s.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-unique/unique_empty.s.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-unique/unique_shared.s.diff?cvsroot=src&r1=NONE&r2=1.1
CVSROOT: /cvs/src Module name: src Branch: binutils-2_21-branch Changes by: amodra@sourceware.org 2011-04-27 07:17:45 Modified files: bfd : ChangeLog bfd-in2.h bfd.c coff-aux.c elf-bfd.h elf.c elf32-i386.c elf32-ppc.c elf32-sparc.c elf64-ppc.c elf64-sparc.c elf64-x86-64.c elfcode.h elflink.c linker.c opncls.c plugin.c simple.c xcofflink.c gas/testsuite : ChangeLog gas/testsuite/gas/elf: elf.exp include : ChangeLog bfdlink.h ld : ChangeLog ld.texinfo ldfile.c ldlang.c ldlang.h ldmain.c lexsup.c plugin.c plugin.h ld/testsuite : ChangeLog ld/testsuite/ld-plugin: plugin-7.d plugin-8.d plugin.exp Added files: gas/testsuite/gas/elf: section9.d section9.s ld/testsuite/ld-plugin: plugin-12.d ld/testsuite/ld-unique: unique.exp unique.s unique_empty.s unique_shared.s Log message: PR ld/12696 PR ld/12672 PR ld/12507 PR ld/12365 PR 10549 Backport fixes for these PRs. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.5180.2.26&r2=1.5180.2.27 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/bfd-in2.h.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.522.2.1&r2=1.522.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/bfd.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.114.2.1&r2=1.114.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/coff-aux.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.10&r2=1.10.10.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf-bfd.h.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.313.2.1&r2=1.313.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.524.2.1&r2=1.524.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-i386.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.241&r2=1.241.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-ppc.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.290.2.2&r2=1.290.2.3 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-sparc.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.94&r2=1.94.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-ppc.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.339.2.7&r2=1.339.2.8 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-sparc.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.124&r2=1.124.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-x86-64.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.202&r2=1.202.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elfcode.h.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.103&r2=1.103.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.388.2.1&r2=1.388.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/linker.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.77.2.1&r2=1.77.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/opncls.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.66&r2=1.66.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/plugin.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.9.2.1&r2=1.9.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/simple.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.34&r2=1.34.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/xcofflink.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.76.2.1&r2=1.76.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.1802.2.8&r2=1.1802.2.9 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/elf/section9.d.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/elf/section9.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/elf/elf.exp.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.69.2.1&r2=1.69.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.510.2.1&r2=1.510.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/bfdlink.h.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.82&r2=1.82.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.2222.2.18&r2=1.2222.2.19 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ld.texinfo.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.267.2.1&r2=1.267.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldfile.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.58.2.1&r2=1.58.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.347.2.2&r2=1.347.2.3 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.h.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.91.2.1&r2=1.91.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldmain.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.145.2.2&r2=1.145.2.3 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/lexsup.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.120.2.1&r2=1.120.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.7.2.3&r2=1.7.2.4 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.h.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.2.2.2&r2=1.2.2.3 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.1322.2.8&r2=1.1322.2.9 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-12.d.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-7.d.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.1&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-8.d.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.1&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin.exp.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.5&r2=1.5.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-unique/unique.exp.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-unique/unique.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-unique/unique_empty.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-unique/unique_shared.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
Fixed mainline and branch, except for arm on the 2.21 branch where ifunc support was missing.
The master branch has been updated by Maciej W. Rozycki <macro@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6d6a648c0789fb227ee2adfb089fe0ce8174708d commit 6d6a648c0789fb227ee2adfb089fe0ce8174708d Author: Maciej W. Rozycki <macro@imgtec.com> Date: Tue May 3 23:47:55 2016 +0100 PR 10549: MIPS/LD: Handle OSABI setting for STB_GNU_UNIQUE Add missing OSABI handling for MIPS/LD, complementing: commit f64b2e8d60f277b705c96d4b4e585f5f7c847cc4 Author: Nick Clifton <nickc@redhat.com> Date: Mon Apr 11 08:13:22 2011 +0000 Adjust test coverage accordingly. bfd/ PR 10549 * elfxx-mips.c (_bfd_mips_elf_add_symbol_hook): Handle STB_GNU_UNIQUE. ld/ PR 10549 * testsuite/ld-unique/unique.exp: Also run for `mips*-*-*'.