]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
bfd/
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 5 Aug 2005 13:52:13 +0000 (13:52 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 5 Aug 2005 13:52:13 +0000 (13:52 +0000)
2005-08-05  H.J. Lu  <hongjiu.lu@intel.com>

* bfd.c (bfd_hide_symbol): New.
* bfd-in2.h: Regenerated.

ld/

2005-08-05  H.J. Lu  <hongjiu.lu@intel.com>

* 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.

bfd/ChangeLog
bfd/bfd-in2.h
bfd/bfd.c
ld/ChangeLog
ld/ld.texinfo
ld/ldexp.c
ld/ldexp.h
ld/ldgram.y
ld/ldlex.l
ld/scripttempl/elf.sc

index db023c91c988279b4bccb302a5e9b6cdb77df9e2..ced5b40767da512fc1a4dd088a3c77d69ed2a1c9 100644 (file)
@@ -1,3 +1,8 @@
+2005-08-05  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * bfd.c (bfd_hide_symbol): New.
+       * bfd-in2.h: Regenerated.
+
 2005-08-04  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elf64-x86-64.c (elf64_x86_64_merge_symbol): When mixing a
index 8ca1d6f8b16c1264d9e1f64056abc0e0cb592c05..1c99cc20e480ea12fd5207852cf8a139bba68243 100644 (file)
@@ -4486,6 +4486,10 @@ void bfd_preserve_restore (bfd *, struct bfd_preserve *);
 
 void bfd_preserve_finish (bfd *, struct bfd_preserve *);
 
+void bfd_hide_symbol
+   (bfd *, struct bfd_link_info *,
+    struct bfd_link_hash_entry *, bfd_boolean);
+
 /* Extracted from archive.c.  */
 symindex bfd_get_next_mapent
    (bfd *abfd, symindex previous, carsym **sym);
index 908d79471f68f311ea99baaed73d0a513934c8b7..c8be7396cce161f178d8f59fac9815df6c369e07 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1508,3 +1508,29 @@ bfd_preserve_finish (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_preserve *preserve)
      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);
+}
index 51d8f679e7de0258e5470e77beea12eff714d126..5e764011d2a0f8c3a9ed36495dfb33dd28ab4532 100644 (file)
@@ -1,3 +1,18 @@
+2005-08-05  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * 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.
+
 2005-08-05  Alan Modra  <amodra@bigpond.net.au>
 
        * emulparams/elf_x86_64.sh: Revert last change.
index 7e526a3da8934b50c7b792bab77faf31e68ae5a7..cada21302fe6e0226c40d1b5991b8b367b449ce0 100644 (file)
@@ -2779,6 +2779,7 @@ the symbol and place it into the symbol table with a global scope.
 @menu
 * Simple Assignments::         Simple Assignments
 * PROVIDE::                    PROVIDE
+* PROVIDE_HIDDEN::             PROVIDE_HIDDEN
 * Source Code Reference::      How to use a linker script defined symbol in source code
 @end menu
 
@@ -2872,6 +2873,12 @@ underscore), the linker will silently use the definition in the program.
 If the program references @samp{etext} but does not define it, the
 linker will use the definition in the linker script.
 
+@node PROVIDE_HIDDEN
+@subsection PROVIDE_HIDDEN
+@cindex PROVIDE_HIDDEN
+Similar to @code{PROVIDE}.  For ELF targeted ports, the symbol will be
+hidden and won't be exported.
+
 @node Source Code Reference
 @subsection Source Code Reference
 
index 6c3c717eb882ad8a3b65052777f3b97086c192f9..d0ecb0c12b5fc561f38e82fbdc8c5e422282677b 100644 (file)
@@ -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, etree_type *src)
 /* 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 *src)
   n->assign.type.node_class = etree_provide;
   n->assign.src = src;
   n->assign.dst = dst;
+  n->assign.hidden = hidden;
   return n;
 }
 
index 7cf8ea7374d7ffcbc223fe7f960d6a9fc43fb1f6..fed3a0da44c9e2d62f7f944a6549b82ad7b3d8e1 100644 (file)
@@ -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
index 2d5b07429a715351e9ea5c3992a9d689ab33fd66..44896e1dd4f6b8888e954a9cfe761b3c583bd868 100644 (file)
@@ -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 <token> assign_op atype attributes_opt sect_constraint
 %type <name>  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));
                }
        ;
 
index e01ce0688dd48494676ea4a024504ae09d53ef1f..56ec39164b4629dd8905bc12ccd7c26175286b12 100644 (file)
@@ -313,6 +313,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
 <EXPRESSION,BOTH,SCRIPT>"AT"           { RTOKEN(AT);}
 <EXPRESSION,BOTH,SCRIPT>"SUBALIGN"     { RTOKEN(SUBALIGN);}
 <EXPRESSION,BOTH,SCRIPT>"PROVIDE"      { RTOKEN(PROVIDE); }
+<EXPRESSION,BOTH,SCRIPT>"PROVIDE_HIDDEN" { RTOKEN(PROVIDE_HIDDEN); }
 <EXPRESSION,BOTH,SCRIPT>"KEEP"         { RTOKEN(KEEP); }
 <EXPRESSION,BOTH,SCRIPT>"EXCLUDE_FILE"  { RTOKEN(EXCLUDE_FILE); }
 <MRI>"#".*\n?                  { ++ lineno; }
index 8140cca954098fa880e0e832a9e68012d9af8383..2f5971ece6883898e6a33ac7224d494b5e9b486e 100644 (file)
@@ -379,21 +379,21 @@ cat <<EOF
 
   .preinit_array   ${RELOCATING-0} :
   {
-    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_start = .);}}
+    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__preinit_array_start = .);}}
     KEEP (*(.preinit_array))
-    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_end = .);}}
+    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__preinit_array_end = .);}}
   }
   .init_array   ${RELOCATING-0} :
   {
-     ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_start = .);}}
+     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__init_array_start = .);}}
      KEEP (*(.init_array))
-     ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_end = .);}}
+     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__init_array_end = .);}}
   }
   .fini_array   ${RELOCATING-0} :
   {
-    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_start = .);}}
+    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__fini_array_start = .);}}
     KEEP (*(.fini_array))
-    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_end = .);}}
+    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__fini_array_end = .);}}
   }
   ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
   ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}