bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gold/22628] New: gold ignores version of --wrap symbols


From: benjamin at benjamin dot pe
Subject: [Bug gold/22628] New: gold ignores version of --wrap symbols
Date: Mon, 18 Dec 2017 07:30:38 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=22628

            Bug ID: 22628
           Summary: gold ignores version of --wrap symbols
           Product: binutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gold
          Assignee: ccoutant at gmail dot com
          Reporter: benjamin at benjamin dot pe
                CC: ian at airs dot com
  Target Milestone: ---

gold drops symbol version information from symbols being wrapped with the
--wraps command line option. (A comment source code says this is for the
convenience of wrappers.) Unfortunately, that breaks excessively clever code
like this:

[wrapper.c]
#include <string.h>

__asm__(".symver memcpy,address@hidden");
void* __wrap_memcpy(void* dest, const void* src, size_t n) {
  return memcpy(dest, src, n);
}

In the hands of gold, __wrap_memcpy() is linked into an infinite loop:
$ gcc -O3 -fuse-ld=gold -shared -o wrapped.so wrapper.c -Wl,--wrap=memcpy
$ objdump -d wrapped.so | grep -A1 __wrap_memcpy\>
0000000000000670 <__wrap_memcpy>:
 670:   e9 0b ff ff ff          jmpq   580 <address@hidden>

whereas ld.bfd resolves the memcpy call to address@hidden as the code
intends:
$ gcc -O3 -fuse-ld=bfd -shared -o wrapped.so wrapper.c -Wl,--wrap=memcpy
$ objdump -d wrapped.so | grep -A1 __wrap_memcpy\>
0000000000000610 <__wrap_memcpy>:
 610:   e9 fb fe ff ff          jmpq   510 <address@hidden>

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]