[LLVMbugs] [Bug 22115] New: PPC32: Base pointer clobbered with -fPIC

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jan 7 03:44:44 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22115

            Bug ID: 22115
           Summary: PPC32: Base pointer clobbered with -fPIC
           Product: clang
           Version: 3.5
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: marcus at mc.pp.se
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 13646
  --> http://llvm.org/bugs/attachment.cgi?id=13646&action=edit
Output from clang -fPIC -S for foo.c

clang uses R30 as a pointer to a compilation-unit specific constant pool, but
does not save it in either the caller or callee in cross-compilation-unit
calls.

If the following example:

--8<-- foo.c --8<--
#include <stdio.h>

int foo()
{
  fprintf(stderr, "Two\n");
  return 0;
}

void dummy()
{
  fprintf(stderr, "Gotcha\n");
}
--8<-- bar.c --8<--
#include <stdio.h>
extern int foo(void);

int bar()
{
  fprintf(stderr, "One\n");
  int r = foo();
  fprintf(stderr, "Three\n");
  return r;
}
--8<--

is compiled with -fPIC, the output printed by bar() becomes

One
Two
Gothca

instead of the correct

One
Two
Three

Attaching assembler code generated by clang.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150107/b836709b/attachment.html>


More information about the llvm-bugs mailing list