coff section align from byte size helper

This commit is contained in:
Nikita Smith
2024-10-23 16:15:49 -07:00
parent 37b27a9cff
commit 15b1ebcd21
2 changed files with 28 additions and 0 deletions
+27
View File
@@ -143,6 +143,30 @@ coff_align_size_from_section_flags(COFF_SectionFlags flags)
return align;
}
internal COFF_SectionFlags
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;
}
flags <<= COFF_SectionFlag_ALIGN_SHIFT;
return flags;
}
internal COFF_SymbolValueInterpType
coff_interp_symbol(COFF_Symbol32 *symbol)
{
@@ -235,6 +259,9 @@ coff_parse_section_name(String8 full_name, String8 *name_out, String8 *postfix_o
// H: Clang extension produced with /debug:ghash, array of type hashes
*name_out = full_name;
*postfix_out = str8_lit("");
if (str8_match(full_name, str8_lit(".tls"), 0)) {
int x = 0;
}
for (U64 i = 0; i < full_name.size; ++i) {
if (full_name.str[i] == '$') {
*name_out = str8(full_name.str, i);
+1
View File
@@ -841,6 +841,7 @@ internal B32 coff_is_big_obj(String8 data);
internal B32 coff_is_obj(String8 data);
internal COFF_HeaderInfo coff_header_info_from_data(String8 data);
internal U64 coff_align_size_from_section_flags(COFF_SectionFlags flags);
internal COFF_SectionFlags coff_section_flag_from_align_size(U64 align);
internal COFF_SymbolValueInterpType coff_interp_symbol(COFF_Symbol32 *symbol);
internal U64 coff_foff_from_voff(COFF_SectionHeader *sections, U64 section_count, U64 voff);