diff options
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 29 | ||||
-rw-r--r-- | ld/emultempl/beos.em | 3 | ||||
-rw-r--r-- | ld/emultempl/pe.em | 7 | ||||
-rw-r--r-- | ld/emultempl/pep.em | 7 | ||||
-rw-r--r-- | ld/emultempl/spuelf.em | 2 | ||||
-rw-r--r-- | ld/emultempl/xtensaelf.em | 2 | ||||
-rw-r--r-- | ld/ld.texinfo | 26 | ||||
-rw-r--r-- | ld/ldctor.c | 6 | ||||
-rw-r--r-- | ld/ldexp.c | 16 | ||||
-rw-r--r-- | ld/ldexp.h | 3 | ||||
-rw-r--r-- | ld/ldgram.y | 12 | ||||
-rw-r--r-- | ld/ldlang.c | 4 | ||||
-rw-r--r-- | ld/ldlex.l | 1 | ||||
-rw-r--r-- | ld/mri.c | 2 |
14 files changed, 96 insertions, 24 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index c066fef..451f110 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,32 @@ +2012-08-06 Maciej W. Rozycki <macro@codesourcery.com> + + * ldexp.h (etree_union): Add defsym member to the assign member + structure. + (exp_assign): Add hidden argument to prototype. + * ldexp.c (exp_fold_tree_1): Use the defsym member to handle + --defsym symbols. + (exp_assop): Add defsym argument, initialize the defsym member + of the assign structure. + (exp_assign): Handle hidden symbols. + (exp_defsym): Update to use the defsym argument to exp_assop. + (exp_provide): Update to handle the defsym argument to exp_assop. + * ldlex.l (HIDDEN): New token. + * ldgram.y (HIDDEN): Likewise. + (assignment, section): Update calls to exp_assign. + * ldctor.c (ldctor_build_sets): Likewise. + * mri.c (mri_format): Likewise. + * ldlang.c (lang_insert_orphan, lang_leave_overlay): Likewise. + (open_input_bfds): Remove --defsym symbols special case. + * emultempl/beos.em (gld_${EMULATION_NAME}_set_symbols): Update + call to exp_assign. + * emultempl/pe.em (gld_${EMULATION_NAME}_set_symbols): Likewise. + * emultempl/pep.em (gld_${EMULATION_NAME}_set_symbols): Likewise. + * emultempl/spuelf.em (spu_place_special_section): Likewise. + * emultempl/xtensaelf.em (ld_xtensa_insert_page_offsets): + Likewise. + * ld.texinfo (Assigning Values to Symbols): Add HIDDEN. + (HIDDEN): New subsection. + 2012-07-31 H.J. Lu <hongjiu.lu@intel.com> PR ld/14156 diff --git a/ld/emultempl/beos.em b/ld/emultempl/beos.em index 2071d8e..f59e000 100644 --- a/ld/emultempl/beos.em +++ b/ld/emultempl/beos.em @@ -348,7 +348,8 @@ gld_${EMULATION_NAME}_set_symbols (void) for (j = 0; init[j].ptr; j++) { long val = init[j].value; - lang_add_assignment (exp_assign (init[j].symbol, exp_intop (val))); + lang_add_assignment (exp_assign (init[j].symbol, exp_intop (val), + FALSE)); if (init[j].size == sizeof(short)) *(short *)init[j].ptr = val; else if (init[j].size == sizeof(int)) diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 947f6ad..a565eb7 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -944,7 +944,7 @@ gld_${EMULATION_NAME}_set_symbols (void) lang_assignment_statement_type *rv; rv = lang_add_assignment (exp_assign (GET_INIT_SYMBOL_NAME (j), - exp_intop (val))); + exp_intop (val), FALSE)); if (init[j].size == sizeof (short)) *(short *) init[j].ptr = val; else if (init[j].size == sizeof (int)) @@ -1721,8 +1721,9 @@ gld_${EMULATION_NAME}_unrecognized_file (lang_input_statement_type *entry ATTRIB = pe_def_file->base_address; init[IMAGEBASEOFF].inited = 1; if (image_base_statement) - image_base_statement->exp = exp_assign ("__image_base__", - exp_intop (pe.ImageBase)); + image_base_statement->exp + = exp_assign ("__image_base__", exp_intop (pe.ImageBase), + FALSE); } if (pe_def_file->stack_reserve != -1 diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index d3f5c83..fc3cdc3 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -856,7 +856,7 @@ gld_${EMULATION_NAME}_set_symbols (void) lang_assignment_statement_type *rv; rv = lang_add_assignment (exp_assign (GET_INIT_SYMBOL_NAME (j), - exp_intop (val))); + exp_intop (val), FALSE)); if (init[j].size == sizeof (short)) *(short *) init[j].ptr = (short) val; else if (init[j].size == sizeof (int)) @@ -1522,8 +1522,9 @@ gld_${EMULATION_NAME}_unrecognized_file (lang_input_statement_type *entry ATTRIB = pep_def_file->base_address; init[IMAGEBASEOFF].inited = 1; if (image_base_statement) - image_base_statement->exp = exp_assign ("__image_base__", - exp_intop (pep.ImageBase)); + image_base_statement->exp + = exp_assign ("__image_base__", exp_intop (pep.ImageBase), + FALSE); } if (pep_def_file->stack_reserve != -1 diff --git a/ld/emultempl/spuelf.em b/ld/emultempl/spuelf.em index eef57aa..1b35612 100644 --- a/ld/emultempl/spuelf.em +++ b/ld/emultempl/spuelf.em @@ -165,7 +165,7 @@ spu_place_special_section (asection *s, asection *o, const char *output_name) push_stat_ptr (&os->children); e_size = exp_intop (params.line_size - s->size); - lang_add_assignment (exp_assign (".", e_size)); + lang_add_assignment (exp_assign (".", e_size, FALSE)); pop_stat_ptr (); } lang_add_section (&os->children, s, NULL, os); diff --git a/ld/emultempl/xtensaelf.em b/ld/emultempl/xtensaelf.em index b37a67b..1e6eb07 100644 --- a/ld/emultempl/xtensaelf.em +++ b/ld/emultempl/xtensaelf.em @@ -1887,7 +1887,7 @@ ld_xtensa_insert_page_offsets (bfd_vma dot, etree_type *name_op = exp_nameop (NAME, "."); etree_type *addend_op = exp_intop (1 << xtensa_page_power); etree_type *add_op = exp_binop ('+', name_op, addend_op); - etree_type *assign_op = exp_assign (".", add_op); + etree_type *assign_op = exp_assign (".", add_op, FALSE); lang_assignment_statement_type *assign_stmt; lang_statement_union_type *assign_union; diff --git a/ld/ld.texinfo b/ld/ld.texinfo index d0a5d90..dd3149c 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -3410,6 +3410,7 @@ the symbol and place it into the symbol table with a global scope. @menu * Simple Assignments:: Simple Assignments +* HIDDEN:: HIDDEN * PROVIDE:: PROVIDE * PROVIDE_HIDDEN:: PROVIDE_HIDDEN * Source Code Reference:: How to use a linker script defined symbol in source code @@ -3473,6 +3474,31 @@ the last @samp{.text} input section. The symbol @samp{_bdata} will be defined as the address following the @samp{.text} output section aligned upward to a 4 byte boundary. +@node HIDDEN +@subsection HIDDEN +@cindex HIDDEN +For ELF targeted ports, define a symbol that will be hidden and won't be +exported. The syntax is @code{HIDDEN(@var{symbol} = @var{expression})}. + +Here is the example from @ref{Simple Assignments}, rewritten to use +@code{HIDDEN}: + +@smallexample +HIDDEN(floating_point = 0); +SECTIONS +@{ + .text : + @{ + *(.text) + HIDDEN(_etext = .); + @} + HIDDEN(_bdata = (. + 3) & ~ 3); + .data : @{ *(.data) @} +@} +@end smallexample +@noindent +In this case none of the three symbols will be visible outside this module. + @node PROVIDE @subsection PROVIDE @cindex PROVIDE diff --git a/ld/ldctor.c b/ld/ldctor.c index 1a86eb3..b29c1e0 100644 --- a/ld/ldctor.c +++ b/ld/ldctor.c @@ -321,9 +321,11 @@ ldctor_build_sets (void) lang_add_assignment (exp_assign (".", exp_unop (ALIGN_K, - exp_intop (reloc_size)))); + exp_intop (reloc_size)), + FALSE)); lang_add_assignment (exp_assign (p->h->root.string, - exp_nameop (NAME, "."))); + exp_nameop (NAME, "."), + FALSE)); lang_add_data (size, exp_intop (p->count)); for (e = p->elements; e != NULL; e = e->next) @@ -892,7 +892,7 @@ exp_fold_tree_1 (etree_type *tree) if (expld.result.valid_p || (expld.phase <= lang_mark_phase_enum && tree->type.node_class == etree_assign - && tree->assign.hidden)) + && tree->assign.defsym)) { if (h == NULL) { @@ -1054,6 +1054,7 @@ static etree_type * exp_assop (const char *dst, etree_type *src, enum node_tree_enum class, + bfd_boolean defsym, bfd_boolean hidden) { etree_type *n; @@ -1065,20 +1066,25 @@ exp_assop (const char *dst, n->assign.type.node_class = class; n->assign.src = src; n->assign.dst = dst; + n->assign.defsym = defsym; n->assign.hidden = hidden; return n; } +/* Handle linker script assignments and HIDDEN. */ + etree_type * -exp_assign (const char *dst, etree_type *src) +exp_assign (const char *dst, etree_type *src, bfd_boolean hidden) { - return exp_assop (dst, src, etree_assign, FALSE); + return exp_assop (dst, src, etree_assign, FALSE, hidden); } +/* Handle --defsym command-line option. */ + etree_type * exp_defsym (const char *dst, etree_type *src) { - return exp_assop (dst, src, etree_assign, TRUE); + return exp_assop (dst, src, etree_assign, TRUE, FALSE); } /* Handle PROVIDE. */ @@ -1086,7 +1092,7 @@ exp_defsym (const char *dst, etree_type *src) etree_type * exp_provide (const char *dst, etree_type *src, bfd_boolean hidden) { - return exp_assop (dst, src, etree_provide, hidden); + return exp_assop (dst, src, etree_provide, FALSE, hidden); } /* Handle ASSERT. */ @@ -67,6 +67,7 @@ typedef union etree_union { node_type type; const char *dst; union etree_union *src; + bfd_boolean defsym; bfd_boolean hidden; } assign; struct { @@ -199,7 +200,7 @@ etree_type *exp_unop etree_type *exp_nameop (int, const char *); etree_type *exp_assign - (const char *, etree_type *); + (const char *, etree_type *, bfd_boolean); etree_type *exp_defsym (const char *, etree_type *); etree_type *exp_provide diff --git a/ld/ldgram.y b/ld/ldgram.y index 6e00118..ee88196 100644 --- a/ld/ldgram.y +++ b/ld/ldgram.y @@ -146,7 +146,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 PROVIDE_HIDDEN AS_NEEDED +%token ALIGNMOD AT SUBALIGN HIDDEN 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 @@ -759,7 +759,7 @@ end: ';' | ',' assignment: NAME '=' mustbe_exp { - lang_add_assignment (exp_assign ($1, $3)); + lang_add_assignment (exp_assign ($1, $3, FALSE)); } | NAME assign_op mustbe_exp { @@ -767,7 +767,11 @@ assignment: exp_binop ($2, exp_nameop (NAME, $1), - $3))); + $3), FALSE)); + } + | HIDDEN '(' NAME '=' mustbe_exp ')' + { + lang_add_assignment (exp_assign ($3, $5, TRUE)); } | PROVIDE '(' NAME '=' mustbe_exp ')' { @@ -1085,7 +1089,7 @@ section: NAME { ldlex_expression(); } opt_exp_with_type { ldlex_popstate (); - lang_add_assignment (exp_assign (".", $3)); + lang_add_assignment (exp_assign (".", $3, FALSE)); } '{' sec_or_group_p1 '}' | INCLUDE filename diff --git a/ld/ldlang.c b/ld/ldlang.c index 0f5c91a3..0c97898 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -3286,7 +3286,7 @@ open_input_bfds (lang_statement_union_type *s, enum open_bfd_mode mode) #endif break; case lang_assignment_statement_enum: - if (s->assignment_statement.exp->assign.hidden) + if (s->assignment_statement.exp->assign.defsym) /* This is from a --defsym on the command line. */ exp_fold_tree_no_dot (s->assignment_statement.exp); break; @@ -7437,7 +7437,7 @@ lang_leave_overlay (etree_type *lma_expr, { overlay_list->os->update_dot = 1; overlay_list->os->update_dot_tree - = exp_assign (".", exp_binop ('+', overlay_vma, overlay_max)); + = exp_assign (".", exp_binop ('+', overlay_vma, overlay_max), FALSE); } l = overlay_list; @@ -320,6 +320,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* <BOTH,SCRIPT>"PHDRS" { RTOKEN (PHDRS); } <EXPRESSION,BOTH,SCRIPT>"AT" { RTOKEN(AT);} <EXPRESSION,BOTH,SCRIPT>"SUBALIGN" { RTOKEN(SUBALIGN);} +<EXPRESSION,BOTH,SCRIPT>"HIDDEN" { RTOKEN(HIDDEN); } <EXPRESSION,BOTH,SCRIPT>"PROVIDE" { RTOKEN(PROVIDE); } <EXPRESSION,BOTH,SCRIPT>"PROVIDE_HIDDEN" { RTOKEN(PROVIDE_HIDDEN); } <EXPRESSION,BOTH,SCRIPT>"KEEP" { RTOKEN(KEEP); } @@ -297,7 +297,7 @@ mri_format (const char *name) void mri_public (const char *name, etree_type *exp) { - lang_add_assignment (exp_assign (name, exp)); + lang_add_assignment (exp_assign (name, exp, FALSE)); } void |