static const struct
{
token_code_type code;
- char * name;
+ const char * name;
}
table[] =
{
static void
new_rel_from_abs (bfd_vma value)
{
+ asection *s = expld.section;
+
+ if (s == bfd_abs_section_ptr && expld.phase == lang_final_phase_enum)
+ s = section_for_dot ();
expld.result.valid_p = TRUE;
- expld.result.value = value - expld.section->vma;
+ expld.result.value = value - s->vma;
expld.result.str = NULL;
- expld.result.section = expld.section;
+ expld.result.section = s;
}
static void
output_section);
}
else if (expld.phase == lang_final_phase_enum
- || expld.assigning_to_dot)
+ || (expld.phase != lang_mark_phase_enum
+ && expld.assigning_to_dot))
einfo (_("%F%S: undefined symbol `%s'"
" referenced in expression\n"),
tree, tree->name.name);
tree, tree->name.name);
new_number (0);
}
- else if (os->processed_vma)
+ else if (os->bfd_section != NULL)
{
bfd_vma val;
new_number (val);
}
+ else
+ new_number (0);
}
break;
if (tree->type.node_class != etree_assign)
einfo (_("%F%S can not PROVIDE assignment to"
" location counter\n"), tree);
- /* After allocation, assignment to dot should not be done inside
- an output section since allocation adds a padding statement
- that effectively duplicates the assignment. */
- if (expld.phase == lang_mark_phase_enum
- || expld.phase == lang_allocating_phase_enum
- || ((expld.phase == lang_assigning_phase_enum
- || expld.phase == lang_final_phase_enum)
- && expld.section == bfd_abs_section_ptr))
+ if (expld.phase != lang_first_phase_enum)
{
/* Notify the folder that this is an assignment to dot. */
expld.assigning_to_dot = TRUE;
}
else if (expld.dotp == NULL)
einfo (_("%F%S assignment to location counter"
- " invalid outside of SECTION\n"), tree);
- else
+ " invalid outside of SECTIONS\n"), tree);
+
+ /* After allocation, assignment to dot should not be
+ done inside an output section since allocation adds a
+ padding statement that effectively duplicates the
+ assignment. */
+ else if (expld.phase <= lang_allocating_phase_enum
+ || expld.section == bfd_abs_section_ptr)
{
bfd_vma nextdot;
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)
{
exp_assop (const char *dst,
etree_type *src,
enum node_tree_enum class,
+ bfd_boolean defsym,
bfd_boolean hidden)
{
etree_type *n;
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. */
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. */
case DATA_SEGMENT_ALIGN:
case DATA_SEGMENT_RELRO_END:
function_like = TRUE;
+ break;
+ case SEGMENT_START:
+ /* Special handling because arguments are in reverse order and
+ the segment name is quoted. */
+ exp_print_token (tree->type.node_code, FALSE);
+ fputs (" (\"", config.map_file);
+ exp_print_tree (tree->binary.rhs);
+ fputs ("\", ", config.map_file);
+ exp_print_tree (tree->binary.lhs);
+ fputc (')', config.map_file);
+ return;
}
if (function_like)
{