| @@ -726,38 +726,20 @@ static int pe_write(struct pe_info *pe) · 725 unmodified lines |
| 726 | 726 | /*----------------------------------------------------------------------------*/ |
| 727 | 727 | |
| 728 | 728 | #if defined(TCC_TARGET_X86_64) |
| 729 | | −#define ELFW_R_(type) ELF64_R_##type |
| 730 | | −#define ElfW_Rel ElfW(Rela) |
| 731 | | − |
| 732 | 729 | #define REL_TYPE_DIRECT R_X86_64_64 |
| 733 | 730 | #define R_XXX_THUNKFIX R_X86_64_PC32 |
| 734 | 731 | #define R_XXX_RELATIVE R_X86_64_RELATIVE |
| 735 | 732 | |
| 736 | | −#define ELFW_ST_BIND ELF64_ST_BIND |
| 737 | | −#define ELFW_ST_TYPE ELF64_ST_TYPE |
| 738 | | −#define ELFW_ST_INFO ELF64_ST_INFO |
| 739 | 733 | #elif defined(TCC_TARGET_I386) |
| 740 | | −#define ELFW_R_(type) ELF32_R_##type |
| 741 | | −#define ElfW_Rel ElfW(Rel) |
| 742 | | − |
| 743 | 734 | #define REL_TYPE_DIRECT R_386_32 |
| 744 | 735 | #define R_XXX_THUNKFIX R_386_32 |
| 745 | 736 | #define R_XXX_RELATIVE R_386_RELATIVE |
| 746 | 737 | |
| 747 | | −#define ELFW_ST_BIND ELF32_ST_BIND |
| 748 | | −#define ELFW_ST_TYPE ELF32_ST_TYPE |
| 749 | | −#define ELFW_ST_INFO ELF32_ST_INFO |
| 750 | 738 | #elif defined(TCC_TARGET_ARM) |
| 751 | | −#define ELFW_R_(type) ELF32_R_##type |
| 752 | | −#define ElfW_Rel ElfW(Rel) |
| 753 | | − |
| 754 | 739 | #define REL_TYPE_DIRECT R_ARM_ABS32 |
| 755 | 740 | #define R_XXX_THUNKFIX R_ARM_ABS32 |
| 756 | 741 | #define R_XXX_RELATIVE R_ARM_RELATIVE |
| 757 | 742 | |
| 758 | | −#define ELFW_ST_BIND ELF32_ST_BIND |
| 759 | | −#define ELFW_ST_TYPE ELF32_ST_TYPE |
| 760 | | −#define ELFW_ST_INFO ELF32_ST_INFO |
| 761 | 743 | #endif |
| 762 | 744 | /*----------------------------------------------------------------------------*/ |
| 763 | 745 | |
| @@ -1003,7 +985,7 @@ static void pe_build_reloc (struct pe_info *pe) · 239 unmodified lines |
| 1003 | 985 | |
| 1004 | 986 | for(;;) { |
| 1005 | 987 | if (rel < rel_end) { |
| 1006 | | − int type = ELFW_R_(TYPE)(rel->r_info); |
| 988 | + int type = ELFW(R_TYPE)(rel->r_info); |
| 1007 | 989 | addr = rel->r_offset + s->sh_addr; |
| 1008 | 990 | ++ rel; |
| 1009 | 991 | if (type != REL_TYPE_DIRECT) |
| @@ -1185,8 +1167,8 @@ static void pe_relocate_rva (struct pe_info *pe, Section *s) · 175 unmodified lines |
| 1185 | 1167 | ElfW_Rel *rel, *rel_end; |
| 1186 | 1168 | rel_end = (ElfW_Rel *)(sr->data + sr->data_offset); |
| 1187 | 1169 | for(rel = (ElfW_Rel *)sr->data; rel < rel_end; rel++) { |
| 1188 | | − if (ELFW_R_(TYPE)(rel->r_info) == R_XXX_RELATIVE) { |
| 1189 | | − int sym_index = ELFW_R_(SYM)(rel->r_info); |
| 1170 | + if (ELFW(R_TYPE)(rel->r_info) == R_XXX_RELATIVE) { |
| 1171 | + int sym_index = ELFW(R_SYM)(rel->r_info); |
| 1190 | 1172 | DWORD addr = s->sh_addr; |
| 1191 | 1173 | if (sym_index) { |
| 1192 | 1174 | ElfW(Sym) *sym = (ElfW(Sym) *)symtab_section->data + sym_index; |
| @@ -1230,7 +1212,7 @@ static int pe_check_symbols(struct pe_info *pe) · 37 unmodified lines |
| 1230 | 1212 | if (sym->st_shndx == SHN_UNDEF) { |
| 1231 | 1213 | |
| 1232 | 1214 | const char *name = symtab_section->link->data + sym->st_name; |
| 1233 | | − unsigned type = ELFW_ST_TYPE(sym->st_info); |
| 1215 | + unsigned type = ELFW(ST_TYPE)(sym->st_info); |
| 1234 | 1216 | int imp_sym = pe_find_import(pe->s1, sym); |
| 1235 | 1217 | struct import_symbol *is; |
| 1236 | 1218 | |
| @@ -1274,7 +1256,7 @@ static int pe_check_symbols(struct pe_info *pe) · 37 unmodified lines |
| 1274 | 1256 | sprintf(buffer, "IAT.%s", name); |
| 1275 | 1257 | is->iat_index = put_elf_sym( |
| 1276 | 1258 | symtab_section, 0, sizeof(DWORD), |
| 1277 | | − ELFW_ST_INFO(STB_GLOBAL, STT_OBJECT), |
| 1259 | + ELFW(ST_INFO)(STB_GLOBAL, STT_OBJECT), |
| 1278 | 1260 | 0, SHN_UNDEF, buffer); |
| 1279 | 1261 | #ifdef TCC_TARGET_ARM |
| 1280 | 1262 | put_elf_reloc(symtab_section, text_section, |
| @@ -1309,7 +1291,7 @@ static int pe_check_symbols(struct pe_info *pe) · 28 unmodified lines |
| 1309 | 1291 | ret = -1; |
| 1310 | 1292 | |
| 1311 | 1293 | } else if (pe->s1->rdynamic |
| 1312 | | − && ELFW_ST_BIND(sym->st_info) != STB_LOCAL) { |
| 1294 | + && ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) { |
| 1313 | 1295 | /* if -rdynamic option, then export all non local symbols */ |
| 1314 | 1296 | sym->st_other |= 1; |
| 1315 | 1297 | } |
| @@ -1408,8 +1390,8 @@ static void pe_print_section(FILE * f, Section * s) · 92 unmodified lines |
| 1408 | 1390 | (unsigned)sym->st_name, |
| 1409 | 1391 | (unsigned)sym->st_value, |
| 1410 | 1392 | (unsigned)sym->st_size, |
| 1411 | | − (unsigned)ELFW_ST_BIND(sym->st_info), |
| 1412 | | − (unsigned)ELFW_ST_TYPE(sym->st_info), |
| 1393 | + (unsigned)ELFW(ST_BIND)(sym->st_info), |
| 1394 | + (unsigned)ELFW(ST_TYPE)(sym->st_info), |
| 1413 | 1395 | (unsigned)sym->st_other, |
| 1414 | 1396 | (unsigned)sym->st_shndx, |
| 1415 | 1397 | name); |
| @@ -1417,12 +1399,12 @@ static void pe_print_section(FILE * f, Section * s) · 1 unmodified line |
| 1417 | 1399 | } else if (s->sh_type == SHT_RELX) { |
| 1418 | 1400 | ElfW_Rel *rel = (ElfW_Rel *) (p + i); |
| 1419 | 1401 | ElfW(Sym) *sym = |
| 1420 | | − (ElfW(Sym) *) s->link->data + ELFW_R_(SYM)(rel->r_info); |
| 1402 | + (ElfW(Sym) *) s->link->data + ELFW(R_SYM)(rel->r_info); |
| 1421 | 1403 | const char *name = s->link->link->data + sym->st_name; |
| 1422 | 1404 | fprintf(f, " %04X %02X %04X \"%s\"", |
| 1423 | 1405 | (unsigned)rel->r_offset, |
| 1424 | | − (unsigned)ELFW_R_(TYPE)(rel->r_info), |
| 1425 | | − (unsigned)ELFW_R_(SYM)(rel->r_info), |
| 1406 | + (unsigned)ELFW(R_TYPE)(rel->r_info), |
| 1407 | + (unsigned)ELFW(R_SYM)(rel->r_info), |
| 1426 | 1408 | name); |
| 1427 | 1409 | } else { |
| 1428 | 1410 | fprintf(f, " "); |
| @@ -1505,7 +1487,7 @@ ST_FUNC int pe_putimport(TCCState *s1, int dllindex, const char *name, const voi · 76 unmodified lines |
| 1505 | 1487 | s1->dynsymtab_section, |
| 1506 | 1488 | (uplong)value, |
| 1507 | 1489 | dllindex, /* st_size */ |
| 1508 | | − ELFW_ST_INFO(STB_GLOBAL, STT_NOTYPE), |
| 1490 | + ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), |
| 1509 | 1491 | 0, |
| 1510 | 1492 | value ? SHN_ABS : SHN_UNDEF, |
| 1511 | 1493 | name |
| @@ -1794,7 +1776,7 @@ static void pe_add_runtime_ex(TCCState *s1, struct pe_info *pe) · 282 unmodified lines |
| 1794 | 1776 | if (start_symbol) |
| 1795 | 1777 | add_elf_sym(symtab_section, |
| 1796 | 1778 | 0, 0, |
| 1797 | | − ELFW_ST_INFO(STB_GLOBAL, STT_NOTYPE), 0, |
| 1779 | + ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0, |
| 1798 | 1780 | SHN_UNDEF, start_symbol); |
| 1799 | 1781 | |
| 1800 | 1782 | if (0 == s1->nostdlib) { |
| @@ -1820,7 +1802,7 @@ static void pe_add_runtime_ex(TCCState *s1, struct pe_info *pe) · 19 unmodified lines |
| 1820 | 1802 | /* for -run GUI's, put '_runwinmain' instead of 'main' */ |
| 1821 | 1803 | add_elf_sym(symtab_section, |
| 1822 | 1804 | addr, 0, |
| 1823 | | − ELFW_ST_INFO(STB_GLOBAL, STT_NOTYPE), 0, |
| 1805 | + ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0, |
| 1824 | 1806 | text_section->sh_num, "main"); |
| 1825 | 1807 | } |
| 1826 | 1808 | |