public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/65780] New: [5 Regression] Uninitialized common handling in executables
Date: Wed, 15 Apr 2015 22:29:00 -0000	[thread overview]
Message-ID: <bug-65780-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65780

            Bug ID: 65780
           Summary: [5 Regression] Uninitialized common handling in
                    executables
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org

int optopt;

int
main ()
{
  optopt = 4;
  return 0;
}

fails to link with GCC 5 on powerpc64{,le}-linux:
gcc -O2 -o a a.c
/usr/bin/ld: /tmp/cckV8RvX.o: In function `main':
a.c:(.text.startup+0x6): unresolvable R_PPC64_TOC16_HA against
`optopt@@GLIBC_2.3'
/usr/bin/ld: a.c:(.text.startup+0xe): unresolvable R_PPC64_TOC16_LO against
`optopt@@GLIBC_2.3'
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status

The problem seems to be that targetm.binds_local_p now returns true for !shlib
DECL_COMMON with NULL (or error_mark_node) DECL_INITIAL.
Looking at the difference between 4.9 and 5, there is:
  if (defined_locally && weak_dominate && !shlib)
    resolved_locally = true;
and finally (similar to 4.9)
  /* Uninitialized COMMON variable may be unified with symbols
     resolved from other modules.  */
  if (DECL_COMMON (exp)
      && !resolved_locally
      && (DECL_INITIAL (exp) == NULL
          || (!in_lto_p && DECL_INITIAL (exp) == error_mark_node)))
    return false;
Looking at what x86_64-linux linker does in this case, assuming that an
unitialized common binds locally in the executable if it is defined there works
fine, but clearly not on ppc*.  Either it is a linker bug there, or we for
powerpc* (some other targets too) should treat the uninitialized DECL_COMMON
defined_locally && weak_dominate && !shlib differently - not set
resolved_locally in that case?
Can people try other targets?  The testcase relies on optopt being an integer
variable defined in libc shared library, if that is not the case, create a
shared library with that symbol and link it to the binary.


             reply	other threads:[~2015-04-15 22:29 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-15 22:29 jakub at gcc dot gnu.org [this message]
2015-04-15 22:30 ` [Bug target/65780] " jakub at gcc dot gnu.org
2015-04-15 23:01 ` james410 at cowgill dot org.uk
2015-04-15 23:13 ` hjl.tools at gmail dot com
2015-04-15 23:41 ` hjl.tools at gmail dot com
2015-04-16  0:37 ` amodra at gmail dot com
2015-04-16  2:10 ` hjl.tools at gmail dot com
2015-04-16  2:38 ` hjl.tools at gmail dot com
2015-04-16  3:22 ` [Bug target/65780] [5 Regression] Uninitialized common handling in PIE hjl.tools at gmail dot com
2015-04-16  3:28 ` [Bug target/65780] [5 Regression] Uninitialized common handling in executables amodra at gmail dot com
2015-04-16  4:32 ` hjl.tools at gmail dot com
2015-04-16  7:33 ` jakub at gcc dot gnu.org
2015-04-16  7:39 ` [Bug target/65780] [5/6 " rguenth at gcc dot gnu.org
2015-04-16  7:46 ` jakub at gcc dot gnu.org
2015-04-16 11:09 ` jakub at gcc dot gnu.org
2015-04-16 11:12 ` hjl.tools at gmail dot com
2015-04-16 11:20 ` hjl.tools at gmail dot com
2015-04-16 11:40 ` hjl.tools at gmail dot com
2015-04-16 11:44 ` jakub at gcc dot gnu.org
2015-04-16 11:46 ` hjl.tools at gmail dot com
2015-04-16 11:53 ` hjl.tools at gmail dot com
2015-04-16 12:12 ` jakub at gcc dot gnu.org
2015-04-16 12:33 ` hjl.tools at gmail dot com
2015-04-16 12:41 ` jakub at gcc dot gnu.org
2015-04-16 13:08 ` hjl.tools at gmail dot com
2015-04-16 13:10 ` jakub at gcc dot gnu.org
2015-04-16 13:16 ` hjl.tools at gmail dot com
2015-04-16 15:36 ` jakub at gcc dot gnu.org
2015-04-16 16:09 ` hjl.tools at gmail dot com
2015-04-16 18:14 ` law at redhat dot com
2015-04-16 18:33 ` hjl.tools at gmail dot com
2015-04-16 18:36 ` hjl.tools at gmail dot com
2015-04-16 19:20 ` law at redhat dot com
2015-04-16 19:28 ` hjl.tools at gmail dot com
2015-04-16 21:03 ` jakub at gcc dot gnu.org
2015-04-16 22:02 ` hjl.tools at gmail dot com
2015-04-17 16:12 ` law at redhat dot com
2015-04-17 16:26 ` [Bug target/65780] [5 " hjl.tools at gmail dot com
2015-04-17 16:30 ` jakub at gcc dot gnu.org
2015-04-17 16:36 ` hjl at gcc dot gnu.org
2015-04-17 16:37 ` hjl.tools at gmail dot com
2015-04-17 21:14 ` dominiq at lps dot ens.fr
2015-04-17 21:54 ` hjl at gcc dot gnu.org
2015-04-17 21:55 ` hjl at gcc dot gnu.org
2015-04-17 23:16 ` howarth.at.gcc at gmail dot com
2015-04-18  5:36 ` jakub at gcc dot gnu.org
2015-04-21 14:14 ` evstupac at gmail dot com
2015-04-21 14:18 ` jakub at gcc dot gnu.org
2015-05-11  7:09 ` jakub at gcc dot gnu.org
2015-05-11  7:14 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-65780-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).