Skip to content

Commit

Permalink
[MC][ELF] Copy top 3 bits of st_other to .symver aliases
Browse files Browse the repository at this point in the history
On PowerPC64 ELFv2 ABI, the top 3 bits of st_other encode the local
entry offset. A versioned symbol alias created by .symver should copy
the bits from the source symbol.

This partly fixes PR41048. A full fix needs tracking of .set assignments
and updating st_other fields when finish() is called, see D56586.

Patch by Alfredo Dal'Ava Júnior

Differential Revision: https://reviews.llvm.org/D59436

llvm-svn: 360442
  • Loading branch information
MaskRay authored and MrSidims committed May 24, 2019
1 parent e48a496 commit 80c77e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions llvm/lib/MC/ELFObjectWriter.cpp
Expand Up @@ -1279,6 +1279,7 @@ void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
// This is the first place we are able to copy this information.
Alias->setExternal(Symbol.isExternal());
Alias->setBinding(Symbol.getBinding());
Alias->setOther(Symbol.getOther());

if (!Symbol.isUndefined() && !Rest.startswith("@@@"))
continue;
Expand Down
17 changes: 17 additions & 0 deletions llvm/test/MC/PowerPC/ppc64-localentry-symver.s
@@ -0,0 +1,17 @@
# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-freebsd13.0 %s -o %t
# RUN: llvm-objdump -t %t | FileCheck %s

# CHECK: 0000000000000000 gw F .text 00000000 0x60 __impl_foo
# CHECK: 0000000000000000 g F .text 00000000 0x60 foo
# CHECK: 0000000000000000 gw F .text 00000000 0x60 foo@FBSD_1.1

.globl foo
.type foo,@function
foo:
nop
nop
.localentry foo, 8

.symver __impl_foo, foo@FBSD_1.1
.weak __impl_foo
.set __impl_foo, foo

0 comments on commit 80c77e3

Please sign in to comment.