Build failure for 5.1.0-RC2 on Mac OS 10.8

Jack Howarth howarth at bromo.med.uc.edu
Tue Dec 11 22:53:31 CET 2012


On Mon, Dec 10, 2012 at 11:58:46PM +0100, Torbjorn Granlund wrote:
> Oops, that code triggeres other Apple bugs.  I could reproduce it on the
> test system to which I have access.  Please try yet another valid form,
> hoping that the Apple envelope is not of negative volume...
> 

Torbjörn,
     According to the darwin linker developer, the correct modification
to the assembly generated by m4 from mod_34lsub1.asm on darwin is...

--- tmp-mod_34lsub1.s.bad	2012-12-11 14:52:43.000000000 -0500
+++ mod_34lsub1.fixed.s	2012-12-11 16:34:37.000000000 -0500
@@ -137,18 +137,25 @@
 	lea	(%r10, %r8), %r8
 	jmp	*%r8
 
-		.section	__TEXT,__const
-Ltab:	.long	L0-Ltab
-	.long	L1-Ltab
-	.long	L2-Ltab
-	.long	L3-Ltab
-	.long	L4-Ltab
-	.long	L5-Ltab
-	.long	L6-Ltab
-	.long	L7-Ltab
-	.long	L8-Ltab
+Ltab:	
+  .set LC1, L1-Ltab
+  .long	LC1
+  .set LC2, L2-Ltab
+  .long	LC2
+  .set LC3, L3-Ltab
+  .long	LC3
+  .set LC4, L4-Ltab
+  .long	LC4
+  .set LC5, L5-Ltab
+  .long	LC5
+  .set LC6, L6-Ltab
+  .long	LC6
+  .set LC7, L7-Ltab
+  .long	LC7
+  .set LC8, L8-Ltab
+  .long	LC8
+
 
-	.text
 L6:	add	(%rdi), %rax
 	adc	8(%rdi), %rcx
 	adc	16(%rdi), %rdx

and his reasoning as follows...

--------------------------------------------------

The deal is, you want the assembler to evaluate the deltas and not pass relocations on to the linker. You can see the compiler doing this is you just c
ompile a simple switch like:

[/tmp]> cat sw.c

int foo(int x) {
  switch (x) {
    case 1:
      return 5;
    case 2:
      return 53;
    case 3:
      return 22;
    case 4:
      return 51;
    case 5:
      return 33;
    case 6:
      return 78;
    case 7:
      return 11;
    case 8:
      return 91;
  }
  return 0;
}

[/tmp]> cc sw.c -Os -S
[/tmp]> cat sw.s
	.section	__TEXT,__text,regular,pure_instructions
	.globl	_foo
_foo:                                   ## @foo
	.cfi_startproc
## BB#0:
	pushq	%rbp
Ltmp2:
	.cfi_def_cfa_offset 16
Ltmp3:
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
Ltmp4:
	.cfi_def_cfa_register %rbp
                                        ## kill: EDI<def> EDI<kill> RDI<def>
	decl	%edi
	cmpl	$7, %edi
	jbe	LBB0_1
## BB#9:
	xorl	%eax, %eax
LBB0_10:
	popq	%rbp
	ret
LBB0_1:
	movl	$5, %eax
	leaq	LJTI0_0(%rip), %rdx
	movslq	(%rdx,%rdi,4), %rcx
	addq	%rdx, %rcx
	jmpq	*%rcx
LBB0_2:
	movl	$53, %eax
	jmp	LBB0_10
LBB0_3:
	movl	$22, %eax
	jmp	LBB0_10
LBB0_4:
	movl	$51, %eax
	jmp	LBB0_10
LBB0_5:
	movl	$33, %eax
	jmp	LBB0_10
LBB0_6:
	movl	$78, %eax
	jmp	LBB0_10
LBB0_7:
	movl	$11, %eax
	jmp	LBB0_10
LBB0_8:
	movl	$91, %eax
	jmp	LBB0_10
	.cfi_endproc
	.align	2, 0x90
L0_0_set_10 = LBB0_10-LJTI0_0
L0_0_set_2 = LBB0_2-LJTI0_0
L0_0_set_3 = LBB0_3-LJTI0_0
L0_0_set_4 = LBB0_4-LJTI0_0
L0_0_set_5 = LBB0_5-LJTI0_0
L0_0_set_6 = LBB0_6-LJTI0_0
L0_0_set_7 = LBB0_7-LJTI0_0
L0_0_set_8 = LBB0_8-LJTI0_0
LJTI0_0:
	.long	L0_0_set_10
	.long	L0_0_set_2
	.long	L0_0_set_3
	.long	L0_0_set_4
	.long	L0_0_set_5
	.long	L0_0_set_6
	.long	L0_0_set_7
	.long	L0_0_set_8

-----------------------------------------------------------
    Jack


> 
> -- 
> Torbjörn

> _______________________________________________
> gmp-bugs mailing list
> gmp-bugs at gmplib.org
> https://gmplib.org/mailman/listinfo/gmp-bugs



More information about the gmp-bugs mailing list