From 2980ccad5958af178f80fd2a2a0fa781bf91b0aa Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 7 Aug 2017 08:02:12 -0700 Subject: [PATCH] Move common symbol check after bed->common_definition 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 | 5 +++++ bfd/elflink.c | 11 ++++++----- ld/ChangeLog | 8 ++++++++ ld/testsuite/ld-elf/pr21903.s | 12 ++++-------- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 5d045717170..3ed2e9e16d7 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2017-08-07 H.J. Lu + + * elflink.c (elf_link_add_object_symbols): Move common symbol + check after bed->common_definition. + 2017-08-07 Alan Modra PR 21910 diff --git a/bfd/elflink.c b/bfd/elflink.c index b89d537df51..424de21f0d9 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -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); diff --git a/ld/ChangeLog b/ld/ChangeLog index 33fb86848d5..96dc608db24 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,11 @@ +2017-08-07 H.J. Lu + + * testsuite/ld-elf/pr21903.s (start): Removed. + (_start): Likewise. + (__start): Likewise. + (main): Likewise. + (bar): New. + 2017-08-07 Alan Modra * testsuite/ld-alpha/alpha.exp: Add --hash-style=sysv to various diff --git a/ld/testsuite/ld-elf/pr21903.s b/ld/testsuite/ld-elf/pr21903.s index 9dbf96c62e5..ce26b33f029 100644 --- a/ld/testsuite/ld-elf/pr21903.s +++ b/ld/testsuite/ld-elf/pr21903.s @@ -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 -- 2.30.2