|
|
@@ -912,9 +912,6 @@ get_native_symbol_list_size(AOTCompContext *comp_ctx)
|
|
|
return len;
|
|
|
}
|
|
|
|
|
|
-static uint32
|
|
|
-get_name_section_size(AOTCompData *comp_data);
|
|
|
-
|
|
|
static uint32
|
|
|
get_custom_sections_size(AOTCompContext *comp_ctx, AOTCompData *comp_data);
|
|
|
|
|
|
@@ -972,15 +969,6 @@ get_aot_file_size(AOTCompContext *comp_ctx, AOTCompData *comp_data,
|
|
|
size += get_native_symbol_list_size(comp_ctx);
|
|
|
}
|
|
|
|
|
|
- if (comp_ctx->enable_aux_stack_frame) {
|
|
|
- /* custom name section */
|
|
|
- size = align_uint(size, 4);
|
|
|
- /* section id + section size + sub section id */
|
|
|
- size += (uint32)sizeof(uint32) * 3;
|
|
|
- size += (comp_data->aot_name_section_size =
|
|
|
- get_name_section_size(comp_data));
|
|
|
- }
|
|
|
-
|
|
|
size_custom_section = get_custom_sections_size(comp_ctx, comp_data);
|
|
|
if (size_custom_section > 0) {
|
|
|
size = align_uint(size, 4);
|
|
|
@@ -1333,6 +1321,21 @@ get_custom_sections_size(AOTCompContext *comp_ctx, AOTCompData *comp_data)
|
|
|
const uint8 *content = NULL;
|
|
|
uint32 length = 0;
|
|
|
|
|
|
+ if (strcmp(section_name, "name") == 0) {
|
|
|
+ /* custom name section */
|
|
|
+ comp_data->aot_name_section_size = get_name_section_size(comp_data);
|
|
|
+ if (comp_data->aot_name_section_size == 0) {
|
|
|
+ LOG_WARNING("Can't find custom section [name], ignore it");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ size = align_uint(size, 4);
|
|
|
+ /* section id + section size + sub section id */
|
|
|
+ size += (uint32)sizeof(uint32) * 3;
|
|
|
+ size += comp_data->aot_name_section_size;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
content = wasm_loader_get_custom_section(comp_data->wasm_module,
|
|
|
section_name, &length);
|
|
|
if (!content) {
|
|
|
@@ -2066,23 +2069,25 @@ static bool
|
|
|
aot_emit_name_section(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
|
|
|
AOTCompData *comp_data, AOTCompContext *comp_ctx)
|
|
|
{
|
|
|
- if (comp_ctx->enable_aux_stack_frame) {
|
|
|
- uint32 offset = *p_offset;
|
|
|
+ uint32 offset = *p_offset;
|
|
|
|
|
|
- *p_offset = offset = align_uint(offset, 4);
|
|
|
+ if (comp_data->aot_name_section_size == 0)
|
|
|
+ return true;
|
|
|
|
|
|
- EMIT_U32(AOT_SECTION_TYPE_CUSTOM);
|
|
|
- /* sub section id + name section size */
|
|
|
- EMIT_U32(sizeof(uint32) * 1 + comp_data->aot_name_section_size);
|
|
|
- EMIT_U32(AOT_CUSTOM_SECTION_NAME);
|
|
|
- bh_memcpy_s((uint8 *)(buf + offset), (uint32)(buf_end - buf),
|
|
|
- comp_data->aot_name_section_buf,
|
|
|
- (uint32)comp_data->aot_name_section_size);
|
|
|
- offset += comp_data->aot_name_section_size;
|
|
|
+ offset = align_uint(offset, 4);
|
|
|
|
|
|
- *p_offset = offset;
|
|
|
- }
|
|
|
+ EMIT_U32(AOT_SECTION_TYPE_CUSTOM);
|
|
|
+ /* sub section id + name section size */
|
|
|
+ EMIT_U32(sizeof(uint32) * 1 + comp_data->aot_name_section_size);
|
|
|
+ EMIT_U32(AOT_CUSTOM_SECTION_NAME);
|
|
|
+ bh_memcpy_s((uint8 *)(buf + offset), (uint32)(buf_end - buf),
|
|
|
+ comp_data->aot_name_section_buf,
|
|
|
+ (uint32)comp_data->aot_name_section_size);
|
|
|
+ offset += comp_data->aot_name_section_size;
|
|
|
|
|
|
+ *p_offset = offset;
|
|
|
+
|
|
|
+ LOG_DEBUG("emit name section");
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -2098,6 +2103,16 @@ aot_emit_custom_sections(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
|
|
|
const uint8 *content = NULL;
|
|
|
uint32 length = 0;
|
|
|
|
|
|
+ if (strcmp(section_name, "name") == 0) {
|
|
|
+ *p_offset = offset;
|
|
|
+ if (!aot_emit_name_section(buf, buf_end, p_offset, comp_data,
|
|
|
+ comp_ctx))
|
|
|
+ return false;
|
|
|
+
|
|
|
+ offset = *p_offset;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
content = wasm_loader_get_custom_section(comp_data->wasm_module,
|
|
|
section_name, &length);
|
|
|
if (!content) {
|
|
|
@@ -3589,6 +3604,10 @@ aot_emit_aot_file_buf(AOTCompContext *comp_ctx, AOTCompData *comp_data,
|
|
|
return NULL;
|
|
|
|
|
|
aot_file_size = get_aot_file_size(comp_ctx, comp_data, obj_data);
|
|
|
+ if (aot_file_size == 0) {
|
|
|
+ aot_set_last_error("get aot file size failed");
|
|
|
+ goto fail1;
|
|
|
+ }
|
|
|
|
|
|
if (!(buf = aot_file_buf = wasm_runtime_malloc(aot_file_size))) {
|
|
|
aot_set_last_error("allocate memory failed.");
|
|
|
@@ -3610,7 +3629,6 @@ aot_emit_aot_file_buf(AOTCompContext *comp_ctx, AOTCompData *comp_data,
|
|
|
|| !aot_emit_relocation_section(buf, buf_end, &offset, comp_ctx,
|
|
|
comp_data, obj_data)
|
|
|
|| !aot_emit_native_symbol(buf, buf_end, &offset, comp_ctx)
|
|
|
- || !aot_emit_name_section(buf, buf_end, &offset, comp_data, comp_ctx)
|
|
|
|| !aot_emit_custom_sections(buf, buf_end, &offset, comp_data,
|
|
|
comp_ctx))
|
|
|
goto fail2;
|