Commit 5f35e0ffcc05a72ce0aacf228dc06d1262754660

Richard Henderson 2014-11-24T16:26:50

x86: Avoid using gas local labels Which are unsupported by Darwin cctools as. Thankfully this doesn't uglify the source too much.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
diff --git a/src/x86/sysv.S b/src/x86/sysv.S
index f737371..49dc38d 100644
--- a/src/x86/sysv.S
+++ b/src/x86/sysv.S
@@ -41,6 +41,12 @@
 # define C(X)     X
 #endif
 
+#ifdef X86_DARWIN
+# define L(X)     C1(L, X)
+#else
+# define L(X)     C1(.L, X)
+#endif
+
 #ifdef __ELF__
 # define ENDF(X)  .type	X,@function; .size X, . - X
 #else
@@ -61,9 +67,9 @@
    The use of ORG asserts that we're at the correct location.  */
 /* ??? The clang assembler doesn't handle .org with symbolic expressions.  */
 #if defined(__clang__) || defined(__APPLE__)
-# define E(X)	.balign 8
+# define E(BASE, X)	.balign 8
 #else
-# define E(X)	.balign 8; .org 0b + X * 8
+# define E(BASE, X)	.balign 8; .org BASE + X * 8
 #endif
 
 	.text
@@ -113,48 +119,50 @@ ffi_call_i386:
 	andl	$X86_RET_TYPE_MASK, %ecx
 #ifdef __PIC__
 	call	C(__x86.get_pc_thunk.bx)
-1:	leal	0f-1b(%ebx, %ecx, 8), %ebx
+L(pc1):
+	leal	L(store_table)-L(pc1)(%ebx, %ecx, 8), %ebx
 #else
-	leal	0f(,%ecx, 8), %ebx
+	leal	L(store_table)(,%ecx, 8), %ebx
 #endif
 	movl	16(%ebp), %ecx		/* load result address */
 	jmp	*%ebx
 
 	.balign	8
-0:
-E(X86_RET_FLOAT)
+L(store_table):
+E(L(store_table), X86_RET_FLOAT)
 	fstps	(%ecx)
-	jmp	9f
-E(X86_RET_DOUBLE)
+	jmp	L(e1)
+E(L(store_table), X86_RET_DOUBLE)
 	fstpl	(%ecx)
-	jmp	9f
-E(X86_RET_LDOUBLE)
+	jmp	L(e1)
+E(L(store_table), X86_RET_LDOUBLE)
 	fstpt	(%ecx)
-	jmp	9f
-E(X86_RET_SINT8)
+	jmp	L(e1)
+E(L(store_table), X86_RET_SINT8)
 	movsbl	%al, %eax
 	mov	%eax, (%ecx)
-	jmp	9f
-E(X86_RET_SINT16)
+	jmp	L(e1)
+E(L(store_table), X86_RET_SINT16)
 	movswl	%ax, %eax
 	mov	%eax, (%ecx)
-	jmp	9f
-E(X86_RET_UINT8)
+	jmp	L(e1)
+E(L(store_table), X86_RET_UINT8)
 	movzbl	%al, %eax
 	mov	%eax, (%ecx)
-	jmp	9f
-E(X86_RET_UINT16)
+	jmp	L(e1)
+E(L(store_table), X86_RET_UINT16)
 	movzwl	%ax, %eax
 	mov	%eax, (%ecx)
-	jmp	9f
-E(X86_RET_INT64)
+	jmp	L(e1)
+E(L(store_table), X86_RET_INT64)
 	movl	%edx, 4(%ecx)
 	/* fallthru */
-E(X86_RET_INT32)
+E(L(store_table), X86_RET_INT32)
 	movl	%eax, (%ecx)
 	/* fallthru */
-E(X86_RET_VOID)
-9:	movl	8(%ebp), %ebx
+E(L(store_table), X86_RET_VOID)
+L(e1):
+	movl	8(%ebp), %ebx
 	movl	%ebp, %esp
 	popl	%ebp
 	cfi_remember_state
@@ -164,21 +172,21 @@ E(X86_RET_VOID)
 	ret
 	cfi_restore_state
 
-E(X86_RET_STRUCTPOP)
-	jmp	9b
-E(X86_RET_STRUCTARG)
-	jmp	9b
-E(X86_RET_STRUCT_1B)
+E(L(store_table), X86_RET_STRUCTPOP)
+	jmp	L(e1)
+E(L(store_table), X86_RET_STRUCTARG)
+	jmp	L(e1)
+E(L(store_table), X86_RET_STRUCT_1B)
 	movb	%al, (%ecx)
-	jmp	9b
-E(X86_RET_STRUCT_2B)
+	jmp	L(e1)
+E(L(store_table), X86_RET_STRUCT_2B)
 	movw	%ax, (%ecx)
-	jmp	9b
+	jmp	L(e1)
 
 	/* Fill out the table so that bad values are predictable.  */
