refactor(ast2ir): 重构ABI类型系统并修复union结构问题
- 将scc_ast_def.h中的attr_of从union改为struct以修复结构定义问题 - 添加type_abi依赖到ast2ir模块的cbuild.toml配置文件中 - 重命名scc_ast2ir.h中的abi字段为type_abi,并更新相关初始化函数签名 - 移除废弃的scc_abi_type.h和相关平台ABI头文件 - 添加辅助函数is_variadic_marker和fixed_param_count用于处理可变参数 - 添加数组和聚合类型初始化的辅助函数
This commit is contained in:
@@ -212,8 +212,7 @@ void sccf2pe(scc_pe_builder_t *builder, const sccf_t *sccf) {
|
||||
|
||||
scc_mcode_t mcode;
|
||||
scc_mcode_init(&mcode, SCC_MCODE_ARCH_X86_64);
|
||||
// FIXME hack
|
||||
mcode.code = *(scc_mcode_buff_t *)code_data;
|
||||
scc_mcode_adopt_buf(&mcode, (scc_mcode_buff_t *)code_data);
|
||||
scc_vec_foreach(relocs, i) {
|
||||
sccf_reloc_t *reloc = &scc_vec_at(relocs, i);
|
||||
if (reloc->reloc_type == SCCF_RELOC_TYPE_EMPTY) {
|
||||
@@ -243,7 +242,7 @@ void sccf2pe(scc_pe_builder_t *builder, const sccf_t *sccf) {
|
||||
scc_x86_patch(&mcode, SCC_X86_PATCH_PC32, reloc->offset + reloc->addend,
|
||||
(i64)rva - (i64)code_range.virual_address);
|
||||
}
|
||||
*(scc_mcode_buff_t *)code_data = mcode.code;
|
||||
scc_mcode_disown_buf(&mcode, (scc_mcode_buff_t *)code_data);
|
||||
|
||||
scc_pe_write_header(builder, &config);
|
||||
if (code_data != nullptr) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <sccf2pe.h>
|
||||
#include <sccf_builder.h>
|
||||
#include <stdio.h>
|
||||
#include <x86/scc_x86_patch.h>
|
||||
|
||||
int main() {
|
||||
char data[] = "Hello, World from SCC PE Builder!\n\0";
|
||||
@@ -56,13 +57,13 @@ int main() {
|
||||
.offset = 7,
|
||||
.sect_type = SCCF_SECT_CODE,
|
||||
.sym_idx = str_idx,
|
||||
.reloc_type = SCCF_RELOC_TYPE_REL});
|
||||
.reloc_type = SCC_X86_OPR_RELBR});
|
||||
sccf_builder_add_reloc(&builder,
|
||||
(sccf_reloc_t){.addend = 4,
|
||||
.offset = 13,
|
||||
.sect_type = SCCF_SECT_CODE,
|
||||
.sym_idx = puts_idx,
|
||||
.reloc_type = SCCF_RELOC_TYPE_REL});
|
||||
.reloc_type = SCC_X86_OPR_RELBR});
|
||||
const sccf_t *sccf = sccf_builder_to_sccf(&builder);
|
||||
|
||||
scc_pe_builder_t pe_builder;
|
||||
|
||||
Reference in New Issue
Block a user