//===----------------------------------------------------------------------===// // Testcases //===----------------------------------------------------------------------===// TEST_F(ReadStageTest, quake) { mcld::sys::fs::Path top_level = TOPDIR; // set up output m_pLinker->config()->output().setType(mcld::Output::DynObj); m_pLinker->setOutput(top_level + "unittests/plasma.so"); // set up input m_pLinker->addObject(top_level + "test/libs/ARM/Android/android-14/crtbegin_so.o"); m_pLinker->addObject(top_level + "test/Android/Plasma/ARM/plasma.o"); m_pLinker->addNameSpec("m"); m_pLinker->addNameSpec("log"); m_pLinker->addNameSpec("jnigraphics"); m_pLinker->addNameSpec("c"); m_pLinker->addObject(top_level + "test/libs/ARM/Android/android-14/crtend_so.o"); // dump status m_pLinker->getDriver()->normalize(); FileHandle file; file.open(top_level + "unittests/read_stage.xml", FileHandle::ReadWrite | FileHandle::Create | FileHandle::Truncate, 0644); InputTree::iterator input, inEnd = m_pLinker->config()->inputs().end(); for (input = m_pLinker->config()->inputs().begin(); input != inEnd; ++input) { dumpInput(**input, file, 1); } dumpOutput(m_pLinker->config()->output(), file, 1); // dump status ASSERT_TRUE(m_pLinker->getDriver()->mergeSections()); }
bool Linker::emit(const std::string& pPath) { FileHandle file; FileHandle::Permission perm = FileHandle::Permission(0x755); if (!file.open(pPath, FileHandle::ReadWrite | FileHandle::Truncate | FileHandle::Create, perm)) { error(diag::err_cannot_open_output_file) << "Linker::emit()" << pPath; return false; } MemoryArea* output = new MemoryArea(file); bool result = emit(*output); delete output; file.close(); return result; }
MemoryArea* MemoryAreaFactory::produce(const sys::fs::Path& pPath, FileHandle::OpenMode pMode) { HandleToArea::Result map_result = m_HandleToArea.findFirst(pPath); if (NULL == map_result.area) { // can not found FileHandle* handler = new FileHandle(); if (!handler->open(pPath, pMode)) { error(diag::err_cannot_open_file) << pPath << sys::strerror(handler->error()); } MemoryArea* result = allocate(); new (result) MemoryArea(*handler); m_HandleToArea.push_back(handler, result); return result; } return map_result.area; }