-E(X86_RET_UNUSED14)
+E(L(store_table), X86_RET_UNUSED14)
 	ud2
-E(X86_RET_UNUSED15)
+E(L(store_table), X86_RET_UNUSED15)
 	ud2
 
 	cfi_endproc
@@ -216,18 +224,19 @@ ENDF(ffi_call_i386)
 	movl	%esp, %ecx;			/* load closure_data */	\
 	leal	closure_FS+4(%esp), %edx;	/* load incoming stack */ \
 	call	ffi_closure_inner
-#define FFI_CLOSURE_MASK_AND_JUMP					\
+#define FFI_CLOSURE_MASK_AND_JUMP(N)					\
 	andl	$X86_RET_TYPE_MASK, %eax;				\
-	leal	0f(, %eax, 8), %eax;					\
+	leal	L(C1(load_table,N))(, %eax, 8), %eax;			\
 	jmp	*%eax
 
 #ifdef __PIC__
 # if defined X86_DARWIN || defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
 #  undef FFI_CLOSURE_MASK_AND_JUMP
-#  define FFI_CLOSURE_MASK_AND_JUMP					\
+#  define FFI_CLOSURE_MASK_AND_JUMP(N)					\
 	andl	$X86_RET_TYPE_MASK, %eax;				\
 	call	C(__x86.get_pc_thunk.dx);				\
-1:	leal	0f-1b(%edx, %eax, 8), %eax;				\
+L(C1(pc,N)):								\
+	leal	L(C1(load_table,N))-L(C1(pc,N))(%edx, %eax, 8), %eax;	\
 	jmp	*%eax
 # else
 #  undef FFI_CLOSURE_CALL_INNER
@@ -237,19 +246,19 @@ ENDF(ffi_call_i386)
 	movl	%ebx, 40(%esp);			/* save ebx */		\
 	cfi_rel_offset(%ebx, 40);					\
 	call	C(__x86.get_pc_thunk.bx);	/* load got register */	\
-1:	addl	$C(_GLOBAL_OFFSET_TABLE_), %ebx;			\
+	addl	$C(_GLOBAL_OFFSET_TABLE_), %ebx;			\
 	call	ffi_closure_inner@PLT
 #  undef FFI_CLOSURE_MASK_AND_JUMP
-#  define FFI_CLOSURE_MASK_AND_JUMP					\
+#  define FFI_CLOSURE_MASK_AND_JUMP(N)					\
 	andl	$X86_RET_TYPE_MASK, %eax;				\
-	leal	0f@GOTOFF(%ebx, %eax, 8), %eax;				\
+	leal	L(C1(load_table,N))@GOTOFF(%ebx, %eax, 8), %eax;	\
 	movl	40(%esp), %ebx;			/* restore ebx */	\
 	cfi_restore(%ebx);						\
 	jmp	*%eax
 # endif /* DARWIN || HIDDEN */
 #endif /* __PIC__ */
 
-#define FFI_GO_CLOSURE(suffix, chain, t1, t2)				\
+#define FFI_GO_CLOSURE(suffix, chain, t1, t2, entry)			\
 	.balign	16;							\
 	.globl	C(C1(ffi_go_closure_,suffix));				\
 	FFI_HIDDEN(C(C1(ffi_go_closure_,suffix)));			\
@@ -264,12 +273,12 @@ C(C1(ffi_go_closure_,suffix)):						\
 	movl	t1, 28(%esp);						\
 	movl	t2, 32(%esp);						\
 	movl	chain, 36(%esp);	/* closure is user_data */	\
-	jmp	88f;							\
+	jmp	entry;							\
 	cfi_endproc;							\
 ENDF(C(C1(ffi_go_closure_,suffix)))
 
-FFI_GO_CLOSURE(EAX, %eax, %edx, %ecx)
-FFI_GO_CLOSURE(ECX, %ecx, %edx, %eax)
+FFI_GO_CLOSURE(EAX, %eax, %edx, %ecx, L(do_closure_i386))
+FFI_GO_CLOSURE(ECX, %ecx, %edx, %eax, L(do_closure_i386))
 
 /* The closure entry points are reached from the ffi_closure trampoline.
    On entry, %eax contains the address of the ffi_closure.  */
@@ -287,70 +296,72 @@ C(ffi_closure_i386):
 	FFI_CLOSURE_SAVE_REGS
 	FFI_CLOSURE_COPY_TRAMP_DATA
 
-88:	/* Entry point from preceeding Go closures.  */
+	/* Entry point from preceeding Go closures.  */
+L(do_closure_i386):
 
 	FFI_CLOSURE_CALL_INNER
-	FFI_CLOSURE_MASK_AND_JUMP
+	FFI_CLOSURE_MASK_AND_JUMP(2)
 
 	.balign	8
-0:
-E(X86_RET_FLOAT)
+L(load_table2):
+E(L(load_table2), X86_RET_FLOAT)
 	flds	(%esp)
