diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-10-06 16:47:31 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-10-06 16:47:31 +0000 |
commit | 3223f19ff0920ffee686faba3bf74babf580e8a5 (patch) | |
tree | 6f0c6b781d9110bfaaf58487eedd36d03c44dc2e | |
parent | 8cecf253e45f144b9a7fd0ace85eeeeb0bebfc83 (diff) | |
download | external_llvm-3223f19ff0920ffee686faba3bf74babf580e8a5.zip external_llvm-3223f19ff0920ffee686faba3bf74babf580e8a5.tar.gz external_llvm-3223f19ff0920ffee686faba3bf74babf580e8a5.tar.bz2 |
Make sure weak symbols are listed after the local ones.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115795 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/MC/ELFObjectWriter.cpp | 5 | ||||
-rw-r--r-- | lib/MC/MCELFStreamer.cpp | 1 | ||||
-rw-r--r-- | test/MC/ELF/weak.s | 16 |
3 files changed, 20 insertions, 2 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index da3e7ef..cbe0ebf 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -512,8 +512,9 @@ void ELFObjectWriterImpl::WriteSymbolTable(MCDataFragment *F, for (unsigned i = 0, e = ExternalSymbolData.size(); i != e; ++i) { ELFSymbolData &MSD = ExternalSymbolData[i]; MCSymbolData &Data = *MSD.SymbolData; - assert((Data.getFlags() & ELF_STB_Global) && - "External symbol requires STB_GLOBAL flag"); + assert(((Data.getFlags() & ELF_STB_Global) || + (Data.getFlags() & ELF_STB_Weak)) && + "External symbol requires STB_GLOBAL or STB_WEAK flag"); WriteSymbol(F, MSD, Layout); if (GetBinding(Data) == ELF::STB_LOCAL) LastLocalSymbolIndex++; diff --git a/lib/MC/MCELFStreamer.cpp b/lib/MC/MCELFStreamer.cpp index b63bedc..65a0a7d 100644 --- a/lib/MC/MCELFStreamer.cpp +++ b/lib/MC/MCELFStreamer.cpp @@ -272,6 +272,7 @@ void MCELFStreamer::EmitSymbolAttribute(MCSymbol *Symbol, case MCSA_WeakReference: case MCSA_Weak: SetBinding(SD, ELF::STB_WEAK); + SD.setExternal(true); BindingExplicitlySet.insert(Symbol); break; diff --git a/test/MC/ELF/weak.s b/test/MC/ELF/weak.s index ef8e000..0b93a87 100644 --- a/test/MC/ELF/weak.s +++ b/test/MC/ELF/weak.s @@ -5,6 +5,20 @@ .weak foo .long foo +// And that bar is after all local symbols + .weak bar +bar: + +//CHECK: # Symbol 4 +//CHECK-NEXT: (('st_name', 5) # 'bar' +//CHECK-NEXT: ('st_bind', 2) +//CHECK-NEXT: ('st_type', 0) +//CHECK-NEXT: ('st_other', 0) +//CHECK-NEXT: ('st_shndx', 1) +//CHECK-NEXT: ('st_value', 0) +//CHECK-NEXT: ('st_size', 0) +//CHECK-NEXT: ), +//CHECK-NEXT: # Symbol 5 //CHECK: (('st_name', 1) # 'foo' //CHECK-NEXT: ('st_bind', 2) //CHECK-NEXT: ('st_type', 0) @@ -12,3 +26,5 @@ //CHECK-NEXT: ('st_shndx', 0) //CHECK-NEXT: ('st_value', 0) //CHECK-NEXT: ('st_size', 0) +//CHECK-NEXT: ), +//CHECK-NEXT: ]) |