[llvm] r215219 - getLoadName is only implemented for ELF, make it ELF only.
Rafael Espindola
rafael.espindola at gmail.com
Fri Aug 8 09:39:22 PDT 2014
Author: rafael
Date: Fri Aug 8 11:39:22 2014
New Revision: 215219
URL: http://llvm.org/viewvc/llvm-project?rev=215219&view=rev
Log:
getLoadName is only implemented for ELF, make it ELF only.
Modified:
llvm/trunk/include/llvm/Object/COFF.h
llvm/trunk/include/llvm/Object/ELFObjectFile.h
llvm/trunk/include/llvm/Object/MachO.h
llvm/trunk/include/llvm/Object/ObjectFile.h
llvm/trunk/lib/Object/COFFObjectFile.cpp
llvm/trunk/lib/Object/MachOObjectFile.cpp
llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
Modified: llvm/trunk/include/llvm/Object/COFF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=215219&r1=215218&r2=215219&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFF.h (original)
+++ llvm/trunk/include/llvm/Object/COFF.h Fri Aug 8 11:39:22 2014
@@ -435,7 +435,6 @@ public:
uint8_t getBytesInAddress() const override;
StringRef getFileFormatName() const override;
unsigned getArch() const override;
- StringRef getLoadName() const override;
import_directory_iterator import_directory_begin() const;
import_directory_iterator import_directory_end() const;
Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=215219&r1=215218&r2=215219&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Fri Aug 8 11:39:22 2014
@@ -201,7 +201,7 @@ public:
uint8_t getBytesInAddress() const override;
StringRef getFileFormatName() const override;
unsigned getArch() const override;
- StringRef getLoadName() const override;
+ StringRef getLoadName() const;
std::error_code getPlatformFlags(unsigned &Result) const override {
Result = EF.getHeader()->e_flags;
Modified: llvm/trunk/include/llvm/Object/MachO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachO.h?rev=215219&r1=215218&r2=215219&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/MachO.h (original)
+++ llvm/trunk/include/llvm/Object/MachO.h Fri Aug 8 11:39:22 2014
@@ -146,8 +146,6 @@ public:
StringRef getFileFormatName() const override;
unsigned getArch() const override;
- StringRef getLoadName() const override;
-
relocation_iterator section_rel_begin(unsigned Index) const;
relocation_iterator section_rel_end(unsigned Index) const;
Modified: llvm/trunk/include/llvm/Object/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=215219&r1=215218&r2=215219&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ObjectFile.h Fri Aug 8 11:39:22 2014
@@ -330,11 +330,6 @@ public:
virtual StringRef getFileFormatName() const = 0;
virtual /* Triple::ArchType */ unsigned getArch() const = 0;
- /// For shared objects, returns the name which this object should be
- /// loaded from at runtime. This corresponds to DT_SONAME on ELF and
- /// LC_ID_DYLIB (install name) on MachO.
- virtual StringRef getLoadName() const = 0;
-
/// Returns platform-specific object flags, if any.
virtual std::error_code getPlatformFlags(unsigned &Result) const {
Result = 0;
Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=215219&r1=215218&r2=215219&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Fri Aug 8 11:39:22 2014
@@ -620,11 +620,6 @@ library_iterator COFFObjectFile::needed_
report_fatal_error("Libraries needed unimplemented in COFFObjectFile");
}
-StringRef COFFObjectFile::getLoadName() const {
- // COFF does not have this field.
- return "";
-}
-
import_directory_iterator COFFObjectFile::import_directory_begin() const {
return import_directory_iterator(
ImportDirectoryEntryRef(ImportDirectory, 0, this));
Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=215219&r1=215218&r2=215219&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Fri Aug 8 11:39:22 2014
@@ -1410,11 +1410,6 @@ unsigned MachOObjectFile::getArch() cons
return getArch(getCPUType(this));
}
-StringRef MachOObjectFile::getLoadName() const {
- // TODO: Implement
- report_fatal_error("get_load_name() unimplemented in MachOObjectFile");
-}
-
relocation_iterator MachOObjectFile::section_rel_begin(unsigned Index) const {
DataRefImpl DRI;
DRI.d.a = Index;
Modified: llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp?rev=215219&r1=215218&r2=215219&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp Fri Aug 8 11:39:22 2014
@@ -24,6 +24,7 @@
#include "ObjDumper.h"
#include "StreamWriter.h"
#include "llvm/Object/Archive.h"
+#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
@@ -210,6 +211,17 @@ static std::error_code createDumper(cons
return readobj_error::unsupported_obj_file_format;
}
+static StringRef getLoadName(const ObjectFile *Obj) {
+ if (auto *ELF = dyn_cast<ELF32LEObjectFile>(Obj))
+ return ELF->getLoadName();
+ if (auto *ELF = dyn_cast<ELF64LEObjectFile>(Obj))
+ return ELF->getLoadName();
+ if (auto *ELF = dyn_cast<ELF32BEObjectFile>(Obj))
+ return ELF->getLoadName();
+ if (auto *ELF = dyn_cast<ELF64BEObjectFile>(Obj))
+ return ELF->getLoadName();
+ llvm_unreachable("Not ELF");
+}
/// @brief Dumps the specified object file.
static void dumpObject(const ObjectFile *Obj) {
@@ -228,7 +240,7 @@ static void dumpObject(const ObjectFile
<< "\n";
outs() << "AddressSize: " << (8*Obj->getBytesInAddress()) << "bit\n";
if (Obj->isELF())
- outs() << "LoadName: " << Obj->getLoadName() << "\n";
+ outs() << "LoadName: " << getLoadName(Obj) << "\n";
if (opts::FileHeaders)
Dumper->printFileHeaders();
More information about the llvm-commits
mailing list