2003-05-01 H.J. Lu <hjl@gnu.org>
[deliverable/binutils-gdb.git] / gas / config / obj-elf.c
index 5dc4279b2dc8acfb92815ffbf620f1905f129f67..08e131fe30d86a0f0e309bffa4518d9c06b6fb9b 100644 (file)
@@ -1,6 +1,6 @@
 /* ELF object file format
    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002 Free Software Foundation, Inc.
+   2001, 2002, 2003 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -290,9 +290,10 @@ elf_common (is_common)
   char *name;
   char c;
   char *p;
-  int temp, size;
+  offsetT temp, size, sign;
   symbolS *symbolP;
   int have_align;
+  expressionS exp;
 
   if (flag_mri && is_common)
     {
@@ -313,13 +314,15 @@ elf_common (is_common)
       return NULL;
     }
   input_line_pointer++;                /* skip ',' */
-  if ((temp = get_absolute_expression ()) < 0)
+  temp = get_absolute_expr (&exp);
+  sign = (offsetT) 1 << (stdoutput->arch_info->bits_per_address - 1);
+  size = temp & ((sign << 1) - 1);
+  if (temp != size || !exp.X_unsigned)
     {
-      as_bad (_(".COMMon length (%d.) <0! Ignored."), temp);
+      as_bad (_(".COMMon length (%ld) out of range, ignored."), (long) temp);
       ignore_rest_of_line ();
       return NULL;
     }
-  size = temp;
   *p = 0;
   symbolP = symbol_find_or_make (name);
   *p = c;
@@ -333,8 +336,9 @@ elf_common (is_common)
     {
       if (S_GET_VALUE (symbolP) != (valueT) size)
        {
-         as_warn (_("length of .comm \"%s\" is already %ld; not changed to %d"),
-                  S_GET_NAME (symbolP), (long) S_GET_VALUE (symbolP), size);
+         as_warn (_("length of .comm \"%s\" is already %ld; not changed to %ld"),
+                  S_GET_NAME (symbolP), (long) S_GET_VALUE (symbolP),
+                  (long) size);
        }
     }
   know (symbolP->sy_frag == &zero_address_frag);
@@ -352,8 +356,8 @@ elf_common (is_common)
        temp = 0;
       else
        {
-         temp = get_absolute_expression ();
-         if (temp < 0)
+         temp = get_absolute_expr (&exp);
+         if (!exp.X_unsigned)
            {
              temp = 0;
              as_warn (_("common alignment negative; 0 assumed"));
@@ -751,11 +755,12 @@ obj_elf_change_section (name, type, attr, entsize, group_name, linkonce, push)
       if (type == SHT_NOBITS)
         seg_info (sec)->bss = 1;
 
+      if (linkonce)
+       flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
       bfd_set_section_flags (stdoutput, sec, flags);
       if (flags & SEC_MERGE)
        sec->entsize = entsize;
       elf_group_name (sec) = group_name;
-      elf_linkonce_p (sec) = linkonce;
 
       /* Add a symbol for this section to the symbol table.  */
       secsym = symbol_find (name);
@@ -772,8 +777,8 @@ obj_elf_change_section (name, type, attr, entsize, group_name, linkonce, push)
       if (((old_sec->flags ^ flags)
           & (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE
              | SEC_EXCLUDE | SEC_SORT_ENTRIES | SEC_MERGE | SEC_STRINGS
-             | SEC_THREAD_LOCAL))
-         || linkonce != elf_linkonce_p (sec))
+             | SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD
+             | SEC_THREAD_LOCAL)))
        as_warn (_("ignoring changed section attributes for %s"), name);
       if ((flags & SEC_MERGE) && old_sec->entsize != (unsigned) entsize)
        as_warn (_("ignoring changed section entity size for %s"), name);
@@ -864,6 +869,8 @@ obj_elf_section_word (str, len)
     return SHF_ALLOC;
   if (len == 9 && strncmp (str, "execinstr", 9) == 0)
     return SHF_EXECINSTR;
+  if (len == 3 && strncmp (str, "tls", 3) == 0)
+    return SHF_TLS;
 
 #ifdef md_elf_section_word
   {
@@ -933,6 +940,9 @@ obj_elf_section_name ()
       name = xmalloc (end - input_line_pointer + 1);
       memcpy (name, input_line_pointer, end - input_line_pointer);
       name[end - input_line_pointer] = '\0';
+#ifdef tc_canonicalize_section_name
+      name = tc_canonicalize_section_name (name);
+#endif
       input_line_pointer = end;
     }
   SKIP_WHITESPACE ();
@@ -1262,6 +1272,7 @@ obj_elf_symver (ignore)
     }
 
   ++input_line_pointer;
+  SKIP_WHITESPACE ();
   name = input_line_pointer;
 
   /* Temporarily include '@' in symbol names.  */
@@ -1634,6 +1645,12 @@ obj_elf_type (ignore)
   else if (strcmp (typename, "object") == 0
           || strcmp (typename, "STT_OBJECT") == 0)
     type = BSF_OBJECT;
+  else if (strcmp (typename, "tls_object") == 0
+          || strcmp (typename, "STT_TLS") == 0)
+    type = BSF_OBJECT | BSF_THREAD_LOCAL;
+  else if (strcmp (typename, "notype") == 0
+          || strcmp (typename, "STT_NOTYPE") == 0)
+    ;
 #ifdef md_elf_symbol_type
   else if ((type = md_elf_symbol_type (typename, sym, elfsym)) != -1)
     ;
@@ -2028,7 +2045,7 @@ elf_frob_file ()
 
       flags = SEC_READONLY | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_GROUP;
       for (s = list.head[i]; s != NULL; s = elf_next_in_group (s))
-       if (elf_linkonce_p (s) != ((flags & SEC_LINK_ONCE) != 0))
+       if ((s->flags ^ flags) & SEC_LINK_ONCE)
          {
            flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
            if (s != list.head[i])
This page took 0.026655 seconds and 4 git commands to generate.