[8] | 1 | /*
|
---|
| 2 | * TOPPERS Software
|
---|
| 3 | * Toyohashi Open Platform for Embedded Real-Time Systems
|
---|
| 4 | *
|
---|
| 5 | * Copyright (C) 2005-2008 by TAKAGI Nobuhisa
|
---|
| 6 | *
|
---|
| 7 | * ãLì ÒÍCȺÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
|
---|
| 8 | * Ai{\tgEFAðüϵ½àÌðÜÞDȺ¯¶jðgpE¡»Eü
|
---|
| 9 | * ÏEÄzziȺCpÆÄÔj·é±Æð³Åø·éD
|
---|
| 10 | * (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
|
---|
| 11 | * \¦C±Ìpð¨æѺL̳ÛØKèªC»ÌÜÜÌ`Å\[
|
---|
| 12 | * XR[hÉÜÜêÄ¢é±ÆD
|
---|
| 13 | * (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJÉg
|
---|
| 14 | * pÅ«é`ÅÄzz·éêÉÍCÄzzɺ¤hL
|
---|
| 15 | gip
|
---|
| 16 | * Ò}j
|
---|
| 17 | AÈÇjÉCãLÌì \¦C±Ìpð¨æѺL
|
---|
| 18 | * ̳ÛØKèðfÚ·é±ÆD
|
---|
| 19 | * (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJÉg
|
---|
| 20 | * pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
|
---|
| 21 | * ÆD
|
---|
| 22 | * (a) Äzzɺ¤hL
|
---|
| 23 | gipÒ}j
|
---|
| 24 | AÈÇjÉCãLÌ
|
---|
| 25 | * ì \¦C±Ìpð¨æѺL̳ÛØKèðfÚ·é±ÆD
|
---|
| 26 | * (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
|
---|
| 27 | * ñ·é±ÆD
|
---|
| 28 | * (4) {\tgEFAÌpÉæè¼ÚIܽÍÔÚIɶ¶é¢©Èé¹
|
---|
| 29 | * Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
|
---|
| 30 | * ܽC{\tgEFAÌ[UܽÍGh[U©çÌ¢©Èé
|
---|
| 31 | * RÉîÿ©çàCãLì Ò¨æÑTOPPERSvWFNgð
|
---|
| 32 | * ÆÓ·é±ÆD
|
---|
| 33 | *
|
---|
| 34 | * {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
|
---|
| 35 | * æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
|
---|
| 36 | * ÉηéK«àÜßÄC¢©ÈéÛØàsíÈ¢DܽC{\tgEF
|
---|
| 37 | * AÌpÉæè¼ÚIܽÍÔÚIɶ¶½¢©Èé¹QÉÖµÄàC»
|
---|
| 38 | * ÌÓCðíÈ¢D
|
---|
| 39 | *
|
---|
| 40 | */
|
---|
| 41 |
|
---|
| 42 | /*
|
---|
| 43 | * toppers/nm_symbol.cpp
|
---|
| 44 | */
|
---|
| 45 | #include "toppers/nm_symbol.hpp"
|
---|
| 46 | #include <istream>
|
---|
| 47 | #include <sstream>
|
---|
| 48 | #include <cctype>
|
---|
| 49 |
|
---|
| 50 | namespace toppers
|
---|
| 51 | {
|
---|
| 52 |
|
---|
| 53 | /*!
|
---|
| 54 | * \brief V{e[uÌ[h
|
---|
| 55 | * \param istr üÍXg[
|
---|
| 56 | */
|
---|
| 57 | void nm_symbol::load( std::istream& istr )
|
---|
| 58 | {
|
---|
| 59 | while ( istr )
|
---|
| 60 | {
|
---|
| 61 | std::string buf;
|
---|
| 62 | std::getline( istr, buf );
|
---|
| 63 | std::istringstream isstr( buf );
|
---|
| 64 |
|
---|
| 65 | unsigned long address = 0;
|
---|
| 66 | char type;
|
---|
| 67 | std::string symbol;
|
---|
| 68 | if ( !std::isspace( static_cast< unsigned char >( buf[0] ) ) )
|
---|
| 69 | {
|
---|
| 70 | isstr >> std::hex >> address;
|
---|
| 71 | }
|
---|
| 72 | isstr >> type >> symbol;
|
---|
| 73 |
|
---|
| 74 | if ( !symbol.empty() )
|
---|
| 75 | {
|
---|
| 76 | entry e;
|
---|
| 77 | e.address = address;
|
---|
| 78 | e.type = static_cast< unsigned char >( type );
|
---|
| 79 | symbol_map_[symbol] = e;
|
---|
| 80 | }
|
---|
| 81 | }
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | /*!
|
---|
| 85 | * \brief V{ÌTõ
|
---|
| 86 | * \param symbol Tõ·éV{¶ñ
|
---|
| 87 | * \return V{ÉηéGgðÔ·
|
---|
| 88 | */
|
---|
| 89 | nm_symbol::entry const nm_symbol::find( std::string const& symbol ) const
|
---|
| 90 | {
|
---|
| 91 | std::map< std::string, entry >::const_iterator iter( symbol_map_.find( symbol ) );
|
---|
| 92 | entry e = { 0, -1 };
|
---|
| 93 | if ( iter != symbol_map_.end() )
|
---|
| 94 | {
|
---|
| 95 | e = iter->second;
|
---|
| 96 | }
|
---|
| 97 | else
|
---|
| 98 | {
|
---|
| 99 | iter = symbol_map_.find( "_" + symbol ); // ¯ÊqÉ'_'ªtÁ³êéêÉÎ
|
---|
| 100 | if ( iter != symbol_map_.end() )
|
---|
| 101 | {
|
---|
| 102 | e = iter->second;
|
---|
| 103 | }
|
---|
| 104 | }
|
---|
| 105 | return e;
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | }
|
---|