Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Feb 2013 00:31:50 +0400
From:      Lev Serebryakov <lev@FreeBSD.org>
To:        Dimitry Andric <dimitry@andric.com>,  freebsd-current <freebsd-current@freebsd.org>
Subject:   Re: r245741 (clang as cc) can not build binaries for GEODE processor
Message-ID:  <136287724.20130223003150@serebryakov.spb.ru>
In-Reply-To: <386635586.20130223001445@serebryakov.spb.ru>
References:  <108875110.20130222104603@serebryakov.spb.ru> <51277EFE.4000703@andric.com> <15917508.20130222194954@serebryakov.spb.ru> <5127997A.2000901@andric.com> <386635586.20130223001445@serebryakov.spb.ru>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
Hello, Lev.
You wrote 23 февраля 2013 г., 0:14:45:

LS> Hello, Dimitry.
LS> You wrote 22 февраля 2013 г., 20:14:50:

DA>> As Joerg Sonnenberger mentioned to me, the address 0x10351d6 you show in
DA>> the gdb session seems to be quite high, possibly pointing to some shared
DA>> library.  Maybe you can try to figure out which library it is?
LS> Here  is two long NOPs in output of clang in -CURRENT without "-march"
LS> options:

LS> objdump -d test

LS> 080483a0 <_start1>:
LS> ...
LS>  80483e8:       40                      inc    %eax
LS>  80483e9:       0f 1f 80 00 00 00 00    nopl   0x0(%eax)
LS>  80483f0:       8a 08                   mov    (%eax),%cl
LS> ...
LS>  8048496:       31 ff                   xor    %edi,%edi
LS>  8048498:       0f 1f 84 00 00 00 00    nopl   0x0(%eax,%eax,1)
LS>  804849f:       00 
LS>  80484a0:       8b 04 bd 68 96 04 08    mov    0x8049668(,%edi,4),%eax
  And  sample code is EXACTLY THE SAME with "-march=geode" and crashes the
 same!

 I'm puzzled, why system binaries works in such case!?

 But disassembly of system binaries (for example, /usr/bin/who)
doesn't contains "nopl" at all!

 I've attached disassembly of "start1" form:

 (a) unstripped "who" command built in "make buildworld" stage with
     CPUTYPE=geode set.
 (b) unstripped "Hello world" program, built with simple "cc -o test \
     test.c" (contains "nopl")
 (c) unstripped "Hello world" program, built with simple "cc \
     -march=geode -o test.geode test.c" (contains "nopl" too!)

  Oh, I see... "start1" is linked from startup code like crt0.o, am I
right?

  So, rebuilding only ports with "CPUTYPE=geode" will not help!

  But, in any case, it seems to be bug in clang to generate such
  instructions in "default" case.

