[PATCH] D67206: [ELF][MC] Fix IFunc alias resolving issue
Sr.Zhang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 4 18:31:01 PDT 2019
zsrkmyn added a comment.
Suppose we have foo.s as follows:
.text
.p2align 3
.globl foo_impl
.type foo_impl, at function
foo_impl:
ret
.globl foo_resolver
.type foo_resolver, at function
foo_resolver:
mov $foo_impl, %rax
ret
.globl foo
.type foo, at gnu_indirect_function
.set foo,foo_resolver
.globl foo2
.set foo2,foo
and assemble foo.s with GNU as, and check foo.o with nm:
$ as foo.s -o foo.o
$ nm foo.o | grep foo2
0000000000000006 i foo
0000000000000006 i foo2 <- foo2 is an ifunc identical to foo
0000000000000000 T foo_impl
0000000000000006 T foo_resolver
and the 'foo2' is also an ifunc whose resolver is foo_resolver.
However, when assemble with llvm-mc, the 'foo2' becomes normal a
function identical to 'foo_resolver':
$ llvm-mc foo.s -filetype obj -o foo.o
$ nm foo.o
0000000000000006 i foo
0000000000000006 T foo2 <- foo2 is a strong symbol identical to foo_resolver
0000000000000000 T foo_impl
0000000000000006 T foo_resolver
The reason is as follows:
When we 'getBaseSymbol' from 'ELFwriter::writeSymbol' in lib/MC/ELFObjectWriter.cpp, it recursively evaluates the 'Value' of the 'Symbol', and the two direcives -- '.set foo,foo_resolver' and '.set foo2,foo' -- make foo2 is evaluated as 'foo_resolver', and the 'Type' we get below becomes function, while it should be ifunc.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67206/new/
https://reviews.llvm.org/D67206
More information about the llvm-commits
mailing list