-	jmp	9f
-E(X86_RET_DOUBLE)
+	jmp	L(e2)
+E(L(load_table2), X86_RET_DOUBLE)
 	fldl	(%esp)
-	jmp	9f
-E(X86_RET_LDOUBLE)
+	jmp	L(e2)
+E(L(load_table2), X86_RET_LDOUBLE)
 	fldt	(%esp)
-	jmp	9f
-E(X86_RET_SINT8)
+	jmp	L(e2)
+E(L(load_table2), X86_RET_SINT8)
 	movsbl	(%esp), %eax
-	jmp	9f
-E(X86_RET_SINT16)
+	jmp	L(e2)
+E(L(load_table2), X86_RET_SINT16)
 	movswl	(%esp), %eax
-	jmp	9f
-E(X86_RET_UINT8)
+	jmp	L(e2)
+E(L(load_table2), X86_RET_UINT8)
 	movzbl	(%esp), %eax
-	jmp	9f
-E(X86_RET_UINT16)
+	jmp	L(e2)
+E(L(load_table2), X86_RET_UINT16)
 	movzwl	(%esp), %eax
-	jmp	9f
-E(X86_RET_INT64)
+	jmp	L(e2)
+E(L(load_table2), X86_RET_INT64)
 	movl	4(%esp), %edx
 	/* fallthru */
-E(X86_RET_INT32)
+E(L(load_table2), X86_RET_INT32)
 	movl	(%esp), %eax
 	/* fallthru */
-E(X86_RET_VOID)
-9:	addl	$closure_FS, %esp
+E(L(load_table2), X86_RET_VOID)
+L(e2):
+	addl	$closure_FS, %esp
 	cfi_adjust_cfa_offset(-closure_FS)
 	ret
 	cfi_adjust_cfa_offset(closure_FS)
-E(X86_RET_STRUCTPOP)
+E(L(load_table2), X86_RET_STRUCTPOP)
 	addl	$closure_FS, %esp
 	cfi_adjust_cfa_offset(-closure_FS)
 	ret	$4
 	cfi_adjust_cfa_offset(closure_FS)
-E(X86_RET_STRUCTARG)
+E(L(load_table2), X86_RET_STRUCTARG)
 	movl	(%esp), %eax
-	jmp	9b
-E(X86_RET_STRUCT_1B)
+	jmp	L(e2)
+E(L(load_table2), X86_RET_STRUCT_1B)
 	movzbl	(%esp), %eax
-	jmp	9b
-E(X86_RET_STRUCT_2B)
+	jmp	L(e2)
+E(L(load_table2), X86_RET_STRUCT_2B)
 	movzwl	(%esp), %eax
-	jmp	9b
+	jmp	L(e2)
 
 	/* Fill out the table so that bad values are predictable.  */
-E(X86_RET_UNUSED14)
+E(L(load_table2), X86_RET_UNUSED14)
 	ud2
-E(X86_RET_UNUSED15)
+E(L(load_table2), X86_RET_UNUSED15)
 	ud2
 
 	cfi_endproc
 ENDF(C(ffi_closure_i386))
 
-FFI_GO_CLOSURE(STDCALL, %ecx, %edx, %eax)
+FFI_GO_CLOSURE(STDCALL, %ecx, %edx, %eax, L(do_closure_STDCALL))
 
 /* For REGISTER, we have no available parameter registers, and so we
    enter here having pushed the closure onto the stack.  */
@@ -371,7 +382,7 @@ C(ffi_closure_REGISTER):
 	movl	closure_FS-4(%esp), %ecx	/* load retaddr */
 	movl	closure_FS(%esp), %eax		/* load closure */
 	movl	%ecx, closure_FS(%esp)		/* move retaddr */
-	jmp	0f
+	jmp	L(do_closure_REGISTER)
 
 	cfi_endproc
 ENDF(C(ffi_closure_REGISTER))
@@ -391,11 +402,13 @@ C(ffi_closure_STDCALL):
 
 	FFI_CLOSURE_SAVE_REGS
 
-0:	/* Entry point from ffi_closure_REGISTER.  */
+	/* Entry point from ffi_closure_REGISTER.  */
+L(do_closure_REGISTER):
 
 	FFI_CLOSURE_COPY_TRAMP_DATA
 
-88:	/* Entry point from preceeding Go closure.  */
+	/* Entry point from preceeding Go closure.  */
+L(do_closure_STDCALL):
 
 	FFI_CLOSURE_CALL_INNER
 
@@ -411,70 +424,70 @@ C(ffi_closure_STDCALL):
 	   there is always a window between the mov and the ret which
 	   will be wrong from one point of view or another.  */
 
-	FFI_CLOSURE_MASK_AND_JUMP
+	FFI_CLOSURE_MASK_AND_JUMP(3)
 
 	.balign	8
