// segments - do zapisania
// sections - sekcje tego samego typy (te same flagi)
// rel_sections - wektor wszystkich sekcji z pliku rel
// offset_map - mapa, index_sekcji -> offset sekcji
// segments_flag - flagi
void addNewSegment(Context& ctx, headerT& header,
vector<segmentT>& segments,
const vector<pair<int, sectionT>>& sections,
vector<sectionT>& rel_sections,
unordered_map<int, uint64_t>& offset_map,
int segment_flags) {
if (sections.size()) {
segmentT p;
int size = 0;
int new_off = header.e_shoff;
if (new_off % constants::kPageSize != 0) {
new_off += constants::kPageSize - (new_off % constants::kPageSize);
}
for (auto& s : sections) {
if (size % s.second.sh_addralign != 0) {
size += s.second.sh_addralign - (size % s.second.sh_addralign);
};
offset_map[s.first] = new_off + size;
size += s.second.sh_size;
}
if (size != 0) {
p.p_type = PT_LOAD;
p.p_flags = segment_flags;
p.p_offset = new_off;
p.p_vaddr = new_off + ctx.base_address;
p.p_paddr = new_off + ctx.base_address;
p.p_filesz = size;
p.p_memsz = size;
p.p_align = constants::kPageSize;
ctx.last_segment += size;
segments.emplace_back(p);
header.e_phnum++;
header.e_shoff += size;
}
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}