Add sanitization markers.
[deliverable/binutils-gdb.git] / gas / literal.c
index 5ae2ff29c9c64cc2ac6d9614c83cee34aec809c0..ada59e73630cabc38e34cb99d6c815475d3a00f4 100644 (file)
@@ -1,5 +1,6 @@
 /* as.c - GAS literal pool management.
    Copyright (C) 1994 Free Software Foundation, Inc.
+   Written by Ken Raeburn (raeburn@cygnus.com).
 
    This file is part of GAS, the GNU Assembler.
 
    ever a .lit4?)  On the MIPS, it could be used for .lit4 as well.
 
    The expressions passed here should contain either constants or symbols,
-   *not* a combination of both.  Typically, the constant pool is accessed
+   not a combination of both.  Typically, the constant pool is accessed
    with some sort of GP register, so the size of the pool must be kept down
    if possible.  The exception is section offsets -- if you're storing a
    pointer to the start of .data, for example, and your machine provides
    for 16-bit signed addends, you might want to store .data+32K, so that
-   you can access all of the first 64K of .data with the one pointer...  */
+   you can access all of the first 64K of .data with the one pointer.
+
+   This isn't a requirement, just a guideline that can help keep .o file
+   size down.  */
 
 #include "as.h"
 #include "subsegs.h"
@@ -49,6 +53,20 @@ add_to_literal_pool (sym, addend, sec, size)
   valueT offset;
   bfd_reloc_code_real_type reloc_type;
   char *p;
+  segment_info_type *seginfo = seg_info (sec);
+  fixS *fixp;
+
+  offset = 0;
+  /* @@ This assumes all entries in a given section will be of the same
+     size...  Probably correct, but unwise to rely on.  */
+  /* This must always be called with the same subsegment.  */
+  for (fixp = frchain_now->fix_root;
+       fixp != (fixS *) NULL;
+       fixp = fixp->fx_next, offset += size)
+    {
+      if (fixp->fx_addsy == sym && fixp->fx_offset == addend)
+       return offset;
+    }
 
   subseg_set (sec, 0);
   p = frag_more (size);
@@ -70,8 +88,8 @@ add_to_literal_pool (sym, addend, sec, size)
 
   subseg_set (current_section, current_subsec);
 
-  offset = seg_info (sec)->literal_pool_size;
-  seg_info (sec)->literal_pool_size += size;
+  offset = seginfo->literal_pool_size;
+  seginfo->literal_pool_size += size;
 
   return offset;
 }
This page took 0.024053 seconds and 4 git commands to generate.