gnu_unique_object.
* doc/as.texinfo: Document new feature of .type directive.
* NEWS: Mention support for gnu_unique_object symbol type.
* common.h (STB_GNU_UNIQUE): Define.
* NEWS: Mention the linker's support for symbols with a binding of
STB_GNU_UNIQUE.
* gas/elf/type.s: Add unique global symbol definition.
* gas/elf/type.e: Add expected readelf output for global unique
symbol.
* elfcpp.h (enum STB): Add STB_GNU_UNIQUE.
* readelf.c (get_symbol_binding): For Linux targeted files return
UNIQUE for symbols with the STB_GNU_UNIQUE binding.
* doc/binutils.texi: Document the meaning of the 'u' symbol
binding in the output of nm and objdump --syms.
* elf-bfd.h (struct elf_link_hash_entry): Add unique_global field.
* elf.c (swap_out_syms): Set binding to STB_GNU_UNIQUE for symbols
with the BSF_GNU_UNIQUE flag bit set.
* elfcode.h (elf_slurp_symbol_table): Set the BSF_GNU_UNIQUE flag
for symbols with STB_GNU_UNIQUE binding.
* elflink.c (_bfd_elf_merge_symbol): Set unique_global for symbols
with the STB_GNU_UNIQUE binding.
(elf_link_add_object_symbols): Set the BSF_GNU_UNIQUE flag for
symbols with STB_GNU_UNIQUE binding. Set STB_GNU_UNIQUE for
symbols with the unique_global field set.
(elf_link_output_extsym): Set unique_global field for symbols with
the STB_GNU_UNIQUE binding.
* syms.c (struct bfd_symbol): Define BSF_GNU_UNIQUE flag bit.
(bfd_print_symbol_vandf): Print a 'u' character for BSF_GNU_UNIQUE
symbols.
(bfd_decode_symclass): Return a 'u' character for BSF_GNU_UNIQUE
symbols.
* bfd-in2.h: Regenerate.
+2009-07-23 Ulrich Drepper <drepper@redhat.com>
+
+ * elf-bfd.h (struct elf_link_hash_entry): Add unique_global field.
+ * elf.c (swap_out_syms): Set binding to STB_GNU_UNIQUE for symbols
+ with the BSF_GNU_UNIQUE flag bit set.
+ * elfcode.h (elf_slurp_symbol_table): Set the BSF_GNU_UNIQUE flag
+ for symbols with STB_GNU_UNIQUE binding.
+ * elflink.c (_bfd_elf_merge_symbol): Set unique_global for symbols
+ with the STB_GNU_UNIQUE binding.
+ (elf_link_add_object_symbols): Set the BSF_GNU_UNIQUE flag for
+ symbols with STB_GNU_UNIQUE binding. Set STB_GNU_UNIQUE for
+ symbols with the unique_global field set.
+ (elf_link_output_extsym): Set unique_global field for symbols with
+ the STB_GNU_UNIQUE binding.
+ * syms.c (struct bfd_symbol): Define BSF_GNU_UNIQUE flag bit.
+ (bfd_print_symbol_vandf): Print a 'u' character for BSF_GNU_UNIQUE
+ symbols.
+ (bfd_decode_symclass): Return a 'u' character for BSF_GNU_UNIQUE
+ symbols.
+ * bfd-in2.h: Regenerate.
+
2009-07-22 H.J. Lu <hongjiu.lu@intel.com>
* elflink.c (elf_link_output_extsym): Revert the last change.
calling the function that it points to. BSF_FUNCTION must
also be also set. */
#define BSF_GNU_INDIRECT_FUNCTION (1 << 22)
+ /* This symbol is a globally unique data object. The dynamic linker
+ will make sure that in the entire process there is just one symbol
+ with this name and type in use. BSF_OBJECT must also be set. */
+#define BSF_GNU_UNIQUE (1 << 23)
flagword flags;
/* Symbol is referenced with a relocation where C/C++ pointer equality
matters. */
unsigned int pointer_equality_needed : 1;
+ /* Symbol is a unique global symbol. */
+ unsigned int unique_global : 1;
/* String table index in .dynstr if this is a dynamic symbol. */
unsigned long dynstr_index;
if (flags & BSF_LOCAL)
bind = STB_LOCAL;
+ else if (flags & BSF_GNU_UNIQUE)
+ bind = STB_GNU_UNIQUE;
else if (flags & BSF_WEAK)
bind = STB_WEAK;
else if (flags & BSF_GLOBAL)
/* ELF executable support for BFD.
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
Written by Fred Fish @ Cygnus Support, from information published
case STB_WEAK:
sym->symbol.flags |= BSF_WEAK;
break;
+ case STB_GNU_UNIQUE:
+ sym->symbol.flags |= BSF_GNU_UNIQUE;
+ break;
}
switch (ELF_ST_TYPE (isym->st_info))
oldweak = (h->root.type == bfd_link_hash_defweak
|| h->root.type == bfd_link_hash_undefweak);
+ if (bind == STB_GNU_UNIQUE)
+ h->unique_global = 1;
+
/* If a new weak symbol definition comes from a regular file and the
old symbol comes from a dynamic library, we treat the new one as
strong. Similarly, an old weak symbol definition from a regular
common = bed->common_definition (isym);
bind = ELF_ST_BIND (isym->st_info);
- if (bind == STB_LOCAL)
+ switch (bind)
{
+ case STB_LOCAL:
/* This should be impossible, since ELF requires that all
global symbols follow all local symbols, and that sh_info
point to the first global symbol. Unfortunately, Irix 5
screws this up. */
continue;
- }
- else if (bind == STB_GLOBAL)
- {
+
+ case STB_GLOBAL:
if (isym->st_shndx != SHN_UNDEF && !common)
flags = BSF_GLOBAL;
- }
- else if (bind == STB_WEAK)
- flags = BSF_WEAK;
- else
- {
+ break;
+
+ case STB_WEAK:
+ flags = BSF_WEAK;
+ break;
+
+ case STB_GNU_UNIQUE:
+ flags = BSF_GNU_UNIQUE;
+ break;
+
+ default:
/* Leave it up to the processor backend. */
+ break;
}
if (isym->st_shndx == SHN_UNDEF)
while (h->root.type == bfd_link_hash_indirect
|| h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
*sym_hash = h;
+ h->unique_global = (flags & BSF_GNU_UNIQUE) != 0;
new_weakdef = FALSE;
if (dynamic
sym.st_other = h->other;
if (h->forced_local)
sym.st_info = ELF_ST_INFO (STB_LOCAL, h->type);
+ else if (h->unique_global)
+ sym.st_info = ELF_ST_INFO (STB_GNU_UNIQUE, h->type);
else if (h->root.type == bfd_link_hash_undefweak
|| h->root.type == bfd_link_hash_defweak)
sym.st_info = ELF_ST_INFO (STB_WEAK, h->type);
. calling the function that it points to. BSF_FUNCTION must
. also be also set. *}
.#define BSF_GNU_INDIRECT_FUNCTION (1 << 22)
+. {* This symbol is a globally unique data object. The dynamic linker
+. will make sure that in the entire process there is just one symbol
+. with this name and type in use. BSF_OBJECT must also be set. *}
+.#define BSF_GNU_UNIQUE (1 << 23)
.
. flagword flags;
.
fprintf (file, " %c%c%c%c%c%c%c",
((type & BSF_LOCAL)
? (type & BSF_GLOBAL) ? '!' : 'l'
- : (type & BSF_GLOBAL) ? 'g' : ' '),
+ : (type & BSF_GLOBAL) ? 'g'
+ : (type & BSF_GNU_UNIQUE) ? 'u' : ' '),
(type & BSF_WEAK) ? 'w' : ' ',
(type & BSF_CONSTRUCTOR) ? 'C' : ' ',
(type & BSF_WARNING) ? 'W' : ' ',
else
return 'W';
}
+ if (symbol->flags & BSF_GNU_UNIQUE)
+ return 'u';
if (!(symbol->flags & (BSF_GLOBAL | BSF_LOCAL)))
return '?';
+2009-07-23 Ulrich Drepper <drepper@redhat.com>
+
+ * readelf.c (get_symbol_binding): For Linux targeted files return
+ UNIQUE for symbols with the STB_GNU_UNIQUE binding.
+ * doc/binutils.texi: Document the meaning of the 'u' symbol
+ binding in the output of nm and objdump --syms.
+
2009-07-20 H.J. Lu <hongjiu.lu@intel.com>
* NEWS: Mention --insn-width.
such as a global int variable as opposed to a large global array.
@item i
-The symbol is in a section specific to the implementation of DLLs.
+For PE format files this indicates that the symbol is in a section
+specific to the implementation of DLLs. For ELF format files this
+indicates that the symbol is an indirect function. This is a GNU
+extension to the standard set of ELF symbol types. It indicates a
+symbol which if referenced by a relocation does not evaluate to its
+address, but instead must be invoked at runtime. The runtime
+execution will then return the value to be used in the relocation.
@item N
The symbol is a debugging symbol.
@item U
The symbol is undefined.
+@item u
+The symbol is a unique global symbol. This is a GNU extension to the
+standard set of ELF symbol bindings. For such a symbol the dynamic linker
+will make sure that in the entire process there is just one symbol with
+this name and type in use.
+
@item V
@itemx v
The symbol is a weak object. When a weak defined symbol is linked with
@table @code
@item l
@itemx g
+@itemx u
@itemx !
-The symbol is local (l), global (g), neither (a space) or both (!). A
+The symbol is a local (l), global (g), unique global (u), neither
+global nor local (a space) or both global and local (!). A
symbol can be neither local or global for a variety of reasons, e.g.,
because it is used for debugging, but it is probably an indication of
-a bug if it is ever both local and global.
+a bug if it is ever both local and global. Unique global symbols are
+a GNU extension to the standard set of ELF symbol bindings. For such
+a symbol the dynamic linker will make sure that in the entire process
+there is just one symbol with this name and type in use.
@item w
The symbol is weak (w) or strong (a space).
snprintf (buff, sizeof (buff), _("<processor specific>: %d"),
binding);
else if (binding >= STB_LOOS && binding <= STB_HIOS)
- snprintf (buff, sizeof (buff), _("<OS specific>: %d"), binding);
+ {
+ if (binding == STB_GNU_UNIQUE
+ && (elf_header.e_ident[EI_OSABI] == ELFOSABI_LINUX
+ /* GNU/Linux is still using the default value 0. */
+ || elf_header.e_ident[EI_OSABI] == ELFOSABI_NONE))
+ return "UNIQUE";
+ snprintf (buff, sizeof (buff), _("<OS specific>: %d"), binding);
+ }
else
snprintf (buff, sizeof (buff), _("<unknown>: %d"), binding);
return buff;
+2009-07-23 Ulrich Drepper <drepper@redhat.com>
+
+ * elfcpp.h (enum STB): Add STB_GNU_UNIQUE.
+
2009-06-21 Ian Lance Taylor <iant@google.com>
* elfcpp.h (SHN_X86_64_LCOMMON): Define enum constant.
STB_GLOBAL = 1,
STB_WEAK = 2,
STB_LOOS = 10,
+ STB_GNU_UNIQUE = 10,
STB_HIOS = 12,
STB_LOPROC = 13,
STB_HIPROC = 15
+2009-07-23 Ulrich Drepper <drepper@redhat.com>
+
+ * config/obj-elf.c (obj_elf_type): Add code to support a type of
+ gnu_unique_object.
+ * doc/as.texinfo: Document new feature of .type directive.
+ * NEWS: Mention support for gnu_unique_object symbol type.
+
2009-07-23 Nick Clifton <nickc@redhat.com>
PR binutils/10379
-*- text -*-
+* GNU/Linux targets now supports "gnu_unique_object" as a value in the .type
+ pseudo op. It marks the symbol as being globally unique in the entire
+ process.
+
* ARM assembler now supports .inst[.nw] pseudo-ops to insert opcodes specified
in binary rather than text.
}
}
else if (strcmp (typename, "gnu_indirect_function") == 0
- || strcmp (typename, "10") == 0
- || strcmp (typename, "STT_GNU_IFUNC") == 0)
+ || strcmp (typename, "10") == 0
+ || strcmp (typename, "STT_GNU_IFUNC") == 0)
{
const struct elf_backend_data *bed;
typename);
type = BSF_FUNCTION | BSF_GNU_INDIRECT_FUNCTION;
}
+ else if (strcmp (typename, "gnu_unique_object") == 0)
+ {
+ const struct elf_backend_data *bed;
+
+ bed = get_elf_backend_data (stdoutput);
+ if (!(bed->elf_osabi == ELFOSABI_LINUX
+ /* GNU/Linux is still using the default value 0. */
+ || bed->elf_osabi == ELFOSABI_NONE))
+ as_bad (_("symbol type \"%s\" is supported only by GNU targets"),
+ typename);
+ type = BSF_OBJECT | BSF_GNU_UNIQUE;
+ }
#ifdef md_elf_symbol_type
else if ((type = md_elf_symbol_type (typename, sym, elfsym)) != -1)
;
@itemx notype
Does not mark the symbol in any way. It is supported just for completeness.
+@item gnu_unique_object
+Marks the symbol as being a globally unique data object. The dynamic linker
+will make sure that in the entire process there is just one symbol with this
+name and type in use. (This is only supported on Linux targeted assemblers).
+
@end table
Note: Some targets support extra types in addition to those listed above.
+2009-07-23 Ulrich Drepper <drepper@redhat.com>
+
+ * gas/elf/type.s: Add unique global symbol definition.
+ * gas/elf/type.e: Add expected readelf output for global unique
+ symbol.
+
2009-07-21 H.J. Lu <hongjiu.lu@intel.com>
PR gas/10420
.: 0+0 1 OBJECT LOCAL DEFAULT . object
.: 0+1 1 TLS LOCAL DEFAULT . tls_object
..: 0+2 1 NOTYPE LOCAL DEFAULT . notype
+ ..: 0+3 1 OBJECT UNIQUE DEFAULT . unique_global
..: 0+1 1 (COMMON|OBJECT) GLOBAL DEFAULT COM common
.text
+
.size function,1
.type function,%function
function:
.byte 0x0
+
.size indirect_function,1
.type indirect_function,%gnu_indirect_function
indirect_function:
.byte 0x0
+
.data
+
.type object,%object
.size object,1
object:
.byte 0x0
.type tls_object,%tls_object
+
.size tls_object,1
tls_object:
.byte 0x0
.type notype,%notype
+
.size notype,1
notype:
.byte 0x0
.comm common, 1
.type common,STT_COMMON
+
+ .type unique_global,%gnu_unique_object
+unique_global:
+ .byte 0x0
+ .size unique_global,1
+2009-07-23 Ulrich Drepper <drepper@redhat.com>
+
+ * common.h (STB_GNU_UNIQUE): Define.
+
2009-07-10 Tom Tromey <tromey@redhat.com>
* dwarf2.h: Move to `..'.
/* ELF support for BFD.
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
Written by Fred Fish @ Cygnus Support, from information published
#define STB_GLOBAL 1 /* Symbol visible outside obj */
#define STB_WEAK 2 /* Like globals, lower precedence */
#define STB_LOOS 10 /* OS-specific semantics */
+#define STB_GNU_UNIQUE 10 /* Symbol is unique in namespace */
#define STB_HIOS 12 /* OS-specific semantics */
#define STB_LOPROC 13 /* Processor-specific semantics */
#define STB_HIPROC 15 /* Processor-specific semantics */
+2009-07-23 Ulrich Drepper <drepper@redhat.com>
+
+ * NEWS: Mention the linker's support for symbols with a binding of
+ STB_GNU_UNIQUE.
+
2009-07-22 H.J. Lu <hongjiu.lu@intel.com>
PR ld/10429
-*- text -*-
+* GNU/Linux targets now support the STB_GNU_UNIQUE symbol binding. This is a
+ GNU extension to the standard set of ELF symbol bindings. The binding will
+ be passed on to the dynamic linker which will make sure that in the entire
+ process there is just one symbol with the given name and type in use.
* PE targets now support a GNU extension to allow the alignment of common
common symbols to be specified. This support uses custom options in