bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch resolving inverted attributes


From: Yakov Yazlovitsky
Subject: Patch resolving inverted attributes
Date: Tue, 27 Sep 2011 22:16:32 -0400
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10

Index: gold/script-c.h
===================================================================
RCS file: core-toolchain-4x/binutils-2.21/gold/script-c.h,v
retrieving revision 1.1
diff -u -r1.1 script-c.h
--- gold/script-c.h    9 Apr 2011 11:05:29 -0000    1.1
+++ gold/script-c.h    27 Sep 2011 15:23:20 -0000
@@ -198,6 +198,12 @@
   Expression_ptr load_address;
 };

+struct Memory_attr
+{
+  int flags;
+  int inverted_flags;
+};
+
 struct Version_dependency_list;
 struct Version_expression_list;
 struct Version_tree;
@@ -424,11 +430,11 @@
 /* Called by the bison parser for MEMORY regions.  */

 extern void
-script_add_memory(void*, const char*, size_t, unsigned int,
+script_add_memory(void*, const char*, size_t, struct Memory_attr,
           Expression_ptr, Expression_ptr);

 extern unsigned int
-script_parse_memory_attr(void*, const char*, size_t, int);
+script_parse_memory_attr(void*, const char*, size_t);

 extern void
 script_set_section_region(void*, const char*, size_t, int);
Index: gold/script-sections.cc
===================================================================
RCS file: core-toolchain-4x/binutils-2.21/gold/script-sections.cc,v
retrieving revision 1.1
diff -u -r1.1 script-sections.cc
--- gold/script-sections.cc    9 Apr 2011 11:05:29 -0000    1.1
+++ gold/script-sections.cc    27 Sep 2011 15:23:20 -0000
@@ -3031,7 +3031,7 @@

 void
 Script_sections::add_memory_region(const char* name, size_t namelen,
-                   unsigned int attributes,
+                   struct Memory_attr attributes,
                    Expression* start, Expression* length)
 {
   if (this->memory_regions_ == NULL)
Index: gold/script-sections.h
===================================================================
RCS file: core-toolchain-4x/binutils-2.21/gold/script-sections.h,v
retrieving revision 1.1
diff -u -r1.1 script-sections.h
--- gold/script-sections.h    9 Apr 2011 11:05:29 -0000    1.1
+++ gold/script-sections.h    27 Sep 2011 15:23:20 -0000
@@ -221,7 +221,7 @@

   // Add a memory region.
   void
-  add_memory_region(const char*, size_t, unsigned int,
+  add_memory_region(const char*, size_t, struct Memory_attr,
             Expression*, Expression*);

   // Find a memory region's origin.
Index: gold/script.cc
===================================================================
RCS file: core-toolchain-4x/binutils-2.21/gold/script.cc,v
retrieving revision 1.1
diff -u -r1.1 script.cc
--- gold/script.cc    9 Apr 2011 11:05:29 -0000    1.1
+++ gold/script.cc    27 Sep 2011 15:23:20 -0000
@@ -3272,8 +3272,7 @@
 }

 extern "C" unsigned int
-script_parse_memory_attr(void* closurev, const char* attrs, size_t attrlen,
-             int invert)
+script_parse_memory_attr(void* closurev, const char* attrs, size_t attrlen)
 {
   int attributes = 0;

@@ -3301,9 +3300,6 @@
     yyerror(closurev, _("unknown MEMORY attribute"));
       }

-  if (invert)
-    attributes = (~ attributes) & MEM_ATTR_MASK;
-
   return attributes;
 }

Index: gold/yyscript.y
===================================================================
RCS file: core-toolchain-4x/binutils-2.21/gold/yyscript.y,v
retrieving revision 1.1
diff -u -r1.1 yyscript.y
--- gold/yyscript.y    9 Apr 2011 11:05:30 -0000    1.1
+++ gold/yyscript.y    27 Sep 2011 15:23:20 -0000
@@ -71,6 +71,7 @@
   struct Wildcard_section wildcard_section;
   /* A list of strings.  */
   String_list_ptr string_list;
+  struct Memory_attr memory_attr;
   /* Information for a program header.  */
   struct Phdr_info phdr_info;
   /* Used for version scripts and within VERSION {}.  */
@@ -217,7 +218,8 @@
 %type <wildcard_section> wildcard_file wildcard_section
 %type <string_list> exclude_names
 %type <string> wildcard_name
-%type <integer> phdr_type memory_attr
+%type <memory_attr> memory_attr memory_attr_list
+%type <integer> phdr_type
 %type <phdr_info> phdr_info
 %type <versyms> vers_defns
 %type <versnode> vers_tag
@@ -710,14 +712,32 @@

 /* The (optional) attributes of a MEMORY region.  */
 memory_attr:
-      '(' string ')'
-      { $$ = script_parse_memory_attr(closure, $2.value, $2.length, 0); }
-        | /* Inverted attributes. */
-      '(' '!' string ')'
-      { $$ = script_parse_memory_attr(closure, $3.value, $3.length, 1); }
-    | /* empty */
-        { $$ = 0; }
-    ;
+          '(' memory_attr_list ')'
+          { $$ = $2; }
+        | /* empty */
+         {
+           $$.flags = 0;
+           $$.inverted_flags = 0;
+         }
+       ;
+
+memory_attr_list:
+          memory_attr_list string
+          {
+            $$ = $1;
+ $$.flags |= script_parse_memory_attr(closure, $2.value, $2.length);
+          }
+        | memory_attr_list '!' string
+          {
+            $$ = $1;
+ $$.inverted_flags |= script_parse_memory_attr(closure, $3.value, $3.length);
+          }
+        | /* empty */
+         {
+           $$.flags = 0;
+           $$.inverted_flags = 0;
+         }
+       ;

 memory_origin:
           ORIGIN




reply via email to

[Prev in Thread] Current Thread [Next in Thread]