public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/95846] New: Combination of LTO and -Wl,--defsym causes symbol to be resolved as NULL
@ 2020-06-23 17:16 cbaylis at gcc dot gnu.org
  2020-06-23 19:55 ` [Bug lto/95846] Combination of LTO and -Wl, --defsym " hjl.tools at gmail dot com
  2020-06-23 21:38 ` cbaylis at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: cbaylis at gcc dot gnu.org @ 2020-06-23 17:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95846
           Summary: Combination of LTO and -Wl,--defsym causes symbol to
                    be resolved as NULL
           Product: gcc
           Version: 10.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cbaylis at gcc dot gnu.org
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

The following program demonstrates this problem:

==============< test1.c >==================
#include <stdio.h>

void f(void);
void g(void);

void f(void)
{
      printf("in f()\n");
      g();
      printf("back in f()\n");
}
==============< test2.c >==================
#include <stdio.h>

void f(void);

void real_g(void)
{
printf("in real_g()\n");
}

int main()
{
    real_g();
    f();
}
============== end ==================

$ gcc -Os -c test1.c
$ gcc -O2 -flto -c test2.c
$ gcc -O2 test1.o test2.o -o test -Wl,--defsym,g=real_g
$ ./test
in real_g()
in f()
Segmentation fault (core dumped)

The segfault is caused because there is no real_g symbol and g has been
resolved to NULL.

0000000000401146 <f>:
  401146:       50                      push   %rax
  401147:       bf 15 20 40 00          mov    $0x402015,%edi
  40114c:       e8 df fe ff ff          callq  401030 <puts@plt>
  401151:       e8 aa ee bf ff          callq  0 <g>    <---------------- oops!
  401156:       bf 10 20 40 00          mov    $0x402010,%edi
  40115b:       5a                      pop    %rdx
  40115c:       e9 cf fe ff ff          jmpq   401030 <puts@plt>
  401161:       66 2e 0f 1f 84 00 00    nopw   %cs:0x0(%rax,%rax,1)
  401168:       00 00 00 
  40116b:       0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)

Seen on Fedora 32 (gcc 10.1.1, binutils 2.34) and Ubuntu 18.04 (gcc 7.5.0,
binutils 2.30)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug lto/95846] Combination of LTO and -Wl, --defsym causes symbol to be resolved as NULL
  2020-06-23 17:16 [Bug lto/95846] New: Combination of LTO and -Wl,--defsym causes symbol to be resolved as NULL cbaylis at gcc dot gnu.org
@ 2020-06-23 19:55 ` hjl.tools at gmail dot com
  2020-06-23 21:38 ` cbaylis at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: hjl.tools at gmail dot com @ 2020-06-23 19:55 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |MOVED

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
It is a binutils bug.  Please open a binutils bug at

https://sourceware.org/bugzilla/enter_bug.cgi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug lto/95846] Combination of LTO and -Wl, --defsym causes symbol to be resolved as NULL
  2020-06-23 17:16 [Bug lto/95846] New: Combination of LTO and -Wl,--defsym causes symbol to be resolved as NULL cbaylis at gcc dot gnu.org
  2020-06-23 19:55 ` [Bug lto/95846] Combination of LTO and -Wl, --defsym " hjl.tools at gmail dot com
@ 2020-06-23 21:38 ` cbaylis at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: cbaylis at gcc dot gnu.org @ 2020-06-23 21:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from cbaylis at gcc dot gnu.org ---
Reported to binutils bugzilla:
https://sourceware.org/bugzilla/show_bug.cgi?id=26163

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-23 21:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23 17:16 [Bug lto/95846] New: Combination of LTO and -Wl,--defsym causes symbol to be resolved as NULL cbaylis at gcc dot gnu.org
2020-06-23 19:55 ` [Bug lto/95846] Combination of LTO and -Wl, --defsym " hjl.tools at gmail dot com
2020-06-23 21:38 ` cbaylis at gcc dot gnu.org

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).