-0:
-E(X86_RET_FLOAT)
+L(load_table3):
+E(L(load_table3), X86_RET_FLOAT)
 	flds    (%esp)
 	movl    %ecx, %esp
 	ret
-E(X86_RET_DOUBLE)
+E(L(load_table3), X86_RET_DOUBLE)
 	fldl    (%esp)
 	movl    %ecx, %esp
 	ret
-E(X86_RET_LDOUBLE)
+E(L(load_table3), X86_RET_LDOUBLE)
 	fldt    (%esp)
 	movl    %ecx, %esp
 	ret
-E(X86_RET_SINT8)
+E(L(load_table3), X86_RET_SINT8)
 	movsbl  (%esp), %eax
 	movl    %ecx, %esp
 	ret
-E(X86_RET_SINT16)
+E(L(load_table3), X86_RET_SINT16)
 	movswl  (%esp), %eax
 	movl    %ecx, %esp
 	ret
-E(X86_RET_UINT8)
+E(L(load_table3), X86_RET_UINT8)
 	movzbl  (%esp), %eax
 	movl    %ecx, %esp
 	ret
-E(X86_RET_UINT16)
+E(L(load_table3), X86_RET_UINT16)
 	movzwl  (%esp), %eax
 	movl    %ecx, %esp
 	ret
-E(X86_RET_INT64)
+E(L(load_table3), X86_RET_INT64)
 	popl    %eax
 	popl    %edx
 	movl    %ecx, %esp
 	ret
-E(X86_RET_INT32)
+E(L(load_table3), X86_RET_INT32)
 	movl    (%esp), %eax
 	movl    %ecx, %esp
 	ret
-E(X86_RET_VOID)
+E(L(load_table3), X86_RET_VOID)
 	movl    %ecx, %esp
 	ret
-E(X86_RET_STRUCTPOP)
+E(L(load_table3), X86_RET_STRUCTPOP)
 	movl    %ecx, %esp
 	ret
-E(X86_RET_STRUCTARG)
+E(L(load_table3), X86_RET_STRUCTARG)
 	movl	(%esp), %eax
 	movl	%ecx, %esp
 	ret
-E(X86_RET_STRUCT_1B)
+E(L(load_table3), X86_RET_STRUCT_1B)
 	movzbl	(%esp), %eax
 	movl	%ecx, %esp
 	ret
-E(X86_RET_STRUCT_2B)
+E(L(load_table3), X86_RET_STRUCT_2B)
 	movzwl	(%esp), %eax
 	movl	%ecx, %esp
 	ret
 
 	/* Fill out the table so that bad values are predictable.  */
-E(X86_RET_UNUSED14)
+E(L(load_table3), X86_RET_UNUSED14)
 	ud2
-E(X86_RET_UNUSED15)
+E(L(load_table3), X86_RET_UNUSED15)
 	ud2
 
 	cfi_endproc
@@ -509,67 +522,69 @@ C(ffi_closure_raw_SYSV):
 	andl	$X86_RET_TYPE_MASK, %eax
 #ifdef __PIC__
 	call	C(__x86.get_pc_thunk.bx)
-1:	leal	0f-1b(%ebx, %eax, 8), %eax
+L(pc4):
+	leal	L(load_table4)-L(pc4)(%ebx, %eax, 8), %eax
 #else
-	leal	0f(,%eax, 8), %eax
+	leal	L(load_table4)(,%eax, 8), %eax
 #endif
 	movl	raw_closure_S_FS-4(%esp), %ebx
 	cfi_restore(%ebx)
 	jmp	*%eax
 
 	.balign	8
-0:
-E(X86_RET_FLOAT)
+L(load_table4):
+E(L(load_table4), X86_RET_FLOAT)
 	flds	16(%esp)
-	jmp	9f
-E(X86_RET_DOUBLE)
+	jmp	L(e4)
+E(L(load_table4), X86_RET_DOUBLE)
 	fldl	16(%esp)
-	jmp	9f
-E(X86_RET_LDOUBLE)
+	jmp	L(e4)
+E(L(load_table4), X86_RET_LDOUBLE)
 	fldt	16(%esp)
-	jmp	9f
-E(X86_RET_SINT8)
+	jmp	L(e4)
+E(L(load_table4), X86_RET_SINT8)
 	movsbl	16(%esp), %eax
-	jmp	9f
-E(X86_RET_SINT16)
+	jmp	L(e4)
+E(L(load_table4), X86_RET_SINT16)
 	movswl	16(%esp), %eax
-	jmp	9f
-E(X86_RET_UINT8)
+	jmp	L(e4)
+E(L(load_table4), X86_RET_UINT8)
 	movzbl	16(%esp), %eax
-	jmp	9f
-E(X86_RET_UINT16)
+	jmp	L(e4)
+E(L(load_table4), X86_RET_UINT16)
 	movzwl	16(%esp), %eax
