forked from OSchip/llvm-project
Handle null and file symbol on doInitialization
llvm-svn: 77354
This commit is contained in:
parent
faf0c64d9d
commit
c6c5dbd5b8
|
@ -36,7 +36,7 @@ namespace llvm {
|
||||||
/// startFunction - This callback is invoked when a new machine function is
|
/// startFunction - This callback is invoked when a new machine function is
|
||||||
/// about to be emitted.
|
/// about to be emitted.
|
||||||
void ELFCodeEmitter::startFunction(MachineFunction &MF) {
|
void ELFCodeEmitter::startFunction(MachineFunction &MF) {
|
||||||
DEBUG(errs() << "processing function: "
|
DEBUG(errs() << "processing function: "
|
||||||
<< MF.getFunction()->getName() << "\n");
|
<< MF.getFunction()->getName() << "\n");
|
||||||
|
|
||||||
// Get the ELF Section that this function belongs in.
|
// Get the ELF Section that this function belongs in.
|
||||||
|
|
|
@ -143,6 +143,11 @@ bool ELFWriter::doInitialization(Module &M) {
|
||||||
// Add the null section, which is required to be first in the file.
|
// Add the null section, which is required to be first in the file.
|
||||||
getNullSection();
|
getNullSection();
|
||||||
|
|
||||||
|
// The first entry in the symtab is the null symbol and the second
|
||||||
|
// is a local symbol containing the module/file name
|
||||||
|
SymbolList.push_back(new ELFSym());
|
||||||
|
SymbolList.push_back(ELFSym::getFileSym());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +194,7 @@ ELFSection &ELFWriter::getConstantPoolSection(MachineConstantPoolEntry &CPE) {
|
||||||
|
|
||||||
const TargetLoweringObjectFile &TLOF =
|
const TargetLoweringObjectFile &TLOF =
|
||||||
TM.getTargetLowering()->getObjFileLowering();
|
TM.getTargetLowering()->getObjFileLowering();
|
||||||
|
|
||||||
return getSection(TLOF.getSectionForMergeableConstant(Kind)->getName(),
|
return getSection(TLOF.getSectionForMergeableConstant(Kind)->getName(),
|
||||||
ELFSection::SHT_PROGBITS,
|
ELFSection::SHT_PROGBITS,
|
||||||
ELFSection::SHF_MERGE | ELFSection::SHF_ALLOC,
|
ELFSection::SHF_MERGE | ELFSection::SHF_ALLOC,
|
||||||
|
@ -320,7 +325,7 @@ void ELFWriter::EmitGlobal(const GlobalValue *GV) {
|
||||||
const TargetLoweringObjectFile &TLOF =
|
const TargetLoweringObjectFile &TLOF =
|
||||||
TM.getTargetLowering()->getObjFileLowering();
|
TM.getTargetLowering()->getObjFileLowering();
|
||||||
|
|
||||||
// Get ELF section from TAI
|
// Get the ELF section where this global belongs from TLOF
|
||||||
const Section *S = TLOF.SectionForGlobal(GV, TM);
|
const Section *S = TLOF.SectionForGlobal(GV, TM);
|
||||||
unsigned SectionFlags = getElfSectionFlags(S->getKind());
|
unsigned SectionFlags = getElfSectionFlags(S->getKind());
|
||||||
|
|
||||||
|
@ -522,9 +527,6 @@ bool ELFWriter::doFinalization(Module &M) {
|
||||||
if (TAI->getNonexecutableStackDirective())
|
if (TAI->getNonexecutableStackDirective())
|
||||||
getNonExecStackSection();
|
getNonExecStackSection();
|
||||||
|
|
||||||
// Emit module name
|
|
||||||
SymbolList.push_back(ELFSym::getFileSym());
|
|
||||||
|
|
||||||
// Emit a symbol for each section created until now, skip null section
|
// Emit a symbol for each section created until now, skip null section
|
||||||
for (unsigned i = 1, e = SectionList.size(); i < e; ++i) {
|
for (unsigned i = 1, e = SectionList.size(); i < e; ++i) {
|
||||||
ELFSection &ES = *SectionList[i];
|
ELFSection &ES = *SectionList[i];
|
||||||
|
@ -798,9 +800,6 @@ void ELFWriter::EmitSymbolTable() {
|
||||||
// Size of each symtab entry.
|
// Size of each symtab entry.
|
||||||
SymTab.EntSize = TEW->getSymTabEntrySize();
|
SymTab.EntSize = TEW->getSymTabEntrySize();
|
||||||
|
|
||||||
// The first entry in the symtab is the null symbol
|
|
||||||
SymbolList.insert(SymbolList.begin(), new ELFSym());
|
|
||||||
|
|
||||||
// Reorder the symbol table with local symbols first!
|
// Reorder the symbol table with local symbols first!
|
||||||
unsigned FirstNonLocalSymbol = SortSymbols();
|
unsigned FirstNonLocalSymbol = SortSymbols();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue