public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/64420] New: LTO can miscompile IFUNCs designated via top-level asm
@ 2014-12-27 20:23 amonakov at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: amonakov at gcc dot gnu.org @ 2014-12-27 20:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64420
           Summary: LTO can miscompile IFUNCs designated via top-level asm
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amonakov at gcc dot gnu.org

Minimal testcase:

$ cat >test.c <<EOF
#ifdef USE_ASM
void *f_resolver() asm("f");
asm(".type f, %gnu_indirect_function");
void *g_resolver() asm("g");
asm(".type g, %gnu_indirect_function");
#else
int f() __attribute__((ifunc("f_resolver")));
int g() __attribute__((ifunc("g_resolver")));
#endif

static int (*fptr)();
static int (*gptr)();

void *f_resolver() { return fptr; }
void *g_resolver() { return gptr; }
EOF

$ gcc test.c -fPIC -shared -flto -flto-partition=max

$ nm a.out |grep [fg]$
0000000000000750 i f
0000000000000740 i g

$ gcc test.c -fPIC -shared -flto -flto-partition=max -DUSE_ASM

$ nm a.out |grep [fg]$
00000000000006f0 T f
00000000000006e0 i g

Due to LTO partitioning, asm directive and function body can end up in
different assembly files.  The result of such translation will correctly link
without any diagnostics, and fail only at runtime.

This can be a problem for projects using top-level asms to designate ifuncs,
for example in order to avoid bumping the minimum required gcc version to 4.7.

Were there plans to disable LTO partitioning in TUs that contain top-level
asms?


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-12-27 20:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-27 20:23 [Bug ipa/64420] New: LTO can miscompile IFUNCs designated via top-level asm amonakov 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).