This is the mail archive of the binutils@sourceware.cygnus.com 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]

Patch to add ARM Mapping symbols


Attached is a patch which generates the ARM Mapping Symbols, defined in the
ARM ELF Specification, which can be used to determine which areas of a
section contain ARM code, Thumb code or data.

Keith
This patch to the binutils packag provides the ability to create the
ARM Mapping symbols defined in section 5.4.6 in the ARM ELF specification
(which can be found at http://www.arm.com/Documentation/ISTSpecs/).

This facility is included by defining the pre-processor symbol
ARM_MAPPING_SYMBOLS.

[The sorting of mapping symbols to before the local symbols (are required
in the ARM ELD specification) is, unfortunately, included in what is
effectively generic code rather than ARM specific code.  Someone who
is more proficient with the source can hopefully identify if there
is a more appropriate place for this code.]


Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.37
diff -c -r1.37 elf.c
*** elf.c	2000/06/19 01:22:37	1.37
--- elf.c	2000/07/05 10:22:52
***************
*** 2130,2135 ****
--- 2130,2160 ----
  	}
      }
  
+ #ifdef ARM_MAPPING_SYMBOLS
+   /* sort mapping symbols before normal local symbols */
+   {
+     int changed;
+     do
+       {
+       changed = 0;
+       for (idx=0; idx <num_locals-1; idx++)
+ 	{
+ 	  if (new_syms[idx]->name[0] != new_syms[idx+1]->name[0]
+ 	    && new_syms[idx+1]->name[0] == '$'
+ 	    && new_syms[idx+1]->name[2] == '\0')
+ 	    {
+ 	      asymbol *sym = new_syms[idx];
+ 	      new_syms[idx] = new_syms[idx+1];
+ 	      new_syms[idx+1] = sym;
+ 	      new_syms[idx]->udata.i = idx+1;
+ 	      new_syms[idx+1]->udata.i = idx+2;
+ 	      changed++;
+ 	    }
+ 	}
+       } while (changed);
+   }
+ #endif
+ 
    bfd_set_symtab (abfd, new_syms, num_locals + num_globals);
  
    elf_num_locals (abfd) = num_locals;
Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.49
diff -c -r1.49 tc-arm.c
*** tc-arm.c	2000/07/04 05:49:04	1.49
--- tc-arm.c	2000/07/05 10:22:58
***************
*** 1407,1412 ****
--- 1407,1461 ----
    demand_empty_rest_of_line ();
  }
  
+ #ifdef ARM_MAPPING_SYMBOLS
+ enum mstate { MAP_DATA, MAP_ARM, MAP_THUMB, MAP_THUMB_BL };
+ mapping_state(state)
+      enum mstate state;
+ {
+   static enum mstate mapstate = MAP_DATA;
+   symbolS *symbolP;
+   const char *symname;
+   int type;
+ 
+   switch (state)
+     {
+     case MAP_DATA:
+     case MAP_ARM:
+     case MAP_THUMB:
+       if (mapstate == state)
+ 	return;
+       mapstate = state;
+       break;
+     }
+ 
+   switch (state)
+     {
+     case MAP_DATA:
+       symname = "$d";
+       type = BSF_OBJECT;
+       break;
+     case MAP_ARM:
+       symname = "$a";
+       type = BSF_FUNCTION;
+       break;
+     case MAP_THUMB:
+       symname = "$t";
+       type = BSF_FUNCTION;
+       break;
+     case MAP_THUMB_BL:
+       symname = "$b";
+       type = BSF_FUNCTION;
+       break;
+     default:
+       return;
+     }
+ 
+   symbolP = symbol_new (symname, now_seg, (valueT) frag_now_fix(), frag_now);
+   symbol_table_insert (symbolP);
+   symbol_get_bfdsym (symbolP)->flags |= type;
+ }
+ #endif
+ 
  static void
  s_thumb_func (ignore)
       int ignore ATTRIBUTE_UNUSED;
***************
*** 1419,1424 ****
--- 1468,1476 ----
    label_is_thumb_function_name = true;
  
    demand_empty_rest_of_line ();
+ #ifdef ARM_MAPPING_SYMBOLS
+   mapping_state (MAP_THUMB);
+ #endif
  }
  
  /* Perform a .set directive, but also mark the alias as
***************
*** 1576,1581 ****
--- 1628,1636 ----
               coming from ARM mode, which is word-aligned. */
            record_alignment (now_seg, 1);
  	}
+ #ifdef ARM_MAPPING_SYMBOLS
+ 	mapping_state (MAP_THUMB);
+ #endif
        break;
  
      case 32:
***************
*** 1588,1593 ****
--- 1643,1651 ----
              frag_align (2, 0, 0);
            record_alignment (now_seg, 1);
  	}
+ #ifdef ARM_MAPPING_SYMBOLS
+ 	mapping_state (MAP_ARM);
+ #endif
        break;
  
      default:
***************
*** 4839,4844 ****
--- 4897,4906 ----
    if (my_get_expression (& inst.reloc.exp, & str))
      return;
    
+ #ifdef ARM_MAPPING_SYMBOLS
+   mapping_state (MAP_THUMB_BL);
+ #endif
+ 
    inst.reloc.type   = BFD_RELOC_THUMB_PCREL_BRANCH23;
    inst.reloc.pc_rel = 1;
    end_of_line (str);
***************
*** 7338,7343 ****
--- 7400,7409 ----
  
  #ifdef md_cons_align
    md_cons_align (nbytes);
+ #endif
+ 
+ #ifdef ARM_MAPPING_SYMBOLS
+   mapping_state (MAP_DATA);
  #endif
  
    do
Index: gas/config/tc-arm.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.h,v
retrieving revision 1.5
diff -c -r1.5 tc-arm.h
*** tc-arm.h	1999/10/27 18:12:32	1.5
--- tc-arm.h	2000/07/05 10:23:01
***************
*** 208,211 ****
--- 208,212 ----
  #define GLOBAL_OFFSET_TABLE_NAME "__GLOBAL_OFFSET_TABLE_"
  #endif
       
+ #define ARM_MAPPING_SYMBOLS
  /* end of tc-arm.h */
Keith Walker		keith.walker@arm.com		Tel:+44 (1628) 427732
ARM Ltd		http://www.arm.com

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