]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: Port "copy st_size only if unset" to aarch64 and riscv
authorFangrui Song <i@maskray.me>
Fri, 8 Apr 2022 21:06:36 +0000 (14:06 -0700)
committerFangrui Song <i@maskray.me>
Fri, 8 Apr 2022 21:06:36 +0000 (14:06 -0700)
And disable the new test gas/elf/size.s for alpha which uses its own
.set, for hppa*-*-hpux* which does not allow .size before declaration.

gas/config/tc-aarch64.c
gas/config/tc-riscv.c
gas/testsuite/gas/elf/size.d

index cbebc6b48c848caf213cf8258e68e8ca6826beb1..dee7d19d94ab218a2017c84bf64f27f162e564c9 100644 (file)
@@ -10469,17 +10469,17 @@ aarch64_elf_copy_symbol_attributes (symbolS *dest, symbolS *src)
 {
   struct elf_obj_sy *srcelf = symbol_get_obj (src);
   struct elf_obj_sy *destelf = symbol_get_obj (dest);
-  if (srcelf->size)
+  /* If size is unset, copy size from src.  Because we don't track whether
+     .size has been used, we can't differentiate .size dest, 0 from the case
+     where dest's size is unset.  */
+  if (!destelf->size && S_GET_SIZE (dest) == 0)
     {
-      if (destelf->size == NULL)
-       destelf->size = XNEW (expressionS);
-      *destelf->size = *srcelf->size;
-    }
-  else
-    {
-      free (destelf->size);
-      destelf->size = NULL;
+      if (srcelf->size)
+       {
+         destelf->size = XNEW (expressionS);
+         *destelf->size = *srcelf->size;
+       }
+      S_SET_SIZE (dest, S_GET_SIZE (src));
     }
-  S_SET_SIZE (dest, S_GET_SIZE (src));
 }
 #endif
index bb5f6e4aedd6f4fb369365d398c7b28ec4d256bb..fb3fc649802cfa8e3c5d1da362f640be26d748be 100644 (file)
@@ -4540,19 +4540,18 @@ riscv_elf_copy_symbol_attributes (symbolS *dest, symbolS *src)
 {
   struct elf_obj_sy *srcelf = symbol_get_obj (src);
   struct elf_obj_sy *destelf = symbol_get_obj (dest);
-  if (srcelf->size)
+  /* If size is unset, copy size from src.  Because we don't track whether
+     .size has been used, we can't differentiate .size dest, 0 from the case
+     where dest's size is unset.  */
+  if (!destelf->size && S_GET_SIZE (dest) == 0)
     {
-      if (destelf->size == NULL)
-       destelf->size = XNEW (expressionS);
-      *destelf->size = *srcelf->size;
-    }
-  else
-    {
-      if (destelf->size != NULL)
-       free (destelf->size);
-      destelf->size = NULL;
+      if (srcelf->size)
+       {
+         destelf->size = XNEW (expressionS);
+         *destelf->size = *srcelf->size;
+       }
+      S_SET_SIZE (dest, S_GET_SIZE (src));
     }
-  S_SET_SIZE (dest, S_GET_SIZE (src));
 }
 
 /* RISC-V pseudo-ops table.  */
index 51bf4eb66ca7c4048252c989399f0a1d044c4261..5890386a14da6203f290a28d3255c9fa6a393aff 100644 (file)
@@ -1,5 +1,7 @@
 #readelf: -sW
 #name: ELF symbol size
+#notarget: alpha-*-* hppa*-*-hpux*
+# The Alpha target uses its own .set pseudo-insn.
 
 #...
  +[0-9]+: 0+ +1 +NOTYPE +LOCAL +DEFAULT +[0-9]+ +foo1