mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-10-14 21:09:41 -07:00
simplify section table
This commit is contained in:
1 parent
ecdee57c60
commit
9d93eda3ed
6 files changed
+175
-242
No files matched your search
@@ -20,18 +20,9 @@ typedef struct LNK_SectionContrib
|
||||
U8 unused[2];
|
||||
};
|
||||
} u;
|
||||
U16 align; // alignment of the contribution in the image
|
||||
U16 align; // contribution alignment in the image
|
||||
} LNK_SectionContrib;
|
||||
|
||||
typedef struct LNK_CommonBlockContrib
|
||||
{
|
||||
struct LNK_Symbol *symbol;
|
||||
union {
|
||||
U32 size;
|
||||
U32 offset;
|
||||
} u;
|
||||
} LNK_CommonBlockContrib;
|
||||
|
||||
typedef struct LNK_SectionContribChunk
|
||||
{
|
||||
struct LNK_SectionContribChunk *next;
|
||||
@@ -49,24 +40,14 @@ typedef struct LNK_SectionContribChunkList
|
||||
LNK_SectionContribChunk *last;
|
||||
} LNK_SectionContribChunkList;
|
||||
|
||||
typedef struct LNK_SectionDefinition
|
||||
{
|
||||
String8 name;
|
||||
COFF_SectionFlags flags;
|
||||
U64 contribs_count;
|
||||
struct LNK_Obj *obj;
|
||||
U64 obj_sect_idx;
|
||||
} LNK_SectionDefinition;
|
||||
|
||||
typedef struct LNK_Section
|
||||
{
|
||||
U64 id;
|
||||
String8 name;
|
||||
COFF_SectionFlags flags;
|
||||
B32 is_merged;
|
||||
U64 merge_id;
|
||||
LNK_SectionContribChunkList contribs;
|
||||
|
||||
struct LNK_Section *merge_dst;
|
||||
|
||||
U64 voff;
|
||||
U64 vsize;
|
||||
U64 fsize;
|
||||
@@ -97,23 +78,44 @@ typedef struct LNK_SectionArray
|
||||
typedef struct LNK_SectionTable
|
||||
{
|
||||
Arena *arena;
|
||||
U64 id_max;
|
||||
U64 next_sect_idx;
|
||||
LNK_SectionList list;
|
||||
LNK_SectionList merge_list;
|
||||
HashTable *sect_ht; // name -> LNK_Section *
|
||||
HashTable *sect_ht; // (name * COFF_SectionFlags) -> LNK_Section *
|
||||
U64 next_sect_idx;
|
||||
} LNK_SectionTable;
|
||||
|
||||
////////////////////////////////
|
||||
// --- Section Contrib Chunk List ----------------------------------------------
|
||||
|
||||
internal U8 lnk_code_align_byte_from_machine(COFF_MachineType machine);
|
||||
internal U16 lnk_default_align_from_machine(COFF_MachineType machine);
|
||||
internal LNK_SectionContrib * lnk_section_contrib_chunk_push(LNK_SectionContribChunk *chunk, U64 count);
|
||||
internal LNK_SectionContrib * lnk_section_contrib_chunk_push_atomic(LNK_SectionContribChunk *chunk, U64 count);
|
||||
internal LNK_SectionContribChunk * lnk_section_contrib_chunk_list_push_chunk(Arena *arena, LNK_SectionContribChunkList *list, U64 cap, String8 sort_idx);
|
||||
internal void lnk_section_contrib_chunk_list_concat_in_place(LNK_SectionContribChunkList *list, LNK_SectionContribChunkList *to_concat);
|
||||
internal LNK_SectionContribChunk ** lnk_array_from_section_contrib_chunk_list(Arena *arena, LNK_SectionContribChunkList list);
|
||||
|
||||
////////////////////////////////
|
||||
// --- Section List ------------------------------------------------------------
|
||||
|
||||
internal LNK_SectionArray lnk_section_array_from_list(Arena *arena, LNK_SectionList list);
|
||||
|
||||
////////////////////////////////
|
||||
// --- Section Table -----------------------------------------------------------
|
||||
|
||||
internal String8 lnk_make_name_with_flags(Arena *arena, String8 name, COFF_SectionFlags flags);
|
||||
|
||||
internal LNK_SectionTable * lnk_section_table_alloc(void);
|
||||
internal void lnk_section_table_release(LNK_SectionTable **sectab_ptr);
|
||||
internal LNK_Section * lnk_section_table_push(LNK_SectionTable *sectab, String8 name, COFF_SectionFlags flags);
|
||||
internal LNK_SectionNode * lnk_section_table_remove(LNK_SectionTable *sectab, String8 name);
|
||||
internal LNK_Section * lnk_section_table_search(LNK_SectionTable *sectab, String8 name, COFF_SectionFlags flags);
|
||||
internal LNK_SectionArray lnk_section_table_search_many(Arena *arena, LNK_SectionTable *sectab, String8 full_or_partial_name);
|
||||
internal void lnk_section_table_merge(LNK_SectionTable *sectab, LNK_MergeDirectiveList merge_list);
|
||||
|
||||
// --- Section Finalization ----------------------------------------------------
|
||||
|
||||
internal void lnk_finalize_section_layout (LNK_Section *sect, U64 file_align);
|
||||
internal void lnk_assign_section_index (LNK_Section *sect, U64 sect_idx);
|
||||
internal void lnk_assign_section_virtual_space(LNK_Section *sect, U64 sect_align, U64 *voff_cursor);
|
||||
internal void lnk_assign_section_file_space (LNK_Section *sect, U64 *foff_cursor);
|
||||
|
||||
// --- Section Contribution ----------------------------------------------------
|
||||
|
||||
internal U64 lnk_size_from_section_contrib(LNK_SectionContrib *sc);
|
||||
internal U64 lnk_voff_from_section_contrib(COFF_SectionHeader **image_section_table, LNK_SectionContrib *sc);
|
||||
@@ -124,21 +126,3 @@ internal LNK_SectionContrib * lnk_get_first_section_contrib(LNK_Section *sect);
|
||||
internal LNK_SectionContrib * lnk_get_last_section_contrib(LNK_Section *sect);
|
||||
internal U64 lnk_get_section_contrib_size(LNK_Section *sect);
|
||||
internal U64 lnk_get_first_section_contrib_voff(COFF_SectionHeader **image_section_table, LNK_Section *sect);
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
internal LNK_SectionTable * lnk_section_table_alloc(void);
|
||||
internal void lnk_section_table_release(LNK_SectionTable **st_ptr);
|
||||
internal LNK_Section * lnk_section_table_push(LNK_SectionTable *sectab, String8 name, COFF_SectionFlags flags);
|
||||
internal LNK_SectionNode * lnk_section_table_remove(LNK_SectionTable *sectab, String8 name);
|
||||
internal LNK_Section * lnk_section_table_search(LNK_SectionTable *sectab, String8 name, COFF_SectionFlags flags);
|
||||
internal LNK_SectionArray lnk_section_table_search_many(Arena *arena, LNK_SectionTable *sectab, String8 full_or_partial_name);
|
||||
internal void lnk_section_table_merge(LNK_SectionTable *sectab, LNK_MergeDirectiveList merge_list);
|
||||
internal LNK_SectionArray lnk_section_table_get_output_sections(Arena *arena, LNK_SectionTable *sectab);
|
||||
internal LNK_Section * lnk_finalized_section_from_id(LNK_SectionTable *sectab, U64 id);
|
||||
|
||||
internal LNK_SectionArray lnk_section_table_get_output_sections(Arena *arena, LNK_SectionTable *sectab);
|
||||
internal void lnk_finalize_section_layout(LNK_SectionTable *sectab, LNK_Section *sect, U64 file_align);
|
||||
internal void lnk_assign_section_index(LNK_Section *sect, U64 sect_idx);
|
||||
internal void lnk_assign_section_virtual_space(LNK_Section *sect, U64 sect_align, U64 *voff_cursor);
|
||||
internal void lnk_assign_section_file_space(LNK_Section *sect, U64 *foff_cursor);
|
||||
Reference in new issue
Block a user