align sizeofs

This commit is contained in:
Nikita Smith
2025-06-25 10:53:24 -07:00
committed by Ryan Fleury
parent 32a22779da
commit d604456def
2 changed files with 9 additions and 6 deletions
+4 -1
View File
@@ -2013,7 +2013,10 @@ lnk_build_win32_header(Arena *arena, LNK_SymbolTable *symtab, LNK_Config *config
} }
sizeof_image = Max(sizeof_image, sects.v[sect_idx]->voff + sects.v[sect_idx]->vsize); sizeof_image = Max(sizeof_image, sects.v[sect_idx]->voff + sects.v[sect_idx]->vsize);
} }
sizeof_image = AlignPow2(sizeof_image, 4096); sizeof_code = AlignPow2(sizeof_code, config->file_align);
sizeof_inited_data = AlignPow2(sizeof_inited_data, config->file_align);
sizeof_uninited_data = AlignPow2(sizeof_uninited_data, config->file_align);
sizeof_image = AlignPow2(sizeof_image, 4096);
// //
// compute image headers size // compute image headers size
+5 -5
View File
@@ -605,7 +605,7 @@ t_simple_link_test(void)
COFF_ObjWriter *obj_writer = coff_obj_writer_alloc(0, COFF_MachineType_X64); COFF_ObjWriter *obj_writer = coff_obj_writer_alloc(0, COFF_MachineType_X64);
COFF_ObjSection *text_sect = coff_obj_writer_push_section(obj_writer, str8_lit(".text"), PE_TEXT_SECTION_FLAGS, str8_array_fixed(text_payload)); COFF_ObjSection *text_sect = coff_obj_writer_push_section(obj_writer, str8_lit(".text"), PE_TEXT_SECTION_FLAGS, str8_array_fixed(text_payload));
coff_obj_writer_push_section(obj_writer, str8_lit(".data"), PE_DATA_SECTION_FLAGS, str8_lit("qwe")); coff_obj_writer_push_section(obj_writer, str8_lit(".data"), PE_DATA_SECTION_FLAGS, str8_lit("qwe"));
coff_obj_writer_push_section(obj_writer, str8_lit(".bss"), PE_BSS_SECTION_FLAGS, str8(0, 5)); coff_obj_writer_push_section(obj_writer, str8_lit(".zero"), PE_BSS_SECTION_FLAGS, str8(0, 5));
coff_obj_writer_push_symbol_extern(obj_writer, str8_lit("my_entry"), 0, text_sect); coff_obj_writer_push_symbol_extern(obj_writer, str8_lit("my_entry"), 0, text_sect);
main_obj = coff_obj_writer_serialize(scratch.arena, obj_writer); main_obj = coff_obj_writer_serialize(scratch.arena, obj_writer);
coff_obj_writer_release(&obj_writer); coff_obj_writer_release(&obj_writer);
@@ -681,8 +681,8 @@ t_simple_link_test(void)
goto exit; goto exit;
} }
COFF_SectionHeader *bss_section = t_coff_section_header_from_name(string_table, section_table, pe.section_count, str8_lit(".bss")); COFF_SectionHeader *zero_section = t_coff_section_header_from_name(string_table, section_table, pe.section_count, str8_lit(".zero"));
if (bss_section == 0) { if (zero_section == 0) {
goto exit; goto exit;
} }
@@ -698,7 +698,7 @@ t_simple_link_test(void)
if (opt->sizeof_inited_data != text_section->fsize + data_section->fsize) { if (opt->sizeof_inited_data != text_section->fsize + data_section->fsize) {
goto exit; goto exit;
} }
if (opt->sizeof_uninited_data != 0) { if (opt->sizeof_uninited_data != 0x200) {
goto exit; goto exit;
} }
if (opt->code_base != 0x1000) { if (opt->code_base != 0x1000) {
@@ -728,7 +728,7 @@ t_simple_link_test(void)
if (opt->win32_version_value != 0) { if (opt->win32_version_value != 0) {
goto exit; goto exit;
} }
if (opt->sizeof_image != 0x3000) { if (opt->sizeof_image != 0x4000) {
goto exit; goto exit;
} }
if (opt->sizeof_headers != 0x200) { if (opt->sizeof_headers != 0x200) {