Skip to content

Commit f47e73a

Browse files
committed
Don't generate jmptbl symbol on 32-bit
1 parent a84f9fb commit f47e73a

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

flexdll_initer.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,32 @@ typedef int func(void*);
2222
typedef int func_v2(void*,void*);
2323

2424
extern int reloctbl;
25+
#if defined(_WIN64) || defined(__CYGWIN64__)
2526
extern int jmptbl;
27+
#endif
2628

2729
static int flexdll_init() {
2830
func *sym = 0;
2931
func_v2 *sym_v2 = 0;
30-
char *s = getenv("FLEXDLL_RELOCATE_V2");
3132
/* If the supplied symbol is NULL, treat as "loaded not for execution" */
33+
#if defined(_WIN64) || defined(__CYGWIN64)
34+
char *s = getenv("FLEXDLL_RELOCATE_V2");
3235
if (!s) {
36+
#else
37+
char *s;
38+
#endif
3339
s = getenv("FLEXDLL_RELOCATE");
3440
if (!s) { fprintf(stderr, "Cannot find FLEXDLL_RELOCATE\n"); return FALSE; }
3541
/* The executable image doesn't support the V2 interface, so RELOC_REL32
3642
may fail. */
3743
sscanf(s, "%p", &sym);
3844
if (!sym || sym(&reloctbl)) return TRUE;
45+
#if defined(_WIN64) || defined(__CYGWIN64)
3946
} else {
4047
sscanf(s, "%p", &sym_v2);
4148
if (!sym_v2 || sym_v2(&reloctbl, &jmptbl)) return TRUE;
4249
}
50+
#endif
4351
return FALSE;
4452
}
4553

reloc.ml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ let build_dll link_exe output_file files exts extra_args =
753753
List.iter (fun fn -> collect_file (find_file fn)) exts;
754754

755755
if main_pgm then add_def (usym "static_symtable")
756-
else (add_def (usym "reloctbl"); add_def (usym "jmptbl"));
756+
else (add_def (usym "reloctbl"); if !machine = `x64 then add_def (usym "jmptbl"));
757757

758758
if !machine = `x64 then add_def "__ImageBase"
759759
else add_def "___ImageBase";
@@ -936,7 +936,8 @@ let build_dll link_exe output_file files exts extra_args =
936936
(usym (if main_pgm then "static_symtable" else "symtbl"));
937937
if not main_pgm then begin
938938
add_master_reloc_table obj !reloctbls (usym "reloctbl");
939-
add_master_jmp_table obj !trampolines (usym "jmptbl");
939+
if !machine = `x64 then
940+
add_master_jmp_table obj !trampolines (usym "jmptbl");
940941
end;
941942

942943
if !errors then
@@ -1029,10 +1030,11 @@ let build_dll link_exe output_file files exts extra_args =
10291030
with the Windows 7 SDK in 64-bit mode. *)
10301031

10311032
Printf.sprintf
1032-
"link /nologo %s%s%s%s%s /implib:%s /out:%s /subsystem:%s %s %s %s"
1033+
"link /nologo %s%s%s%s%s%s /implib:%s /out:%s /subsystem:%s %s %s %s"
10331034
(if !verbose >= 2 then "/verbose " else "")
10341035
(if link_exe = `EXE then "" else "/dll ")
1035-
(if main_pgm then "" else "/export:symtbl /export:reloctbl /export:jmptbl ")
1036+
(if main_pgm then "" else "/export:symtbl /export:reloctbl ")
1037+
(if !machine = `x86 then "" else "/export:jmptbl ")
10361038
(if main_pgm then "" else if !noentry then "/noentry " else
10371039
let s =
10381040
match !machine with
@@ -1052,7 +1054,9 @@ let build_dll link_exe output_file files exts extra_args =
10521054
if main_pgm then ""
10531055
else
10541056
let def_file, oc = open_temp_file "flexlink" ".def" in
1055-
Printf.fprintf oc "EXPORTS\n reloctbl\n symtbl\n jmptbl\n";
1057+
Printf.fprintf oc "EXPORTS\n reloctbl\n symtbl\n";
1058+
if !machine = `x64 then
1059+
Printf.fprintf oc " jmptbl\n";
10561060
close_out oc;
10571061
Filename.quote def_file
10581062
in
@@ -1078,7 +1082,9 @@ let build_dll link_exe output_file files exts extra_args =
10781082
if main_pgm then ""
10791083
else
10801084
let def_file, oc = open_temp_file "flexlink" ".def" in
1081-
Printf.fprintf oc "EXPORTS\n reloctbl\n symtbl\n jmptbl\n";
1085+
Printf.fprintf oc "EXPORTS\n reloctbl\n symtbl\n";
1086+
if !machine = `x64 then
1087+
Printf.fprintf oc " jmptbl\n";
10821088
close_out oc;
10831089
Filename.quote def_file
10841090
in

0 commit comments

Comments
 (0)