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
324324 struct section_info {
325325 int cls;
326326 char name[32];
327− DWORD sh_addr;
327+ ADDR3264 sh_addr;
328328 DWORD sh_size;
329329 DWORD pe_flags;
330330 Section *sec;
@@ -451,9 +451,9 @@ static DWORD pe_file_align(struct pe_info *pe, DWORD n) · 120 unmodified lines
451451 return (n + (pe->file_align - 1)) & ~(pe->file_align - 1);
452452 }
453453
454−static DWORD pe_virtual_align(struct pe_info *pe, DWORD n)
454+static ADDR3264 pe_virtual_align(struct pe_info *pe, ADDR3264 n)
455455 {
456− return (n + (pe->section_align - 1)) & ~(pe->section_align - 1);
456+ return (n + (pe->section_align - 1)) & ~(ADDR3264)(pe->section_align - 1);
457457 }
458458
459459 static void pe_align_section(Section *s, int a)
@@ -1108,7 +1108,7 @@ static int pe_section_class(Section *s) · 648 unmodified lines
11081108 static int pe_assign_addresses (struct pe_info *pe)
11091109 {
11101110 int i, k, n, c, nbs;
1111− DWORD addr;
1111+ ADDR3264 addr;
11121112 int *sec_order, *sec_cls;
11131113 struct section_info *si;
11141114 Section *s;
@@ -1198,7 +1198,7 @@ add_section: · 83 unmodified lines
11981198 Section *s = s1->sections[sec_order[i]];
11991199 int type = s->sh_type;
12001200 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",
12021202 s->name,
12031203 type == SHT_PROGBITS ? "progbits" :
12041204 type == SHT_INIT_ARRAY ? "initarr" :
@@ -1207,7 +1207,7 @@ add_section: · 2 unmodified lines
12071207 type == SHT_SYMTAB ? "symtab" :
12081208 type == SHT_STRTAB ? "strtab" :
12091209 type == SHT_RELX ? "rel" : "???",
1210− (unsigned)s->sh_addr,
1210+ s->sh_addr,
12111211 (unsigned)s->data_offset,
12121212 flags & SHF_ALLOC ? "alloc" : "",
12131213 flags & SHF_WRITE ? "write" : "",
@@ -1280,7 +1280,7 @@ static int pe_check_symbols(struct pe_info *pe) · 66 unmodified lines
12801280 is = pe_add_import(pe, imp_sym);
12811281
12821282 if (type == STT_FUNC) {
1283− unsigned long offset = is->thk_offset;
1283+ unsigned offset = is->thk_offset;
12841284 if (offset) {
12851285 /* got aliased symbol, like stricmp and _stricmp */
12861286 } else {
tests/tests2/104+_inline.c+1−1
@@ -1,7 +1,7 @@
11
22 #define GOT(f) \
33 __attribute__((weak)) void f(void); \
4− printf("%d %s\n", !!f, #f);
4+ printf("%d %s\n", !!((__SIZE_TYPE__)f & ~0u), #f);
55
66 int printf(const char*, ...);
77
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
247247 long long diff;
248248 diff = (long long)val - addr;
249249 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
250254 tcc_error("internal error: relocation failed");
251255 }
252256 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