on read memory map files

This commit is contained in:
Nikita Smith authored and Ryan Fleury committed 2025-06-25 10:53:24 -07:00
1 parent 16e72fd573
commit 46663688e2
8 files changed
+405 -377

No files matched your search

+49 -53
View File
@@ -3,6 +3,29 @@
#pragma once
#if OS_WINDOWS
# define LNK_MANIFEST_MERGE_TOOL_NAME "mt.exe"
#elif OS_LINUX || OS_MAC
# define LNK_MANIFEST_MERGE_TOOL_NAME "llvm-mt"
#else
# error
#endif
#define LNK_DEFAULT_THREAD_POOL_NAME "RADLINK_THREAD_POOL"
typedef enum
{
LNK_ParseU64Flag_CheckUnder32bit = (1 << 0),
LNK_ParseU64Flag_CheckPow2 = (1 << 1),
} LNK_ParseU64Flags;
typedef enum
{
LNK_SwitchState_Null,
LNK_SwitchState_No,
LNK_SwitchState_Yes
} LNK_SwitchState;
typedef enum
{
LNK_CmdSwitch_Null,
@@ -128,7 +151,6 @@ typedef enum
LNK_CmdSwitch_Rad_Age,
LNK_CmdSwitch_Rad_BuildInfo,
LNK_CmdSwitch_Rad_CheckUnusedDelayLoadDll,
LNK_CmdSwitch_Rad_Map,
LNK_CmdSwitch_Rad_Debug,
LNK_CmdSwitch_Rad_DebugAltPath,
LNK_CmdSwitch_Rad_DebugName,
@@ -141,6 +163,8 @@ typedef enum
LNK_CmdSwitch_Rad_LinkVer,
LNK_CmdSwitch_Rad_Log,
LNK_CmdSwitch_Rad_Logo,
LNK_CmdSwitch_Rad_Map,
LNK_CmdSwitch_Rad_MemoryMapFiles,
LNK_CmdSwitch_Rad_MtPath,
LNK_CmdSwitch_Rad_OsVer,
LNK_CmdSwitch_Rad_PageSize,
@@ -177,13 +201,6 @@ typedef struct LNK_CmdSwitch
char *desc;
} LNK_CmdSwitch;
typedef enum
{
LNK_SwitchState_Null,
LNK_SwitchState_No,
LNK_SwitchState_Yes
} LNK_SwitchState;
typedef enum
{
LNK_Input_Null,
@@ -285,16 +302,6 @@ typedef enum
LNK_TypeNameHashMode_Full,
} LNK_TypeNameHashMode;
#if OS_WINDOWS
# define LNK_MANIFEST_MERGE_TOOL_NAME "mt.exe"
#elif OS_LINUX || OS_MAC
# define LNK_MANIFEST_MERGE_TOOL_NAME "llvm-mt"
#else
# error
#endif
#define LNK_DEFAULT_THREAD_POOL_NAME "RADLINK_THREAD_POOL"
typedef struct LNK_Config
{
LNK_ConfigFlags flags;
@@ -383,15 +390,10 @@ typedef struct LNK_Config
String8 temp_rad_debug_name;
String8 temp_rad_chunk_map_name;
String8List remove_sections;
LNK_IO_Flags io_flags;
} LNK_Config;
typedef enum
{
LNK_ParseU64Flag_CheckUnder32bit = (1 << 0),
LNK_ParseU64Flag_CheckPow2 = (1 << 1),
} LNK_ParseU64Flags;
////////////////////////////////
// --- MSVC Error Codes --------------------------------------------------------
typedef enum
{
@@ -518,8 +520,7 @@ typedef enum
LNK_MsWarningCode_Lnk4286 = 4286,
} LNK_MsErrorCode;
////////////////////////////////
// Enum <-> String
// --- Enum <-> String ---------------------------------------------------------
internal String8 lnk_string_cmd_switch_type(LNK_CmdSwitchType type);
internal LNK_CmdSwitchType lnk_cmd_switch_type_from_string(String8 string);
@@ -528,36 +529,20 @@ internal LNK_InputType lnk_input_type_from_string(String8 string);
internal LNK_DebugMode lnk_debug_mode_from_string(String8 string);
internal LNK_TypeNameHashMode lnk_type_name_hash_mode_from_string(String8 string);
////////////////////////////////
// Command Line Helpers
// --- Command Line Helpers ----------------------------------------------------
internal LNK_CmdOption * lnk_cmd_line_push_option_if_not_presentf(Arena *arena, LNK_CmdLine *cmd_line, LNK_CmdSwitchType cmd_switch_type, char *param_fmt, ...);
internal LNK_CmdOption * lnk_cmd_line_push_optionf (Arena *arena, LNK_CmdLine *cmd_line, LNK_CmdSwitchType cmd_switch_type, char *param_fmt, ...);
internal B32 lnk_cmd_line_has_switch(LNK_CmdLine cmd_line, LNK_CmdSwitchType cmd_switch_type);
////////////////////////////////
// Errors
internal B32 lnk_cmd_line_has_switch(LNK_CmdLine cmd_line, LNK_CmdSwitchType cmd_switch_type);
// --- Errors ------------------------------------------------------------------
internal void lnk_error_cmd_switch (LNK_ErrorCode code, String8 obj_path, String8 lib_path, LNK_CmdSwitchType cmd_switch, char *fmt, ...);
internal void lnk_error_cmd_switch_invalid_param_count(LNK_ErrorCode code, String8 obj_path, String8 lib_path, LNK_CmdSwitchType cmd_switch);
internal void lnk_error_cmd_switch_invalid_param (LNK_ErrorCode code, String8 obj_path, String8 lib_path, LNK_CmdSwitchType cmd_switch, String8 param);
////////////////////////////////
// Getters
internal String8 lnk_get_image_name(LNK_Config *config);
internal U64 lnk_get_default_function_pad_min(COFF_MachineType machine);
internal U64 lnk_get_base_addr(LNK_Config *config);
internal Version lnk_get_default_subsystem_version(PE_WindowsSubsystem subsystem, COFF_MachineType machine);
internal Version lnk_get_min_subsystem_version(PE_WindowsSubsystem subsystem, COFF_MachineType machine);
internal B32 lnk_do_debug_info (LNK_Config *config);
internal B32 lnk_is_thread_pool_shared(LNK_Config *config);
internal B32 lnk_is_section_removed(LNK_Config *config, String8 section_name);
////////////////////////////////
// Specialized Parsers
// --- Specialized Parsers ------------------------------------------------------
internal B32 lnk_cmd_switch_parse_version (String8 obj_path, String8 lib_path, LNK_CmdSwitchType cmd_switch, String8List value_strings, Version *ver_out);
internal B32 lnk_cmd_switch_parse_tuple (String8 obj_path, String8 lib_path, LNK_CmdSwitchType cmd_switch, String8List value_strings, Rng1U64 *tuple_out);
@@ -572,17 +557,28 @@ internal void lnk_cmd_switch_set_flag_64 (String8 obj_path, String8 lib_path,
internal B32 lnk_cmd_switch_parse_string (String8 obj_path, String8 lib_path, LNK_CmdSwitchType cmd_switch, String8List value_strings, String8 *string_out);
internal void lnk_cmd_switch_parse_string_copy(Arena *arena, String8 obj_path, String8 lib_path, LNK_CmdSwitchType cmd_switch, String8List value_strings, String8 *string_out);
////////////////////////////////
internal B32 lnk_parse_alt_name_directive(String8 input, LNK_AltName *alt_out);
internal B32 lnk_parse_export_directive_ex(Arena *arena, String8List directive, String8 obj_path, String8 lib_path, PE_ExportParse *export_out);
internal B32 lnk_parse_export_directive(Arena *arena, String8 directive, String8 obj_path, String8 lib_path, PE_ExportParse *export_out);
internal LNK_MergeDirectiveNode * lnk_merge_directive_list_push(Arena *arena, LNK_MergeDirectiveList *list, LNK_MergeDirective data);
internal B32 lnk_parse_merge_directive(String8 string, LNK_MergeDirective *parse_out);
////////////////////////////////
// --- Getters -----------------------------------------------------------------
internal String8 lnk_get_image_name(LNK_Config *config);
internal U64 lnk_get_default_function_pad_min(COFF_MachineType machine);
internal U64 lnk_get_base_addr(LNK_Config *config);
internal Version lnk_get_default_subsystem_version(PE_WindowsSubsystem subsystem, COFF_MachineType machine);
internal Version lnk_get_min_subsystem_version(PE_WindowsSubsystem subsystem, COFF_MachineType machine);
internal B32 lnk_do_debug_info (LNK_Config *config);
internal B32 lnk_is_thread_pool_shared(LNK_Config *config);
internal B32 lnk_is_section_removed(LNK_Config *config, String8 section_name);
// --- Config ------------------------------------------------------------------
internal void lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 name, String8List value_list, String8 obj_path, String8 lib_path);
internal LNK_Config * lnk_config_from_cmd_line(Arena *arena, String8List raw_cmd_line, LNK_CmdLine cmd_line);