Browse Source

sync source

master
Ian Ilkyun Oh 2 months ago
parent
commit
1ce7302c6b
  1. BIN
      TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.rc
  2. 28
      TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.vcxproj
  3. 78
      TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.vcxproj.filters
  4. 144
      TestLibDlg/IncSourceTestDlg/IncSourceTestDlgDlg.cpp
  5. 3
      TestLibDlg/IncSourceTestDlg/IncSourceTestDlgDlg.h
  6. 4
      TestLibDlg/IncSourceTestDlg/resource.h

BIN
TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.rc

Binary file not shown.

28
TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.vcxproj

@ -91,10 +91,11 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions);NOMINMAX</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>C:\git_work\a2l\a2l_test\TestLibDlg\IncSourceTestDlg\include;C:\git_work\a2l\a2l_test\TestLibDlg\IncSourceTestDlg\src;C:\boost\include\boost-1_87;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp20</LanguageStandard>
<LanguageStandard_C>Default</LanguageStandard_C>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -199,9 +200,33 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="DlgProxy.h" />
<ClInclude Include="dwarf\data.hh" />
<ClInclude Include="dwarf\dwarf++.hh" />
<ClInclude Include="dwarf\internal.hh" />
<ClInclude Include="dwarf\small_vector.hh" />
<ClInclude Include="elfio.hpp" />
<ClInclude Include="elfio_array.hpp" />
<ClInclude Include="elfio_dump.hpp" />
<ClInclude Include="elfio_dynamic.hpp" />
<ClInclude Include="elfio_header.hpp" />
<ClInclude Include="elfio_modinfo.hpp" />
<ClInclude Include="elfio_note.hpp" />
<ClInclude Include="elfio_relocation.hpp" />
<ClInclude Include="elfio_section.hpp" />
<ClInclude Include="elfio_segment.hpp" />
<ClInclude Include="elfio_strings.hpp" />
<ClInclude Include="elfio_symbols.hpp" />
<ClInclude Include="elfio_utils.hpp" />
<ClInclude Include="elfio_version.hpp" />
<ClInclude Include="elfio_versym.hpp" />
<ClInclude Include="elf\common.hh" />
<ClInclude Include="elf\data.hh" />
<ClInclude Include="elf\elf++.hh" />
<ClInclude Include="elf\to_hex.hh" />
<ClInclude Include="framework.h" />
<ClInclude Include="IncSourceTestDlg.h" />
<ClInclude Include="IncSourceTestDlgDlg.h" />
<ClInclude Include="intelhex.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="src\a2lhelper.h" />
@ -218,6 +243,7 @@
<ClCompile Include="DlgProxy.cpp" />
<ClCompile Include="IncSourceTestDlg.cpp" />
<ClCompile Include="IncSourceTestDlgDlg.cpp" />
<ClCompile Include="intelhex.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>

78
TestLibDlg/IncSourceTestDlg/IncSourceTestDlg.vcxproj.filters

@ -16,6 +16,9 @@
<Filter Include="src">
<UniqueIdentifier>{ab092bfb-4c1e-40f2-bfa9-349fda25fa4c}</UniqueIdentifier>
</Filter>
<Filter Include="intelhex">
<UniqueIdentifier>{00f7a33d-e5dd-4f72-bbad-87059b065042}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="IncSourceTestDlg.h">
@ -63,6 +66,78 @@
<ClInclude Include="src\ifdatascanner.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="intelhex.h">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elfio.hpp">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elfio_array.hpp">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elfio_dump.hpp">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elfio_dynamic.hpp">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elfio_header.hpp">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elfio_modinfo.hpp">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elfio_note.hpp">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elfio_relocation.hpp">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elfio_section.hpp">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elfio_segment.hpp">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elfio_strings.hpp">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elfio_symbols.hpp">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elfio_utils.hpp">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elfio_version.hpp">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elfio_versym.hpp">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="dwarf\data.hh">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="dwarf\dwarf++.hh">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="dwarf\internal.hh">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="dwarf\small_vector.hh">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elf\common.hh">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elf\data.hh">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elf\elf++.hh">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="elf\to_hex.hh">
<Filter>헤더 파일</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="IncSourceTestDlg.cpp">
@ -185,6 +260,9 @@
<ClCompile Include="src\unit.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="intelhex.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Midl Include="IncSourceTestDlg.idl">

144
TestLibDlg/IncSourceTestDlg/IncSourceTestDlgDlg.cpp