-	jmp	9f
-E(X86_RET_INT64)
+	jmp	L(e4)
+E(L(load_table4), X86_RET_INT64)
 	movl	16+4(%esp), %edx
 	/* fallthru */
-E(X86_RET_INT32)
+E(L(load_table4), X86_RET_INT32)
 	movl	16(%esp), %eax
 	/* fallthru */
-E(X86_RET_VOID)
-9:	addl	$raw_closure_S_FS, %esp
+E(L(load_table4), X86_RET_VOID)
+L(e4):
+	addl	$raw_closure_S_FS, %esp
 	cfi_adjust_cfa_offset(-raw_closure_S_FS)
 	ret
 	cfi_adjust_cfa_offset(raw_closure_S_FS)
-E(X86_RET_STRUCTPOP)
+E(L(load_table4), X86_RET_STRUCTPOP)
 	addl	$raw_closure_S_FS, %esp
 	cfi_adjust_cfa_offset(-raw_closure_S_FS)
 	ret	$4
 	cfi_adjust_cfa_offset(raw_closure_S_FS)
-E(X86_RET_STRUCTARG)
+E(L(load_table4), X86_RET_STRUCTARG)
 	movl	16(%esp), %eax
-	jmp	9b
-E(X86_RET_STRUCT_1B)
+	jmp	L(e4)
+E(L(load_table4), X86_RET_STRUCT_1B)
 	movzbl	16(%esp), %eax
-	jmp	9b
-E(X86_RET_STRUCT_2B)
+	jmp	L(e4)
+E(L(load_table4), X86_RET_STRUCT_2B)
 	movzwl	16(%esp), %eax
-	jmp	9b
+	jmp	L(e4)
 
 	/* Fill out the table so that bad values are predictable.  */
-E(X86_RET_UNUSED14)
+E(L(load_table4), X86_RET_UNUSED14)
 	ud2
-E(X86_RET_UNUSED15)
+E(L(load_table4), X86_RET_UNUSED15)
 	ud2
 
 	cfi_endproc
@@ -613,68 +628,70 @@ C(ffi_closure_raw_THISCALL):
 	andl	$X86_RET_TYPE_MASK, %eax
 #ifdef __PIC__
 	call	C(__x86.get_pc_thunk.bx)
-1:	leal	0f-1b(%ebx, %eax, 8), %eax
+L(pc5):
+	leal	L(load_table5)-L(pc5)(%ebx, %eax, 8), %eax
 #else
-	leal	0f(,%eax, 8), %eax
+	leal	L(load_table5)(,%eax, 8), %eax
 #endif
 	movl	raw_closure_T_FS-4(%esp), %ebx
 	cfi_restore(%ebx)
 	jmp	*%eax
 
 	.balign	8
-0:
-E(X86_RET_FLOAT)
+L(load_table5):
+E(L(load_table5), X86_RET_FLOAT)
 	flds	16(%esp)
-	jmp	9f
-E(X86_RET_DOUBLE)
+	jmp	L(e5)
+E(L(load_table5), X86_RET_DOUBLE)
 	fldl	16(%esp)
-	jmp	9f
-E(X86_RET_LDOUBLE)
+	jmp	L(e5)
+E(L(load_table5), X86_RET_LDOUBLE)
 	fldt	16(%esp)
-	jmp	9f
-E(X86_RET_SINT8)
+	jmp	L(e5)
+E(L(load_table5), X86_RET_SINT8)
 	movsbl	16(%esp), %eax
-	jmp	9f
-E(X86_RET_SINT16)
+	jmp	L(e5)
+E(L(load_table5), X86_RET_SINT16)
 	movswl	16(%esp), %eax
-	jmp	9f
-E(X86_RET_UINT8)
+	jmp	L(e5)
+E(L(load_table5), X86_RET_UINT8)
 	movzbl	16(%esp), %eax
-	jmp	9f
-E(X86_RET_UINT16)
+	jmp	L(e5)
+E(L(load_table5), X86_RET_UINT16)
 	movzwl	16(%esp), %eax
-	jmp	9f
-E(X86_RET_INT64)
+	jmp	L(e5)
+E(L(load_table5), X86_RET_INT64)
 	movl	16+4(%esp), %edx
 	/* fallthru */
-E(X86_RET_INT32)
+E(L(load_table5), X86_RET_INT32)
 	movl	16(%esp), %eax
 	/* fallthru */
-E(X86_RET_VOID)
-9:	addl	$raw_closure_T_FS, %esp
+E(L(load_table5), X86_RET_VOID)
+L(e5):
+	addl	$raw_closure_T_FS, %esp
 	cfi_adjust_cfa_offset(-raw_closure_T_FS)
 	/* Remove the extra %ecx argument we pushed.  */
 	ret	$4
 	cfi_adjust_cfa_offset(raw_closure_T_FS)
