This is an archive of the discontinued LLVM Phabricator instance.

--wrap
Needs ReviewPublic

Authored by ruiu on Oct 7 2015, 1:08 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None

Diff Detail

Event Timeline

ruiu updated this revision to Diff 36784.Oct 7 2015, 1:08 PM
ruiu retitled this revision from to --wrap.
ruiu updated this object.

It fails wrap2.s test.

ikudrin added a comment.EditedOct 7 2015, 10:22 PM
$ cat > a.s << EOF
> .globl foo,__wrap_foo,__real_foo
> foo = 0x10
> __wrap_foo = 0x20
> __real_foo = 0x30
> EOF
$ llvm-mc -filetype=obj -triple=x86_64-pc-linux a.s -o a.o
$ ld -shared a.o -o ld.out -wrap=foo
$ lld -flavor gnu2 -shared a.o -o lld.out -wrap=foo
$ readelf -s ld.out | fgrep "foo"
     1: 0000000000000030     0 NOTYPE  GLOBAL DEFAULT  ABS __real_foo
     3: 0000000000000020     0 NOTYPE  GLOBAL DEFAULT  ABS __wrap_foo
     4: 0000000000000010     0 NOTYPE  GLOBAL DEFAULT  ABS foo
     8: 0000000000000030     0 NOTYPE  GLOBAL DEFAULT  ABS __real_foo
    10: 0000000000000020     0 NOTYPE  GLOBAL DEFAULT  ABS __wrap_foo
    11: 0000000000000010     0 NOTYPE  GLOBAL DEFAULT  ABS foo
$ readelf -s lld.out | fgrep "foo"
     1: 0000000000000010     0 NOTYPE  LOCAL  HIDDEN   ABS __real_foo
     2: 0000000000000020     0 NOTYPE  LOCAL  HIDDEN   ABS __wrap_foo
     3: 0000000000000020     0 NOTYPE  LOCAL  HIDDEN   ABS foo
$ cat > wrap.s << EOF
> .globl __wrap_foo
> __wrap_foo:
>   ret
> EOF

$ cat > main.s << EOF
> .globl _start
> _start:
>   call foo
> EOF

$ llvm-mc -filetype=obj -triple=x86_64-pc-linux -o wrap.o wrap.s
$ llvm-mc -filetype=obj -triple=x86_64-pc-linux -o main.o main.s

$ ld -o ld.out main.o wrap.o -wrap=foo

$ lld -flavor gnu2 -o lld.out main.o wrap.o -wrap=foo
undefined symbol: foo in main.o