mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-12 13:30:51 +00:00
llvm-nm: treat weak undefined as undefined.
This matches the behavior of gnu ld. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241512 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1249487852
commit
fa2ca74300
9
test/Object/X86/nm-coff.s
Normal file
9
test/Object/X86/nm-coff.s
Normal file
@ -0,0 +1,9 @@
|
||||
// RUN: llvm-mc %s -o %t -filetype=obj -triple=x86_64-pc-win32
|
||||
// RUN: llvm-nm --undefined-only %t | FileCheck %s
|
||||
// CHECK: w foo
|
||||
|
||||
g:
|
||||
movl foo(%rip), %eax
|
||||
retq
|
||||
|
||||
.weak foo
|
@ -71,6 +71,8 @@ CHECKIDX: Debug\mymath.obj:
|
||||
CHECKIDX: U ??2@YAPAXI@Z
|
||||
CHECKIDX: U ??3@YAXPAX@Z
|
||||
CHECKIDX: U ??_7type_info@@6B@
|
||||
CHECKIDX: w ??_Einvalid_argument@std@@UAEPAXI@Z
|
||||
CHECKIDX: w ??_Elogic_error@std@@UAEPAXI@Z
|
||||
CHECKIDX: U ??_Ginvalid_argument@std@@UAEPAXI@Z
|
||||
CHECKIDX: U ??_Glogic_error@std@@UAEPAXI@Z
|
||||
CHECKIDX: U ?what@exception@std@@UBEPBDXZ
|
||||
@ -222,5 +224,3 @@ CHECKIDX: 00000004 R ??_7logic_error@std@@6B@
|
||||
CHECKIDX: 00000008 r __ehfuncinfo$?Divide@MyMathFuncs@MathFuncs@@SANNN@Z
|
||||
CHECKIDX: 0000000e t __ehhandler$?Divide@MyMathFuncs@MathFuncs@@SANNN@Z
|
||||
CHECKIDX: 00ab9d1b a @comp.id
|
||||
CHECKIDX: w ??_Einvalid_argument@std@@UAEPAXI@Z
|
||||
CHECKIDX: w ??_Elogic_error@std@@UAEPAXI@Z
|
||||
|
@ -180,14 +180,16 @@ struct NMSymbol {
|
||||
uint64_t Size;
|
||||
char TypeChar;
|
||||
StringRef Name;
|
||||
DataRefImpl Symb;
|
||||
BasicSymbolRef Sym;
|
||||
};
|
||||
}
|
||||
|
||||
static bool compareSymbolAddress(const NMSymbol &A, const NMSymbol &B) {
|
||||
if (A.TypeChar == 'U' && B.TypeChar != 'U')
|
||||
bool AUndefined = A.Sym.getFlags() & SymbolRef::SF_Undefined;
|
||||
bool BUndefined = B.Sym.getFlags() & SymbolRef::SF_Undefined;
|
||||
if (AUndefined && !BUndefined)
|
||||
return true;
|
||||
if (A.TypeChar != 'U' && B.TypeChar == 'U')
|
||||
if (!AUndefined && BUndefined)
|
||||
return false;
|
||||
if (A.Address < B.Address)
|
||||
return true;
|
||||
@ -249,11 +251,12 @@ static void darwinPrintSymbol(MachOObjectFile *MachO, SymbolListT::iterator I,
|
||||
uint16_t NDesc;
|
||||
uint32_t NStrx;
|
||||
uint64_t NValue;
|
||||
DataRefImpl SymDRI = I->Sym.getRawDataRefImpl();
|
||||
if (MachO->is64Bit()) {
|
||||
H_64 = MachO->MachOObjectFile::getHeader64();
|
||||
Filetype = H_64.filetype;
|
||||
Flags = H_64.flags;
|
||||
STE_64 = MachO->getSymbol64TableEntry(I->Symb);
|
||||
STE_64 = MachO->getSymbol64TableEntry(SymDRI);
|
||||
NType = STE_64.n_type;
|
||||
NSect = STE_64.n_sect;
|
||||
NDesc = STE_64.n_desc;
|
||||
@ -263,7 +266,7 @@ static void darwinPrintSymbol(MachOObjectFile *MachO, SymbolListT::iterator I,
|
||||
H = MachO->MachOObjectFile::getHeader();
|
||||
Filetype = H.filetype;
|
||||
Flags = H.flags;
|
||||
STE = MachO->getSymbolTableEntry(I->Symb);
|
||||
STE = MachO->getSymbolTableEntry(SymDRI);
|
||||
NType = STE.n_type;
|
||||
NSect = STE.n_sect;
|
||||
NDesc = STE.n_desc;
|
||||
@ -331,7 +334,7 @@ static void darwinPrintSymbol(MachOObjectFile *MachO, SymbolListT::iterator I,
|
||||
break;
|
||||
case MachO::N_SECT: {
|
||||
section_iterator Sec = MachO->section_end();
|
||||
MachO->getSymbolSection(I->Symb, Sec);
|
||||
MachO->getSymbolSection(I->Sym.getRawDataRefImpl(), Sec);
|
||||
DataRefImpl Ref = Sec->getRawDataRefImpl();
|
||||
StringRef SectionName;
|
||||
MachO->getSectionName(Ref, SectionName);
|
||||
@ -390,7 +393,7 @@ static void darwinPrintSymbol(MachOObjectFile *MachO, SymbolListT::iterator I,
|
||||
if ((NType & MachO::N_TYPE) == MachO::N_INDR) {
|
||||
outs() << I->Name << " (for ";
|
||||
StringRef IndirectName;
|
||||
if (MachO->getIndirectName(I->Symb, IndirectName))
|
||||
if (MachO->getIndirectName(I->Sym.getRawDataRefImpl(), IndirectName))
|
||||
outs() << "?)";
|
||||
else
|
||||
outs() << IndirectName << ")";
|
||||
@ -473,13 +476,14 @@ static void darwinPrintStab(MachOObjectFile *MachO, SymbolListT::iterator I) {
|
||||
uint8_t NType;
|
||||
uint8_t NSect;
|
||||
uint16_t NDesc;
|
||||
DataRefImpl SymDRI = I->Sym.getRawDataRefImpl();
|
||||
if (MachO->is64Bit()) {
|
||||
STE_64 = MachO->getSymbol64TableEntry(I->Symb);
|
||||
STE_64 = MachO->getSymbol64TableEntry(SymDRI);
|
||||
NType = STE_64.n_type;
|
||||
NSect = STE_64.n_sect;
|
||||
NDesc = STE_64.n_desc;
|
||||
} else {
|
||||
STE = MachO->getSymbolTableEntry(I->Symb);
|
||||
STE = MachO->getSymbolTableEntry(SymDRI);
|
||||
NType = STE.n_type;
|
||||
NSect = STE.n_sect;
|
||||
NDesc = STE.n_desc;
|
||||
@ -537,9 +541,11 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName,
|
||||
|
||||
for (SymbolListT::iterator I = SymbolList.begin(), E = SymbolList.end();
|
||||
I != E; ++I) {
|
||||
if ((I->TypeChar != 'U') && UndefinedOnly)
|
||||
uint32_t SymFlags = I->Sym.getFlags();
|
||||
bool Undefined = SymFlags & SymbolRef::SF_Undefined;
|
||||
if (!Undefined && UndefinedOnly)
|
||||
continue;
|
||||
if ((I->TypeChar == 'U') && DefinedOnly)
|
||||
if (Undefined && DefinedOnly)
|
||||
continue;
|
||||
if (SizeSort && !PrintAddress)
|
||||
continue;
|
||||
@ -895,7 +901,7 @@ static void dumpSymbolNamesFromObject(SymbolicFile &Obj, bool printName,
|
||||
if (error(Sym.printName(OS)))
|
||||
break;
|
||||
OS << '\0';
|
||||
S.Symb = Sym.getRawDataRefImpl();
|
||||
S.Sym = Sym;
|
||||
SymbolList.push_back(S);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user