History

win64: hi-mem adjustments

- x86_64-link.c: ignore relocation overflow to undefined (weak) symbols - 104_inline.test: test lower 32 bits only - tccpe.c: support -Wl,--image-base=... above the 32bit range

grischka committed 4 years ago

Commit d76e0321 parent c03d59e3 files · +12 −8Browse files

Unified · Split

3 files
  1. tccpe.c +7 −7
  2. tests/tests2/104+_inline.c +1 −1
  3. x86_64-link.c +4 −0
tccpe.c+7−7
@@ -324,7 +324,7 @@ static const DWORD pe_sec_flags[] = { · 323 unmodified lines
324struct section_info {324struct section_info {
325 int cls;325 int cls;
326 char name[32];326 char name[32];
327 DWORD sh_addr;327 ADDR3264 sh_addr;
328 DWORD sh_size;328 DWORD sh_size;
329 DWORD pe_flags;329 DWORD pe_flags;
330 Section *sec;330 Section *sec;
@@ -451,9 +451,9 @@ static DWORD pe_file_align(struct pe_info *pe, DWORD n) · 120 unmodified lines
451 return (n + (pe->file_align - 1)) & ~(pe->file_align - 1);451 return (n + (pe->file_align - 1)) & ~(pe->file_align - 1);
452}452}
453 453
454static DWORD pe_virtual_align(struct pe_info *pe, DWORD n)454static ADDR3264 pe_virtual_align(struct pe_info *pe, ADDR3264 n)
455{455{
456 return (n + (pe->section_align - 1)) & ~(pe->section_align - 1);456 return (n + (pe->section_align - 1)) & ~(ADDR3264)(pe->section_align - 1);
457}457}
458 458
459static void pe_align_section(Section *s, int a)459static void pe_align_section(Section *s, int a)
@@ -1108,7 +1108,7 @@ static int pe_section_class(Section *s) · 648 unmodified lines
1108static int pe_assign_addresses (struct pe_info *pe)1108static int pe_assign_addresses (struct pe_info *pe)
1109{1109{
1110 int i, k, n, c, nbs;1110 int i, k, n, c, nbs;
1111 DWORD addr;1111 ADDR3264 addr;
1112 int *sec_order, *sec_cls;1112 int *sec_order, *sec_cls;
1113 struct section_info *si;1113 struct section_info *si;
1114 Section *s;1114 Section *s;
@@ -1198,7 +1198,7 @@ add_section: · 83 unmodified lines
1198 Section *s = s1->sections[sec_order[i]];1198 Section *s = s1->sections[sec_order[i]];
1199 int type = s->sh_type;1199 int type = s->sh_type;
1200 int flags = s->sh_flags;1200 int flags = s->sh_flags;
1201 printf("section %-16s %-10s %08x %04x %s,%s,%s\n",1201 printf("section %-16s %-10s %p %04x %s,%s,%s\n",
1202 s->name,1202 s->name,
1203 type == SHT_PROGBITS ? "progbits" :1203 type == SHT_PROGBITS ? "progbits" :
1204 type == SHT_INIT_ARRAY ? "initarr" :1204 type == SHT_INIT_ARRAY ? "initarr" :
@@ -1207,7 +1207,7 @@ add_section: · 2 unmodified lines
1207 type == SHT_SYMTAB ? "symtab" :1207 type == SHT_SYMTAB ? "symtab" :
1208 type == SHT_STRTAB ? "strtab" :1208 type == SHT_STRTAB ? "strtab" :
1209 type == SHT_RELX ? "rel" : "???",1209 type == SHT_RELX ? "rel" : "???",
1210 (unsigned)s->sh_addr,1210 s->sh_addr,
1211 (unsigned)s->data_offset,1211 (unsigned)s->data_offset,
1212 flags & SHF_ALLOC ? "alloc" : "",1212 flags & SHF_ALLOC ? "alloc" : "",
1213 flags & SHF_WRITE ? "write" : "",1213 flags & SHF_WRITE ? "write" : "",
@@ -1280,7 +1280,7 @@ static int pe_check_symbols(struct pe_info *pe) · 66 unmodified lines
1280 is = pe_add_import(pe, imp_sym);1280 is = pe_add_import(pe, imp_sym);
1281 1281
1282 if (type == STT_FUNC) {1282 if (type == STT_FUNC) {
1283 unsigned long offset = is->thk_offset;1283 unsigned offset = is->thk_offset;
1284 if (offset) {1284 if (offset) {
1285 /* got aliased symbol, like stricmp and _stricmp */1285 /* got aliased symbol, like stricmp and _stricmp */
1286 } else {1286 } else {
tests/tests2/104+_inline.c+1−1
@@ -1,7 +1,7 @@
1 1
2#define GOT(f) \2#define GOT(f) \
3 __attribute__((weak)) void f(void); \3 __attribute__((weak)) void f(void); \
4 printf("%d %s\n", !!f, #f);4 printf("%d %s\n", !!((__SIZE_TYPE__)f & ~0u), #f);
5 5
6int printf(const char*, ...);6int printf(const char*, ...);
7 7
x86_64-link.c+4−0
@@ -247,6 +247,10 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t · 246 unmodified lines
247 long long diff;247 long long diff;
248 diff = (long long)val - addr;248 diff = (long long)val - addr;
249 if (diff < -2147483648LL || diff > 2147483647LL) {249 if (diff < -2147483648LL || diff > 2147483647LL) {
250#ifdef TCC_TARGET_PE
251 /* ignore overflow with undefined weak symbols */
252 if (((ElfW(Sym)*)symtab_section->data)[sym_index].st_shndx != SHN_UNDEF)
253#endif
250 tcc_error("internal error: relocation failed");254 tcc_error("internal error: relocation failed");
251 }255 }
252 add32le(ptr, diff);256 add32le(ptr, diff);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t