本文整理汇总了C++中Section::GetSymbol方法的典型用法代码示例。如果您正苦于以下问题:C++ Section::GetSymbol方法的具体用法?C++ Section::GetSymbol怎么用?C++ Section::GetSymbol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Section
的用法示例。
在下文中一共展示了Section::GetSymbol方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ObjectFile
Builder::Builder( vector<string> &objFilePath,string lib,string output )
{
libDirPath_ = lib;
outputPath_ = output;
entryFunc_ = "mini_crt_entry";
myEntryFuncObj_ = lib + "/entry.o";
objFilePath.push_back(myEntryFuncObj_);
for( unsigned int i = 0;i < objFilePath.size();++i )
{
//这些变量在后面都会以指针形式被保存下来,所以不能用局部变亮
ObjectFile *pObj = new ObjectFile( objFilePath[i] );
if( !pObj->IsValid() )
{
cout << objFilePath[i] << " is invalid. * Ignore *" << endl;
continue;
}
ElfHeader *pEh = new ElfHeader;
pEh->GetHeader( *pObj );
Section *pSec = new Section();
if( !pSec->GetSection(*pEh) )
{
cout << "error while getting section:" << objFilePath[i] << endl;
exit(0);
}
if( !pSec->GetSymbol() )
{
cout << "error while getting symbols:" << objFilePath[i] << endl;
exit(0);
}
rawSection_.push_back(pSec);
}
}
示例2: CollectSymbol
bool Builder::CollectSymbol()
{
//如果能够集齐返回真
//先处理rawSection,不够的再到标准库中找
for( unsigned int i = 0;i < rawSection_.size();++i )
{
for( unsigned int j = 0;j < rawSection_[i]->symArr_.size();++j )
{
if( !NewSymbol( rawSection_[i]->symArr_[j] ) )
return false;
}
}
map<string,Symbol>::iterator it = finded_.begin();
while( it != finded_.end() )
{
if( it->second.symStr_->st_shndx == SHN_COMMON )
{
cout << "error:" << it->first << "没有初始化" << endl;
return false;
}
++it;
}
if( needed_.empty() )
return true;
cout << "正在链接标准库" <<endl;
/*
* 库中所有的o文件全部载入
*/
vector<string> libObjPath;
GetLibObjPath( libDirPath_,libObjPath );
for( unsigned int i = 0;i < libObjPath.size();++i )
{
// cout << "正在添加库:" << libObjPath[i] << endl;
//方法同Builder构造,只是同时把inLib构建好了
ObjectFile *pObj = new ObjectFile( libObjPath[i] );
if( !pObj->IsValid() )
{
cout << libObjPath[i] << " is invalid. * Ignore *" << endl;
continue;
}
ElfHeader *pEh = new ElfHeader;
pEh->GetHeader( *pObj );
Section *pSec = new Section();
if( !pSec->GetSection(*pEh) )
{
cout << "error while getting section:" << libObjPath[i] << endl;
exit(0);
}
if( !pSec->GetSymbol() )
{
cout << "error while getting symbols:" << libObjPath[i] << endl;
exit(0);
}
for( unsigned int j = 0;j < pSec->symArr_.size();++j )
{
if( pSec->symArr_[j].name_ == "" )
continue;
if( pSec->symArr_[j].symStr_->st_shndx == SHN_UNDEF ||
pSec->symArr_[j].symStr_->st_shndx == SHN_COMMON )
{
continue;
}
if( inLib_.find( pSec->symArr_[j].name_ ) != inLib_.end() )
{
cout << "多次发现:" << pSec->symArr_[j].name_ << " Ignore" << endl;
continue;
}
inLib_.insert( pair<string,Symbol>(pSec->symArr_[j].name_,pSec->symArr_[j]) );
}
libSection_.push_back(pSec);
}
// PrintLibSymbol();
LinkLibSymbol();
if( needed_.size() != 0 )
{
cout << "error:无法找到下列符号定义" << endl;
map<string,Symbol>::iterator it = needed_.begin();
while( it != needed_.end() )
{
cout << it->first << endl;
++it;
}
#ifdef DEBUG
cout << "已找到的符号" << endl;
it = finded_.begin();
while( it != finded_.end() )
{
//.........这里部分代码省略.........