-E(X86_RET_STRUCTPOP)
+E(L(load_table5), X86_RET_STRUCTPOP)
 	addl	$raw_closure_T_FS, %esp
 	cfi_adjust_cfa_offset(-raw_closure_T_FS)
 	ret	$8
 	cfi_adjust_cfa_offset(raw_closure_T_FS)
-E(X86_RET_STRUCTARG)
+E(L(load_table5), X86_RET_STRUCTARG)
 	movl	16(%esp), %eax
-	jmp	9b
-E(X86_RET_STRUCT_1B)
+	jmp	L(e5)
+E(L(load_table5), X86_RET_STRUCT_1B)
 	movzbl	16(%esp), %eax
-	jmp	9b
-E(X86_RET_STRUCT_2B)
+	jmp	L(e5)
+E(L(load_table5), X86_RET_STRUCT_2B)
 	movzwl	16(%esp), %eax
-	jmp	9b
+	jmp	L(e5)
 
 	/* Fill out the table so that bad values are predictable.  */
-E(X86_RET_UNUSED14)
+E(L(load_table5), X86_RET_UNUSED14)
 	ud2
-E(X86_RET_UNUSED15)
+E(L(load_table5), X86_RET_UNUSED15)
 	ud2
 
 	cfi_endproc
diff --git a/src/x86/unix64.S b/src/x86/unix64.S
index 42880d5..4c32213 100644
--- a/src/x86/unix64.S
+++ b/src/x86/unix64.S
@@ -43,6 +43,12 @@
 # define C(X)     X
 #endif
 
+#ifdef __APPLE__
+# define L(X)     C1(L, X)
+#else
+# define L(X)     C1(.L, X)
+#endif
+
 #ifdef __ELF__
 # define PLT(X)	  X@PLT
 # define ENDF(X)  .type	X,@function; .size X, . - X
@@ -55,12 +61,11 @@
    actual table.  The entry points into the table are all 8 bytes.
    The use of ORG asserts that we're at the correct location.  */
 /* ??? The clang assembler doesn't handle .org with symbolic expressions.  */
-.macro E index
-	.balign	8
-#if !defined(__clang__) && !defined(__APPLE__)
-	.org	0b + \index * 8, 0x90
+#if defined(__clang__) || defined(__APPLE__)
+# define E(BASE, X)	.balign 8
+#else
+# define E(BASE, X)	.balign 8; .org BASE + X * 8
 #endif
-.endm
 
 /* ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags,
 	            void *raddr, void (*fnaddr)(void));
@@ -106,8 +111,8 @@ C(ffi_call_unix64):
 	movq	0x28(%r10), %r9
 	movl	0xb0(%r10), %eax
 	testl	%eax, %eax
-	jnz	.Lload_sse
-.Lret_from_load_sse:
+	jnz	L(load_sse)
+L(ret_from_load_sse):
 
 	/* Deallocate the reg arg area, except for r10, then load via pop.  */
 	leaq	0xb8(%r10), %rsp
@@ -129,8 +134,8 @@ C(ffi_call_unix64):
 	/* The first byte of the flags contains the FFI_TYPE.  */
 	cmpb	$UNIX64_RET_LAST, %cl
 	movzbl	%cl, %r10d
-	leaq	0f(%rip), %r11
-	ja	9f
+	leaq	L(store_table)(%rip), %r11
+	ja	L(sa)
 	leaq	(%r11, %r10, 8), %r10
 
 	/* Prep for the structure cases: scratch area in redzone.  */
@@ -138,78 +143,80 @@ C(ffi_call_unix64):
 	jmp	*%r10
 
 	.balign	8
-0:
-E UNIX64_RET_VOID
+L(store_table):
+E(L(store_table), UNIX64_RET_VOID)
 	ret
-E UNIX64_RET_UINT8
+E(L(store_table), UNIX64_RET_UINT8)
 	movzbl	%al, %eax
 	movq	%rax, (%rdi)
 	ret
-E UNIX64_RET_UINT16
+E(L(store_table), UNIX64_RET_UINT16)
 	movzwl	%ax, %eax
 	movq	%rax, (%rdi)
 	ret
-E UNIX64_RET_UINT32
+E(L(store_table), UNIX64_RET_UINT32)
 	movl	%eax, %eax
 	movq	%rax, (%rdi)
 	ret
-E UNIX64_RET_SINT8
+E(L(store_table), UNIX64_RET_SINT8)
 	movsbq	%al, %rax
 	movq	%rax, (%rdi)
 	ret
-E UNIX64_RET_SINT16
+E(L(store_table), UNIX64_RET_SINT16)
 	movswq	%ax, %rax
 	movq	%rax, (%rdi)
 	ret
-E UNIX64_RET_SINT32
+E(L(store_table), UNIX64_RET_SINT32)
 	cltq
 	movq	%rax, (%rdi)
 	ret
-E UNIX64_RET_INT64
+E(L(store_table), UNIX64_RET_INT64)
 	movq	%rax, (%rdi)
 	ret
