toolsandutils/e32tools/checklib/object/coff/coff_file_header.cpp
changeset 0 83f4b4db085c
child 1 d4b442d23379
equal deleted inserted replaced
-1:000000000000 0:83f4b4db085c
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "coff_file_header.h"
       
    17 #include <stdexcept>
       
    18 #include <string>
       
    19 
       
    20 
       
    21 namespace coff
       
    22 {
       
    23     File_header::File_header(const char* p1, const char* p2, bool a_pedantic)
       
    24         : m_data( reinterpret_cast<const coff_file_header_t*>(p1) )
       
    25     {
       
    26         if ( unsigned(p2 - p1 + 1) < sizeof(coff_file_header_t) )
       
    27         {
       
    28             throw std::runtime_error("not a COFF object: the file is too small");
       
    29         }
       
    30 
       
    31         if (m_data->magic != 0x014c)
       
    32         {
       
    33             throw std::runtime_error("not a COFF object: bad magic");
       
    34         }
       
    35 
       
    36         if (a_pedantic) // Do some extra checks for correctness.
       
    37         {
       
    38             // ...
       
    39         }
       
    40     }
       
    41 
       
    42     unsigned File_header::get_symtab_offset() const
       
    43     {
       
    44         return m_data->symtab;
       
    45     }
       
    46 
       
    47     unsigned File_header::get_symcount() const
       
    48     {
       
    49         return m_data->nsyms;
       
    50     }
       
    51 }
       
    52