mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-23 20:24:59 -07:00
helpers for matching string literals
This commit is contained in:
@@ -206,10 +206,13 @@ internal String8 backslashed_from_str8(Arena *arena, String8 string);
|
||||
////////////////////////////////
|
||||
//~ rjf: String Matching
|
||||
|
||||
#define str8_match_lit(a_lit, b, flags) str8_match(str8_lit(a_lit), (b), (flags))
|
||||
#define str8_match_cstr(a_cstr, b, flags) str8_match(str8_cstring(a_cstr), (b), (flags))
|
||||
internal B32 str8_match(String8 a, String8 b, StringMatchFlags flags);
|
||||
internal U64 str8_find_needle(String8 string, U64 start_pos, String8 needle, StringMatchFlags flags);
|
||||
internal U64 str8_find_needle_reverse(String8 string, U64 start_pos, String8 needle, StringMatchFlags flags);
|
||||
internal B32 str8_ends_with(String8 string, String8 end, StringMatchFlags flags);
|
||||
#define str8_ends_with_lit(string, end_lit, flags) str8_ends_with((string), str8_lit(end_lit), (flags))
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: String Slicing
|
||||
|
||||
@@ -458,10 +458,10 @@ internal B32
|
||||
cv_is_udt_name_anon(String8 name)
|
||||
{
|
||||
// corresponds to fUDTAnon from dbi/tm.cpp:817
|
||||
B32 is_anon = str8_match(str8_lit("<unnamed-tag>"), name, 0) ||
|
||||
str8_match(str8_lit("__unnamed"), name, 0) ||
|
||||
str8_match(str8_lit("::<unnamed-tag>"), name, StringMatchFlag_RightSideSloppy) ||
|
||||
str8_match(str8_lit("::__unnamed"), name, StringMatchFlag_RightSideSloppy);
|
||||
B32 is_anon = str8_match_lit("<unnamed-tag>", name, 0) ||
|
||||
str8_match_lit("__unnamed", name, 0) ||
|
||||
str8_match_lit("::<unnamed-tag>", name, StringMatchFlag_RightSideSloppy) ||
|
||||
str8_match_lit("::__unnamed", name, StringMatchFlag_RightSideSloppy);
|
||||
return is_anon;
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -270,7 +270,7 @@ coff_parse_section_name(String8 full_name, String8 *name_out, String8 *postfix_o
|
||||
|
||||
// TLS sections don't have a postfix but we still have to sort them based
|
||||
// on dollar sign so they are sloted between CRT's _tls_start and _tls_end sections.
|
||||
if (str8_match(*name_out, str8_lit(".tls"), 0) && postfix_out->size == 0) {
|
||||
if (str8_match_lit(".tls", *name_out, 0) && postfix_out->size == 0) {
|
||||
*postfix_out = str8_lit("$");
|
||||
}
|
||||
|
||||
@@ -1031,7 +1031,7 @@ coff_parse_archive_member_data(String8 data, U64 cursor, COFF_ArchiveMember *mem
|
||||
internal COFF_ArchiveFirstMember
|
||||
coff_parse_first_archive_member(COFF_ArchiveMember *member)
|
||||
{
|
||||
Assert(str8_match(member->header.name, str8_lit("/"), 0));
|
||||
Assert(str8_match_lit("/", member->header.name, 0));
|
||||
|
||||
U64 cursor = 0;
|
||||
|
||||
@@ -1064,7 +1064,7 @@ coff_parse_second_archive_member(COFF_ArchiveMember *member)
|
||||
{
|
||||
COFF_ArchiveSecondMember result = {0};
|
||||
|
||||
if (str8_match(member->header.name, str8_lit("/"), 0)) {
|
||||
if (str8_match_lit("/", member->header.name, 0)) {
|
||||
U64 cursor = 0;
|
||||
|
||||
U32 member_count = 0;
|
||||
@@ -1232,7 +1232,7 @@ coff_thin_archive_member_iter_next(String8 data, U64 *offset, COFF_ArchiveMember
|
||||
|
||||
if (member_out->header.is_end_correct) {
|
||||
member_out->offset = *offset;
|
||||
if (str8_match(member_out->header.name, str8_lit("/"), 0) || str8_match(member_out->header.name, str8_lit("//"), 0)) {
|
||||
if (str8_match_lit("/", member_out->header.name, 0) || str8_match_lit("//", member_out->header.name, 0)) {
|
||||
member_out->data = str8_substr(data, member_out->header.data_range);
|
||||
} else {
|
||||
// size field in non-header members means size of stand-alone obj
|
||||
@@ -1265,7 +1265,7 @@ coff_archive_parse_from_member_list(COFF_ArchiveMemberList member_list)
|
||||
COFF_ArchiveMemberNode *ptr = member_list.first;
|
||||
|
||||
if (ptr) {
|
||||
if (str8_match(ptr->data.header.name, str8_lit("/"), 0)) {
|
||||
if (str8_match_lit("/", ptr->data.header.name, 0)) {
|
||||
if (ptr->data.header.is_end_correct) {
|
||||
first_header = ptr->data;
|
||||
ptr = ptr->next;
|
||||
@@ -1278,7 +1278,7 @@ coff_archive_parse_from_member_list(COFF_ArchiveMemberList member_list)
|
||||
}
|
||||
|
||||
if (!error.size && ptr) {
|
||||
if (str8_match(ptr->data.header.name, str8_lit("/"), 0)) {
|
||||
if (str8_match_lit("/", ptr->data.header.name, 0)) {
|
||||
if (ptr->data.header.is_end_correct) {
|
||||
second_header = ptr->data;
|
||||
ptr = ptr->next;
|
||||
@@ -1290,7 +1290,7 @@ coff_archive_parse_from_member_list(COFF_ArchiveMemberList member_list)
|
||||
}
|
||||
|
||||
if (!error.size && ptr) {
|
||||
if (str8_match(ptr->data.header.name, str8_lit("//"), 0)) {
|
||||
if (str8_match_lit("//", ptr->data.header.name, 0)) {
|
||||
if (ptr->data.header.is_end_correct) {
|
||||
long_names_member = ptr->data;
|
||||
ptr = ptr->next;
|
||||
|
||||
@@ -1474,24 +1474,24 @@ dw_ext_from_params(String8 producer, Arch arch, ImageType image_type)
|
||||
switch (image_type) {
|
||||
case Image_Null: break;
|
||||
case Image_CoffPe: {
|
||||
if (str8_match(str8_lit("clang"), producer, StringMatchFlag_RightSideSloppy|StringMatchFlag_CaseInsensitive)) {
|
||||
if (str8_match_lit("clang", producer, StringMatchFlag_RightSideSloppy|StringMatchFlag_CaseInsensitive)) {
|
||||
ext = DW_Ext_GNU | DW_Ext_LLVM;
|
||||
} else if (str8_match(str8_lit("GNU"), producer, StringMatchFlag_RightSideSloppy|StringMatchFlag_CaseInsensitive)) {
|
||||
} else if (str8_match_lit("GNU", producer, StringMatchFlag_RightSideSloppy|StringMatchFlag_CaseInsensitive)) {
|
||||
ext = DW_Ext_GNU;
|
||||
}
|
||||
} break;
|
||||
case Image_Elf32:
|
||||
case Image_Elf64: {
|
||||
if (str8_match(str8_lit("clang"), producer, StringMatchFlag_RightSideSloppy|StringMatchFlag_CaseInsensitive)) {
|
||||
if (str8_match_lit("clang", producer, StringMatchFlag_RightSideSloppy|StringMatchFlag_CaseInsensitive)) {
|
||||
ext = DW_Ext_GNU | DW_Ext_LLVM;
|
||||
} else if (str8_match(str8_lit("GNU"), producer, StringMatchFlag_RightSideSloppy|StringMatchFlag_CaseInsensitive)) {
|
||||
} else if (str8_match_lit("GNU", producer, StringMatchFlag_RightSideSloppy|StringMatchFlag_CaseInsensitive)) {
|
||||
ext = DW_Ext_GNU;
|
||||
}
|
||||
} break;
|
||||
case Image_Macho: {
|
||||
if (str8_match(str8_lit("clang"), producer, StringMatchFlag_RightSideSloppy|StringMatchFlag_CaseInsensitive)) {
|
||||
if (str8_match_lit("clang", producer, StringMatchFlag_RightSideSloppy|StringMatchFlag_CaseInsensitive)) {
|
||||
ext = DW_Ext_LLVM | DW_Ext_APPLE;
|
||||
} else if (str8_match(str8_lit("GNU"), producer, StringMatchFlag_RightSideSloppy|StringMatchFlag_CaseInsensitive)) {
|
||||
} else if (str8_match_lit("GNU", producer, StringMatchFlag_RightSideSloppy|StringMatchFlag_CaseInsensitive)) {
|
||||
ext = DW_Ext_GNU | DW_Ext_APPLE;
|
||||
}
|
||||
} break;
|
||||
@@ -2046,7 +2046,7 @@ dw_path_from_file_idx(Arena *arena, DW_LineVMHeader *vm, U64 file_idx)
|
||||
|
||||
String8List path_list = {0};
|
||||
|
||||
if (str8_match(str8_lit(".."), dir, StringMatchFlag_RightSideSloppy)) {
|
||||
if (str8_match_lit("..", dir, StringMatchFlag_RightSideSloppy)) {
|
||||
String8List comp_dir_list = str8_split_path(scratch.arena, vm->dir_table.v[0]);
|
||||
str8_list_concat_in_place(&path_list, &comp_dir_list);
|
||||
}
|
||||
|
||||
+6
-6
@@ -770,7 +770,7 @@ lnk_make_res_obj(TP_Context *tp,
|
||||
LNK_RelocList reloc_list = {0};
|
||||
LNK_RelocList res_data_reloc_list = {0};
|
||||
for (LNK_Reloc *reloc = sect->reloc_list.first; reloc != 0; reloc = reloc->next) {
|
||||
B32 is_reloc_symbol = str8_match(str8_lit("$R"), reloc->symbol->name, StringMatchFlag_RightSideSloppy);
|
||||
B32 is_reloc_symbol = str8_match_lit("$R", reloc->symbol->name, StringMatchFlag_RightSideSloppy);
|
||||
LNK_Reloc *dst;
|
||||
if (is_reloc_symbol) {
|
||||
dst = lnk_reloc_list_push(sect->arena, &res_data_reloc_list);
|
||||
@@ -2464,7 +2464,7 @@ THREAD_POOL_TASK_FUNC(lnk_weak_symbol_finder)
|
||||
case COFF_WeakExtType_SEARCH_ALIAS: {
|
||||
lazy = lnk_symbol_table_search(task->symtab, LNK_SymbolScopeFlag_Lib, symbol->name);
|
||||
if (!lazy) {
|
||||
if (str8_match(str8_lit(".weak."), symbol->name, StringMatchFlag_RightSideSloppy)) {
|
||||
if (str8_match_lit(".weak.", symbol->name, StringMatchFlag_RightSideSloppy)) {
|
||||
// TODO: Clang and MingGW encode extra info in alias
|
||||
//
|
||||
// __attribute__((weak,alias("foo"))) void bar(void);
|
||||
@@ -3349,13 +3349,13 @@ lnk_run(int argc, char **argv)
|
||||
// redirect user entry to appropriate CRT entry
|
||||
if (entry_point_symbol) {
|
||||
config->entry_point_name = entry_point_symbol->name;
|
||||
if (str8_match(config->entry_point_name, str8_lit("wmain"), 0)) {
|
||||
if (str8_match_lit("wmain", config->entry_point_name, 0)) {
|
||||
config->entry_point_name = str8_lit("wmainCRTStartup");
|
||||
} else if (str8_match(config->entry_point_name, str8_lit("main"), 0)) {
|
||||
} else if (str8_match_lit("main", config->entry_point_name, 0)) {
|
||||
config->entry_point_name = str8_lit("mainCRTStartup");
|
||||
} else if (str8_match(config->entry_point_name, str8_lit("WinMain"), 0)) {
|
||||
} else if (str8_match_lit("WinMain", config->entry_point_name, 0)) {
|
||||
config->entry_point_name = str8_lit("WinMainCRTStartup");
|
||||
} else if (str8_match(config->entry_point_name, str8_lit("wWinMain"), 0)) {
|
||||
} else if (str8_match_lit("wWinMain", config->entry_point_name, 0)) {
|
||||
config->entry_point_name = str8_lit("wWinMainCRTStartup");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +135,8 @@ lnk_cmd_line_parse_windows_rules(Arena *arena, String8List arg_list)
|
||||
|
||||
for (String8Node *arg_node = arg_list.first; arg_node != 0; arg_node = arg_node->next) {
|
||||
String8 arg = arg_node->string;
|
||||
B32 is_option = str8_match(str8_lit("/"), arg, StringMatchFlag_RightSideSloppy) ||
|
||||
str8_match(str8_lit("-"), arg, StringMatchFlag_RightSideSloppy);
|
||||
B32 is_option = str8_match_lit("/", arg, StringMatchFlag_RightSideSloppy) ||
|
||||
str8_match_lit("-", arg, StringMatchFlag_RightSideSloppy);
|
||||
if (is_option) {
|
||||
U64 param_start_pos = str8_find_needle(arg, 0, str8_lit(":"), 0);
|
||||
String8 option_name = str8_chop(arg, arg.size - param_start_pos);
|
||||
@@ -195,7 +195,7 @@ lnk_unwrap_rsp(Arena *arena, String8List arg_list)
|
||||
String8List result = {0};
|
||||
|
||||
for (String8Node *curr = arg_list.first; curr != 0; curr = curr->next) {
|
||||
B32 is_rsp = str8_match(str8_lit("@"), curr->string, StringMatchFlag_RightSideSloppy);
|
||||
B32 is_rsp = str8_match_lit("@", curr->string, StringMatchFlag_RightSideSloppy);
|
||||
if (is_rsp) {
|
||||
// remove "@"
|
||||
String8 name = str8_skip(curr->string, 1);
|
||||
|
||||
+107
-141
@@ -4,7 +4,7 @@
|
||||
////////////////////////////////
|
||||
// Enum <-> String
|
||||
|
||||
read_only struct
|
||||
global read_only struct
|
||||
{
|
||||
LNK_CmdSwitchType type;
|
||||
char *name;
|
||||
@@ -164,12 +164,45 @@ read_only struct
|
||||
{ LNK_CmdSwitch_Help, "?", "", "" },
|
||||
};
|
||||
|
||||
global read_only struct
|
||||
{
|
||||
char *name;
|
||||
LNK_InputType type;
|
||||
} g_input_type_map[] = {
|
||||
{ "o", LNK_Input_Obj },
|
||||
{ "obj", LNK_Input_Obj },
|
||||
{ "lib", LNK_Input_Lib },
|
||||
{ "rlib", LNK_Input_Lib }, // rust libs
|
||||
{ "res", LNK_Input_Res },
|
||||
};
|
||||
|
||||
global read_only struct
|
||||
{
|
||||
char *name;
|
||||
LNK_DebugMode mode;
|
||||
} g_debug_mode_map[] = {
|
||||
{ "null", LNK_DebugMode_Null },
|
||||
{ "none", LNK_DebugMode_None },
|
||||
{ "fastlink", LNK_DebugMode_FastLink },
|
||||
{ "ghash", LNK_DebugMode_GHash },
|
||||
{ "full", LNK_DebugMode_Full },
|
||||
};
|
||||
|
||||
global read_only struct
|
||||
{
|
||||
char *name;
|
||||
LNK_TypeNameHashMode mode;
|
||||
} g_type_name_hash_mode_map[] = {
|
||||
{ "none", LNK_TypeNameHashMode_None },
|
||||
{ "lenient", LNK_TypeNameHashMode_Lenient },
|
||||
{ "full", LNK_TypeNameHashMode_Full }
|
||||
};
|
||||
|
||||
internal LNK_CmdSwitchType
|
||||
lnk_cmd_switch_type_from_string(String8 name)
|
||||
{
|
||||
for (U64 i = 0; i < ArrayCount(g_cmd_switch_map); ++i) {
|
||||
String8 curr_name = str8_cstring(g_cmd_switch_map[i].name);
|
||||
if (str8_match(curr_name, name, StringMatchFlag_CaseInsensitive)) {
|
||||
for (U64 i = 0; i < ArrayCount(g_cmd_switch_map); i += 1) {
|
||||
if (str8_match_cstr(g_cmd_switch_map[i].name, name, StringMatchFlag_CaseInsensitive)) {
|
||||
return g_cmd_switch_map[i].type;
|
||||
}
|
||||
}
|
||||
@@ -184,69 +217,36 @@ lnk_string_from_cmd_switch_type(LNK_CmdSwitchType type)
|
||||
return str8_cstring(g_cmd_switch_map[cmd_idx].name);
|
||||
}
|
||||
}
|
||||
return str8(0,0);
|
||||
return str8_zero();
|
||||
}
|
||||
|
||||
read_only struct {
|
||||
char *name;
|
||||
LNK_InputType type;
|
||||
} g_input_type_map[] = {
|
||||
{ "o", LNK_Input_Obj },
|
||||
{ "obj", LNK_Input_Obj },
|
||||
{ "lib", LNK_Input_Lib },
|
||||
{ "rlib", LNK_Input_Lib }, // rust libs
|
||||
{ "res", LNK_Input_Res },
|
||||
};
|
||||
|
||||
internal LNK_InputType
|
||||
lnk_input_type_from_string(String8 string)
|
||||
lnk_input_type_from_string(String8 name)
|
||||
{
|
||||
for (U64 i = 0; i < ArrayCount(g_input_type_map); i += 1) {
|
||||
if (str8_match(str8_cstring(g_input_type_map[i].name), string, StringMatchFlag_CaseInsensitive)) {
|
||||
if (str8_match_cstr(g_input_type_map[i].name, name, StringMatchFlag_CaseInsensitive)) {
|
||||
return g_input_type_map[i].type;
|
||||
}
|
||||
}
|
||||
return LNK_Input_Null;
|
||||
}
|
||||
|
||||
read_only struct
|
||||
{
|
||||
char *name;
|
||||
LNK_DebugMode mode;
|
||||
} g_debug_mode_map[] = {
|
||||
{ "null", LNK_DebugMode_Null },
|
||||
{ "none", LNK_DebugMode_None },
|
||||
{ "fastlink", LNK_DebugMode_FastLink },
|
||||
{ "ghash", LNK_DebugMode_GHash },
|
||||
{ "full", LNK_DebugMode_Full },
|
||||
};
|
||||
|
||||
internal LNK_DebugMode
|
||||
lnk_debug_mode_from_string(String8 string)
|
||||
lnk_debug_mode_from_string(String8 name)
|
||||
{
|
||||
for (U64 i = 0; i < ArrayCount(g_debug_mode_map); i += 1) {
|
||||
if (str8_match(str8_cstring(g_debug_mode_map[i].name), string, StringMatchFlag_CaseInsensitive)) {
|
||||
if (str8_match_cstr(g_debug_mode_map[i].name, name, StringMatchFlag_CaseInsensitive)) {
|
||||
return g_debug_mode_map[i].mode;
|
||||
}
|
||||
}
|
||||
return LNK_DebugMode_Null;
|
||||
}
|
||||
|
||||
read_only struct
|
||||
{
|
||||
char *name;
|
||||
LNK_TypeNameHashMode mode;
|
||||
} g_type_name_hash_mode_map[] = {
|
||||
{ "none", LNK_TypeNameHashMode_None },
|
||||
{ "lenient", LNK_TypeNameHashMode_Lenient },
|
||||
{ "full", LNK_TypeNameHashMode_Full }
|
||||
};
|
||||
|
||||
internal LNK_TypeNameHashMode
|
||||
lnk_type_name_hash_mode_from_string(String8 string)
|
||||
lnk_type_name_hash_mode_from_string(String8 name)
|
||||
{
|
||||
for (U64 i = 0; i < ArrayCount(g_type_name_hash_mode_map); ++i) {
|
||||
if (str8_match(str8_cstring(g_type_name_hash_mode_map[i].name), string, StringMatchFlag_CaseInsensitive)) {
|
||||
for (U64 i = 0; i < ArrayCount(g_type_name_hash_mode_map); i += 1) {
|
||||
if (str8_match_cstr(g_type_name_hash_mode_map[i].name, name, StringMatchFlag_CaseInsensitive)) {
|
||||
return g_type_name_hash_mode_map[i].mode;
|
||||
}
|
||||
}
|
||||
@@ -296,16 +296,12 @@ internal void
|
||||
lnk_error_cmd_switch(LNK_ErrorCode code, String8 obj_path, String8 lib_path, LNK_CmdSwitchType cmd_switch, char *fmt, ...)
|
||||
{
|
||||
Temp scratch = scratch_begin(0,0);
|
||||
|
||||
va_list args; va_start(args, fmt);
|
||||
|
||||
String8 switch_name = lnk_string_from_cmd_switch_type(cmd_switch);
|
||||
String8 message = push_str8fv(scratch.arena, fmt, args);
|
||||
String8 output = push_str8f(scratch.arena, "/%S: %S", switch_name, message);
|
||||
lnk_error_with_loc(code, obj_path, lib_path, "%S", output);
|
||||
|
||||
va_end(args);
|
||||
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
@@ -325,9 +321,9 @@ internal String8
|
||||
lnk_error_check_and_strip_quotes(LNK_ErrorCode error_code, String8 obj_path, String8 lib_path, LNK_CmdSwitchType cmd_switch, String8 string)
|
||||
{
|
||||
String8 result = string;
|
||||
B32 starts_with_quote = str8_match(str8_lit("\""), string, StringMatchFlag_RightSideSloppy);
|
||||
B32 starts_with_quote = str8_match_lit("\"", string, StringMatchFlag_RightSideSloppy);
|
||||
if (starts_with_quote) {
|
||||
if (str8_ends_with(string, str8_lit("\""), 0)) {
|
||||
if (str8_ends_with_lit(string, "\"", 0)) {
|
||||
result = str8_skip(result, 1);
|
||||
result = str8_chop(result, 1);
|
||||
} else {
|
||||
@@ -396,55 +392,45 @@ lnk_get_default_subsystem_version(PE_WindowsSubsystem subsystem, COFF_MachineTyp
|
||||
{
|
||||
Version ver = make_version(0,0);
|
||||
switch (subsystem) {
|
||||
case PE_WindowsSubsystem_WINDOWS_BOOT_APPLICATION: {
|
||||
ver = make_version(1,0);
|
||||
} break;
|
||||
case PE_WindowsSubsystem_WINDOWS_BOOT_APPLICATION: ver = make_version(1,0); break;
|
||||
|
||||
case PE_WindowsSubsystem_WINDOWS_CUI: {
|
||||
switch (machine) {
|
||||
case COFF_MachineType_X64:
|
||||
case COFF_MachineType_X86: {
|
||||
ver = make_version(6,0);
|
||||
} break;
|
||||
case COFF_MachineType_X86: ver = make_version(6,0); break;
|
||||
|
||||
case COFF_MachineType_ARMNT:
|
||||
case COFF_MachineType_ARM64:
|
||||
case COFF_MachineType_ARM: {
|
||||
ver = make_version(6,2);
|
||||
} break;
|
||||
default: { InvalidPath; } break;
|
||||
case COFF_MachineType_ARM: ver = make_version(6,2); break;
|
||||
|
||||
default: lnk_not_implemented("define subsystem(%S) version for %S", pe_string_from_subsystem(subsystem), coff_string_from_machine_type(machine)); break;
|
||||
}
|
||||
} break;
|
||||
|
||||
case PE_WindowsSubsystem_WINDOWS_GUI: {
|
||||
switch (machine) {
|
||||
case COFF_MachineType_X64:
|
||||
case COFF_MachineType_X86: {
|
||||
ver = make_version(6,0);
|
||||
} break;
|
||||
case COFF_MachineType_X86: ver = make_version(6,0); break;
|
||||
|
||||
case COFF_MachineType_ARMNT:
|
||||
case COFF_MachineType_ARM64:
|
||||
case COFF_MachineType_ARM: {
|
||||
ver = make_version(6,2);
|
||||
} break;
|
||||
default: { InvalidPath; } break;
|
||||
case COFF_MachineType_ARM: ver = make_version(6,2); break;
|
||||
|
||||
default: lnk_not_implemented("define subsystem(%S) version for %S", pe_string_from_subsystem(subsystem), coff_string_from_machine_type(machine)); break;
|
||||
}
|
||||
} break;
|
||||
|
||||
case PE_WindowsSubsystem_POSIX_CUI: {
|
||||
ver = make_version(19,90);
|
||||
} break;
|
||||
case PE_WindowsSubsystem_POSIX_CUI: ver = make_version(19,90); break;
|
||||
|
||||
case PE_WindowsSubsystem_EFI_APPLICATION:
|
||||
case PE_WindowsSubsystem_EFI_BOOT_SERVICE_DRIVER:
|
||||
case PE_WindowsSubsystem_EFI_ROM:
|
||||
case PE_WindowsSubsystem_EFI_RUNTIME_DRIVER: {
|
||||
ver = make_version(1,0);
|
||||
} break;
|
||||
case PE_WindowsSubsystem_EFI_RUNTIME_DRIVER: ver = make_version(1,0); break;
|
||||
|
||||
case PE_WindowsSubsystem_NATIVE_WINDOWS:
|
||||
case PE_WindowsSubsystem_NATIVE: {
|
||||
Assert(!"TODO: detect -drive=WDM switch");
|
||||
} break;
|
||||
case PE_WindowsSubsystem_NATIVE: lnk_not_implemented("detect -drive=WDM switch"); break;
|
||||
|
||||
default: lnk_not_implemented("unknown subsystem kind %u", subsystem); break;
|
||||
}
|
||||
return ver;
|
||||
}
|
||||
@@ -454,65 +440,47 @@ lnk_get_min_subsystem_version(PE_WindowsSubsystem subsystem, COFF_MachineType ma
|
||||
{
|
||||
Version ver = make_version(0,0);
|
||||
switch (subsystem) {
|
||||
case PE_WindowsSubsystem_WINDOWS_BOOT_APPLICATION: {
|
||||
ver = make_version(1,0);
|
||||
} break;
|
||||
case PE_WindowsSubsystem_WINDOWS_BOOT_APPLICATION: ver = make_version(1,0); break;
|
||||
|
||||
case PE_WindowsSubsystem_WINDOWS_CUI: {
|
||||
switch (machine) {
|
||||
case COFF_MachineType_X86: {
|
||||
ver = make_version(5,1);
|
||||
} break;
|
||||
case COFF_MachineType_X86: ver = make_version(5,1); break;
|
||||
|
||||
case COFF_MachineType_X64: {
|
||||
ver = make_version(5,2);
|
||||
} break;
|
||||
case COFF_MachineType_X64: ver = make_version(5,2); break;
|
||||
|
||||
case COFF_MachineType_ARMNT:
|
||||
case COFF_MachineType_ARM64:
|
||||
case COFF_MachineType_ARM: {
|
||||
ver = make_version(6,2);
|
||||
} break;
|
||||
case COFF_MachineType_ARM: ver = make_version(6,2); break;
|
||||
|
||||
default: InvalidPath; break;
|
||||
default: lnk_not_implemented("define min subsystem(%S) version for %S", pe_string_from_subsystem(subsystem), coff_string_from_machine_type(machine)); break;
|
||||
}
|
||||
} break;
|
||||
|
||||
case PE_WindowsSubsystem_WINDOWS_GUI: {
|
||||
switch (machine) {
|
||||
case COFF_MachineType_X86: {
|
||||
ver = make_version(5,1);
|
||||
} break;
|
||||
case COFF_MachineType_X86: ver = make_version(5,1); break;
|
||||
|
||||
case COFF_MachineType_X64: {
|
||||
ver = make_version(5,2);
|
||||
} break;
|
||||
case COFF_MachineType_X64: ver = make_version(5,2); break;
|
||||
|
||||
case COFF_MachineType_ARMNT:
|
||||
case COFF_MachineType_ARM64:
|
||||
case COFF_MachineType_ARM: {
|
||||
ver = make_version(6,2);
|
||||
} break;
|
||||
case COFF_MachineType_ARM: ver = make_version(6,2); break;
|
||||
|
||||
default: InvalidPath; break;
|
||||
default: lnk_not_implemented("define min subsystem(%S) version for %S", pe_string_from_subsystem(subsystem), coff_string_from_machine_type(machine)); break;
|
||||
}
|
||||
} break;
|
||||
|
||||
case PE_WindowsSubsystem_POSIX_CUI: {
|
||||
ver = make_version(1,0);
|
||||
} break;
|
||||
case PE_WindowsSubsystem_POSIX_CUI: ver = make_version(1,0); break;
|
||||
|
||||
case PE_WindowsSubsystem_EFI_APPLICATION:
|
||||
case PE_WindowsSubsystem_EFI_BOOT_SERVICE_DRIVER:
|
||||
case PE_WindowsSubsystem_EFI_ROM:
|
||||
case PE_WindowsSubsystem_EFI_RUNTIME_DRIVER: {
|
||||
ver = make_version(1,0);
|
||||
} break;
|
||||
case PE_WindowsSubsystem_EFI_RUNTIME_DRIVER: ver = make_version(1,0); break;
|
||||
|
||||
case PE_WindowsSubsystem_NATIVE_WINDOWS:
|
||||
case PE_WindowsSubsystem_NATIVE: {
|
||||
Assert(!"TODO: detect -drive=WDM switch");
|
||||
} break;
|
||||
case PE_WindowsSubsystem_NATIVE: lnk_not_implemented("detect -drive=WDM switch"); break;
|
||||
|
||||
default: lnk_not_implemented("unknown subsystem kind %u", subsystem);
|
||||
}
|
||||
return ver;
|
||||
}
|
||||
@@ -607,7 +575,6 @@ lnk_try_parse_u64(String8 string, LNK_ParseU64Flags flags, U64 *value_out)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & LNK_ParseU64Flag_CheckPow2) {
|
||||
if (!IsPow2(*value_out)) {
|
||||
return 0;
|
||||
@@ -663,10 +630,10 @@ lnk_cmd_switch_parse_flag(String8 obj_path, String8 lib_path, LNK_CmdSwitchType
|
||||
if (value_strings.node_count > 1) {
|
||||
lnk_error_cmd_switch(LNK_Error_Cmdl, obj_path, lib_path, cmd_switch, "too many parameters");
|
||||
} else if (value_strings.node_count == 1) {
|
||||
if (str8_match(value_strings.first->string, str8_lit("no"), StringMatchFlag_CaseInsensitive)) {
|
||||
if (str8_match_lit("no", value_strings.first->string, StringMatchFlag_CaseInsensitive)) {
|
||||
*value_out = LNK_SwitchState_No;
|
||||
is_parsed = 1;
|
||||
} else if (str8_match(value_strings.first->string, str8_lit("yes"), StringMatchFlag_CaseInsensitive)) {
|
||||
} else if (str8_match_lit("yes", value_strings.first->string, StringMatchFlag_CaseInsensitive)) {
|
||||
*value_out = LNK_SwitchState_Yes;
|
||||
is_parsed = 1;
|
||||
} else if (value_strings.first->string.size == 0) {
|
||||
@@ -1021,7 +988,7 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
||||
if (value_strings.node_count == 2) {
|
||||
String8Node *first_node = value_strings.first;
|
||||
//String8Node *second_node = first_node->next;
|
||||
B32 is_response_file = str8_match(str8_lit("@"), first_node->string, StringMatchFlag_RightSideSloppy);
|
||||
B32 is_response_file = str8_match_lit("@", first_node->string, StringMatchFlag_RightSideSloppy);
|
||||
if (is_response_file) {
|
||||
//String8 file_path = first_node->string;
|
||||
//String8 tag = second_node->string;
|
||||
@@ -1076,9 +1043,9 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
||||
lnk_error_cmd_switch(LNK_Error_Cmdl, obj_path, lib_path, cmd_switch, "invalid number of parameters");
|
||||
} else {
|
||||
String8 value = value_strings.first->string;
|
||||
if (str8_match(value, str8_lit("unload"), StringMatchFlag_CaseInsensitive)) {
|
||||
if (str8_match_lit("unload", value, StringMatchFlag_CaseInsensitive)) {
|
||||
config->flags |= LNK_ConfigFlag_DelayUnload;
|
||||
} else if (str8_match(value, str8_lit("nobind"), StringMatchFlag_CaseInsensitive)) {
|
||||
} else if (str8_match_lit("nobind", value, StringMatchFlag_CaseInsensitive)) {
|
||||
config->flags &= ~LNK_ConfigFlag_DelayBind;
|
||||
} else {
|
||||
lnk_error_cmd_switch(LNK_Error_Cmdl, obj_path, lib_path, cmd_switch, "unknown parameter \"%S\"", value);
|
||||
@@ -1241,14 +1208,13 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
||||
String8List param_list = str8_split_by_string_chars(scratch.arena, value_strings.first->string, str8_lit(","), 0);
|
||||
String8Array param_arr = str8_array_from_list(scratch.arena, ¶m_list);
|
||||
if (param_arr.count > 0) {
|
||||
if (str8_match(param_arr.v[0], str8_lit("embed"), StringMatchFlag_CaseInsensitive)) {
|
||||
if (str8_match_lit("embed", param_arr.v[0], StringMatchFlag_CaseInsensitive)) {
|
||||
config->manifest_opt = LNK_ManifestOpt_Embed;
|
||||
|
||||
if (param_arr.count == 1) {
|
||||
config->manifest_resource_id = 0;
|
||||
} else if (param_arr.count > 1) {
|
||||
// parse resource id
|
||||
if (str8_match(param_arr.v[1], str8_lit("id="), StringMatchFlag_RightSideSloppy|StringMatchFlag_CaseInsensitive)) {
|
||||
if (str8_match_lit("id=", param_arr.v[1], StringMatchFlag_RightSideSloppy|StringMatchFlag_CaseInsensitive)) {
|
||||
String8List res_id_list = str8_split_by_string_chars(scratch.arena, param_arr.v[1], str8_lit("="), 0);
|
||||
String8Array res_id_arr = str8_array_from_list(scratch.arena, &res_id_list);
|
||||
if (res_id_arr.count == 2) {
|
||||
@@ -1267,7 +1233,7 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
||||
} else {
|
||||
lnk_error_cmd_switch_invalid_param_count(LNK_Error_Cmdl, obj_path, lib_path, cmd_switch);
|
||||
}
|
||||
} else if (str8_match(param_arr.v[0], str8_lit("no"), StringMatchFlag_CaseInsensitive)) {
|
||||
} else if (str8_match_lit("no", param_arr.v[0], StringMatchFlag_CaseInsensitive)) {
|
||||
config->manifest_opt = LNK_ManifestOpt_No;
|
||||
} else {
|
||||
lnk_error_cmd_switch_invalid_param(LNK_Error_Cmdl, obj_path, lib_path, cmd_switch, param_arr.v[0]);
|
||||
@@ -1305,15 +1271,15 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
||||
String8List param_list = str8_split_by_string_chars(scratch.arena, uac, str8_lit(" "), 0);
|
||||
String8Array param_arr = str8_array_from_list(scratch.arena, ¶m_list);
|
||||
if (param_arr.count > 0) {
|
||||
if (str8_match(str8_lit("level="), param_arr.v[0], StringMatchFlag_RightSideSloppy|StringMatchFlag_CaseInsensitive)) {
|
||||
if (str8_match_lit("level=", param_arr.v[0], StringMatchFlag_RightSideSloppy|StringMatchFlag_CaseInsensitive)) {
|
||||
String8 level_param = param_arr.v[0];
|
||||
String8List level_list = str8_split_by_string_chars(scratch.arena, level_param, str8_lit("="), 0);
|
||||
if (level_list.node_count == 2) {
|
||||
if (str8_match(level_list.first->string, str8_lit("level"), StringMatchFlag_CaseInsensitive)) {
|
||||
if (str8_match_lit("level", level_list.first->string, StringMatchFlag_CaseInsensitive)) {
|
||||
String8 level = level_list.last->string;
|
||||
if (str8_match(level, str8_lit("'asInvoker'"), 0) ||
|
||||
str8_match(level, str8_lit("'highestAvailable'"), 0) ||
|
||||
str8_match(level, str8_lit("'requireAdministrator'"), 0)) {
|
||||
if (str8_match_lit("'asInvoker'", level, 0) ||
|
||||
str8_match_lit("'highestAvailable'", level, 0) ||
|
||||
str8_match_lit("'requireAdministrator'", level, 0)) {
|
||||
// manifest level was parsed!
|
||||
config->manifest_uac = 1;
|
||||
config->manifest_level = push_str8_copy(arena, level);
|
||||
@@ -1322,8 +1288,8 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
||||
String8List ui_access_list = str8_split_by_string_chars(scratch.arena, ui_access_param, str8_lit("="), 0);
|
||||
if (ui_access_list.node_count == 2) {
|
||||
String8 ui_access = ui_access_list.last->string;
|
||||
if (str8_match(ui_access, str8_lit("'true'"), 0) ||
|
||||
str8_match(ui_access, str8_lit("'false'"), 0)) {
|
||||
if (str8_match_lit("'true'", ui_access, 0) ||
|
||||
str8_match_lit("'false'", ui_access, 0)) {
|
||||
// ui access was parsed!
|
||||
config->manifest_ui_access = push_str8_copy(arena, ui_access);
|
||||
} else {
|
||||
@@ -1342,7 +1308,7 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
||||
} else {
|
||||
lnk_error_invalid_uac_level_param(LNK_Error_Cmdl, obj_path, lib_path, cmd_switch, level_param);
|
||||
}
|
||||
} else if (str8_match(str8_lit("no"), param_arr.v[0], StringMatchFlag_CaseInsensitive)) {
|
||||
} else if (str8_match_lit("no", param_arr.v[0], StringMatchFlag_CaseInsensitive)) {
|
||||
config->manifest_uac = 0;
|
||||
} else {
|
||||
lnk_error_cmd_switch_invalid_param(LNK_Error_Cmdl, obj_path, lib_path, cmd_switch, param_arr.v[0]);
|
||||
@@ -1359,7 +1325,7 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
||||
// warn about invalid natvis extension
|
||||
for (String8Node *node = value_strings.first; node != 0; node = node->next) {
|
||||
String8 ext = str8_skip_last_dot(node->string);
|
||||
if (!str8_match(ext, str8_lit("natvis"), StringMatchFlag_CaseInsensitive)) {
|
||||
if (!str8_match_lit("natvis", ext, StringMatchFlag_CaseInsensitive)) {
|
||||
lnk_error_cmd_switch(LNK_Warning_InvalidNatvisFileExt, obj_path, lib_path, cmd_switch, "Visual Studio expects .natvis extension: \"%S\"", node->string);
|
||||
}
|
||||
}
|
||||
@@ -1396,12 +1362,12 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
||||
case LNK_CmdSwitch_Opt: {
|
||||
for (String8Node *n = value_strings.first; n != 0; n = n->next) {
|
||||
String8 param = n->string;
|
||||
if (str8_match(param, str8_lit("ref"), StringMatchFlag_CaseInsensitive)) {
|
||||
if (str8_match_lit("ref", param, StringMatchFlag_CaseInsensitive)) {
|
||||
config->opt_ref = LNK_SwitchState_Yes;
|
||||
} else if (str8_match(param, str8_lit("noref"), StringMatchFlag_CaseInsensitive)) {
|
||||
} else if (str8_match_lit("noref", param, StringMatchFlag_CaseInsensitive)) {
|
||||
config->opt_ref = LNK_SwitchState_No;
|
||||
} else if (str8_match(param, str8_lit("icf"), StringMatchFlag_CaseInsensitive) ||
|
||||
str8_match(param, str8_lit("icf="), StringMatchFlag_CaseInsensitive | StringMatchFlag_RightSideSloppy)) {
|
||||
} else if (str8_match_lit("icf", param, StringMatchFlag_CaseInsensitive) ||
|
||||
str8_match_lit("icf=", param, StringMatchFlag_CaseInsensitive | StringMatchFlag_RightSideSloppy)) {
|
||||
String8List vals = str8_split_by_string_chars(scratch.arena, param, str8_lit("="), 0);
|
||||
if (vals.node_count > 2) {
|
||||
lnk_error_cmd_switch(LNK_Error_Cmdl, obj_path, lib_path, cmd_switch, "too many parameters for iteration");
|
||||
@@ -1415,11 +1381,11 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
||||
}
|
||||
}
|
||||
config->opt_icf = LNK_SwitchState_Yes;
|
||||
} else if (str8_match(param, str8_lit("noicf"), StringMatchFlag_CaseInsensitive)) {
|
||||
} else if (str8_match_lit("noicf", param, StringMatchFlag_CaseInsensitive)) {
|
||||
config->opt_icf = LNK_SwitchState_No;
|
||||
} else if (str8_match(param, str8_lit("lbr"), StringMatchFlag_CaseInsensitive)) {
|
||||
} else if (str8_match_lit("lbr", param, StringMatchFlag_CaseInsensitive)) {
|
||||
config->opt_lbr = LNK_SwitchState_Yes;
|
||||
} else if (str8_match(param, str8_lit("nolibr"), StringMatchFlag_CaseInsensitive)) {
|
||||
} else if (str8_match_lit("nolibr", param, StringMatchFlag_CaseInsensitive)) {
|
||||
config->opt_lbr = LNK_SwitchState_No;
|
||||
} else {
|
||||
lnk_error_cmd_switch(LNK_Error_Cmdl, obj_path, lib_path, cmd_switch, "unknown option \"%S\"", param);
|
||||
@@ -1566,9 +1532,9 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
||||
|
||||
case LNK_CmdSwitch_Rad_Guid: {
|
||||
if (value_strings.node_count == 1) {
|
||||
if (str8_match(value_strings.first->string, str8_lit("imageblake3"), StringMatchFlag_CaseInsensitive)) {
|
||||
if (str8_match_lit("imageblake3", value_strings.first->string, StringMatchFlag_CaseInsensitive)) {
|
||||
config->guid_type = Lnk_DebugInfoGuid_ImageBlake3;
|
||||
} else if (str8_match(value_strings.first->string, str8_lit("random"), StringMatchFlag_CaseInsensitive)) {
|
||||
} else if (str8_match_lit("random", value_strings.first->string, StringMatchFlag_CaseInsensitive)) {
|
||||
config->guid = os_make_guid();
|
||||
} else {
|
||||
Guid guid;
|
||||
@@ -1605,12 +1571,12 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
||||
#endif
|
||||
}
|
||||
} else if (value_strings.node_count == 1) {
|
||||
if (str8_match(value_strings.first->string, str8_lit("quiet"), StringMatchFlag_CaseInsensitive)) {
|
||||
if (str8_match_lit("quiet", value_strings.first->string, StringMatchFlag_CaseInsensitive)) {
|
||||
OS_ProcessInfo *process_info = os_get_process_info();
|
||||
if (process_info->large_pages_allowed) {
|
||||
arena_default_flags |= ArenaFlag_LargePages;
|
||||
}
|
||||
} else if (str8_match(value_strings.first->string, str8_lit("no"), StringMatchFlag_CaseInsensitive)) {
|
||||
} else if (str8_match_lit("no", value_strings.first->string, StringMatchFlag_CaseInsensitive)) {
|
||||
arena_default_flags &= ~ArenaFlag_LargePages;
|
||||
} else {
|
||||
lnk_error_cmd_switch(LNK_Error_Cmdl, obj_path, lib_path, cmd_switch, "invalid parameter: \"%S\", expected NO or QUIET", value_strings.first->string);
|
||||
@@ -1626,11 +1592,11 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
||||
|
||||
case LNK_CmdSwitch_Rad_Log: {
|
||||
if (value_strings.node_count == 1) {
|
||||
if (str8_match(value_strings.first->string, str8_lit("all"), StringMatchFlag_CaseInsensitive)) {
|
||||
if (str8_match_lit("all", value_strings.first->string, StringMatchFlag_CaseInsensitive)) {
|
||||
for (U64 ilog = 0; ilog < LNK_Log_Count; ilog += 1) {
|
||||
lnk_set_log_status((LNK_LogType)ilog, 1);
|
||||
}
|
||||
} else if (str8_match(value_strings.first->string, str8_lit("io"), StringMatchFlag_CaseInsensitive)) {
|
||||
} else if (str8_match_lit("io", value_strings.first->string, StringMatchFlag_CaseInsensitive)) {
|
||||
lnk_set_log_status(LNK_Log_IO_Read, 1);
|
||||
lnk_set_log_status(LNK_Log_IO_Write, 1);
|
||||
} else {
|
||||
|
||||
@@ -542,7 +542,7 @@ lnk_build_import_entry_obj(Arena *arena, String8 dll_name, COFF_MachineType mach
|
||||
ProfBeginFunction();
|
||||
|
||||
Assert(machine == COFF_MachineType_X64);
|
||||
Assert(str8_match(str8_lit("dll"), str8_skip_last_dot(dll_name), StringMatchFlag_CaseInsensitive|StringMatchFlag_RightSideSloppy));
|
||||
Assert(str8_match_lit("dll", str8_skip_last_dot(dll_name), StringMatchFlag_CaseInsensitive|StringMatchFlag_RightSideSloppy));
|
||||
|
||||
String8List list = {0};
|
||||
|
||||
@@ -802,7 +802,7 @@ lnk_build_null_thunk_data_obj(Arena *arena, String8 dll_name, COFF_MachineType m
|
||||
{
|
||||
ProfBeginFunction();
|
||||
|
||||
Assert(str8_match(str8_lit("dll"), str8_skip_last_dot(dll_name), StringMatchFlag_CaseInsensitive|StringMatchFlag_RightSideSloppy));
|
||||
Assert(str8_match_lit("dll", str8_skip_last_dot(dll_name), StringMatchFlag_CaseInsensitive|StringMatchFlag_RightSideSloppy));
|
||||
|
||||
String8List list = {0};
|
||||
|
||||
|
||||
@@ -1119,7 +1119,7 @@ lnk_directive_info_from_sections(Arena *arena,
|
||||
for (U64 chunk_idx = 0; chunk_idx < chunk_count; ++chunk_idx) {
|
||||
String8 sect_name = sect_name_arr[chunk_idx];
|
||||
LNK_Chunk *sect_chunk = chunk_arr + chunk_idx;
|
||||
if (str8_match(sect_name, str8_lit(".drectve"), 0)) {
|
||||
if (str8_match_lit(".drectve", sect_name, 0)) {
|
||||
if (sect_chunk->type == LNK_Chunk_Leaf) {
|
||||
if (sect_chunk->u.leaf.size >= 3) {
|
||||
if (~sect_chunk->flags & COFF_SectionFlag_LNK_INFO) {
|
||||
|
||||
@@ -91,10 +91,10 @@ lnk_make_section_sort_index(Arena *arena, String8 name, COFF_SectionFlags flags,
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "a");
|
||||
}
|
||||
|
||||
if (str8_match(name, str8_lit(".null"), 0)) {
|
||||
if (str8_match_lit(".null", name, 0)) {
|
||||
// null section always first
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "a");
|
||||
} else if (str8_match(name, str8_lit(".rsrc"), 0)) {
|
||||
} else if (str8_match_lit(".rsrc", name, 0)) {
|
||||
// section with resource data must be last because during runtime windows might append pages
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "c");
|
||||
} else {
|
||||
@@ -104,18 +104,18 @@ lnk_make_section_sort_index(Arena *arena, String8 name, COFF_SectionFlags flags,
|
||||
// sort sections based on the contents
|
||||
if (flags & COFF_SectionFlag_CNT_CODE) {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "a");
|
||||
if (str8_match(name, str8_lit(".text"), 0)) {
|
||||
if (str8_match_lit(".text", name, 0)) {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "a");
|
||||
} else {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "b");
|
||||
}
|
||||
} else if (flags & COFF_SectionFlag_CNT_INITIALIZED_DATA) {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "b");
|
||||
if (str8_match(name, str8_lit(".data"), 0)) {
|
||||
if (str8_match_lit(".data", name, 0)) {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "a");
|
||||
} else if (str8_match(name, str8_lit(".rdata"), 0)) {
|
||||
} else if (str8_match_lit(".rdata", name, 0)) {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "b");
|
||||
} else if (str8_match(name, str8_lit(".tls"), 0)) {
|
||||
} else if (str8_match_lit(".tls", name, 0)) {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "c");
|
||||
} else {
|
||||
str8_list_pushf(scratch.arena, &sort_index_list, "d");
|
||||
@@ -888,7 +888,7 @@ lnk_dump_chunks(LNK_SectionTable *st)
|
||||
LNK_Section *sect = sect_id_map[sect_id];
|
||||
if (!sect) continue;
|
||||
if (sect->is_merged) continue;
|
||||
if (str8_match(sect->name, str8_lit(".text"), 0)) {
|
||||
if (str8_match_lit(".text", sect->name, 0)) {
|
||||
for (U64 chunk_id = 0; chunk_id < sect->cman->total_chunk_count; ++chunk_id) {
|
||||
LNK_ChunkRef chunk_ref = { sect_id, chunk_id };
|
||||
LNK_Chunk *chunk = lnk_chunk_from_chunk_ref(sect_id_map, chunk_id_map, chunk_ref);
|
||||
|
||||
@@ -438,8 +438,8 @@ mscrt_catch_blocks_from_data_x8664(Arena *arena,
|
||||
}
|
||||
*/
|
||||
|
||||
B32 is_handler_v3_or_below = str8_match(handler_name, str8_lit("__CxxFrameHandler3"), 0) ||
|
||||
str8_match(handler_name, str8_lit("__GSHandlerCheck_EH"), 0);
|
||||
B32 is_handler_v3_or_below = str8_match_lit("__CxxFrameHandler3", handler_name, 0) ||
|
||||
str8_match_lit("__GSHandlerCheck_EH", handler_name, 0);
|
||||
if (is_handler_v3_or_below) {
|
||||
U64 func_info_foff = handler_data_foff + sizeof(handler_voff);
|
||||
MSCRT_FuncInfo func_info = {0};
|
||||
@@ -457,8 +457,8 @@ mscrt_catch_blocks_from_data_x8664(Arena *arena,
|
||||
goto next;
|
||||
}
|
||||
|
||||
B32 is_handler_v4 = str8_match(handler_name, str8_lit("__CxxFrameHandler4"), 0) ||
|
||||
str8_match(handler_name, str8_lit("__GSHandlerCheck_EH4"), 0);
|
||||
B32 is_handler_v4 = str8_match_lit("__CxxFrameHandler4", handler_name, 0) ||
|
||||
str8_match_lit("__GSHandlerCheck_EH4", handler_name, 0);
|
||||
if (is_handler_v4) {
|
||||
U32 func_info_voff = *(U32 *)str8_deserial_get_raw_ptr(raw_data, handler_data_foff + sizeof(handler_voff), sizeof(func_info_voff));
|
||||
U64 func_info_foff = coff_foff_from_voff(sections, section_count, func_info_voff);
|
||||
|
||||
+13
-13
@@ -416,9 +416,9 @@ rd_dw_sections_from_coff_section_table(Arena *arena,
|
||||
DW_SectionKind s = DW_Section_Null;
|
||||
B32 is_dwo = 0;
|
||||
#define X(_K,_L,_M,_W) \
|
||||
if (str8_match(name, str8_lit(_L), 0)) { s = DW_Section_##_K; } \
|
||||
if (str8_match(name, str8_lit(_M), 0)) { s = DW_Section_##_K; } \
|
||||
if (str8_match(name, str8_lit(_W), 0)) { s = DW_Section_##_K; is_dwo = 1; }
|
||||
if (str8_match_lit(_L, name, 0)) { s = DW_Section_##_K; } \
|
||||
if (str8_match_lit(_M, name, 0)) { s = DW_Section_##_K; } \
|
||||
if (str8_match_lit(_W, name, 0)) { s = DW_Section_##_K; is_dwo = 1; }
|
||||
DW_SectionKind_XList(X)
|
||||
#undef X
|
||||
|
||||
@@ -4499,7 +4499,7 @@ cv_format_debug_sections(Arena *arena, String8List *out, String8 indent, String8
|
||||
String8 sect_name = coff_name_from_section_header(header, raw_image, string_table_off);
|
||||
Rng1U64 sect_frange = rng_1u64(header->foff, header->foff+header->fsize);
|
||||
String8 raw_sect = str8_substr(raw_image, sect_frange);
|
||||
if (str8_match(sect_name, str8_lit(".debug$S"), 0)) {
|
||||
if (str8_match_lit(".debug$S", sect_name, 0)) {
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
CV_DebugS debug_s = cv_parse_debug_s(scratch.arena, raw_sect);
|
||||
for (String8Node *string_n = debug_s.data_list[CV_C13SubSectionIdxKind_Symbols].first;
|
||||
@@ -4547,12 +4547,12 @@ cv_format_debug_sections(Arena *arena, String8List *out, String8 indent, String8
|
||||
String8 sect_name = coff_name_from_section_header(header, raw_image, string_table_off);
|
||||
Rng1U64 sect_frange = rng_1u64(header->foff, header->foff+header->fsize);
|
||||
String8 raw_sect = str8_substr(raw_image, sect_frange);
|
||||
if (str8_match(sect_name, str8_lit(".debug$S"), 0)) {
|
||||
if (str8_match_lit(".debug$S", sect_name, 0)) {
|
||||
rd_printf("# .debug$S No. %llx", i+1);
|
||||
rd_indent();
|
||||
cv_print_symbols_section(arena, out, indent, arch, raw_sect);
|
||||
rd_unindent();
|
||||
} else if (str8_match(sect_name, str8_lit(".debug$T"), 0)) {
|
||||
} else if (str8_match_lit(".debug$T", sect_name, 0)) {
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
CV_Signature sig = 0;
|
||||
str8_deserial_read_struct(raw_sect, 0, &sig);
|
||||
@@ -6319,19 +6319,19 @@ pe_print_exceptions_x8664(Arena *arena,
|
||||
rd_printf("Handler: %#llx%s%S", handler, handler_name.size ? " " : "", handler_name);
|
||||
|
||||
U32 handler_data_flags = 0;
|
||||
if (str8_match(handler_name, str8_lit("__GSHandlerCheck_EH4"), 0)) {
|
||||
if (str8_match_lit("__GSHandlerCheck_EH4", handler_name, 0)) {
|
||||
handler_data_flags = ExceptionHandlerDataFlag_FuncInfo4;
|
||||
} else if (str8_match(handler_name, str8_lit("__CxxFrameHandler4"), 0)) {
|
||||
} else if (str8_match_lit("__CxxFrameHandler4", handler_name, 0)) {
|
||||
handler_data_flags = ExceptionHandlerDataFlag_FuncInfo4;
|
||||
} else if (str8_match(handler_name, str8_lit("__CxxFrameHandler3"), 0)) {
|
||||
} else if (str8_match_lit("__CxxFrameHandler3", handler_name, 0)) {
|
||||
handler_data_flags = ExceptionHandlerDataFlag_FuncInfo;
|
||||
} else if (str8_match(handler_name, str8_lit("__C_specific_handler"), 0)) {
|
||||
} else if (str8_match_lit("__C_specific_handler", handler_name, 0)) {
|
||||
handler_data_flags = ExceptionHandlerDataFlag_ScopeTable;
|
||||
} else if (str8_match(handler_name, str8_lit("__GSHandlerCheck"), 0)) {
|
||||
} else if (str8_match_lit("__GSHandlerCheck", handler_name, 0)) {
|
||||
handler_data_flags = ExceptionHandlerDataFlag_GS;
|
||||
} else if (str8_match(handler_name, str8_lit("__GSHandlerCheck_SEH"), 0)) {
|
||||
} else if (str8_match_lit("__GSHandlerCheck_SEH", handler_name, 0)) {
|
||||
handler_data_flags = ExceptionHandlerDataFlag_ScopeTable|ExceptionHandlerDataFlag_GS;
|
||||
} else if (str8_match(handler_name, str8_lit("__GSHandlerCheck_EH"), 0)) {
|
||||
} else if (str8_match_lit("__GSHandlerCheck_EH", handler_name, 0)) {
|
||||
handler_data_flags = ExceptionHandlerDataFlag_FuncInfo|ExceptionHandlerDataFlag_GS;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ entry_point(CmdLine *cmdline)
|
||||
if (str8_match(cmd->string, opt_name, StringMatchFlag_CaseInsensitive)) {
|
||||
opt = g_rd_dump_option_map[opt_idx].opt;
|
||||
break;
|
||||
} else if (str8_match(cmd->string, str8_lit("all"), StringMatchFlag_CaseInsensitive)) {
|
||||
} else if (str8_match_lit("all", cmd->string, StringMatchFlag_CaseInsensitive)) {
|
||||
opt = ~0ull & ~(RD_Option_Help|RD_Option_Version);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user