mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-27 02:31:09 +00:00
Add support for 64-bit elf files
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22400 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
39429617e0
commit
46c53054d0
@ -197,11 +197,10 @@ bool ELFWriter::doInitialization(Module &M) {
|
||||
outaddr(0); // e_shoff
|
||||
outword(e_flags); // e_flags = whatever the target wants
|
||||
|
||||
assert(!is64Bit && "These sizes need to be adjusted for 64-bit!");
|
||||
outhalf(52); // e_ehsize = ELF header size
|
||||
outhalf(is64Bit ? 64 : 52); // e_ehsize = ELF header size
|
||||
outhalf(0); // e_phentsize = prog header entry size
|
||||
outhalf(0); // e_phnum = # prog header entries = 0
|
||||
outhalf(40); // e_shentsize = sect header entry size
|
||||
outhalf(is64Bit ? 64 : 40); // e_shentsize = sect header entry size
|
||||
|
||||
|
||||
ELFHeader_e_shnum_Offset = OutputBuffer.size();
|
||||
@ -409,27 +408,36 @@ void ELFWriter::EmitSymbolTable() {
|
||||
|
||||
// Now that we have emitted the string table and know the offset into the
|
||||
// string table of each symbol, emit the symbol table itself.
|
||||
assert(!is64Bit && "Should this be 8 byte aligned for 64-bit?"
|
||||
" (check .Align below also)");
|
||||
align(4);
|
||||
align(is64Bit ? 8 : 4);
|
||||
|
||||
SectionList.push_back(ELFSection(".symtab", OutputBuffer.size()));
|
||||
ELFSection &SymTab = SectionList.back();
|
||||
SymTab.Type = ELFSection::SHT_SYMTAB;
|
||||
SymTab.Align = 4; // FIXME: check for ELF64
|
||||
SymTab.Align = is64Bit ? 8 : 4;
|
||||
SymTab.Link = SectionList.size()-2; // Section Index of .strtab.
|
||||
SymTab.Info = FirstNonLocalSymbol; // First non-STB_LOCAL symbol.
|
||||
SymTab.EntSize = 16; // Size of each symtab entry. FIXME: wrong for ELF64
|
||||
|
||||
assert(!is64Bit && "check this!");
|
||||
for (unsigned i = 0, e = SymbolTable.size(); i != e; ++i) {
|
||||
ELFSym &Sym = SymbolTable[i];
|
||||
outword(Sym.NameIdx);
|
||||
outaddr(Sym.Value);
|
||||
outword(Sym.Size);
|
||||
outbyte(Sym.Info);
|
||||
outbyte(Sym.Other);
|
||||
outhalf(Sym.SectionIdx);
|
||||
if (!is64Bit) { // 32-bit and 64-bit formats are shuffled a bit.
|
||||
for (unsigned i = 0, e = SymbolTable.size(); i != e; ++i) {
|
||||
ELFSym &Sym = SymbolTable[i];
|
||||
outword(Sym.NameIdx);
|
||||
outaddr32(Sym.Value);
|
||||
outword(Sym.Size);
|
||||
outbyte(Sym.Info);
|
||||
outbyte(Sym.Other);
|
||||
outhalf(Sym.SectionIdx);
|
||||
}
|
||||
} else {
|
||||
for (unsigned i = 0, e = SymbolTable.size(); i != e; ++i) {
|
||||
ELFSym &Sym = SymbolTable[i];
|
||||
outword(Sym.NameIdx);
|
||||
outbyte(Sym.Info);
|
||||
outbyte(Sym.Other);
|
||||
outhalf(Sym.SectionIdx);
|
||||
outaddr64(Sym.Value);
|
||||
outxword(Sym.Size);
|
||||
}
|
||||
}
|
||||
|
||||
SymTab.Size = OutputBuffer.size()-SymTab.Offset;
|
||||
|
Loading…
x
Reference in New Issue
Block a user