1 //===- MCLDFile.cpp -------------------------------------------------------===//
2 //
3 // The MCLinker Project
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 #include "mcld/MC/MCLDFile.h"
10 #include "mcld/LD/LDContext.h"
11 #include "mcld/Support/FileSystem.h"
12 #include "mcld/Support/MemoryArea.h"
13 #include <cstring>
14 #include <cstdlib>
15
16 using namespace mcld;
17
18 //===----------------------------------------------------------------------===//
19 // MCLDFile
MCLDFile()20 MCLDFile::MCLDFile()
21 : m_Type(Unknown), m_pContext(0), m_Path(), m_Name(), m_pMemArea(0) {
22 }
23
MCLDFile(llvm::StringRef pName)24 MCLDFile::MCLDFile(llvm::StringRef pName)
25 : m_Type(Unknown), m_pContext(0), m_Path(), m_Name(pName.data()), m_pMemArea(0) {
26 }
27
MCLDFile(llvm::StringRef pName,const sys::fs::Path & pPath,unsigned int pType)28 MCLDFile::MCLDFile(llvm::StringRef pName,
29 const sys::fs::Path& pPath,
30 unsigned int pType)
31 : m_Type(pType), m_pContext(0), m_Path(pPath), m_Name(pName.data()), m_pMemArea(0) {
32 }
33
~MCLDFile()34 MCLDFile::~MCLDFile()
35 {
36 }
37
setSOName(const std::string & pName)38 void MCLDFile::setSOName(const std::string& pName)
39 {
40 size_t pos = pName.find_last_of(sys::fs::separator);
41 if (std::string::npos == pos)
42 m_Name = pName;
43 else
44 m_Name = pName.substr(pos + 1);
45 }
46
47