-E UNIX64_RET_XMM32
+E(L(store_table), UNIX64_RET_XMM32)
 	movd	%xmm0, (%rdi)
 	ret
-E UNIX64_RET_XMM64
+E(L(store_table), UNIX64_RET_XMM64)
 	movq	%xmm0, (%rdi)
 	ret
-E UNIX64_RET_X87
+E(L(store_table), UNIX64_RET_X87)
 	fstpt	(%rdi)
 	ret
-E UNIX64_RET_X87_2
+E(L(store_table), UNIX64_RET_X87_2)
 	fstpt	(%rdi)
 	fstpt	16(%rdi)
 	ret
-E UNIX64_RET_ST_XMM0_RAX
+E(L(store_table), UNIX64_RET_ST_XMM0_RAX)
 	movq	%rax, 8(%rsi)
-	jmp	3f
-E UNIX64_RET_ST_RAX_XMM0
+	jmp	L(s3)
+E(L(store_table), UNIX64_RET_ST_RAX_XMM0)
 	movq	%xmm0, 8(%rsi)
-	jmp	2f
-E UNIX64_RET_ST_XMM0_XMM1
+	jmp	L(s2)
+E(L(store_table), UNIX64_RET_ST_XMM0_XMM1)
 	movq	%xmm1, 8(%rsi)
-	jmp	3f
-E UNIX64_RET_ST_RAX_RDX
+	jmp	L(s3)
+E(L(store_table), UNIX64_RET_ST_RAX_RDX)
 	movq	%rdx, 8(%rsi)
-2:	movq	%rax, (%rsi)
+L(s2):
+	movq	%rax, (%rsi)
 	shrl	$UNIX64_SIZE_SHIFT, %ecx
 	rep movsb
 	ret
 	.balign 8
-3:	movq	%xmm0, (%rsi)
+L(s3):
+	movq	%xmm0, (%rsi)
 	shrl	$UNIX64_SIZE_SHIFT, %ecx
 	rep movsb
 	ret
 
-9:	call	PLT(C(abort))
+L(sa):	call	PLT(C(abort))
 
 	/* Many times we can avoid loading any SSE registers at all.
 	   It's not worth an indirect jump to load the exact set of
 	   SSE registers needed; zero or all is a good compromise.  */
 	.balign 2
 	cfi_restore_state
-.Lload_sse:
+L(load_sse):
 	movdqa	0x30(%r10), %xmm0
 	movdqa	0x40(%r10), %xmm1
 	movdqa	0x50(%r10), %xmm2
@@ -218,7 +225,7 @@ E UNIX64_RET_ST_RAX_RDX
 	movdqa	0x80(%r10), %xmm5
 	movdqa	0x90(%r10), %xmm6
 	movdqa	0xa0(%r10), %xmm7
-	jmp	.Lret_from_load_sse
+	jmp	L(ret_from_load_sse)
 
 	cfi_endproc
 ENDF(C(ffi_call_unix64))
@@ -251,7 +258,7 @@ C(ffi_closure_unix64_sse):
 	movdqa	%xmm5, ffi_closure_OFS_V+0x50(%rsp)
 	movdqa	%xmm6, ffi_closure_OFS_V+0x60(%rsp)
 	movdqa	%xmm7, ffi_closure_OFS_V+0x70(%rsp)
-	jmp	0f
+	jmp	L(sse_entry1)
 
 	cfi_endproc
 ENDF(C(ffi_closure_unix64_sse))
@@ -265,7 +272,7 @@ C(ffi_closure_unix64):
 	subq	$ffi_closure_FS, %rsp
 	/* Note clang bug 21515: adjust_cfa_offset error across endproc.  */
 	cfi_def_cfa_offset(ffi_closure_FS + 8)
-0:
+L(sse_entry1):
 	movq	%rdi, ffi_closure_OFS_G+0x00(%rsp)
 	movq    %rsi, ffi_closure_OFS_G+0x08(%rsp)
 	movq    %rdx, ffi_closure_OFS_G+0x10(%rsp)
@@ -282,7 +289,7 @@ C(ffi_closure_unix64):
 	movq	FFI_TRAMPOLINE_SIZE+8(%r10), %rsi	/* Load fun */
 	movq	FFI_TRAMPOLINE_SIZE+16(%r10), %rdx	/* Load user_data */
 #endif
-.Ldo_closure:
+L(do_closure):
 	leaq	ffi_closure_OFS_RVALUE(%rsp), %rcx	/* Load rvalue */
 	movq	%rsp, %r8				/* Load reg_args */
 	leaq	ffi_closure_FS+8(%rsp), %r9		/* Load argp */
@@ -295,68 +302,70 @@ C(ffi_closure_unix64):
 	/* The first byte of the return value contains the FFI_TYPE.  */
 	cmpb	$UNIX64_RET_LAST, %al
 	movzbl	%al, %r10d
