summaryrefslogtreecommitdiff
path: root/include/mcld/LD/LDSectionFactory.h
blob: 49b11c758bc9af8de0ccc8568a14a12bf379734c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//===- LDSectionFactory.h -------------------------------------------------===//
//
//                     The MCLinker Project
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef MCLD_LDSECTION_FACTORY_H
#define MCLD_LDSECTION_FACTORY_H
#ifdef ENABLE_UNITTEST
#include <gtest.h>
#endif
#include <mcld/Support/GCFactory.h>
#include <mcld/LD/LDSection.h>
#include <mcld/LD/LDFileFormat.h>
#include <string>

namespace mcld
{

/** \class LDSectionFactory
 *  \brief provide the interface to create and delete section data for output
 */
class LDSectionFactory : public GCFactory<LDSection, 0>
{
public:
  /// LDSectionFactory - the factory of LDSection
  /// pNum is the average number of the LDSections in the system.
  LDSectionFactory(size_t pNum);
  ~LDSectionFactory();

  /// produce - produce an empty section information.
  /// This function will create an empty MCSectionData and its LDSection.
  /// @param pName - The name of the section.
  /// @param pKind - The kind of the section. Used to create default section map
  /// @param pType - sh_type in ELF.
  /// @param pFlag - is the same as sh_flags.
  LDSection* produce(const std::string& pName,
                     LDFileFormat::Kind pKind,
                     uint32_t pType,
                     uint32_t pFlag);

  /// destroy - destruct the LDSection.
  /// @oaram - the reference of the pointer to the destructed LDSection.
  ///          after the destruction, the pointer is set to zero.
  void destroy(LDSection*& pSD);

  /// find - find the LDSection* in factory from the given section name.
  ///        return NULL if not found.
  /// @param pName - the name of section
  LDSection* find(const std::string& pName);
};

} // namespace of mcld

#endif