#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixupKindInfo.h"
-#include "llvm/MC/MCMachOSymbolFlags.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSectionMachO.h"
-#include "llvm/MC/MCSymbol.h"
+#include "llvm/MC/MCSymbolMachO.h"
#include "llvm/MC/MCValue.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
// References to weak definitions require external relocation entries; the
// definition may not always be the one in the same object file.
- if (S.getFlags() & SF_WeakDefinition)
+ if (cast<MCSymbolMachO>(S).isWeakDefinition())
return true;
// Otherwise, we can use an internal relocation.
const MCSymbol *AliasedSymbol = &findAliasedSymbol(*Symbol);
uint8_t SectionIndex = MSD.SectionIndex;
uint8_t Type = 0;
- uint16_t Flags = Symbol->getFlags();
uint64_t Address = 0;
bool IsAlias = Symbol != AliasedSymbol;
// Common symbols are encoded with the size in the address
// field, and their alignment in the flags.
Address = Symbol->getCommonSize();
-
- // Common alignment is packed into the 'desc' bits.
- if (unsigned Align = Symbol->getCommonAlignment()) {
- unsigned Log2Size = Log2_32(Align);
- assert((1U << Log2Size) == Align && "Invalid 'common' alignment!");
- if (Log2Size > 15)
- report_fatal_error("invalid 'common' alignment '" +
- Twine(Align) + "' for '" + Symbol->getName() + "'",
- false);
- // FIXME: Keep this mask with the SymbolFlags enumeration.
- Flags = (Flags & 0xF0FF) | (Log2Size << 8);
- }
}
- if (Layout.getAssembler().isThumbFunc(Symbol))
- Flags |= SF_ThumbFunc;
-
// struct nlist (12 bytes)
write32(MSD.StringIndex);
// The Mach-O streamer uses the lowest 16-bits of the flags for the 'desc'
// value.
- write16(Flags);
+ write16(cast<MCSymbolMachO>(Symbol)->getEncodedFlags());
if (is64Bit())
write64(Address);
else
bool Created;
Asm.registerSymbol(*it->Symbol, &Created);
if (Created)
- it->Symbol->setFlags(it->Symbol->getFlags() | 0x0001);
+ cast<MCSymbolMachO>(it->Symbol)->setReferenceTypeUndefinedLazy(true);
}
}
MachSymbolData MSD;
MSD.Symbol = &Symbol;
- MSD.StringIndex = StringTable.getOffset(Symbol.getName());
+ StringRef Name = Symbol.getName();
+ MSD.StringIndex = Name.empty() ? 0 : StringTable.getOffset(Name);
if (Symbol.isAbsolute()) {
MSD.SectionIndex = 0;