MCPcopy Create free account
hub / github.com/GPUOpen-Tools/radeon_gpu_analyzer / Write

Method Write

external/celf/Src/CElf.cpp:893–1133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

891}
892
893bool
894CElf::Write(vector<char>& vBinary)
895{
896 //
897 // General method:
898 // 0. Check the number of sections.
899 // 1. Make new string tables.
900 // 2. Refresh the file format data structures.
901 // This will involve updating:
902 // a. Symbol table section numbers.
903 // b. Section link/info fields where those are section numbers.
904 // c. File offsets of section data.
905 // 3. Write the section headers.
906 // 4. Write the section data.
907 // 5. Write the file header.
908 //
909
910 // Make sure there's no dreck in the vector.
911 vBinary.resize(0);
912
913 if (GetNumSections() >= SHN_LORESERVE)
914 {
915 // The SHN_XINDEX case is not yet implemented, not yet debugged.
916 return false;
917 }
918
919 // Empty section header string table.
920 m_SectionHeaderStringTable->EraseData();
921
922 // Make a map from CElfSection* to index.
923 map<CElfSection*, size_t> SectionMap;
924 {
925 size_t i = 0;
926
927 for (SectionIterator it = SectionsBegin(); it != SectionsEnd(); i++, ++it)
928 {
929 SectionMap[*it] = i;
930 }
931 }
932
933 // for each section
934 // 1. add its name to the section header string table.
935 // 2. update link/info fields
936 for (SectionIterator it = SectionsBegin(); it != SectionsEnd(); ++it)
937 {
938 // If we add support for SHN_XINDEX, more code will be needed here.
939 // Values above SHN_LORESERVE will set SHN_XINDEX.
940 // Other code will need to set up the associated SHT_SYMTAB_SHNDX section.
941 size_t name = m_SectionHeaderStringTable->AddString((*it)->GetName());
942 (*it)->m_Header.sh_name = static_cast<Elf32_Word>(name);
943
944 if ((*it)->GetLinkSection())
945 {
946 size_t link = SectionMap.find((*it)->GetLinkSection())->second;
947 (*it)->SetLink(static_cast<Elf64_Word>(link));
948 }
949
950 if ((*it)->GetInfoSection())

Callers 1

emitter.hFile · 0.80

Calls 15

EraseDataMethod · 0.80
AddStringMethod · 0.80
GetLinkSectionMethod · 0.80
SetLinkMethod · 0.80
GetInfoSectionMethod · 0.80
SymbolsBeginMethod · 0.80
SymbolsEndMethod · 0.80
SetNameIndexMethod · 0.80
SetSectionIndexMethod · 0.80
GetDataSizeMethod · 0.80
SetDataSizeMethod · 0.80

Tested by

no test coverage detected