bfd/ 2005-08-04 H.J. Lu * bfd.c (bfd_hide_symbol): New. * bfd-in2.h: Regenerated. ld/ 2005-08-04 H.J. Lu * ld.texinfo: Document PROVIDE_HIDDEN. * ldexp.c (exp_fold_tree_1): Hide a provided symbol if asked. (exp_provide): Add and set hidden. * ldexp.h (etree_type): Add hidden to assign. * ldgram.y (PROVIDE_HIDDEN): New. * ldlex.l (PROVIDE_HIDDEN): Likewise. * scripttempl/elf.sc: Use PROVIDE_HIDDEN on array bound symbols. --- binutils/bfd/bfd.c.hidden 2005-06-06 08:54:38.000000000 -0700 +++ binutils/bfd/bfd.c 2005-08-04 11:32:16.211121884 -0700 @@ -1508,3 +1508,29 @@ bfd_preserve_finish (bfd *abfd ATTRIBUTE objalloc. */ bfd_hash_table_free (&preserve->section_htab); } + +/* +FUNCTION + bfd_hide_symbol + +SYNOPSIS + void bfd_hide_symbol (bfd *, + struct bfd_link_info *, + struct bfd_link_hash_entry *, + bfd_boolean); + +DESCRIPTION + This function hides a symbol so that it won't be exported. + +*/ + +void +bfd_hide_symbol (bfd *abfd, + struct bfd_link_info *link_info, + struct bfd_link_hash_entry *h, + bfd_boolean force_local) +{ + if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) + (get_elf_backend_data (abfd)->elf_backend_hide_symbol) + (link_info, (struct elf_link_hash_entry *) h, force_local); +} --- binutils/ld/ldexp.c.hidden 2005-06-09 09:14:32.000000000 -0700 +++ binutils/ld/ldexp.c 2005-08-04 11:34:54.774025359 -0700 @@ -740,6 +740,8 @@ exp_fold_tree_1 (etree_type *tree) defined by some object. */ break; } + if (tree->assign.hidden) + bfd_hide_symbol (output_bfd, &link_info, h, TRUE); } exp_fold_tree_1 (tree->assign.src); @@ -884,7 +886,7 @@ exp_assop (int code, const char *dst, et /* Handle PROVIDE. */ etree_type * -exp_provide (const char *dst, etree_type *src) +exp_provide (const char *dst, etree_type *src, bfd_boolean hidden) { etree_type *n; @@ -893,6 +895,7 @@ exp_provide (const char *dst, etree_type n->assign.type.node_class = etree_provide; n->assign.src = src; n->assign.dst = dst; + n->assign.hidden = hidden; return n; } --- binutils/ld/ldexp.h.hidden 2005-06-09 09:14:32.000000000 -0700 +++ binutils/ld/ldexp.h 2005-08-04 11:16:03.433223155 -0700 @@ -63,6 +63,7 @@ typedef union etree_union { node_type type; const char *dst; union etree_union *src; + bfd_boolean hidden; } assign; struct { node_type type; @@ -165,7 +166,7 @@ etree_type *exp_nameop etree_type *exp_assop (int, const char *, etree_type *); etree_type *exp_provide - (const char *, etree_type *); + (const char *, etree_type *, bfd_boolean); etree_type *exp_assert (etree_type *, const char *); void exp_print_tree --- binutils/ld/ldgram.y.hidden 2005-07-24 19:31:17.000000000 -0700 +++ binutils/ld/ldgram.y 2005-08-04 11:14:04.519794108 -0700 @@ -142,7 +142,7 @@ static int error_index; %token STARTUP HLL SYSLIB FLOAT NOFLOAT NOCROSSREFS %token ORIGIN FILL %token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS -%token ALIGNMOD AT SUBALIGN PROVIDE AS_NEEDED +%token ALIGNMOD AT SUBALIGN PROVIDE PROVIDE_HIDDEN AS_NEEDED %type assign_op atype attributes_opt sect_constraint %type filename %token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD ASSERT_K @@ -648,7 +648,11 @@ assignment: } | PROVIDE '(' NAME '=' mustbe_exp ')' { - lang_add_assignment (exp_provide ($3, $5)); + lang_add_assignment (exp_provide ($3, $5, FALSE)); + } + | PROVIDE_HIDDEN '(' NAME '=' mustbe_exp ')' + { + lang_add_assignment (exp_provide ($3, $5, TRUE)); } ; --- binutils/ld/ldlex.l.hidden 2005-05-16 11:04:40.000000000 -0700 +++ binutils/ld/ldlex.l 2005-08-04 11:34:11.716111896 -0700 @@ -313,6 +313,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([ "AT" { RTOKEN(AT);} "SUBALIGN" { RTOKEN(SUBALIGN);} "PROVIDE" { RTOKEN(PROVIDE); } +"PROVIDE_HIDDEN" { RTOKEN(PROVIDE_HIDDEN); } "KEEP" { RTOKEN(KEEP); } "EXCLUDE_FILE" { RTOKEN(EXCLUDE_FILE); } "#".*\n? { ++ lineno; } --- binutils/ld/scripttempl/elf.sc.hidden 2005-08-04 08:56:47.315617114 -0700 +++ binutils/ld/scripttempl/elf.sc 2005-08-04 11:37:29.415574217 -0700 @@ -384,21 +384,21 @@ cat <