Move common symbol check after bed->common_definition
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 7 Aug 2017 15:02:12 +0000 (08:02 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 7 Aug 2017 15:02:29 +0000 (08:02 -0700)
bfd/

* elflink.c (elf_link_add_object_symbols): Move common symbol
check after bed->common_definition.

ld/

* testsuite/ld-elf/pr21903.s (start): Removed.
(_start): Likewise.
(__start): Likewise.
(main): Likewise.
(bar): New.

bfd/ChangeLog
bfd/elflink.c
ld/ChangeLog
ld/testsuite/ld-elf/pr21903.s

index 5d045717170bacc2aa70fdc1e73ca02dc6379d67..3ed2e9e16d7c26e225908080f9708bdac9a26979 100644 (file)
@@ -1,3 +1,8 @@
+2017-08-07  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elflink.c (elf_link_add_object_symbols): Move common symbol
+       check after bed->common_definition.
+
 2017-08-07  Alan Modra  <amodra@gmail.com>
 
        PR 21910
index b89d537df51f209690d16d9d20d281a72dc404b1..424de21f0d98d5845ab84e8674cd1d53f70772d5 100644 (file)
@@ -4250,15 +4250,16 @@ error_free_dyn:
 
       override = FALSE;
 
-      /* Treat common symbol as undefined for --no-define-common.  */
-      if (isym->st_shndx == SHN_COMMON
-         && info->inhibit_common_definition)
-       isym->st_shndx = SHN_UNDEF;
-
       flags = BSF_NO_FLAGS;
       sec = NULL;
       value = isym->st_value;
       common = bed->common_definition (isym);
+      if (common && info->inhibit_common_definition)
+       {
+         /* Treat common symbol as undefined for --no-define-common.  */
+         isym->st_shndx = SHN_UNDEF;
+         common = FALSE;
+       }
       discarded = FALSE;
 
       bind = ELF_ST_BIND (isym->st_info);
index 33fb86848d515c0cb960e62deb0d60ad024d3f02..96dc608db247d4c142c8d3779ebcb31b9e6768f6 100644 (file)
@@ -1,3 +1,11 @@
+2017-08-07  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * testsuite/ld-elf/pr21903.s (start): Removed.
+       (_start): Likewise.
+       (__start): Likewise.
+       (main): Likewise.
+       (bar): New.
+
 2017-08-07  Alan Modra  <amodra@gmail.com>
 
        * testsuite/ld-alpha/alpha.exp: Add --hash-style=sysv to various
index 9dbf96c62e535e667abb0ac10b2202f0ed38ade3..ce26b33f0290f607ed836f3b23e59d2a710411dd 100644 (file)
@@ -1,12 +1,8 @@
        .text
-       .global start   /* Used by SH targets.  */
-start:
-       .global _start
-_start:
-       .global __start
-__start:
-       .global main    /* Used by HPPA targets.  */
-main:
+       .global bar
+bar:
+       .byte 0
+       .data
        .dc.a foo
        .ifdef  HPUX
 foo    .comm   4