1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

[IRObjectFile] Handle undefined weak symbols in RecordStreamer.

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

llvm-svn: 281629
This commit is contained in:
Davide Italiano 2016-09-15 17:54:22 +00:00
parent 08b3f8b372
commit 3f060f1af6
5 changed files with 28 additions and 7 deletions

View File

@ -113,10 +113,13 @@ void IRObjectFile::CollectAsmUndefinedRefs(
Res |= BasicSymbolRef::SF_Undefined;
Res |= BasicSymbolRef::SF_Global;
break;
case RecordStreamer::GlobalWeak:
case RecordStreamer::DefinedWeak:
Res |= BasicSymbolRef::SF_Weak;
Res |= BasicSymbolRef::SF_Global;
break;
case RecordStreamer::UndefinedWeak:
Res |= BasicSymbolRef::SF_Weak;
Res |= BasicSymbolRef::SF_Undefined;
}
AsmUndefinedRefs(Key, BasicSymbolRef::Flags(Res));
}

View File

@ -23,8 +23,10 @@ void RecordStreamer::markDefined(const MCSymbol &Symbol) {
case Used:
S = Defined;
break;
case GlobalWeak:
case DefinedWeak:
break;
case UndefinedWeak:
S = DefinedWeak;
}
}
@ -34,15 +36,16 @@ void RecordStreamer::markGlobal(const MCSymbol &Symbol,
switch (S) {
case DefinedGlobal:
case Defined:
S = (Attribute == MCSA_Weak) ? GlobalWeak : DefinedGlobal;
S = (Attribute == MCSA_Weak) ? DefinedWeak : DefinedGlobal;
break;
case NeverSeen:
case Global:
case Used:
S = (Attribute == MCSA_Weak) ? GlobalWeak : Global;
S = (Attribute == MCSA_Weak) ? UndefinedWeak : Global;
break;
case GlobalWeak:
case UndefinedWeak:
case DefinedWeak:
break;
}
}
@ -53,7 +56,8 @@ void RecordStreamer::markUsed(const MCSymbol &Symbol) {
case DefinedGlobal:
case Defined:
case Global:
case GlobalWeak:
case DefinedWeak:
case UndefinedWeak:
break;
case NeverSeen:

View File

@ -15,7 +15,8 @@
namespace llvm {
class RecordStreamer : public MCStreamer {
public:
enum State { NeverSeen, Global, GlobalWeak, Defined, DefinedGlobal, Used };
enum State { NeverSeen, Global, Defined, DefinedGlobal, DefinedWeak, Used,
UndefinedWeak};
private:
StringMap<State> Symbols;

View File

@ -1,6 +1,7 @@
; RUN: llvm-as %s -o=%t1
; RUN: llvm-nm %t1 | FileCheck %s
; Check that __libc_blah is reported as defined weak.
; CHECK: W __libc_blah
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
@ -8,3 +9,5 @@ target triple = "x86_64-unknown-freebsd11.0"
module asm ".weak __libc_blah"
module asm ".equ __libc_blah, blah"
module asm ".globl blah"
module asm "blah: ret"

View File

@ -0,0 +1,10 @@
; RUN: llvm-as %s -o=%t1
; RUN: llvm-nm %t1 | FileCheck %s
; Check that patatino is reported as undefined weak.
; CHECK: w patatino
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-freebsd11.0"
module asm ".weak patatino"