[llvm-bugs] [Bug 26580] New: Copy relocation against protected symbol doesn't work

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Feb 11 12:22:57 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26580

            Bug ID: 26580
           Summary: Copy relocation against protected symbol doesn't work
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: hjl.tools at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Protected data symbol means that it can't be pre-emptied.  It doesn't mean
its address won't be external.  This is true for pointer to protected
function.  With copy relocation, address of protected data defined in the
shared library may also be external.  We only know that for sure at run-time.
BFD linker refuses to create such binary.  But gold doesn't check it.

[hjl at gnu-6 pr65248]$ cat x.c
extern int a;

extern void bar (void);

int main()
{
  bar ();
  if (a != 30)
    __builtin_abort();
  return 0;
}
[hjl at gnu-6 pr65248]$ cat bar.c
int a;

__attribute__((visibility("protected"))) int a;

void
bar ()
{
  a = 30;
}
[hjl at gnu-6 pr65248]$ make y
/export/build/gnu/llvm-clang/build-x86_64-linux/bin/clang -O3   -c -o x.o x.c
/export/build/gnu/llvm-clang/build-x86_64-linux/bin/clang -O3 -fpic    -c -o
bar.o bar.c
/export/build/gnu/llvm-clang/build-x86_64-linux/bin/clang  -fuse-ld=gold
-shared -o libfoo.so bar.o
/export/build/gnu/llvm-clang/build-x86_64-linux/bin/clang  -fuse-ld=gold -o y
x.o libfoo.so -Wl,-R,.
[hjl at gnu-6 pr65248]$ ./y
Aborted
[hjl at gnu-6 pr65248]$ make x
/export/build/gnu/llvm-clang/build-x86_64-linux/bin/clang  -shared -o libbar.so
bar.o
/usr/local/bin/ld: bar.o: relocation R_X86_64_PC32 against protected symbol `a'
can not be used when making a shared object
/usr/local/bin/ld: final link failed: Bad value
clang-3.9: error: linker command failed with exit code 1 (use -v to see
invocation)
Makefile:58: recipe for target 'libbar.so' failed
make: *** [libbar.so] Error 1
[hjl at gnu-6 pr65248]$

-- 
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/20160211/6ab0f18c/attachment.html>


More information about the llvm-bugs mailing list