section align fixes

This commit is contained in:
Nikita Smith
2025-05-19 13:14:56 -07:00
committed by Ryan Fleury
parent 681c1619fb
commit c0613c2a7e
3 changed files with 17 additions and 16 deletions
+15 -15
View File
@@ -8,7 +8,6 @@ coff_align_size_from_section_flags(COFF_SectionFlags flags)
U32 align_index = COFF_SectionFlags_ExtractAlign(flags);
switch (align_index) {
default: break;
case 0: align = 1; break; // alignment isn't specified, default to 1
case COFF_SectionAlign_1Bytes: align = 1; break;
case COFF_SectionAlign_2Bytes: align = 2; break;
case COFF_SectionAlign_4Bytes: align = 4; break;
@@ -32,20 +31,21 @@ coff_section_flag_from_align_size(U64 align)
{
COFF_SectionFlags flags = 0;
switch (align) {
case 1: flags = COFF_SectionAlign_1Bytes; break;
case 2: flags = COFF_SectionAlign_2Bytes; break;
case 4: flags = COFF_SectionAlign_4Bytes; break;
case 8: flags = COFF_SectionAlign_8Bytes; break;
case 16: flags = COFF_SectionAlign_16Bytes; break;
case 32: flags = COFF_SectionAlign_32Bytes; break;
case 64: flags = COFF_SectionAlign_64Bytes; break;
case 128: flags = COFF_SectionAlign_128Bytes; break;
case 256: flags = COFF_SectionAlign_256Bytes; break;
case 512: flags = COFF_SectionAlign_512Bytes; break;
case 1024: flags = COFF_SectionAlign_1024Bytes; break;
case 2048: flags = COFF_SectionAlign_2048Bytes; break;
case 4096: flags = COFF_SectionAlign_4096Bytes; break;
case 8192: flags = COFF_SectionAlign_8192Bytes; break;
case 0: flags = COFF_SectionAlign_None; break;
case 1: flags = COFF_SectionAlign_1Bytes; break;
case 2: flags = COFF_SectionAlign_2Bytes; break;
case 4: flags = COFF_SectionAlign_4Bytes; break;
case 8: flags = COFF_SectionAlign_8Bytes; break;
case 16: flags = COFF_SectionAlign_16Bytes; break;
case 32: flags = COFF_SectionAlign_32Bytes; break;
case 64: flags = COFF_SectionAlign_64Bytes; break;
case 128: flags = COFF_SectionAlign_128Bytes; break;
case 256: flags = COFF_SectionAlign_256Bytes; break;
case 512: flags = COFF_SectionAlign_512Bytes; break;
case 1024: flags = COFF_SectionAlign_1024Bytes; break;
case 2048: flags = COFF_SectionAlign_2048Bytes; break;
case 4096: flags = COFF_SectionAlign_4096Bytes; break;
case 8192: flags = COFF_SectionAlign_8192Bytes; break;
}
flags <<= COFF_SectionFlag_AlignShift;
return flags;
+1
View File
@@ -103,6 +103,7 @@ typedef struct COFF_BigObjHeader
typedef U32 COFF_SectionAlign;
enum
{
COFF_SectionAlign_None = 0x0,
COFF_SectionAlign_1Bytes = 0x1,
COFF_SectionAlign_2Bytes = 0x2,
COFF_SectionAlign_4Bytes = 0x3,
+1 -1
View File
@@ -2239,7 +2239,7 @@ lnk_build_win32_image(TP_Arena *arena, TP_Context *tp, LNK_Config *config, LNK_S
String8 sect_data = str8_substr(obj->data, rng_1u64(sect_header->foff, sect_header->foff + sect_header->fsize));
// extract align
U16 sc_align = coff_align_size_from_section_flags(COFF_SectionFlags_ExtractAlign(sect_header->flags));
U16 sc_align = coff_align_size_from_section_flags(sect_header->flags);
if (sc_align == 0) {
sc_align = default_align;
}