-- 
// Black Lion AKA Lev Serebryakov <lev@FreeBSD.org>
[-- Attachment #2 --]
080483a0 <_start1>:
 80483a0:	55                   	push   %ebp
 80483a1:	89 e5                	mov    %esp,%ebp
 80483a3:	53                   	push   %ebx
 80483a4:	57                   	push   %edi
 80483a5:	56                   	push   %esi
 80483a6:	83 ec 10             	sub    $0x10,%esp
 80483a9:	8b 45 0c             	mov    0xc(%ebp),%eax
 80483ac:	8b 5d 10             	mov    0x10(%ebp),%ebx
 80483af:	8d 44 83 04          	lea    0x4(%ebx,%eax,4),%eax
 80483b3:	81 3d 60 97 04 08 00 	cmpl   $0x0,0x8049760
 80483ba:	00 00 00 
 80483bd:	75 05                	jne    80483c4 <_start1+0x24>
 80483bf:	a3 60 97 04 08       	mov    %eax,0x8049760
 80483c4:	89 45 f0             	mov    %eax,-0x10(%ebp)
 80483c7:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
 80483cb:	7e 2e                	jle    80483fb <_start1+0x5b>
 80483cd:	8b 03                	mov    (%ebx),%eax
 80483cf:	85 c0                	test   %eax,%eax
 80483d1:	74 28                	je     80483fb <_start1+0x5b>
 80483d3:	eb 0c                	jmp    80483e1 <_start1+0x41>
 80483d5:	66 66 2e 0f 1f 84 00 	nopw   %cs:0x0(%eax,%eax,1)
 80483dc:	00 00 00 00 
 80483e0:	40                   	inc    %eax
 80483e1:	a3 50 97 04 08       	mov    %eax,0x8049750
 80483e6:	eb 08                	jmp    80483f0 <_start1+0x50>
 80483e8:	40                   	inc    %eax
 80483e9:	0f 1f 80 00 00 00 00 	nopl   0x0(%eax)
 80483f0:	8a 08                	mov    (%eax),%cl
 80483f2:	80 f9 2f             	cmp    $0x2f,%cl
 80483f5:	74 e9                	je     80483e0 <_start1+0x40>
 80483f7:	84 c9                	test   %cl,%cl
 80483f9:	75 ed                	jne    80483e8 <_start1+0x48>
 80483fb:	b8 7c 96 04 08       	mov    $0x804967c,%eax
 8048400:	85 c0                	test   %eax,%eax
 8048402:	74 0d                	je     8048411 <_start1+0x71>
 8048404:	8b 45 08             	mov    0x8(%ebp),%eax
 8048407:	89 04 24             	mov    %eax,(%esp)
 804840a:	e8 41 ff ff ff       	call   8048350 <atexit@plt>
 804840f:	eb 05                	jmp    8048416 <_start1+0x76>
 8048411:	e8 4a ff ff ff       	call   8048360 <_init_tls@plt>
 8048416:	b8 7c 96 04 08       	mov    $0x804967c,%eax
 804841b:	85 c0                	test   %eax,%eax
 804841d:	0f 85 a1 00 00 00    	jne    80484c4 <_start1+0x124>
 8048423:	c7 04 24 f0 84 04 08 	movl   $0x80484f0,(%esp)
 804842a:	b9 68 96 04 08       	mov    $0x8049668,%ecx
 804842f:	b8 68 96 04 08       	mov    $0x8049668,%eax
 8048434:	29 c8                	sub    %ecx,%eax
 8048436:	89 c6                	mov    %eax,%esi
 8048438:	c1 fe 1f             	sar    $0x1f,%esi
 804843b:	c1 ee 1e             	shr    $0x1e,%esi
 804843e:	01 c6                	add    %eax,%esi
 8048440:	c1 fe 02             	sar    $0x2,%esi
 8048443:	e8 08 ff ff ff       	call   8048350 <atexit@plt>
 8048448:	85 f6                	test   %esi,%esi
 804844a:	74 28                	je     8048474 <_start1+0xd4>
 804844c:	31 ff                	xor    %edi,%edi
 804844e:	66 90                	xchg   %ax,%ax
 8048450:	8b 04 bd 68 96 04 08 	mov    0x8049668(,%edi,4),%eax
 8048457:	83 f8 02             	cmp    $0x2,%eax
 804845a:	72 13                	jb     804846f <_start1+0xcf>
 804845c:	8b 4d f0             	mov    -0x10(%ebp),%ecx
 804845f:	89 4c 24 08          	mov    %ecx,0x8(%esp)
 8048463:	89 5c 24 04          	mov    %ebx,0x4(%esp)
 8048467:	8b 4d 0c             	mov    0xc(%ebp),%ecx
 804846a:	89 0c 24             	mov    %ecx,(%esp)
 804846d:	ff d0                	call   *%eax
 804846f:	47                   	inc    %edi
 8048470:	39 f7                	cmp    %esi,%edi
 8048472:	72 dc                	jb     8048450 <_start1+0xb0>
 8048474:	b9 68 96 04 08       	mov    $0x8049668,%ecx
 8048479:	b8 68 96 04 08       	mov    $0x8049668,%eax
 804847e:	29 c8                	sub    %ecx,%eax
 8048480:	89 c6                	mov    %eax,%esi
 8048482:	c1 fe 1f             	sar    $0x1f,%esi
 8048485:	c1 ee 1e             	shr    $0x1e,%esi
 8048488:	01 c6                	add    %eax,%esi
 804848a:	c1 fe 02             	sar    $0x2,%esi
 804848d:	e8 8a fe ff ff       	call   804831c <_init>
 8048492:	85 f6                	test   %esi,%esi
 8048494:	74 2e                	je     80484c4 <_start1+0x124>
 8048496:	31 ff                	xor    %edi,%edi
 8048498:	0f 1f 84 00 00 00 00 	nopl   0x0(%eax,%eax,1)
 804849f:	00 
 80484a0:	8b 04 bd 68 96 04 08 	mov    0x8049668(,%edi,4),%eax
 80484a7:	83 f8 02             	cmp    $0x2,%eax
 80484aa:	72 13                	jb     80484bf <_start1+0x11f>
 80484ac:	8b 4d f0             	mov    -0x10(%ebp),%ecx
 80484af:	89 4c 24 08          	mov    %ecx,0x8(%esp)
 80484b3:	89 5c 24 04          	mov    %ebx,0x4(%esp)
 80484b7:	8b 4d 0c             	mov    0xc(%ebp),%ecx
 80484ba:	89 0c 24             	mov    %ecx,(%esp)
 80484bd:	ff d0                	call   *%eax
 80484bf:	47                   	inc    %edi
 80484c0:	39 f7                	cmp    %esi,%edi
 80484c2:	72 dc                	jb     80484a0 <_start1+0x100>
 80484c4:	8b 45 f0             	mov    -0x10(%ebp),%eax
 80484c7:	89 44 24 08          	mov    %eax,0x8(%esp)
 80484cb:	89 5c 24 04          	mov    %ebx,0x4(%esp)
 80484cf:	8b 45 0c             	mov    0xc(%ebp),%eax
 80484d2:	89 04 24             	mov    %eax,(%esp)
 80484d5:	e8 b6 00 00 00       	call   8048590 <main>
 80484da:	89 04 24             	mov    %eax,(%esp)
 80484dd:	e8 8e fe ff ff       	call   8048370 <exit@plt>
 80484e2:	66 66 66 66 66 2e 0f 	nopw   %cs:0x0(%eax,%eax,1)
 80484e9:	1f 84 00 00 00 00 00 

[-- Attachment #3 --]
080483a0 <_start1>:
 80483a0:	55                   	push   %ebp
 80483a1:	89 e5                	mov    %esp,%ebp
 80483a3:	53                   	push   %ebx
 80483a4:	57                   	push   %edi
 80483a5:	56                   	push   %esi
 80483a6:	83 ec 10             	sub    $0x10,%esp
 80483a9:	8b 45 0c             	mov    0xc(%ebp),%eax
 80483ac:	8b 5d 10             	mov    0x10(%ebp),%ebx
 80483af:	8d 44 83 04          	lea    0x4(%ebx,%eax,4),%eax
 80483b3:	81 3d 60 97 04 08 00 	cmpl   $0x0,0x8049760
 80483ba:	00 00 00 
 80483bd:	75 05                	jne    80483c4 <_start1+0x24>
 80483bf:	a3 60 97 04 08       	mov    %eax,0x8049760
 80483c4:	89 45 f0             	mov    %eax,-0x10(%ebp)
 80483c7:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
 80483cb:	7e 2e                	jle    80483fb <_start1+0x5b>
 80483cd:	8b 03                	mov    (%ebx),%eax
 80483cf:	85 c0                	test   %eax,%eax
 80483d1:	74 28                	je     80483fb <_start1+0x5b>
 80483d3:	eb 0c                	jmp    80483e1 <_start1+0x41>
 80483d5:	66 66 2e 0f 1f 84 00 	nopw   %cs:0x0(%eax,%eax,1)
 80483dc:	00 00 00 00 
 80483e0:	40                   	inc    %eax
 80483e1:	a3 50 97 04 08       	mov    %eax,0x8049750
 80483e6:	eb 08                	jmp    80483f0 <_start1+0x50>
 80483e8:	40                   	inc    %eax
 80483e9:	0f 1f 80 00 00 00 00 	nopl   0x0(%eax)
 80483f0:	8a 08                	mov    (%eax),%cl
 80483f2:	80 f9 2f             	cmp    $0x2f,%cl
 80483f5:	74 e9                	je     80483e0 <_start1+0x40>
 80483f7:	84 c9                	test   %cl,%cl
 80483f9:	75 ed                	jne    80483e8 <_start1+0x48>
 80483fb:	b8 7c 96 04 08       	mov    $0x804967c,%eax
 8048400:	85 c0                	test   %eax,%eax
 8048402:	74 0d                	je     8048411 <_start1+0x71>
 8048404:	8b 45 08             	mov    0x8(%ebp),%eax
 8048407:	89 04 24             	mov    %eax,(%esp)
 804840a:	e8 41 ff ff ff       	call   8048350 <atexit@plt>
 804840f:	eb 05                	jmp    8048416 <_start1+0x76>
 8048411:	e8 4a ff ff ff       	call   8048360 <_init_tls@plt>
 8048416:	b8 7c 96 04 08       	mov    $0x804967c,%eax
 804841b:	85 c0                	test   %eax,%eax
 804841d:	0f 85 a1 00 00 00    	jne    80484c4 <_start1+0x124>
 8048423:	c7 04 24 f0 84 04 08 	movl   $0x80484f0,(%esp)
 804842a:	b9 68 96 04 08       	mov    $0x8049668,%ecx
 804842f:	b8 68 96 04 08       	mov    $0x8049668,%eax
 8048434:	29 c8                	sub    %ecx,%eax
 8048436:	89 c6                	mov    %eax,%esi
 8048438:	c1 fe 1f             	sar    $0x1f,%esi
 804843b:	c1 ee 1e             	shr    $0x1e,%esi
 804843e:	01 c6                	add    %eax,%esi
 8048440:	c1 fe 02             	sar    $0x2,%esi
 8048443:	e8 08 ff ff ff       	call   8048350 <atexit@plt>
 8048448:	85 f6                	test   %esi,%esi
 804844a:	74 28                	je     8048474 <_start1+0xd4>
 804844c:	31 ff                	xor    %edi,%edi
 804844e:	66 90                	xchg   %ax,%ax
 8048450:	8b 04 bd 68 96 04 08 	mov    0x8049668(,%edi,4),%eax
 8048457:	83 f8 02             	cmp    $0x2,%eax
 804845a:	72 13                	jb     804846f <_start1+0xcf>
 804845c:	8b 4d f0             	mov    -0x10(%ebp),%ecx
 804845f:	89 4c 24 08          	mov    %ecx,0x8(%esp)
 8048463:	89 5c 24 04          	mov    %ebx,0x4(%esp)
 8048467:	8b 4d 0c             	mov    0xc(%ebp),%ecx
 804846a:	89 0c 24             	mov    %ecx,(%esp)
 804846d:	ff d0                	call   *%eax
 804846f:	47                   	inc    %edi
 8048470:	39 f7                	cmp    %esi,%edi
 8048472:	72 dc                	jb     8048450 <_start1+0xb0>
 8048474:	b9 68 96 04 08       	mov    $0x8049668,%ecx
 8048479:	b8 68 96 04 08       	mov    $0x8049668,%eax
 804847e:	29 c8                	sub    %ecx,%eax
 8048480:	89 c6                	mov    %eax,%esi
 8048482:	c1 fe 1f             	sar    $0x1f,%esi
 8048485:	c1 ee 1e             	shr    $0x1e,%esi
 8048488:	01 c6                	add    %eax,%esi
 804848a:	c1 fe 02             	sar    $0x2,%esi
 804848d:	e8 8a fe ff ff       	call   804831c <_init>
 8048492:	85 f6                	test   %esi,%esi
 8048494:	74 2e                	je     80484c4 <_start1+0x124>
 8048496:	31 ff                	xor    %edi,%edi
 8048498:	0f 1f 84 00 00 00 00 	nopl   0x0(%eax,%eax,1)
 804849f:	00 
 80484a0:	8b 04 bd 68 96 04 08 	mov    0x8049668(,%edi,4),%eax
 80484a7:	83 f8 02             	cmp    $0x2,%eax
 80484aa:	72 13                	jb     80484bf <_start1+0x11f>
 80484ac:	8b 4d f0             	mov    -0x10(%ebp),%ecx
 80484af:	89 4c 24 08          	mov    %ecx,0x8(%esp)
 80484b3:	89 5c 24 04          	mov    %ebx,0x4(%esp)
 80484b7:	8b 4d 0c             	mov    0xc(%ebp),%ecx
 80484ba:	89 0c 24             	mov    %ecx,(%esp)
 80484bd:	ff d0                	call   *%eax
 80484bf:	47                   	inc    %edi
 80484c0:	39 f7                	cmp    %esi,%edi
 80484c2:	72 dc                	jb     80484a0 <_start1+0x100>
 80484c4:	8b 45 f0             	mov    -0x10(%ebp),%eax
 80484c7:	89 44 24 08          	mov    %eax,0x8(%esp)
 80484cb:	89 5c 24 04          	mov    %ebx,0x4(%esp)
 80484cf:	8b 45 0c             	mov    0xc(%ebp),%eax
 80484d2:	89 04 24             	mov    %eax,(%esp)
 80484d5:	e8 b6 00 00 00       	call   8048590 <main>
 80484da:	89 04 24             	mov    %eax,(%esp)
 80484dd:	e8 8e fe ff ff       	call   8048370 <exit@plt>
 80484e2:	66 66 66 66 66 2e 0f 	nopw   %cs:0x0(%eax,%eax,1)
 80484e9:	1f 84 00 00 00 00 00 

[-- Attachment #4 --]
08048b0c <_start1>:
 8048b0c:	55                   	push   %ebp
 8048b0d:	89 e5                	mov    %esp,%ebp
 8048b0f:	57                   	push   %edi
 8048b10:	56                   	push   %esi
 8048b11:	53                   	push   %ebx
 8048b12:	83 ec 1c             	sub    $0x1c,%esp
 8048b15:	a1 08 aa 04 08       	mov    0x804aa08,%eax
 8048b1a:	8b 75 0c             	mov    0xc(%ebp),%esi
 8048b1d:	8b 7d 10             	mov    0x10(%ebp),%edi
 8048b20:	85 c0                	test   %eax,%eax
 8048b22:	8d 5c b7 04          	lea    0x4(%edi,%esi,4),%ebx
 8048b26:	a1 08 aa 04 08       	mov    0x804aa08,%eax
 8048b2b:	0f 44 c3             	cmove  %ebx,%eax
 8048b2e:	85 f6                	test   %esi,%esi
 8048b30:	a3 08 aa 04 08       	mov    %eax,0x804aa08
 8048b35:	7e 2b                	jle    8048b62 <_start1+0x56>
 8048b37:	8b 17                	mov    (%edi),%edx
 8048b39:	85 d2                	test   %edx,%edx
 8048b3b:	74 25                	je     8048b62 <_start1+0x56>
 8048b3d:	89 15 84 a9 04 08    	mov    %edx,0x804a984
 8048b43:	0f b6 02             	movzbl (%edx),%eax
 8048b46:	84 c0                	test   %al,%al
 8048b48:	74 18                	je     8048b62 <_start1+0x56>
 8048b4a:	42                   	inc    %edx
 8048b4b:	3c 2f                	cmp    $0x2f,%al
 8048b4d:	a1 84 a9 04 08       	mov    0x804a984,%eax
 8048b52:	0f 44 c2             	cmove  %edx,%eax
 8048b55:	a3 84 a9 04 08       	mov    %eax,0x804a984
 8048b5a:	0f b6 02             	movzbl (%edx),%eax
 8048b5d:	42                   	inc    %edx
 8048b5e:	84 c0                	test   %al,%al
 8048b60:	75 e9                	jne    8048b4b <_start1+0x3f>
 8048b62:	b8 28 a8 04 08       	mov    $0x804a828,%eax
 8048b67:	85 c0                	test   %eax,%eax
 8048b69:	74 1f                	je     8048b8a <_start1+0x7e>
 8048b6b:	83 ec 0c             	sub    $0xc,%esp
 8048b6e:	ff 75 08             	pushl  0x8(%ebp)
 8048b71:	e8 0a fe ff ff       	call   8048980 <atexit@plt>
 8048b76:	83 c4 10             	add    $0x10,%esp
 8048b79:	50                   	push   %eax
 8048b7a:	53                   	push   %ebx
 8048b7b:	57                   	push   %edi
 8048b7c:	56                   	push   %esi
 8048b7d:	e8 2f 04 00 00       	call   8048fb1 <main>
 8048b82:	89 04 24             	mov    %eax,(%esp)
 8048b85:	e8 46 ff ff ff       	call   8048ad0 <exit@plt>
 8048b8a:	e8 41 fe ff ff       	call   80489d0 <_init_tls@plt>
 8048b8f:	83 ec 0c             	sub    $0xc,%esp
 8048b92:	68 28 8c 04 08       	push   $0x8048c28
 8048b97:	e8 e4 fd ff ff       	call   8048980 <atexit@plt>
 8048b9c:	b8 14 a8 04 08       	mov    $0x804a814,%eax
 8048ba1:	2d 14 a8 04 08       	sub    $0x804a814,%eax
 8048ba6:	83 c4 10             	add    $0x10,%esp
 8048ba9:	c1 f8 02             	sar    $0x2,%eax
 8048bac:	89 45 e8             	mov    %eax,-0x18(%ebp)
 8048baf:	74 2e                	je     8048bdf <_start1+0xd3>
 8048bb1:	c7 45 ec 28 a8 04 08 	movl   $0x804a828,-0x14(%ebp)
 8048bb8:	eb 0b                	jmp    8048bc5 <_start1+0xb9>
 8048bba:	ff 45 ec             	incl   -0x14(%ebp)
 8048bbd:	8b 45 ec             	mov    -0x14(%ebp),%eax
 8048bc0:	39 45 e8             	cmp    %eax,-0x18(%ebp)
 8048bc3:	74 1a                	je     8048bdf <_start1+0xd3>
 8048bc5:	8b 55 ec             	mov    -0x14(%ebp),%edx
 8048bc8:	8b 04 95 14 a8 04 08 	mov    0x804a814(,%edx,4),%eax
 8048bcf:	83 f8 01             	cmp    $0x1,%eax
 8048bd2:	76 e6                	jbe    8048bba <_start1+0xae>
 8048bd4:	51                   	push   %ecx
 8048bd5:	53                   	push   %ebx
 8048bd6:	57                   	push   %edi
 8048bd7:	56                   	push   %esi
 8048bd8:	ff d0                	call   *%eax
 8048bda:	83 c4 10             	add    $0x10,%esp
 8048bdd:	eb db                	jmp    8048bba <_start1+0xae>
 8048bdf:	e8 e8 fc ff ff       	call   80488cc <_init>
 8048be4:	b8 14 a8 04 08       	mov    $0x804a814,%eax
 8048be9:	2d 14 a8 04 08       	sub    $0x804a814,%eax
 8048bee:	c1 f8 02             	sar    $0x2,%eax
 8048bf1:	89 45 e4             	mov    %eax,-0x1c(%ebp)
 8048bf4:	74 83                	je     8048b79 <_start1+0x6d>
 8048bf6:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
 8048bfd:	eb 0f                	jmp    8048c0e <_start1+0x102>
 8048bff:	ff 45 f0             	incl   -0x10(%ebp)
 8048c02:	8b 45 f0             	mov    -0x10(%ebp),%eax
 8048c05:	39 45 e4             	cmp    %eax,-0x1c(%ebp)
 8048c08:	0f 84 6b ff ff ff    	je     8048b79 <_start1+0x6d>
 8048c0e:	8b 55 f0             	mov    -0x10(%ebp),%edx
 8048c11:	8b 04 95 14 a8 04 08 	mov    0x804a814(,%edx,4),%eax
 8048c18:	83 f8 01             	cmp    $0x1,%eax
 8048c1b:	76 e2                	jbe    8048bff <_start1+0xf3>
 8048c1d:	52                   	push   %edx
 8048c1e:	53                   	push   %ebx
 8048c1f:	57                   	push   %edi
 8048c20:	56                   	push   %esi
 8048c21:	ff d0                	call   *%eax
 8048c23:	83 c4 10             	add    $0x10,%esp
 8048c26:	eb d7                	jmp    8048bff <_start1+0xf3>
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?136287724.20130223003150>