forked from OSchip/llvm-project
Add a helper function for getting the first object file.
Also preparation for shared objects. It will become the first ELF file. llvm-svn: 246796
This commit is contained in:
parent
fbe54696cc
commit
8aeb13fec1
|
@ -98,7 +98,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
|
|||
Symtab.reportRemainingUndefines();
|
||||
|
||||
// Write the result.
|
||||
ObjectFileBase &FirstObj = *Symtab.getObjectFiles()[0];
|
||||
ObjectFileBase &FirstObj = *Symtab.getFirstObject();
|
||||
switch (FirstObj.getELFKind()) {
|
||||
case ELF32LEKind:
|
||||
writeResult<object::ELF32LE>(&Symtab);
|
||||
|
|
|
@ -33,10 +33,9 @@ template <class ELFT> void SymbolTable::init() {
|
|||
}
|
||||
|
||||
void SymbolTable::addObject(ObjectFileBase *File) {
|
||||
if (!ObjectFiles.empty()) {
|
||||
ObjectFileBase &Old = *ObjectFiles[0];
|
||||
if (!Old.isCompatibleWith(*File))
|
||||
error(Twine(Old.getName() + " is incompatible with " + File->getName()));
|
||||
if (const ObjectFileBase *Old = getFirstObject()) {
|
||||
if (!Old->isCompatibleWith(*File))
|
||||
error(Twine(Old->getName() + " is incompatible with " + File->getName()));
|
||||
} else {
|
||||
switch (File->getELFKind()) {
|
||||
case ELF32LEKind:
|
||||
|
|
|
@ -34,6 +34,12 @@ public:
|
|||
|
||||
void addFile(std::unique_ptr<InputFile> File);
|
||||
|
||||
ObjectFileBase *getFirstObject() const {
|
||||
if (!ObjectFiles.empty())
|
||||
return ObjectFiles[0].get();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Print an error message on undefined symbols.
|
||||
void reportRemainingUndefines();
|
||||
|
||||
|
|
|
@ -543,7 +543,7 @@ template <class ELFT> void Writer<ELFT>::writeHeader() {
|
|||
|
||||
EHdr->e_type = ET_EXEC;
|
||||
const SymbolTable &Symtab = SymTable.getSymTable();
|
||||
auto &FirstObj = cast<ObjectFile<ELFT>>(*Symtab.getObjectFiles()[0]);
|
||||
auto &FirstObj = cast<ObjectFile<ELFT>>(*Symtab.getFirstObject());
|
||||
EHdr->e_machine = FirstObj.getObj()->getHeader()->e_machine;
|
||||
EHdr->e_version = EV_CURRENT;
|
||||
EHdr->e_entry = 0x401000;
|
||||
|
|
Loading…
Reference in New Issue