diff options
| author | grischka <grischka> | 2011-07-14 19:23:04 +0200 |
|---|---|---|
| committer | grischka <grischka> | 2011-07-14 19:23:04 +0200 |
| commit | aa80e5b1ff9a0dedb5a41916716870345033ca30 (patch) | |
| tree | aadbbdfe6e5394c93cb6a75dbc352c584426ca25 /tccpe.c | |
| parent | d483ab322f797972bb7e55624cd8c406a240a2ad (diff) | |
| download | tinycc-aa80e5b1ff9a0dedb5a41916716870345033ca30.tar.gz tinycc-aa80e5b1ff9a0dedb5a41916716870345033ca30.tar.bz2 | |
tccpe: cleanup ELFW() macros etc.
Diffstat (limited to 'tccpe.c')
| -rw-r--r-- | tccpe.c | 46 |
1 files changed, 14 insertions, 32 deletions
@@ -726,38 +726,20 @@ static int pe_write(struct pe_info *pe) /*----------------------------------------------------------------------------*/ #if defined(TCC_TARGET_X86_64) -#define ELFW_R_(type) ELF64_R_##type -#define ElfW_Rel ElfW(Rela) - #define REL_TYPE_DIRECT R_X86_64_64 #define R_XXX_THUNKFIX R_X86_64_PC32 #define R_XXX_RELATIVE R_X86_64_RELATIVE -#define ELFW_ST_BIND ELF64_ST_BIND -#define ELFW_ST_TYPE ELF64_ST_TYPE -#define ELFW_ST_INFO ELF64_ST_INFO #elif defined(TCC_TARGET_I386) -#define ELFW_R_(type) ELF32_R_##type -#define ElfW_Rel ElfW(Rel) - #define REL_TYPE_DIRECT R_386_32 #define R_XXX_THUNKFIX R_386_32 #define R_XXX_RELATIVE R_386_RELATIVE -#define ELFW_ST_BIND ELF32_ST_BIND -#define ELFW_ST_TYPE ELF32_ST_TYPE -#define ELFW_ST_INFO ELF32_ST_INFO #elif defined(TCC_TARGET_ARM) -#define ELFW_R_(type) ELF32_R_##type -#define ElfW_Rel ElfW(Rel) - #define REL_TYPE_DIRECT R_ARM_ABS32 #define R_XXX_THUNKFIX R_ARM_ABS32 #define R_XXX_RELATIVE R_ARM_RELATIVE -#define ELFW_ST_BIND ELF32_ST_BIND -#define ELFW_ST_TYPE ELF32_ST_TYPE -#define ELFW_ST_INFO ELF32_ST_INFO #endif /*----------------------------------------------------------------------------*/ @@ -1003,7 +985,7 @@ static void pe_build_reloc (struct pe_info *pe) for(;;) { if (rel < rel_end) { - int type = ELFW_R_(TYPE)(rel->r_info); + int type = ELFW(R_TYPE)(rel->r_info); addr = rel->r_offset + s->sh_addr; ++ rel; if (type != REL_TYPE_DIRECT) @@ -1185,8 +1167,8 @@ static void pe_relocate_rva (struct pe_info *pe, Section *s) ElfW_Rel *rel, *rel_end; rel_end = (ElfW_Rel *)(sr->data + sr->data_offset); for(rel = (ElfW_Rel *)sr->data; rel < rel_end; rel++) { - if (ELFW_R_(TYPE)(rel->r_info) == R_XXX_RELATIVE) { - int sym_index = ELFW_R_(SYM)(rel->r_info); + if (ELFW(R_TYPE)(rel->r_info) == R_XXX_RELATIVE) { + int sym_index = ELFW(R_SYM)(rel->r_info); DWORD addr = s->sh_addr; if (sym_index) { ElfW(Sym) *sym = (ElfW(Sym) *)symtab_section->data + sym_index; @@ -1230,7 +1212,7 @@ static int pe_check_symbols(struct pe_info *pe) if (sym->st_shndx == SHN_UNDEF) { const char *name = symtab_section->link->data + sym->st_name; - unsigned type = ELFW_ST_TYPE(sym->st_info); + unsigned type = ELFW(ST_TYPE)(sym->st_info); int imp_sym = pe_find_import(pe->s1, sym); struct import_symbol *is; @@ -1274,7 +1256,7 @@ static int pe_check_symbols(struct pe_info *pe) sprintf(buffer, "IAT.%s", name); is->iat_index = put_elf_sym( symtab_section, 0, sizeof(DWORD), - ELFW_ST_INFO(STB_GLOBAL, STT_OBJECT), + ELFW(ST_INFO)(STB_GLOBAL, STT_OBJECT), 0, SHN_UNDEF, buffer); #ifdef TCC_TARGET_ARM put_elf_reloc(symtab_section, text_section, @@ -1309,7 +1291,7 @@ static int pe_check_symbols(struct pe_info *pe) ret = -1; } else if (pe->s1->rdynamic - && ELFW_ST_BIND(sym->st_info) != STB_LOCAL) { + && ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) { /* if -rdynamic option, then export all non local symbols */ sym->st_other |= 1; } @@ -1408,8 +1390,8 @@ static void pe_print_section(FILE * f, Section * s) (unsigned)sym->st_name, (unsigned)sym->st_value, (unsigned)sym->st_size, - (unsigned)ELFW_ST_BIND(sym->st_info), - (unsigned)ELFW_ST_TYPE(sym->st_info), + (unsigned)ELFW(ST_BIND)(sym->st_info), + (unsigned)ELFW(ST_TYPE)(sym->st_info), (unsigned)sym->st_other, (unsigned)sym->st_shndx, name); @@ -1417,12 +1399,12 @@ static void pe_print_section(FILE * f, Section * s) } else if (s->sh_type == SHT_RELX) { ElfW_Rel *rel = (ElfW_Rel *) (p + i); ElfW(Sym) *sym = - (ElfW(Sym) *) s->link->data + ELFW_R_(SYM)(rel->r_info); + (ElfW(Sym) *) s->link->data + ELFW(R_SYM)(rel->r_info); const char *name = s->link->link->data + sym->st_name; fprintf(f, " %04X %02X %04X \"%s\"", (unsigned)rel->r_offset, - (unsigned)ELFW_R_(TYPE)(rel->r_info), - (unsigned)ELFW_R_(SYM)(rel->r_info), + (unsigned)ELFW(R_TYPE)(rel->r_info), + (unsigned)ELFW(R_SYM)(rel->r_info), name); } else { fprintf(f, " "); @@ -1505,7 +1487,7 @@ ST_FUNC int pe_putimport(TCCState *s1, int dllindex, const char *name, const voi s1->dynsymtab_section, (uplong)value, dllindex, /* st_size */ - ELFW_ST_INFO(STB_GLOBAL, STT_NOTYPE), + ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0, value ? SHN_ABS : SHN_UNDEF, name @@ -1794,7 +1776,7 @@ static void pe_add_runtime_ex(TCCState *s1, struct pe_info *pe) if (start_symbol) add_elf_sym(symtab_section, 0, 0, - ELFW_ST_INFO(STB_GLOBAL, STT_NOTYPE), 0, + ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0, SHN_UNDEF, start_symbol); if (0 == s1->nostdlib) { @@ -1820,7 +1802,7 @@ static void pe_add_runtime_ex(TCCState *s1, struct pe_info *pe) /* for -run GUI's, put '_runwinmain' instead of 'main' */ add_elf_sym(symtab_section, addr, 0, - ELFW_ST_INFO(STB_GLOBAL, STT_NOTYPE), 0, + ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0, text_section->sh_num, "main"); } |
