2012-05-04 2 views
0

this hexadecimal view of the .o file in xvi32 이 .cpp의 데이터와 어떻게 일치하는지 설명 할 수 있습니까? 즉 '/ 18'/ 65 '/ 139와 같은 숫자와'.rdata '는 무엇을 의미합니까? 예를 들어 해당 exe를 열면 그 파일이 약간의 차이점과 비슷합니다. 적어도이 시작 부분입니다. 그러나 특히 : exe에서 ".rdata"가 ".data"가되는 이유는 무엇입니까? 이것은 작은 햄버거를보고하고 묻는 것과 같다xvi32의 .o 파일 검색

// exercise_for.cpp : Defines the entry point for the console application. 
// 

#include "stdafx.h" 
#include <iostream> 
#include <vector> 
#include <list> 
#include <map> 

#include <iterator> 
#include <algorithm> 
#include <fstream> 

#include <limits> 

struct myStruct{ 
    int a; 
    double b; 
    virtual void func()=0; 
    void f(){}; 
}; 
struct sB{virtual void g()=0;}; 
struct myStruct2:sB{ 
    void f(){}; 
    void g(){std::cout<<"\nmyStruct2";} 
}; 
struct myStruct3:sB{ 
    void f(int const &in){a=in;}; 
    void g(){std::cout<<"\nmyStruct3";}; 
    myStruct3():a(0){}; 
    int show(){return a;}; 
private: 
    int a; 
}; 

class myC : public myStruct{ 
    int i; 
    void func(){}; 
}; 

std::map<std::string,int> histogram; 
void record(const std::string& in){ 
    histogram[in]++; 
} 
void print(const std::pair<const std::string,int>& in){ 
    std::cout<<(in.first)<<" "<<in.second<<"\n"; 
} 

int _tmain(int argc, _TCHAR* argv[]) 
{ 
    std::cout<<"largest float:"<<std::numeric_limits<float>::max()<< 
     "\nchar is signed:"<<std::numeric_limits<char>::is_signed<< 
     "\nlargest int:"<<std::numeric_limits<int>::max()<< 
     "\nlargest double:"<<std::numeric_limits<double>::max()<< 
     "\nlargest short int:"<<std::numeric_limits<short int>::max()<< 
     "\nlargest long int:"<<std::numeric_limits<long int>::max()<<"\n\n"; 

    for(int i=0;i<10;++i){ 
     std::cout<<++i; 
    } 

    myC mC; 
    myStruct2 m; 
    myStruct3 n; 
    std::cout<<"n: "<<n.show(); 
    m.f(); 
    n.f(4); 
    std::cout<<"\nn: "<<n.show(); 

    std::cout<<"\nmem_fun"; 
    std::list<sB*> myList; 
    myList.push_back(&m); 
    myList.push_back(&n); 
    std::for_each(myList.begin(),myList.end(),std::mem_fun(&sB::g)); 
    std::list<sB*>::iterator it=myList.begin(); 

    std::istream_iterator<std::string> ii(std::cin); 
    std::istream_iterator<std::string> eos; 
    std::for_each(ii,eos,record); 
    int i=0xffff; 
    std::string z; 
    std::cout<<"\n\nprinting: sizeof(int)="<<sizeof(int)<<" i:"<<i<<"\n"; 
    int* i_ptr; 
    std::cout<<"sizeof(int*)="<<sizeof(i_ptr)<<"\n"; 
    std::cout<<"sizeof(double)="<<sizeof(double)<<"\n"; 
    std::cout<<"sizeof(double*)="<<sizeof(double*)<<"\n"; 
    std::cout<<"sizeof(string)="<<sizeof(z)<<"\n"; 
    float fl=1000+1.6+1.6+1.6+1.6; 
    std::cout<<"\nf:"<<fl; 
    std::for_each(histogram.begin(),histogram.end(),print); 

    std::vector<std::string> sL; 
    std::string s("spadaj"); 
    sL.push_back(s); 
    std::copy(sL.begin(),sL.end(),std::ostream_iterator<std::string>(std::cout, " ")); 
    std::ofstream f("myFile.txt"); 
    std::copy(sL.begin(),sL.end(),std::ostream_iterator<std::string>(f, " ")); 
    return 0; 
} 

답변

1

: 여기 이 .o 인 생성 된에서 통화 당은 "소의 어떤 부분이 어디에서 왔는가?" 주어진 햄버거에는 3 개 또는 4 개의 다른 소의 각기 다른 부분의 육류가 들어있을 수 있습니다.

어디서나 많은 것을 얻으려면 개체 파일 (또는 실행 파일)의 일반 16 진수 덤프보다 조금 더 지능적인 것으로 시작하고 싶을 것입니다. 아마도 적어도 어셈블리 언어 소스 코드로서 출력에서 ​​좀 더 직접적으로 또는 덜 직접적으로 보일 수있는 것보다 역 디스 셈 블러를 사용하고 싶을 것입니다. 그것 없이는 객체 파일 형식에 대해 상당히 친밀한 지식이 필요하다. 실제로 어떤 부분을 볼 것인지, 어떤 부분이 재배치 레코드와 같은 것인지 또는 심지어 섹션 사이에 패딩 (즉, 전혀 의미가 없다. 분명히 그렇게 할 수는 있지만 선택의 여지가 없다면 거의 시간을 보내는 즐거운 방법이 아닙니다.

Microsoft Windows SDK에는 dumpbin이라는 도구가 포함되어있어 /disasm 플래그를 사용하여 실행 파일의 코드를 디스 어셈블 할 수 있습니다. 주위를 둘러 보시면 다양한 디스어셈블러를 사용할 수 있습니다. 돈을 기꺼이 쓰고 싶다면 IDA Pro을 내가 사용한 최고로 권하고 싶습니다. 확실히 이 아니며은 무료이거나 특히 저렴하지만,이 정도면 많은 돈을 벌 수 있습니다.

+0

나는 그것이이 암소와 같다는 것을 알고 있지만 나는이 암소를보고 "암소의 어느 부분에서 왔는가?" : D – 4pie0

+0

덕분에, dumpbin은 정말 도움이됩니다. – 4pie0