* ldexp.c (exp_print_tree): Print function-like binary nodes as

functions rather than in-fix operators.  Use fputs and fputc
	where appropriate.
This commit is contained in:
Alan Modra 2010-07-28 06:43:32 +00:00
parent 5a93804749
commit ae78bbeb22
2 changed files with 35 additions and 11 deletions

View File

@ -1,3 +1,9 @@
2010-07-28 Alan Modra <amodra@gmail.com>
* ldexp.c (exp_print_tree): Print function-like binary nodes as
functions rather than in-fix operators. Use fputs and fputc
where appropriate.
2010-07-23 Naveen.H.S <naveen.S@kpitcummins.com> 2010-07-23 Naveen.H.S <naveen.S@kpitcummins.com>
Ina Pandit <ina.pandit@kpitcummins.com> Ina Pandit <ina.pandit@kpitcummins.com>

View File

@ -1002,6 +1002,8 @@ exp_assert (etree_type *exp, const char *message)
void void
exp_print_tree (etree_type *tree) exp_print_tree (etree_type *tree)
{ {
bfd_boolean function_like;
if (config.map_file == NULL) if (config.map_file == NULL)
config.map_file = stderr; config.map_file = stderr;
@ -1022,7 +1024,7 @@ exp_print_tree (etree_type *tree)
minfo ("%s+0x%v", tree->rel.section->name, tree->rel.value); minfo ("%s+0x%v", tree->rel.section->name, tree->rel.value);
return; return;
case etree_assign: case etree_assign:
fprintf (config.map_file, "%s", tree->assign.dst); fputs (tree->assign.dst, config.map_file);
exp_print_token (tree->type.node_code, TRUE); exp_print_token (tree->type.node_code, TRUE);
exp_print_tree (tree->assign.src); exp_print_tree (tree->assign.src);
break; break;
@ -1030,20 +1032,38 @@ exp_print_tree (etree_type *tree)
case etree_provided: case etree_provided:
fprintf (config.map_file, "PROVIDE (%s, ", tree->assign.dst); fprintf (config.map_file, "PROVIDE (%s, ", tree->assign.dst);
exp_print_tree (tree->assign.src); exp_print_tree (tree->assign.src);
fprintf (config.map_file, ")"); fputc (')', config.map_file);
break; break;
case etree_binary: case etree_binary:
fprintf (config.map_file, "("); function_like = FALSE;
switch (tree->type.node_code)
{
case MAX_K:
case MIN_K:
case ALIGN_K:
case DATA_SEGMENT_ALIGN:
case DATA_SEGMENT_RELRO_END:
function_like = TRUE;
}
if (function_like)
{
exp_print_token (tree->type.node_code, FALSE);
fputc (' ', config.map_file);
}
fputc ('(', config.map_file);
exp_print_tree (tree->binary.lhs); exp_print_tree (tree->binary.lhs);
if (function_like)
fprintf (config.map_file, ", ");
else
exp_print_token (tree->type.node_code, TRUE); exp_print_token (tree->type.node_code, TRUE);
exp_print_tree (tree->binary.rhs); exp_print_tree (tree->binary.rhs);
fprintf (config.map_file, ")"); fputc (')', config.map_file);
break; break;
case etree_trinary: case etree_trinary:
exp_print_tree (tree->trinary.cond); exp_print_tree (tree->trinary.cond);
fprintf (config.map_file, "?"); fputc ('?', config.map_file);
exp_print_tree (tree->trinary.lhs); exp_print_tree (tree->trinary.lhs);
fprintf (config.map_file, ":"); fputc (':', config.map_file);
exp_print_tree (tree->trinary.rhs); exp_print_tree (tree->trinary.rhs);
break; break;
case etree_unary: case etree_unary:
@ -1052,7 +1072,7 @@ exp_print_tree (etree_type *tree)
{ {
fprintf (config.map_file, " ("); fprintf (config.map_file, " (");
exp_print_tree (tree->unary.child); exp_print_tree (tree->unary.child);
fprintf (config.map_file, ")"); fputc (')', config.map_file);
} }
break; break;
@ -1064,9 +1084,7 @@ exp_print_tree (etree_type *tree)
case etree_name: case etree_name:
if (tree->type.node_code == NAME) if (tree->type.node_code == NAME)
{ fputs (tree->name.name, config.map_file);
fprintf (config.map_file, "%s", tree->name.name);
}
else else
{ {
exp_print_token (tree->type.node_code, FALSE); exp_print_token (tree->type.node_code, FALSE);