CLRX  1
An unofficial OpenCL extensions designed for Radeon GPUs
ElfBinaries.h
Go to the documentation of this file.
1 /*
2  * CLRadeonExtender - Unofficial OpenCL Radeon Extensions Library
3  * Copyright (C) 2014-2018 Mateusz Szpakowski
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
23 #ifndef __CLRX_ELFBINARIES_H__
24 #define __CLRX_ELFBINARIES_H__
25 
26 #include <CLRX/Config.h>
27 #include <cstddef>
28 #include <cstdint>
29 #include <climits>
30 #include <string>
31 #include <utility>
32 #include <ostream>
33 #include <CLRX/amdbin/Elf.h>
34 #include <CLRX/utils/MemAccess.h>
35 #include <CLRX/utils/Utilities.h>
36 #include <CLRX/utils/Containers.h>
37 #include <CLRX/utils/InputOutput.h>
38 
39 /* INFO: in this file is used ULEV function for conversion
40  * from LittleEndian and unaligned access to other memory access policy and endianness
41  * Please use this function whenever you want to get or set word in ELF binary,
42  * because ELF binaries can be unaligned in memory (as inner binaries).
43  */
44 
46 namespace CLRX
47 {
48 
49 enum: cxuint {
50  BINGEN_DEFAULT = UINT_MAX,
51  BINGEN_NOTSUPPLIED = UINT_MAX-1
52 };
53 
54 enum: uint64_t {
55  BINGEN64_DEFAULT = UINT64_MAX,
56  BINGEN64_NOTSUPPLIED = UINT64_MAX-1
57 };
58 
59 enum: uint16_t {
60  BINGEN16_DEFAULT = UINT16_MAX,
61  BINGEN16_NOTSUPPLIED = UINT16_MAX-1
62 };
63 
64 enum: uint8_t {
65  BINGEN8_DEFAULT = UINT8_MAX,
66  BINGEN8_NOTSUPPLIED = UINT8_MAX-1
67 };
68 
69 enum : Flags {
74 };
75 
77 class BinException: public Exception
78 {
79 public:
81  BinException() = default;
83  explicit BinException(const std::string& message);
85  virtual ~BinException() noexcept = default;
86 };
87 
90 {
91 public:
93  BinGenException() = default;
95  explicit BinGenException(const std::string& message);
97  virtual ~BinGenException() noexcept = default;
98 };
99 
102 {
103  typedef uint32_t Size;
104  typedef uint32_t Word;
105  typedef uint32_t SectionFlags;
106  typedef Elf32_Ehdr Ehdr;
107  typedef Elf32_Shdr Shdr;
108  typedef Elf32_Phdr Phdr;
109  typedef Elf32_Sym Sym;
110  typedef Elf32_Nhdr Nhdr;
111  typedef Elf32_Dyn Dyn;
112  typedef Elf32_Rel Rel;
113  typedef Elf32_Rela Rela;
114  static const cxbyte ELFCLASS;
115  static const cxuint bitness;
116  static const char* bitName;
117  static const Word nobase = Word(0)-1;
118  static const cxuint relSymShift = 8;
119 };
120 
123 {
124  typedef size_t Size;
125  typedef uint64_t Word;
126  typedef uint64_t SectionFlags;
127  typedef Elf64_Ehdr Ehdr;
128  typedef Elf64_Shdr Shdr;
129  typedef Elf64_Phdr Phdr;
130  typedef Elf64_Sym Sym;
131  typedef Elf64_Nhdr Nhdr;
132  typedef Elf64_Dyn Dyn;
133  typedef Elf64_Rel Rel;
134  typedef Elf64_Rela Rela;
135  static const cxbyte ELFCLASS;
136  static const cxuint bitness;
137  static const char* bitName;
138  static const Word nobase = Word(0)-1;
139  static const cxuint relSymShift = 32;
140 };
141 
143 
146 template<typename Types>
148 {
149 public:
154 protected:
156  size_t binaryCodeSize;
165  SectionIndexMap sectionIndexMap;
166  SymbolIndexMap symbolIndexMap;
167  SymbolIndexMap dynSymIndexMap;
168 
169  typename Types::Size symbolsNum;
170  typename Types::Size dynSymbolsNum;
171  typename Types::Size noteTableSize;
172  typename Types::Size dynamicsNum;
173  uint16_t symbolEntSize;
174  uint16_t dynSymEntSize;
175  typename Types::Size dynamicEntSize;
176 
177 public:
184  ElfBinaryTemplate(size_t binaryCodeSize, cxbyte* binaryCode,
185  Flags creationFlags = ELF_CREATE_ALL);
186  virtual ~ElfBinaryTemplate();
187 
190  { return creationFlags; }
191 
193  bool hasSectionMap() const
194  { return (creationFlags & ELF_CREATE_SECTIONMAP) != 0; }
195 
197  bool hasSymbolMap() const
198  { return (creationFlags & ELF_CREATE_SYMBOLMAP) != 0; }
199 
201  bool hasDynSymbolMap() const
202  { return (creationFlags & ELF_CREATE_DYNSYMMAP) != 0; }
203 
205  size_t getSize() const
206  { return binaryCodeSize; }
207 
209  operator bool() const
210  { return binaryCode!=nullptr; }
211 
213  bool operator!() const
214  { return binaryCode==nullptr; }
215 
217  const cxbyte* getBinaryCode() const
218  { return binaryCode; }
221  { return binaryCode; }
222 
224  const typename Types::Ehdr& getHeader() const
225  { return *reinterpret_cast<const typename Types::Ehdr*>(binaryCode); }
226 
228  typename Types::Ehdr& getHeader()
229  { return *reinterpret_cast<typename Types::Ehdr*>(binaryCode); }
230 
232  uint16_t getSectionHeadersNum() const
233  { return ULEV(getHeader().e_shnum); }
234 
236  const typename Types::Shdr& getSectionHeader(uint16_t index) const
237  {
238  const typename Types::Ehdr& ehdr = getHeader();
239  return *reinterpret_cast<const typename Types::Shdr*>(binaryCode +
240  ULEV(ehdr.e_shoff) + size_t(ULEV(ehdr.e_shentsize))*index);
241  }
242 
244  typename Types::Shdr& getSectionHeader(uint16_t index)
245  {
246  const typename Types::Ehdr& ehdr = getHeader();
247  return *reinterpret_cast<typename Types::Shdr*>(binaryCode +
248  ULEV(ehdr.e_shoff) + size_t(ULEV(ehdr.e_shentsize))*index);
249  }
250 
252  uint16_t getProgramHeadersNum() const
253  { return ULEV(getHeader().e_phnum); }
254 
256  const typename Types::Phdr& getProgramHeader(uint16_t index) const
257  {
258  const typename Types::Ehdr& ehdr = getHeader();
259  return *reinterpret_cast<const typename Types::Phdr*>(binaryCode +
260  ULEV(ehdr.e_phoff) + size_t(ULEV(ehdr.e_phentsize))*index);
261  }
262 
264  typename Types::Phdr& getProgramHeader(uint16_t index)
265  {
266  const typename Types::Ehdr& ehdr = getHeader();
267  return *reinterpret_cast<typename Types::Phdr*>(binaryCode +
268  ULEV(ehdr.e_phoff) + size_t(ULEV(ehdr.e_phentsize))*index);
269  }
270 
272  typename Types::Size getSymbolsNum() const
273  { return symbolsNum; }
274 
276  typename Types::Size getDynSymbolsNum() const
277  { return dynSymbolsNum; }
278 
280  const typename Types::Sym& getSymbol(typename Types::Size index) const
281  {
282  return *reinterpret_cast<const typename Types::Sym*>(symbolTable +
283  size_t(index)*symbolEntSize);
284  }
285 
287  typename Types::Sym& getSymbol(typename Types::Size index)
288  {
289  return *reinterpret_cast<typename Types::Sym*>(
290  symbolTable + size_t(index)*symbolEntSize);
291  }
292 
294  const typename Types::Sym& getDynSymbol(typename Types::Size index) const
295  {
296  return *reinterpret_cast<const typename Types::Sym*>(dynSymTable +
297  size_t(index)*dynSymEntSize);
298  }
299 
301  typename Types::Sym& getDynSymbol(typename Types::Size index)
302  {
303  return *reinterpret_cast<typename Types::Sym*>(dynSymTable +
304  size_t(index)*dynSymEntSize);
305  }
306 
308  const char* getSymbolName(typename Types::Size index) const
309  {
310  const typename Types::Sym& sym = getSymbol(index);
311  return reinterpret_cast<const char*>(symbolStringTable + ULEV(sym.st_name));
312  }
313 
315  const char* getDynSymbolName(typename Types::Size index) const
316  {
317  const typename Types::Sym& sym = getDynSymbol(index);
318  return reinterpret_cast<const char*>(dynSymStringTable + ULEV(sym.st_name));
319  }
320 
322  const char* getSectionName(uint16_t index) const
323  {
324  const typename Types::Shdr& section = getSectionHeader(index);
325  return reinterpret_cast<const char*>(sectionStringTable + ULEV(section.sh_name));
326  }
327 
330  { return sectionIndexMap.end(); }
331 
334  {
336  sectionIndexMap.begin(), sectionIndexMap.end(), name, CStringLess());
337  if (it == sectionIndexMap.end())
338  throw BinException(std::string("Can't find Elf")+Types::bitName+" Section");
339  return it;
340  }
341 
343  uint16_t getSectionIndex(const char* name) const;
344 
346  typename Types::Size getSymbolIndex(const char* name) const;
347 
349  typename Types::Size getDynSymbolIndex(const char* name) const;
350 
353  { return symbolIndexMap.end(); }
354 
357  { return dynSymIndexMap.end(); }
358 
361  {
363  symbolIndexMap.begin(), symbolIndexMap.end(), name, CStringLess());
364  if (it == symbolIndexMap.end())
365  throw BinException(std::string("Can't find Elf")+Types::bitName+" Symbol");
366  return it;
367  }
368 
371  {
373  dynSymIndexMap.begin(), dynSymIndexMap.end(), name, CStringLess());
374  if (it == dynSymIndexMap.end())
375  throw BinException(std::string("Can't find Elf")+Types::bitName+" DynSymbol");
376  return it;
377  }
378 
380  const typename Types::Shdr& getSectionHeader(const char* name) const
381  { return getSectionHeader(getSectionIndex(name)); }
382 
384  typename Types::Shdr& getSectionHeader(const char* name)
385  { return getSectionHeader(getSectionIndex(name)); }
386 
388  const typename Types::Sym& getSymbol(const char* name) const
389  { return getSymbol(getSymbolIndex(name)); }
390 
392  typename Types::Sym& getSymbol(const char* name)
393  { return getSymbol(getSymbolIndex(name)); }
394 
396  const typename Types::Sym& getDynSymbol(const char* name) const
397  { return getDynSymbol(getDynSymbolIndex(name)); }
398 
400  typename Types::Sym& getDynSymbol(const char* name)
401  { return getDynSymbol(getDynSymbolIndex(name)); }
402 
404  const typename Types::Nhdr* getNotes() const
405  { return reinterpret_cast<typename Types::Nhdr*>(noteTable); }
406 
408  typename Types::Nhdr* getNotes()
409  { return reinterpret_cast<typename Types::Nhdr*>(noteTable); }
410 
412  typename Types::Size getNotesSize() const
413  { return noteTableSize; }
414 
416  const typename Types::Size getDynamicsNum() const
417  { return dynamicsNum; }
418 
420  const typename Types::Size getDynamicEntrySize() const
421  { return dynamicEntSize; }
422 
424  const typename Types::Dyn* getDynamicTable() const
425  { return reinterpret_cast<const typename Types::Dyn*>(dynamicTable); }
426 
428  typename Types::Dyn* getDynamicTable()
429  { return reinterpret_cast<typename Types::Dyn*>(dynamicTable); }
430 
432  const cxbyte* getSectionContent(uint16_t index) const
433  {
434  const typename Types::Shdr& shdr = getSectionHeader(index);
435  return binaryCode + ULEV(shdr.sh_offset);
436  }
437 
439  cxbyte* getSectionContent(uint16_t index)
440  {
441  typename Types::Shdr& shdr = getSectionHeader(index);
442  return binaryCode + ULEV(shdr.sh_offset);
443  }
444 
446  const cxbyte* getSectionContent(const char* name) const
447  { return getSectionContent(getSectionIndex(name)); }
448 
450  cxbyte* getSectionContent(const char* name)
451  { return getSectionContent(getSectionIndex(name)); }
452 
453  static uint32_t getElfRelType(typename Types::Word info);
454  static uint32_t getElfRelSym(typename Types::Word info);
455 };
456 
457 template<>
459 { return ELF32_R_TYPE(info); }
460 
461 template<>
463 { return ELF32_R_SYM(info); }
464 
465 template<>
467 { return ELF64_R_TYPE(info); }
468 
469 template<>
471 { return ELF64_R_SYM(info); }
472 
473 
474 extern template class ElfBinaryTemplate<Elf32Types>;
475 extern template class ElfBinaryTemplate<Elf64Types>;
476 
478 extern bool isElfBinary(size_t binarySize, const cxbyte* binary);
479 
484 
487 {
488  PHDR_TABLE,
489  SHDR_TABLE,
490  SECTION,
491  USER
492 };
493 
496 {
497 public:
498  virtual ~ElfRegionContent();
499 
501  virtual void operator()(FastOutputBuffer& fob) const = 0;
502 };
503 
505 template<typename Types>
507 {
508  typename Types::Word paddrBase;
509  typename Types::Word vaddrBase;
512  uint16_t type;
513  uint16_t machine;
514  uint32_t version;
516  typename Types::Word entry;
517  uint32_t flags;
518 };
519 
524 
527 
528 enum: ElfBinSectId {
529  ELFSECTID_VAL_MAX = UINT_MAX,
530  ELFSECTID_START = ELFSECTID_VAL_MAX-255,
531  ELFSECTID_SHSTRTAB = ELFSECTID_START,
532  ELFSECTID_STRTAB,
533  ELFSECTID_SYMTAB,
534  ELFSECTID_DYNSTR,
535  ELFSECTID_DYNSYM,
536  ELFSECTID_TEXT,
537  ELFSECTID_RODATA,
538  ELFSECTID_DATA,
539  ELFSECTID_BSS,
540  ELFSECTID_COMMENT,
541  ELFSECTID_STD_MAX = ELFSECTID_COMMENT,
542  ELFSECTID_OTHER_BUILTIN = ELFSECTID_STD_MAX+1,
543  ELFSECTID_NULL = ELFSECTID_VAL_MAX-2,
544  ELFSECTID_ABS = ELFSECTID_VAL_MAX-1,
545  ELFSECTID_UNDEF = ELFSECTID_VAL_MAX
546 };
547 
550 {
552  size_t size;
553  const cxbyte* data;
554  uint64_t align;
555  uint32_t type;
556  uint64_t flags;
558  uint32_t info;
559  size_t entSize;
560 };
561 
563 struct BinSymbol
564 {
566  uint64_t value;
567  uint64_t size;
569  bool valueIsAddr;
572 };
573 
575 extern uint16_t convertSectionId(cxuint sectionIndex, const uint16_t* builtinSections,
576  cxuint maxBuiltinSection, ElfBinSectId extraSectionIndex);
577 
579 template<typename Types>
581 {
583 
586 
588 
590  typename Types::Word size;
591  typename Types::Word align;
592  union
593  {
594  const cxbyte* data;
596  };
597  struct {
598  const char* name;
599  uint32_t type;
600  typename Types::SectionFlags flags;
601  uint32_t link;
602  uint32_t info;
603  typename Types::Word addrBase;
604  typename Types::Word entSize;
605  bool zeroOffset;
606  typename Types::Word align;
607  } section;
608 
609  ElfRegionTemplate() : type(ElfRegionType::USER), dataFromPointer(false), size(0),
610  align(0), data(0)
611  { }
613  ElfRegionTemplate(typename Types::Word _size,
614  const cxbyte* _data, typename Types::Word _align)
615  : type(ElfRegionType::USER), dataFromPointer(true), size(_size),
616  align(_align), data(_data)
617  { }
618 
620  ElfRegionTemplate(typename Types::Word _size,
621  const ElfRegionContent* contentGen, typename Types::Word _align)
622  : type(ElfRegionType::USER), dataFromPointer(false), size(_size),
623  align(_align), dataGen(contentGen)
624  { }
625 
627  ElfRegionTemplate(ElfRegionType _type, typename Types::Word _size,
628  const cxbyte* _data, typename Types::Word _align)
629  : type(_type), dataFromPointer(true), size(_size),
630  align(_align), data(_data)
631  { }
632 
634  ElfRegionTemplate(ElfRegionType _type, typename Types::Word _size,
635  const ElfRegionContent* contentGen, typename Types::Word _align)
636  : type(_type), dataFromPointer(false), size(_size),
637  align(_align), dataGen(contentGen)
638  { }
639 
641  ElfRegionTemplate(typename Types::Word _size, const cxbyte* _data,
642  typename Types::Word _align, const char* _name, uint32_t _type,
643  typename Types::SectionFlags _flags, uint32_t _link = 0, uint32_t _info = 0,
644  typename Types::Word _addrBase = 0,
645  typename Types::Word _entSize = 0, bool _zeroOffset = false,
646  typename Types::Word _sectAlign = 0)
647  : type(ElfRegionType::SECTION), dataFromPointer(true), size(_size),
648  align(_align), data(_data)
649  {
650  section = {_name, _type, _flags, _link, _info, _addrBase,
651  _entSize, _zeroOffset, _sectAlign};
652  }
653 
655  ElfRegionTemplate(typename Types::Word _size, const ElfRegionContent* _data,
656  typename Types::Word _align, const char* inName, uint32_t _type,
657  typename Types::SectionFlags _flags, uint32_t _link = 0, uint32_t _info = 0,
658  typename Types::Word _addrBase = 0,
659  typename Types::Word _entSize = 0, bool _zeroOffset = false,
660  typename Types::Word _sectAlign = 0)
661  : type(ElfRegionType::SECTION), dataFromPointer(false), size(_size),
662  align(_align), dataGen(_data)
663  {
664  section = {inName, _type, _flags, _link, _info, _addrBase,
665  _entSize, _zeroOffset, _sectAlign};
666  }
668 
674  ElfRegionTemplate(const BinSection& binSection, const uint16_t* builtinSections,
675  cxuint maxBuiltinSection, ElfBinSectId startExtraIndex)
676  : type(ElfRegionType::SECTION), dataFromPointer(true), size(binSection.size),
677  align(binSection.align), data(binSection.data)
678  {
679  section = { binSection.name.c_str(), binSection.type,
680  typename Types::SectionFlags(binSection.flags),
681  uint32_t(convertSectionId(binSection.linkId, builtinSections,
682  maxBuiltinSection, startExtraIndex)),
683  binSection.info, 0, typename Types::Word(binSection.entSize), 0 };
684  }
685 
688  { return ElfRegionTemplate(ElfRegionType::PHDR_TABLE, 0, (const cxbyte*)nullptr,
689  sizeof(typename Types::Word)); }
690 
693  { return ElfRegionTemplate(ElfRegionType::SHDR_TABLE, 0, (const cxbyte*)nullptr,
694  sizeof(typename Types::Word)); }
695 
698  { return ElfRegionTemplate(0, (const cxbyte*)nullptr, 1, ".strtab", SHT_STRTAB, 0); }
699 
702  { return ElfRegionTemplate(0, (const cxbyte*)nullptr, 1, ".dynstr", SHT_STRTAB,
703  SHF_ALLOC); }
704 
707  { return ElfRegionTemplate(0, (const cxbyte*)nullptr, 1, ".shstrtab", SHT_STRTAB, 0); }
708 
710  static ElfRegionTemplate symtabSection(bool defInfo = true)
711  { return ElfRegionTemplate(0, (const cxbyte*)nullptr, sizeof(typename Types::Word),
712  ".symtab", SHT_SYMTAB, 0, 0, defInfo ? BINGEN_DEFAULT : 0); }
713 
715  static ElfRegionTemplate dynsymSection(bool defInfo = true)
716  { return ElfRegionTemplate(0, (const cxbyte*)nullptr, sizeof(typename Types::Word),
717  ".dynsym", SHT_DYNSYM, SHF_ALLOC, 0, defInfo ? BINGEN_DEFAULT : 0); }
718 
720  static ElfRegionTemplate hashSection(uint16_t link)
721  { return ElfRegionTemplate(0, (const cxbyte*)nullptr, sizeof(typename Types::Word),
722  ".hash", SHT_HASH, SHF_ALLOC, link); }
723 
726  { return ElfRegionTemplate(0, (const cxbyte*)nullptr, 4, ".note", SHT_NOTE, 0); }
727 
729  static ElfRegionTemplate dynamicSection(uint16_t link)
730  { return ElfRegionTemplate(0, (const cxbyte*)nullptr, sizeof(typename Types::Word),
731  ".dynamic", SHT_DYNAMIC, SHF_ALLOC|SHF_WRITE, link); }
732 };
733 
735 struct ElfNote
736 {
737  const char* name;
738  size_t descSize;
739  const cxbyte* desc;
740  uint32_t type;
741 };
742 
747 
748 enum: cxuint {
749  PHREGION_FILESTART = UINT_MAX
750 };
752 template<typename Types>
754 {
755  uint32_t type;
756  uint32_t flags;
759  bool haveMemSize;
760  typename Types::Word paddrBase;
761  typename Types::Word vaddrBase;
762  typename Types::Word memSize;
763  typename Types::Word align;
764 };
765 
770 
772 template<typename Types>
774 {
775  const char* name;
776  uint16_t sectionIndex;
779  bool valueIsAddr;
780  typename Types::Word value;
781  typename Types::Word size;
782 
783  ElfSymbolTemplate() : name(nullptr), sectionIndex(0), info(0), other(0),
784  valueIsAddr(false), value(0), size(0)
785  { }
786 
788  ElfSymbolTemplate(const char* _name, uint16_t _sectionIndex,
789  cxbyte _info, cxbyte _other, bool _valueIsAddr,
790  typename Types::Word _value, typename Types::Word _size)
791  : name(_name), sectionIndex(_sectionIndex), info(_info), other(_other),
792  valueIsAddr(_valueIsAddr), value(_value), size(_size)
793  { }
795 
801  ElfSymbolTemplate(const BinSymbol& binSymbol, const uint16_t* builtinSections,
802  cxuint maxBuiltinSection, ElfBinSectId startExtraIndex)
803  {
804  name = binSymbol.name.c_str();
805  sectionIndex = convertSectionId(binSymbol.sectionId, builtinSections,
806  maxBuiltinSection, startExtraIndex);
807  info = binSymbol.info;
808  other = binSymbol.other;
809  valueIsAddr = binSymbol.valueIsAddr;
810  value = binSymbol.value;
811  size = binSymbol.size;
812  }
813 };
814 
819 
821 template<typename Types>
823 {
824 private:
825  bool sizeComputed;
826  bool addNullSym, addNullDynSym;
827  bool addNullSection;
828  cxuint addrStartRegion;
829  uint16_t shStrTab, strTab, dynStr;
830  cxuint shdrTabRegion, phdrTabRegion;
831  uint16_t sectionsNum;
832  typename Types::Word size;
834  std::vector<ElfRegionTemplate<Types> > regions;
835  std::unique_ptr<typename Types::Word[]> regionOffsets;
836  std::unique_ptr<typename Types::Word[]> regionAddresses;
837  std::unique_ptr<cxuint[]> sectionRegions;
838  std::vector<ElfProgramHeaderTemplate<Types> > progHeaders;
839  std::vector<ElfSymbolTemplate<Types> > symbols;
840  std::vector<ElfSymbolTemplate<Types> > dynSymbols;
841  std::vector<ElfNote> notes;
842  std::vector<int32_t> dynamics;
843  std::unique_ptr<typename Types::Word[]> dynamicValues;
844  uint32_t bucketsNum;
845  std::unique_ptr<uint32_t[]> hashCodes;
846  bool isHashDynSym;
847 
848  void computeSize();
849 public:
852 
859  explicit ElfBinaryGenTemplate(const ElfHeaderTemplate<Types>& header,
860  bool addNullSym = true, bool addNullDynSym = true,
861  bool addNullSection = true, cxuint addrCountingFromRegion = 0);
862 
865  { this->header = header; }
866 
868  void addRegion(const ElfRegionTemplate<Types>& region);
870  void addProgramHeader(const ElfProgramHeaderTemplate<Types>& progHeader);
871 
874  { symbols.clear(); }
877  { dynSymbols.clear(); }
880  { symbols.push_back(symbol); }
883  { dynSymbols.push_back(symbol); }
885  void addNote(const ElfNote& note)
886  { notes.push_back(note); }
888  void addDynamic(int32_t dynamicTag)
889  { dynamics.push_back(dynamicTag); }
891  void addDynamics(size_t dynamicsNum, const int32_t* dynTags)
892  { dynamics.insert(dynamics.end(), dynTags, dynTags + dynamicsNum); }
893 
895  uint64_t countSize();
896 
897  // return offset for specified region
898  typename Types::Word getRegionOffset(cxuint i) const
899  { return regionOffsets[i]; }
900 
902  void generate(FastOutputBuffer& fob);
903 
905  void generate(std::ostream& os)
906  {
907  FastOutputBuffer fob(256, os);
908  generate(fob);
909  }
910 
911  static typename Types::Word getRelInfo(size_t symbolIndex, uint32_t rtype);
912 };
913 
914 template<>
916  size_t symbolIndex, uint32_t rtype)
917 { return ELF32_R_INFO(symbolIndex, rtype); }
918 
919 template<>
921  size_t symbolIndex, uint32_t rtype)
922 { return ELF64_R_INFO(symbolIndex, rtype); }
923 
924 extern template class ElfBinaryGenTemplate<Elf32Types>;
925 extern template class ElfBinaryGenTemplate<Elf64Types>;
926 
931 
932 };
933 
934 #endif
const char * getDynSymbolName(typename Types::Size index) const
get dynamic symbol name with specified index
Definition: ElfBinaries.h:315
Types::Word memSize
size in memory
Definition: ElfBinaries.h:762
const Types::Sym & getDynSymbol(typename Types::Size index) const
get dynamic symbol with specified index
Definition: ElfBinaries.h:294
const Types::Shdr & getSectionHeader(uint16_t index) const
get section header with specified index
Definition: ElfBinaries.h:236
uint32_t link
section link
Definition: ElfBinaries.h:601
ELF note structure.
Definition: ElfBinaries.h:735
uint32_t Word
word size in ELF
Definition: ElfBinaries.h:104
SymbolIndexMap::const_iterator getDynSymbolIterEnd() const
get end iterator of dynamic symbol index map
Definition: ElfBinaries.h:356
Elf64_Sym Sym
symbol header
Definition: ElfBinaries.h:130
program header table
if set in field then field has been ignored
Definition: ElfBinaries.h:51
void addDynamic(int32_t dynamicTag)
add dynamic
Definition: ElfBinaries.h:888
Elf64_Ehdr Ehdr
ELF header.
Definition: ElfBinaries.h:127
const cxbyte * data
data content
Definition: ElfBinaries.h:553
cxbyte info
info
Definition: ElfBinaries.h:570
Types::Shdr & getSectionHeader(const char *name)
get section header with specified name
Definition: ElfBinaries.h:384
ELF binary class.
Definition: ElfBinaries.h:147
create map of symbols
Definition: ElfBinaries.h:71
Types::Word paddrBase
physical address base
Definition: ElfBinaries.h:508
Types::Size noteTableSize
size of note table
Definition: ElfBinaries.h:171
Definition: Elf.h:73
uint32_t type
section type
Definition: ElfBinaries.h:555
uint32_t Flags
type for declaring various flags
Definition: Utilities.h:100
Definition: Elf.h:244
const Types::Ehdr & getHeader() const
get ELF binary header
Definition: ElfBinaries.h:224
const T * begin() const
get iterator to first element
Definition: Containers.h:253
static ElfRegionTemplate symtabSection(bool defInfo=true)
get symtab section
Definition: ElfBinaries.h:710
Elf32_Nhdr Nhdr
note header
Definition: ElfBinaries.h:110
Types::Word vaddrBase
vaddr base
Definition: ElfBinaries.h:761
Iter binaryMapFind(Iter begin, Iter end, const typename std::iterator_traits< Iter >::value_type::first_type &k)
binary find helper for array-map
Definition: Containers.h:440
size_t binaryCodeSize
binary code size
Definition: ElfBinaries.h:156
ElfRegionType type
type of region
Definition: ElfBinaries.h:582
fast and direct output buffer
Definition: InputOutput.h:350
const char * c_str() const
return C-style string pointer
Definition: CString.h:254
uint32_t info
section info
Definition: ElfBinaries.h:602
template of ElfRegion
Definition: ElfBinaries.h:580
static ElfRegionTemplate shstrtabSection()
get .shstrtab section
Definition: ElfBinaries.h:706
uint64_t flags
section flags
Definition: ElfBinaries.h:556
elf header template
Definition: ElfBinaries.h:506
void addDynSymbol(const ElfSymbolTemplate< Types > &symbol)
add dynamic symbol
Definition: ElfBinaries.h:882
Types::Sym & getSymbol(typename Types::Size index)
get symbol with specified index
Definition: ElfBinaries.h:287
uint64_t value
symbol value
Definition: ElfBinaries.h:566
const Types::Sym & getDynSymbol(const char *name) const
get dynamic symbol with specified name (requires dynamic symbol index map)
Definition: ElfBinaries.h:396
Elf32_Rela Rela
relocation with addend
Definition: ElfBinaries.h:113
uint64_t size
symbol size
Definition: ElfBinaries.h:567
const cxbyte * desc
description
Definition: ElfBinaries.h:739
const Types::Dyn * getDynamicTable() const
get dynamic table
Definition: ElfBinaries.h:424
bool hasSectionMap() const
returns true if object has a section&#39;s index map
Definition: ElfBinaries.h:193
bool valueIsAddr
true if value should be treats as address
Definition: ElfBinaries.h:779
ELF 32-bit types.
Definition: ElfBinaries.h:101
ElfRegionTemplate< Elf32Types > ElfRegion32
32-bit region (for 32-bit elf)
Definition: ElfBinaries.h:744
Definition: Elf.h:353
Elf64_Rela Rela
relocation with addend
Definition: ElfBinaries.h:134
Binary generator exception class.
Definition: ElfBinaries.h:89
section header table
bool haveMemSize
true if program header has memory size
Definition: ElfBinaries.h:759
class ElfBinaryTemplate< Elf64Types > ElfBinary64
type for 64-bit ELF binary
Definition: ElfBinaries.h:483
Types::Nhdr * getNotes()
get note table
Definition: ElfBinaries.h:408
Elf64_Rel Rel
relocation
Definition: ElfBinaries.h:133
ElfRegionTemplate(ElfRegionType _type, typename Types::Word _size, const cxbyte *_data, typename Types::Word _align)
constructor for region
Definition: ElfBinaries.h:627
create map of sections
Definition: ElfBinaries.h:70
cxbyte * binaryCode
pointer to binary code
Definition: ElfBinaries.h:157
static ElfRegionTemplate sectionHeaderTable()
get program header table region
Definition: ElfBinaries.h:692
SymbolIndexMap::const_iterator getSymbolIterEnd() const
get end iterator of symbol index map
Definition: ElfBinaries.h:352
symbol structure to external usage (fo example in the binary generator input)
Definition: ElfBinaries.h:563
ElfRegionTemplate(typename Types::Word _size, const ElfRegionContent *_data, typename Types::Word _align, const char *inName, uint32_t _type, typename Types::SectionFlags _flags, uint32_t _link=0, uint32_t _info=0, typename Types::Word _addrBase=0, typename Types::Word _entSize=0, bool _zeroOffset=false, typename Types::Word _sectAlign=0)
constructor for section with generator
Definition: ElfBinaries.h:655
cxbyte info
info
Definition: ElfBinaries.h:777
if set in field then field has been ignored
Definition: ElfBinaries.h:66
Types::Size dynSymbolsNum
dynamic symbols number
Definition: ElfBinaries.h:170
Types::Word addrBase
section address base
Definition: ElfBinaries.h:603
Elf64_Nhdr Nhdr
note header
Definition: ElfBinaries.h:131
bool dataFromPointer
true if content from pointer, otherwise will be generated from class
Definition: ElfBinaries.h:585
CString name
name of section
Definition: ElfBinaries.h:551
uint64_t align
region alignment
Definition: ElfBinaries.h:554
Elf64_Shdr Shdr
Section header.
Definition: ElfBinaries.h:128
Definition: Elf.h:455
Array< std::pair< const char *, size_t > > SymbolIndexMap
symbol index map
Definition: ElfBinaries.h:153
static ElfRegionTemplate programHeaderTable()
get program header table region
Definition: ElfBinaries.h:687
const cxbyte * getSectionContent(uint16_t index) const
get section content pointer
Definition: ElfBinaries.h:432
Types::Size symbolsNum
symbols number
Definition: ElfBinaries.h:169
Elf32_Dyn Dyn
dynamic entry
Definition: ElfBinaries.h:111
Types::Size dynamicEntSize
get dynamic entry size
Definition: ElfBinaries.h:175
an array class
Definition: Containers.h:41
Elf32_Sym Sym
symbol header
Definition: ElfBinaries.h:109
Types::Word entSize
entries size
Definition: ElfBinaries.h:604
if set in field then field has been ignored
Definition: ElfBinaries.h:56
cxbyte abiVersion
ABI version.
Definition: ElfBinaries.h:511
Configuration header.
uint32_t version
version
Definition: ElfBinaries.h:514
ElfHeaderTemplate< Elf64Types > ElfHeader64
64-bit elf header
Definition: ElfBinaries.h:523
cxbyte * getBinaryCode()
get binary code
Definition: ElfBinaries.h:220
const std::pair< const char *, size_t > * const_iterator
type of constant iterator
Definition: Containers.h:45
void generate(std::ostream &os)
generate binary
Definition: ElfBinaries.h:905
const Types::Sym & getSymbol(const char *name) const
get symbol with specified name (requires symbol index map)
Definition: ElfBinaries.h:388
Types::Phdr & getProgramHeader(uint16_t index)
get program header with specified index
Definition: ElfBinaries.h:264
Definition: Elf.h:462
CString name
name
Definition: ElfBinaries.h:565
Types::Sym & getSymbol(const char *name)
get symbol with specified name (requires symbol index map)
Definition: ElfBinaries.h:392
static ElfRegionTemplate dynamicSection(uint16_t link)
get dynamic
Definition: ElfBinaries.h:729
void clearDynSymbols()
clear dynamic symbols
Definition: ElfBinaries.h:876
static ElfRegionTemplate hashSection(uint16_t link)
get hash section
Definition: ElfBinaries.h:720
const Types::Size getDynamicsNum() const
get dynamic entries number
Definition: ElfBinaries.h:416
Definition: Elf.h:609
size_t descSize
description size
Definition: ElfBinaries.h:738
uint16_t convertSectionId(cxuint sectionIndex, const uint16_t *builtinSections, cxuint maxBuiltinSection, ElfBinSectId extraSectionIndex)
convert section id to elf section id
ELF binary generator.
Definition: ElfBinaries.h:822
if set in field then field has been filled later
Definition: ElfBinaries.h:60
uint32_t info
section info
Definition: ElfBinaries.h:558
Definition: Elf.h:436
const char * getSymbolName(typename Types::Size index) const
get symbol name with specified index
Definition: ElfBinaries.h:308
uint32_t type
section type
Definition: ElfBinaries.h:599
section structure to external usage (for example in the binary generator input)
Definition: ElfBinaries.h:549
Types::Dyn * getDynamicTable()
get dynamic table
Definition: ElfBinaries.h:428
const Types::Sym & getSymbol(typename Types::Size index) const
get symbol with specified index
Definition: ElfBinaries.h:280
void addNote(const ElfNote &note)
add note
Definition: ElfBinaries.h:885
void addSymbol(const ElfSymbolTemplate< Types > &symbol)
add symbol
Definition: ElfBinaries.h:879
uint16_t getSectionHeadersNum() const
get section headers number
Definition: ElfBinaries.h:232
static ElfRegionTemplate noteSection()
get note section
Definition: ElfBinaries.h:725
cxbyte * symbolStringTable
pointer to symbol&#39;s string table
Definition: ElfBinaries.h:159
Types::Sym & getDynSymbol(typename Types::Size index)
get dynamic symbol with specified index
Definition: ElfBinaries.h:301
elf region content generator for elf region
Definition: ElfBinaries.h:495
const char * name
name
Definition: ElfBinaries.h:775
cxuint regionsNum
number of regions whose is in program header data
Definition: ElfBinaries.h:758
cxbyte osABI
os abi
Definition: ElfBinaries.h:510
const char * getSectionName(uint16_t index) const
get section name with specified index
Definition: ElfBinaries.h:322
ElfSymbolTemplate< Elf64Types > ElfSymbol64
64-bit elf symbol
Definition: ElfBinaries.h:818
creation flags for ELF binaries
Definition: ElfBinaries.h:73
ElfRegionTemplate(ElfRegionType _type, typename Types::Word _size, const ElfRegionContent *contentGen, typename Types::Word _align)
constructor for region with content generator
Definition: ElfBinaries.h:634
Types::Size getNotesSize() const
get size of notes in bytes
Definition: ElfBinaries.h:412
ElfRegionTemplate< Elf64Types > ElfRegion64
64-bit region (for 64-bit elf)
Definition: ElfBinaries.h:746
const char * name
section name
Definition: ElfBinaries.h:598
input output utilities
static const char * bitName
bitness name
Definition: ElfBinaries.h:116
SectionIndexMap::const_iterator getSectionIter(const char *name) const
get section iterator with specified name (requires section index map)
Definition: ElfBinaries.h:333
Types::Size dynamicsNum
get dynamic entries number
Definition: ElfBinaries.h:172
const Types::Shdr & getSectionHeader(const char *name) const
get section header with specified name
Definition: ElfBinaries.h:380
SymbolIndexMap symbolIndexMap
symbol&#39;s index map
Definition: ElfBinaries.h:166
ElfProgramHeaderTemplate< Elf64Types > ElfProgramHeader64
64-bit elf program header
Definition: ElfBinaries.h:769
SymbolIndexMap::const_iterator getSymbolIter(const char *name) const
get symbol iterator with specified name (requires symbol index map)
Definition: ElfBinaries.h:360
static ElfRegionTemplate dynsymSection(bool defInfo=true)
get dynsym section
Definition: ElfBinaries.h:715
size_t entSize
entries size
Definition: ElfBinaries.h:559
const cxbyte * getSectionContent(const char *name) const
get section content pointer
Definition: ElfBinaries.h:446
unsigned char cxbyte
unsigned byte
Definition: Config.h:229
uint32_t flags
flags
Definition: ElfBinaries.h:517
void setHeader(const ElfHeaderTemplate< Types > &header)
set elf header
Definition: ElfBinaries.h:864
static const char * bitName
bitness name
Definition: ElfBinaries.h:137
Types::Ehdr & getHeader()
get ELF binary header
Definition: ElfBinaries.h:228
Flags creationFlags
creation flags holder
Definition: ElfBinaries.h:155
uint32_t flags
flags
Definition: ElfBinaries.h:756
Types::Word entry
entry offset relative to region
Definition: ElfBinaries.h:516
ElfSymbolTemplate(const BinSymbol &binSymbol, const uint16_t *builtinSections, cxuint maxBuiltinSection, ElfBinSectId startExtraIndex)
constructor for extra symbol
Definition: ElfBinaries.h:801
main namespace
Definition: AsmDefs.h:38
bool hasDynSymbolMap() const
returns true if object has a dynamic symbol&#39;s index map
Definition: ElfBinaries.h:201
uint16_t symbolEntSize
symbol entry size in a symbol&#39;s table
Definition: ElfBinaries.h:173
size_t size
size of content
Definition: ElfBinaries.h:552
uint16_t dynSymEntSize
dynamic symbol entry size in a dynamic symbol&#39;s table
Definition: ElfBinaries.h:174
static const cxuint bitness
ELF bitness.
Definition: ElfBinaries.h:136
cxbyte other
other
Definition: ElfBinaries.h:571
unsigned int cxuint
unsigned int
Definition: Config.h:237
if set in field then field has been ignored
Definition: ElfBinaries.h:61
size_t getSize() const
get size of binaries
Definition: ElfBinaries.h:205
void addDynamics(size_t dynamicsNum, const int32_t *dynTags)
add dynamic
Definition: ElfBinaries.h:891
const char * name
note name
Definition: ElfBinaries.h:737
Definition: Elf.h:552
cxuint entryRegion
region in which is entry
Definition: ElfBinaries.h:515
ElfRegionTemplate(typename Types::Word _size, const cxbyte *_data, typename Types::Word _align, const char *_name, uint32_t _type, typename Types::SectionFlags _flags, uint32_t _link=0, uint32_t _info=0, typename Types::Word _addrBase=0, typename Types::Word _entSize=0, bool _zeroOffset=false, typename Types::Word _sectAlign=0)
constructor for section
Definition: ElfBinaries.h:641
cxuint ElfBinSectId
type for Elf BinSection Id (sectionIndex)
Definition: ElfBinaries.h:526
bool isElfBinary(size_t binarySize, const cxbyte *binary)
check whether binary data is is ELF binary
bool valueIsAddr
true if value should be treats as address
Definition: ElfBinaries.h:569
uint32_t Size
size used to return size value
Definition: ElfBinaries.h:103
const Types::Nhdr * getNotes() const
get note table
Definition: ElfBinaries.h:404
uint64_t SectionFlags
section flags
Definition: ElfBinaries.h:126
ElfProgramHeaderTemplate< Elf32Types > ElfProgramHeader32
32-bit elf program header
Definition: ElfBinaries.h:767
inlines for accessing memory words in LittleEndian and unaligned
Types::Word vaddrBase
virtual address base
Definition: ElfBinaries.h:509
Definition: Elf.h:545
const cxbyte * data
content from pointer
Definition: ElfBinaries.h:594
if set in field then field has been filled later
Definition: ElfBinaries.h:55
ElfSymbolTemplate(const char *_name, uint16_t _sectionIndex, cxbyte _info, cxbyte _other, bool _valueIsAddr, typename Types::Word _value, typename Types::Word _size)
constructor (to replace initializer list construction)
Definition: ElfBinaries.h:788
ELF symbol template.
Definition: ElfBinaries.h:773
Types::Word align
region alignment
Definition: ElfBinaries.h:591
Types::Size getDynSymbolsNum() const
get dynamic symbols number
Definition: ElfBinaries.h:276
cxbyte * dynSymTable
pointer to dynamic symbol table
Definition: ElfBinaries.h:162
uint32_t type
type
Definition: ElfBinaries.h:740
ElfHeaderTemplate< Elf32Types > ElfHeader32
32-bit elf header
Definition: ElfBinaries.h:521
Definition: Elf.h:619
template of ELF program header
Definition: ElfBinaries.h:753
virtual ~BinException() noexcept=default
destructor
SymbolIndexMap dynSymIndexMap
dynamic symbol&#39;s index map
Definition: ElfBinaries.h:167
uint16_t getProgramHeadersNum() const
get program headers number
Definition: ElfBinaries.h:252
Elf64_Phdr Phdr
program header
Definition: ElfBinaries.h:129
cxbyte * getSectionContent(const char *name)
get section content pointer
Definition: ElfBinaries.h:450
bool hasSymbolMap() const
returns true if object has a symbol&#39;s index map
Definition: ElfBinaries.h:197
Flags getCreationFlags() const
get creation flags
Definition: ElfBinaries.h:189
utilities for other libraries and programs
uint16_t sectionIndex
section index for which symbol is
Definition: ElfBinaries.h:776
ElfRegionType
type of Elf region
Definition: ElfBinaries.h:486
std::string message
message
Definition: Utilities.h:64
uint32_t SectionFlags
section flags
Definition: ElfBinaries.h:105
const cxbyte * getBinaryCode() const
get binary code
Definition: ElfBinaries.h:217
exception class
Definition: Utilities.h:61
cxbyte * sectionStringTable
pointer to section&#39;s string table
Definition: ElfBinaries.h:158
cxbyte other
other
Definition: ElfBinaries.h:778
const Types::Phdr & getProgramHeader(uint16_t index) const
get program header with specified index
Definition: ElfBinaries.h:256
Types::Word size
region size
Definition: ElfBinaries.h:590
static ElfRegionTemplate strtabSection()
get .strtab section
Definition: ElfBinaries.h:697
Elf32_Rel Rel
relocation
Definition: ElfBinaries.h:112
class ElfBinaryGenTemplate< Elf32Types > ElfBinaryGen32
type for 32-bit ELF binary generator
Definition: ElfBinaries.h:928
cxuint linkId
link section id (ELFSECTID_* or an extra section index)
Definition: ElfBinaries.h:557
uint32_t type
type
Definition: ElfBinaries.h:755
static ElfRegionTemplate dynstrSection()
get .dynstr section
Definition: ElfBinaries.h:701
cxbyte * getSectionContent(uint16_t index)
get section content pointer
Definition: ElfBinaries.h:439
if set in field then field has been filled later
Definition: ElfBinaries.h:65
Elf32_Ehdr Ehdr
ELF header.
Definition: ElfBinaries.h:106
Types::Word size
symbol size
Definition: ElfBinaries.h:781
Types::Size getSymbolsNum() const
get symbols number
Definition: ElfBinaries.h:272
SectionIndexMap sectionIndexMap
section&#39;s index map
Definition: ElfBinaries.h:165
Bin exception class.
Definition: ElfBinaries.h:77
Types::Shdr & getSectionHeader(uint16_t index)
get section header with specified index
Definition: ElfBinaries.h:244
Definition: Elf.h:447
const ElfRegionContent * dataGen
content generator pointer
Definition: ElfBinaries.h:595
cxuint sectionId
section id (ELFSECTID_* or an extra section index)
Definition: ElfBinaries.h:568
static const cxbyte ELFCLASS
ELF class.
Definition: ElfBinaries.h:114
ElfSymbolTemplate< Elf32Types > ElfSymbol32
32-bit elf symbol
Definition: ElfBinaries.h:816
class ElfBinaryTemplate< Elf32Types > ElfBinary32
type for 32-bit ELF binary
Definition: ElfBinaries.h:481
ElfRegionTemplate(typename Types::Word _size, const ElfRegionContent *contentGen, typename Types::Word _align)
constructor for user region with content generator
Definition: ElfBinaries.h:620
function class that returns true if first C string is less than second
Definition: Utilities.h:313
Types::Word paddrBase
paddr base
Definition: ElfBinaries.h:760
Types::SectionFlags flags
section flags
Definition: ElfBinaries.h:600
SymbolIndexMap::const_iterator getDynSymbolIter(const char *name) const
get dynamic symbol iterator with specified name (requires dynamic symbol index map) ...
Definition: ElfBinaries.h:370
Definition: Elf.h:493
cxbyte * dynSymStringTable
pointer to dynamic symbol&#39;s string table
Definition: ElfBinaries.h:161
Array< std::pair< const char *, size_t > > SectionIndexMap
section index map
Definition: ElfBinaries.h:151
static const cxbyte ELFCLASS
ELF class.
Definition: ElfBinaries.h:135
uint16_t machine
machine
Definition: ElfBinaries.h:513
uint16_t type
type
Definition: ElfBinaries.h:512
Definition: Elf.h:363
Types::Sym & getDynSymbol(const char *name)
get dynamic symbol with specified name (requires dynamic symbol index map)
Definition: ElfBinaries.h:400
Types::Word value
symbol value
Definition: ElfBinaries.h:780
Elf32_Shdr Shdr
Section header.
Definition: ElfBinaries.h:107
const T * end() const
get iterator to after last element
Definition: Containers.h:260
SectionIndexMap::const_iterator getSectionIterEnd() const
get end iterator if section index map
Definition: ElfBinaries.h:329
class ElfBinaryGenTemplate< Elf64Types > ElfBinaryGen64
type for 64-bit ELF binary generator
Definition: ElfBinaries.h:930
Elf32_Phdr Phdr
program header
Definition: ElfBinaries.h:108
Definition: Elf.h:481
ElfRegionTemplate(const BinSection &binSection, const uint16_t *builtinSections, cxuint maxBuiltinSection, ElfBinSectId startExtraIndex)
constructor for external section (BinSection)
Definition: ElfBinaries.h:674
BinException()=default
empty constructor
size_t Size
size used to return size value
Definition: ElfBinaries.h:124
if set in field then field has been filled later
Definition: ElfBinaries.h:50
Types::Word align
alignment
Definition: ElfBinaries.h:763
cxbyte * dynamicTable
pointer to dynamic table
Definition: ElfBinaries.h:164
bool operator!() const
returns true if object is uninitialized
Definition: ElfBinaries.h:213
uint8_t ULEV(const uint8_t &t)
convert from/to little endian value from unaligned memory
simple C-string container
Definition: CString.h:38
Elf.h definitions.
ELF 32-bit types.
Definition: ElfBinaries.h:122
containers and other utils for other libraries and programs
const Types::Size getDynamicEntrySize() const
get dynamic entries size
Definition: ElfBinaries.h:420
void clearSymbols()
clear symbols
Definition: ElfBinaries.h:873
cxbyte * noteTable
pointer to note table
Definition: ElfBinaries.h:163
static const cxuint bitness
ELF bitness.
Definition: ElfBinaries.h:115
cxbyte * symbolTable
pointer to symbol table
Definition: ElfBinaries.h:160
create map of dynamic symbols
Definition: ElfBinaries.h:72
uint64_t Word
word size in ELF
Definition: ElfBinaries.h:125
Elf64_Dyn Dyn
dynamic entry
Definition: ElfBinaries.h:132
Definition: Elf.h:91
ElfRegionTemplate(typename Types::Word _size, const cxbyte *_data, typename Types::Word _align)
constructor for user region
Definition: ElfBinaries.h:613
Definition: Elf.h:258
cxuint regionStart
number of first region which is in program header data
Definition: ElfBinaries.h:757