-	leaq	0f(%rip), %r11
-	ja	9f
+	leaq	L(load_table)(%rip), %r11
+	ja	L(la)
 	leaq	(%r11, %r10, 8), %r10
 	leaq	ffi_closure_RED_RVALUE(%rsp), %rsi
 	jmp	*%r10
 
 	.balign	8
-0:
-E UNIX64_RET_VOID
+L(load_table):
+E(L(load_table), UNIX64_RET_VOID)
 	ret
-E UNIX64_RET_UINT8
+E(L(load_table), UNIX64_RET_UINT8)
 	movzbl	(%rsi), %eax
 	ret
-E UNIX64_RET_UINT16
+E(L(load_table), UNIX64_RET_UINT16)
 	movzwl	(%rsi), %eax
 	ret
-E UNIX64_RET_UINT32
+E(L(load_table), UNIX64_RET_UINT32)
 	movl	(%rsi), %eax
 	ret
-E UNIX64_RET_SINT8
+E(L(load_table), UNIX64_RET_SINT8)
 	movsbl	(%rsi), %eax
 	ret
-E UNIX64_RET_SINT16
+E(L(load_table), UNIX64_RET_SINT16)
 	movswl	(%rsi), %eax
 	ret
-E UNIX64_RET_SINT32
+E(L(load_table), UNIX64_RET_SINT32)
 	movl	(%rsi), %eax
 	ret
-E UNIX64_RET_INT64
+E(L(load_table), UNIX64_RET_INT64)
 	movq	(%rsi), %rax
 	ret
-E UNIX64_RET_XMM32
+E(L(load_table), UNIX64_RET_XMM32)
 	movd	(%rsi), %xmm0
 	ret
-E UNIX64_RET_XMM64
+E(L(load_table), UNIX64_RET_XMM64)
 	movq	(%rsi), %xmm0
 	ret
-E UNIX64_RET_X87
+E(L(load_table), UNIX64_RET_X87)
 	fldt	(%rsi)
 	ret
-E UNIX64_RET_X87_2
+E(L(load_table), UNIX64_RET_X87_2)
 	fldt	16(%rsi)
 	fldt	(%rsi)
 	ret
-E UNIX64_RET_ST_XMM0_RAX
+E(L(load_table), UNIX64_RET_ST_XMM0_RAX)
 	movq	8(%rsi), %rax
-	jmp	3f
-E UNIX64_RET_ST_RAX_XMM0
+	jmp	L(l3)
+E(L(load_table), UNIX64_RET_ST_RAX_XMM0)
 	movq	8(%rsi), %xmm0
-	jmp	2f
-E UNIX64_RET_ST_XMM0_XMM1
+	jmp	L(l2)
+E(L(load_table), UNIX64_RET_ST_XMM0_XMM1)
 	movq	8(%rsi), %xmm1
-	jmp	3f
-E UNIX64_RET_ST_RAX_RDX
+	jmp	L(l3)
+E(L(load_table), UNIX64_RET_ST_RAX_RDX)
 	movq	8(%rsi), %rdx
-2:	movq	(%rsi), %rax
+L(l2):
+	movq	(%rsi), %rax
 	ret
 	.balign	8
-3:	movq	(%rsi), %xmm0
+L(l3):
+	movq	(%rsi), %xmm0
 	ret
 
-9:	call	PLT(C(abort))
+L(la):	call	PLT(C(abort))
 
 	cfi_endproc
 ENDF(C(ffi_closure_unix64))
@@ -379,7 +388,7 @@ C(ffi_go_closure_unix64_sse):
 	movdqa	%xmm5, ffi_closure_OFS_V+0x50(%rsp)
 	movdqa	%xmm6, ffi_closure_OFS_V+0x60(%rsp)
 	movdqa	%xmm7, ffi_closure_OFS_V+0x70(%rsp)
-	jmp	0f
+	jmp	L(sse_entry2)
 
 	cfi_endproc
 ENDF(C(ffi_go_closure_unix64_sse))
@@ -393,7 +402,7 @@ C(ffi_go_closure_unix64):
 	subq	$ffi_closure_FS, %rsp
 	/* Note clang bug 21515: adjust_cfa_offset error across endproc.  */
 	cfi_def_cfa_offset(ffi_closure_FS + 8)
-0:
+L(sse_entry2):
 	movq	%rdi, ffi_closure_OFS_G+0x00(%rsp)
 	movq    %rsi, ffi_closure_OFS_G+0x08(%rsp)
 	movq    %rdx, ffi_closure_OFS_G+0x10(%rsp)
@@ -410,7 +419,7 @@ C(ffi_go_closure_unix64):
 	movq	16(%r10), %rsi		/* Load fun */
 	movq	%r10, %rdx		/* Load closure (user_data) */
 #endif
-	jmp	.Ldo_closure
+	jmp	L(do_closure)
 
 	cfi_endproc
 ENDF(C(ffi_go_closure_unix64))