@ -10,6 +10,15 @@
#include "afxdialogex.h"
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include "intelhex.h"
#include "elfio.hpp"
#include "elfio_dump.hpp"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -96,6 +105,8 @@ BEGIN_MESSAGE_MAP(CIncSourceTestDlgDlg, CDialogEx)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_OPEN, &CIncSourceTestDlgDlg::OnBnClickedButtonOpen)
ON_BN_CLICKED(IDC_BUTTON_ELF, &CIncSourceTestDlgDlg::OnBnClickedButtonElf)
ON_BN_CLICKED(IDC_BUTTON_HEX, &CIncSourceTestDlgDlg::OnBnClickedButtonHex)
END_MESSAGE_MAP()
@ -587,4 +598,135 @@ void CIncSourceTestDlgDlg::AddLogString(std::string strMessage)
message_w.assign(strMessage.begin(), strMessage.end());
pListBox->AddString(message_w.c_str());
}
}
void CIncSourceTestDlgDlg::OnBnClickedButtonElf()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
TCHAR hexExt[] = _T("*.elf");
TCHAR hexBaseFilter[] = _T("ELF file(*.ELF) | *.elf;*.ELF | 모든파일(*.*) | *.* ||");
CFileDialog dlg(TRUE, hexExt, NULL, OFN_HIDEREADONLY, hexBaseFilter);
if (dlg.DoModal() == IDOK) {
std::wstring strPath = dlg.GetPathName().GetBuffer();
std::string strHexPath;
strHexPath.assign(strPath.begin(), strPath.end());
ELFIO::elfio reader;
if (reader.load(strHexPath.c_str())) {
// Print ELF file properties
std::cout << "ELF file class : ";
if (reader.get_class() == ELFIO::ELFCLASS32) {
std::cout << "ELF32" << std::endl;
AddLogString(string_format("ELF file class : ELF32"));
}
else {
std::cout << "ELF64" << std::endl;
AddLogString(string_format("ELF file class : ELF64"));
}
std::cout << "ELF file encoding : ";
if (reader.get_encoding() == ELFIO::ELFDATA2LSB) {
std::cout << "Little endian" << std::endl;
AddLogString(string_format("ELF file encoding : Little endian"));
}
else {
std::cout << "Big endian" << std::endl;
AddLogString(string_format("ELF file encoding : Big endian"));
}
// Print ELF file sections info
ELFIO::Elf_Half sec_num = reader.sections.size();
std::cout << "Number of sections: " << sec_num << std::endl;
AddLogString(string_format("Number of sections: %d", sec_num));
for (int i = 0; i < sec_num; ++i) {
ELFIO::section* psec = reader.sections[i];
std::cout << " [" << i << "] " << psec->get_name() << "\t"
<< psec->get_size() << std::endl;
AddLogString(string_format(" [%d] %s [%d]", i, psec->get_name(), psec->get_size()));
// Access to section's data
// const char* p = reader.sections[i]->get_data()
}
// Print ELF file segments info
ELFIO::Elf_Half seg_num = reader.segments.size();
std::cout << "Number of segments: " << seg_num << std::endl;
AddLogString(string_format("Number of segments: %d", seg_num));
for (int i = 0; i < seg_num; ++i) {
const ELFIO::segment* pseg = reader.segments[i];
std::cout << " [" << i << "] 0x" << std::hex << pseg->get_flags()
<< "\t0x" << pseg->get_virtual_address() << "\t0x"
<< pseg->get_file_size() << "\t0x" << pseg->get_memory_size()
<< std::endl;
AddLogString(string_format(" [%d] 0x%X 0x%X [%d]", i, pseg->get_flags(), pseg->get_virtual_address(), pseg->get_memory_size()));
// Access to segments's data
// const char* p = reader.segments[i]->get_data()
}
for (int i = 0; i < sec_num; ++i) {
ELFIO::section* psec = reader.sections[i];
// Check section type
if (psec->get_type() == ELFIO::SHT_SYMTAB) {
const ELFIO::symbol_section_accessor symbols(reader, psec);
for (unsigned int j = 0; j < symbols.get_symbols_num(); ++j) {
std::string name;
ELFIO::Elf64_Addr value;
ELFIO::Elf_Xword size;
unsigned char bind;
unsigned char type;
ELFIO::Elf_Half section_index;
unsigned char other;
// Read symbol properties
symbols.get_symbol(j, name, value, size, bind, type,
section_index, other);
std::cout << j << " " << name << " " << value << std::endl;
if (type == 1)
AddLogString(string_format("[%d][%d] %s 0x%X %d type=%d bind=%d section_index=0x%X other=%d",i, j, name.c_str(), value, size, type, bind, section_index, other));
}
}
}
}
}
}
void CIncSourceTestDlgDlg::OnBnClickedButtonHex()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
TCHAR hexExt[] = _T("*.hex");
TCHAR hexBaseFilter[] = _T("HEX file(*.HEX) | *.hex;*.HEX | 모든파일(*.*) | *.* ||");
CFileDialog dlg(TRUE, hexExt, NULL, OFN_HIDEREADONLY, hexBaseFilter);
if (dlg.DoModal() == IDOK) {
std::wstring strPath = dlg.GetPathName().GetBuffer();
std::string strHexPath;
strHexPath.assign(strPath.begin(), strPath.end());
intelhex::hex_data ithex;
ithex.load(strHexPath.c_str());
intelhex::hex_data::iterator iter = ithex.begin();
for (; iter != ithex.end(); iter++) {
(*iter).second;
}
}
}

3
TestLibDlg/IncSourceTestDlg/IncSourceTestDlgDlg.h

@ -61,4 +61,7 @@ public:
private:
void loadA2lFile(std::string strFilePath);
void AddLogString(std::string strMessage);
public:
afx_msg void OnBnClickedButtonElf();
afx_msg void OnBnClickedButtonHex();
};

4
TestLibDlg/IncSourceTestDlg/resource.h

@ -8,8 +8,10 @@
#define IDS_ABOUTBOX 101
#define IDD_INCSOURCETESTDLG_DIALOG 102
#define IDR_MAINFRAME 128
#define IDC_BUTTON_ELF 1000
#define IDC_LIST_DATA 1001
#define IDC_BUTTON_OPEN 1002
#define IDC_BUTTON_HEX 1003
// Next default values for new objects
//
@ -17,7 +19,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_CONTROL_VALUE 1004
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

Loading…
Cancel
Save