mirror of
https://gitee.com/openharmony/arkcompiler_runtime_core
synced 2024-11-23 14:50:51 +00:00
Revert literals changes
Signed-off-by: hufeng <hufeng20@huawei.com> Change-Id: I8157f7791c6473c2e7f2fced6cbf70a51a1f59e7
This commit is contained in:
parent
29fec77722
commit
1dc8c84377
@ -588,6 +588,12 @@ bool CheckHeader(const os::mem::ConstBytePtr &ptr, const std::string_view &filen
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CheckHeaderElementOffset(header->literalarray_idx_off, header->num_literalarrays, header->file_size)) {
|
||||
LOG(ERROR, PANDAFILE) << "Invalid panda file literalarray_idx_off " << header->literalarray_idx_off <<
|
||||
" or num_literalarrays " << header->num_literalarrays;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CheckHeaderElementOffset<File::IndexHeader>(header->index_section_off, header->num_indexes,
|
||||
header->file_size)) {
|
||||
LOG(ERROR, PANDAFILE) << "Invalid panda file index_section_off " << header->index_section_off <<
|
||||
|
@ -421,8 +421,9 @@ void ItemContainer::DeduplicateItems(bool computeLayout)
|
||||
uint32_t ItemContainer::ComputeLayout()
|
||||
{
|
||||
uint32_t num_classes = class_map_.size();
|
||||
uint32_t num_literalarrays = literalarray_map_.size();
|
||||
uint32_t class_idx_offset = sizeof(File::Header);
|
||||
uint32_t cur_offset = class_idx_offset + num_classes * ID_SIZE;
|
||||
uint32_t cur_offset = class_idx_offset + (num_classes + num_literalarrays) * ID_SIZE;
|
||||
|
||||
UpdateOrderIndexes();
|
||||
|
||||
@ -571,13 +572,12 @@ bool ItemContainer::WriteHeaderIndexInfo(Writer *writer)
|
||||
return false;
|
||||
}
|
||||
|
||||
// reserve [num_literalarrays] field
|
||||
if (!writer->Write<uint32_t>(INVALID_INDEX)) {
|
||||
if (!writer->Write<uint32_t>(literalarray_map_.size())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// reserve [literalarray_idx_off] field
|
||||
if (!writer->Write<uint32_t>(INVALID_OFFSET)) {
|
||||
uint32_t literalarray_idx_offset = sizeof(File::Header) + class_map_.size() * ID_SIZE;
|
||||
if (!writer->Write<uint32_t>(literalarray_idx_offset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -585,7 +585,7 @@ bool ItemContainer::WriteHeaderIndexInfo(Writer *writer)
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t index_section_off = sizeof(File::Header) + class_map_.size() * ID_SIZE;
|
||||
size_t index_section_off = literalarray_idx_offset + literalarray_map_.size() * ID_SIZE;
|
||||
return writer->Write<uint32_t>(index_section_off);
|
||||
}
|
||||
|
||||
@ -651,6 +651,14 @@ bool ItemContainer::Write(Writer *writer, bool deduplicateItems)
|
||||
}
|
||||
}
|
||||
|
||||
// Write literalArray idx
|
||||
|
||||
for (auto &entry : literalarray_map_) {
|
||||
if (!writer->Write(entry.second->GetOffset())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Write index section
|
||||
|
||||
if (!index_section_item_.Write(writer)) {
|
||||
|
@ -21,9 +21,7 @@ LiteralDataAccessor::LiteralDataAccessor(const File &panda_file, File::EntityId
|
||||
: panda_file_(panda_file), literal_data_id_(literal_data_id)
|
||||
{
|
||||
literal_num_ = panda_file_.GetHeader()->num_literalarrays;
|
||||
if (literal_num_ != INVALID_INDEX) {
|
||||
literal_data_sp_ = panda_file_.GetSpanFromId(literal_data_id_);
|
||||
}
|
||||
literal_data_sp_ = panda_file_.GetSpanFromId(literal_data_id_);
|
||||
}
|
||||
|
||||
} // namespace panda::panda_file
|
||||
|
Loading…
Reference in New Issue
Block a user