This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] ld: improve print of SEGMENT_START expression.


Hi,

the SEGMENT_START command is not currently well printed in linker map.

Eg:

. = SEGMENT_START("text-segment", (DEFINED (__wrs_rtp_base) ? __wrs_rtp_base : 0)) + SIZEOF_HEADERS;

is currently printed as:

. = ((DEFINED (__wrs_rtp_base)?__wrs_rtp_base:0x0 SEGMENT_START text-segment) + SIZEOF_HEADERS)

which is not very user friendly.  With this patch, it is printed almost like it was written:

. = (SEGMENT_START ("text-segment", DEFINED (__wrs_rtp_base)?__wrs_rtp_base:0x0) + SIZEOF_HEADERS)

No regressions in the ld test suite when cross testing for powerpc-wrs-vxworks.

Ok for trunk ?

Tristan.

ld/
2012-03-07  Tristan Gingold  <gingold@adacore.com>

	* ldexp.c (exp_print_tree): Special case for SEGMENT_START.
	(exp_print_token): Constify.


diff --git a/ld/ldexp.c b/ld/ldexp.c
index bf0e00b..59743ea 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -59,7 +59,7 @@ exp_print_token (token_code_type code, int infix_p)
   static const struct
   {
     token_code_type code;
-    char * name;
+    const char * name;
   }
   table[] =
   {
@@ -1145,6 +1145,17 @@ exp_print_tree (etree_type *tree)
 	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)
 	{


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]