NetBSD Problem Report #50218

From www@NetBSD.org  Mon Sep  7 15:15:17 2015
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E650AA6562
	for <gnats-bugs@gnats.NetBSD.org>; Mon,  7 Sep 2015 15:15:17 +0000 (UTC)
Message-Id: <20150907151516.90548A65BA@mollari.NetBSD.org>
Date: Mon,  7 Sep 2015 15:15:16 +0000 (UTC)
From: mzaidibrahime@gmail.com
Reply-To: mzaidibrahime@gmail.com
To: gnats-bugs@NetBSD.org
Subject: ARM executables linked with native linker on cortex-a9 raises SIGILL 
X-Send-Pr-Version: www-1.0

>Number:         50218
>Category:       port-arm32
>Synopsis:       ARM executables linked with native linker on cortex-a9 raises SIGILL
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    port-arm32-maintainer
>State:          open
>Class:          support
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 07 15:20:00 +0000 2015
>Last-Modified:  Sat Sep 19 14:30:00 +0000 2015
>Originator:     Zaid
>Release:        5.1
>Organization:
>Environment:
NetBSD 5.1_STABLE evbarm
>Description:
I am trying to do native compilation in ARM target(armv7-a). 

This target was built with with NetBSD5.1 kernel cross compiled and userland was created with Machine as evbarm and architecture as armv7eb in NetBSD5.1 source. 

         NetBSD version:   5.1
         MACHINE:          evbarm
         MACHINE_ARCH:     armv7eb
         Build platform:   Linux 2.6.18-194.32.1.el5PAE i686
         HOST_SH:          /bin/sh


Kernel and userland application like (ls, chmod,etc) which were cross-compiled executes successfully.

I have also built developer tool chain and installed on the target ARM machine. 

gcc version: 4.1.3
ld version: 2.6.1
as version 2.6.1

Using this version of developer tools on the target, I am trying to compile some C programs natively. I am facing SIGILL on executing the binaries. On analyzing the objs generated by the compiler, all the instructions generated are proper ARM instructions in Big Endian. 
However on linking, the executable created does not do the endianness swapping(be8 option of the linker) *completely*. I am seeing the mix of little endian and big endian instructions in the text section. I understand that all the instructions are supposed to swapped into little endian.

Small programs(<6K size) does not result in SIGILL as all the instruction are properly swapped for endianness by the linker.

Here is an extract of
Correct instruction in the executables:

   1594:	0dc0a0e1 	stceql	0, cr10, [r0, #900]
    1598:	00dc2de9 	sbceqs	r2, ip, r9, ror #27
    159c:	04b04ce2 	ldreqt	r4, [r0], #3298
    15a0:	10a09fe5 	adcne	r9, r0, r5, ror #31


Wrong instruction which are not swapped which results in SIGILLs

    15c0:	e1a0c00d 	mov	ip, sp
    15c4:	e92dd800 	stmdb	sp!, {fp, ip, lr, pc}
    15c8:	e24cb004 	sub	fp, ip, #4	; 0x4


Want to understand how to get the correct executable on the target. Cross compilation of the C files is not an option for me.
>How-To-Repeat:
Create userland(Cross compiled) for armv7eb with NetBSD5.1 and copy the same to the ARM target. chroot to the userland. 

1. create a big static/dynamic library. now link the library to a C program and execute the program
Commands that I have used
gcc -msoft-float -dynamic -mtune=cortex-a9 -g -c example-deconstructor.o example-deconstructor.c 

gcc -I../include -msoft-float -dynamic -mtune=cortex-a9 -g -o example-deconstructor example-deconstructor.o  ./libmyx.so.2

2. Compile C file with -static option and run the executable.

SIGILL will be seen
>Fix:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-arm32/50218: ARM executables linked with native linker on cortex-a9 raises SIGILL
Date: Mon, 7 Sep 2015 17:26:33 +0200

 On Mon, Sep 07, 2015 at 03:20:00PM +0000, mzaidibrahime@gmail.com wrote:
 > Small programs(<6K size) does not result in SIGILL as all the instruction are properly swapped for endianness by the linker.

 Are you sure that it depends on size of the program?

 Sounds more like the bogusly stripped libgcc, see
 http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=49337

 The fix is only in netbsd-7 or current AFAIK.

 Martin

From: Zaid Ibrahime <mzaidibrahime@gmail.com>
To: gnats-bugs@netbsd.org
Cc: port-arm32-maintainer@netbsd.org, gnats-admin@netbsd.org, 
	netbsd-bugs@netbsd.org
Subject: Re: port-arm32/50218: ARM executables linked with native linker on
 cortex-a9 raises SIGILL
Date: Tue, 8 Sep 2015 11:12:40 +0530

 --94eb2c032e60958c6f051f35d5ba
 Content-Type: text/plain; charset=UTF-8

  > Small programs(<6K size) does not result in SIGILL as all the
 instruction are properly swapped for endianness by the linker.

  > Are you sure that it depends on size of the program?

 The size may be not significant. The byte swapping happens partially.

 On Mon, Sep 7, 2015 at 9:00 PM, Martin Husemann <martin@duskware.de> wrote:

 > The following reply was made to PR port-arm32/50218; it has been noted by
 > GNATS.
 >
 > From: Martin Husemann <martin@duskware.de>
 > To: gnats-bugs@NetBSD.org
 > Cc:
 > Subject: Re: port-arm32/50218: ARM executables linked with native linker
 > on cortex-a9 raises SIGILL
 > Date: Mon, 7 Sep 2015 17:26:33 +0200
 >
 >  On Mon, Sep 07, 2015 at 03:20:00PM +0000, mzaidibrahime@gmail.com wrote:
 >  > Small programs(<6K size) does not result in SIGILL as all the
 > instruction are properly swapped for endianness by the linker.
 >
 >  Are you sure that it depends on size of the program?
 >
 >  Sounds more like the bogusly stripped libgcc, see
 >  http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=49337
 >
 >  The fix is only in netbsd-7 or current AFAIK.
 >
 >  Martin
 >
 >

 --94eb2c032e60958c6f051f35d5ba
 Content-Type: text/html; charset=UTF-8
 Content-Transfer-Encoding: quoted-printable

 <div dir=3D"ltr"><span style=3D"font-size:12.8px">=C2=A0&gt; Small programs=
 (&lt;6K size) does not result in SIGILL as all the instruction are properly=
  swapped for endianness by the linker.</span><br style=3D"font-size:12.8px"=
 ><br style=3D"font-size:12.8px"><span style=3D"font-size:12.8px">=C2=A0&gt;=
  Are you sure that it depends on size of the program?</span><br><div><span =
 style=3D"font-size:12.8px"><br></span></div><div><span style=3D"font-size:1=
 2.8px">The size may be not significant. The byte swapping happens partially=
 .</span></div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quot=
 e">On Mon, Sep 7, 2015 at 9:00 PM, Martin Husemann <span dir=3D"ltr">&lt;<a=
  href=3D"mailto:martin@duskware.de" target=3D"_blank">martin@duskware.de</a=
 >&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 =
 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The following reply w=
 as made to PR port-arm32/50218; it has been noted by GNATS.<br>
 <br>
 From: Martin Husemann &lt;<a href=3D"mailto:martin@duskware.de">martin@dusk=
 ware.de</a>&gt;<br>
 To: gnats-bugs@NetBSD.org<br>
 Cc:<br>
 Subject: Re: port-arm32/50218: ARM executables linked with native linker on=
  cortex-a9 raises SIGILL<br>
 Date: Mon, 7 Sep 2015 17:26:33 +0200<br>
 <br>
 =C2=A0On Mon, Sep 07, 2015 at 03:20:00PM +0000, <a href=3D"mailto:mzaidibra=
 hime@gmail.com">mzaidibrahime@gmail.com</a> wrote:<br>
 =C2=A0&gt; Small programs(&lt;6K size) does not result in SIGILL as all the=
  instruction are properly swapped for endianness by the linker.<br>
 <br>
 =C2=A0Are you sure that it depends on size of the program?<br>
 <br>
 =C2=A0Sounds more like the bogusly stripped libgcc, see<br>
 =C2=A0<a href=3D"http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=
 =3D49337" rel=3D"noreferrer" target=3D"_blank">http://gnats.netbsd.org/cgi-=
 bin/query-pr-single.pl?number=3D49337</a><br>
 <br>
 =C2=A0The fix is only in netbsd-7 or current AFAIK.<br>
 <span class=3D"HOEnZb"><font color=3D"#888888"><br>
 =C2=A0Martin<br>
 <br>
 </font></span></blockquote></div><br></div>

 --94eb2c032e60958c6f051f35d5ba--

From: Martin Husemann <martin@duskware.de>
To: Zaid Ibrahime <mzaidibrahime@gmail.com>
Cc: gnats-bugs@netbsd.org
Subject: Re: port-arm32/50218: ARM executables linked with native linker on cortex-a9 raises SIGILL
Date: Tue, 8 Sep 2015 08:58:29 +0200

 On Tue, Sep 08, 2015 at 11:12:40AM +0530, Zaid Ibrahime wrote:
 >  > Small programs(<6K size) does not result in SIGILL as all the
 > instruction are properly swapped for endianness by the linker.
 > 
 >  > Are you sure that it depends on size of the program?

 Are you building from a single c source, or from libs?
 My bet is the swapping happens fine for c source or "normal" objects,
 but you are using some lib that has been partially stripped, which kills
 the $t/$a markers. libgcc was one of those libraries (untill fixed)

 Martin

From: Zaid Ibrahime <mzaidibrahime@gmail.com>
To: gnats-bugs@netbsd.org
Cc: port-arm32-maintainer@netbsd.org, gnats-admin@netbsd.org, 
	netbsd-bugs@netbsd.org
Subject: Re: port-arm32/50218: ARM executables linked with native linker on
 cortex-a9 raises SIGILL
Date: Tue, 8 Sep 2015 16:55:57 +0530

 --94eb2c032e6048771a051f3aa196
 Content-Type: text/plain; charset=UTF-8

 > Are you building from a single c source, or from libs?
 > My bet is the swapping happens fine for c source or "normal" objects,
 > but you are using some lib that has been partially stripped, which kills
 > the $t/$a markers. libgcc was one of those libraries (untill fixed)

 I have compiled 1 file.
 gcc -o api.o -DHAVE_CONFIG_H  -I. -I.. -I../include  -c  api.c

 Now I have written a simple C function which calls only one function from
 the objs.

 gcc -o test2 -DHAVE_CONFIG_H  -I. -I.. -I../include test1.c api.o

 # ./test2
 pid 447 (test2), uid 0: exited on signal 4 (core not dumped, err = 2)
 [1]   Illegal instruction     ./test2

 # gcc -o api.o -DHAVE_CONFIG_H  -I. -I.. -I../include  -c  api.c
 # gcc -o test2 -DHAVE_CONFIG_H  -I. -I.. -I../include test1.c api.o
 # ./test2
 #

 The content of the test1.c is always the same.

 # cat test1.c
 #include <yaml.h>

 int main ()
 {
   yaml_parser_t parser;
   yaml_parser_initialize (&parser);
 return 0;
 }

 The obj is correctly endianness swapped in the latter case. Wonder why the
 same function crashes in one case and not the other.




 On Tue, Sep 8, 2015 at 12:30 PM, Martin Husemann <martin@duskware.de> wrote:

 > The following reply was made to PR port-arm32/50218; it has been noted by
 > GNATS.
 >
 > From: Martin Husemann <martin@duskware.de>
 > To: Zaid Ibrahime <mzaidibrahime@gmail.com>
 > Cc: gnats-bugs@netbsd.org
 > Subject: Re: port-arm32/50218: ARM executables linked with native linker
 > on cortex-a9 raises SIGILL
 > Date: Tue, 8 Sep 2015 08:58:29 +0200
 >
 >  On Tue, Sep 08, 2015 at 11:12:40AM +0530, Zaid Ibrahime wrote:
 >  >  > Small programs(<6K size) does not result in SIGILL as all the
 >  > instruction are properly swapped for endianness by the linker.
 >  >
 >  >  > Are you sure that it depends on size of the program?
 >
 >  Are you building from a single c source, or from libs?
 >  My bet is the swapping happens fine for c source or "normal" objects,
 >  but you are using some lib that has been partially stripped, which kills
 >  the $t/$a markers. libgcc was one of those libraries (untill fixed)
 >
 >  Martin
 >
 >

 --94eb2c032e6048771a051f3aa196
 Content-Type: text/html; charset=UTF-8
 Content-Transfer-Encoding: quoted-printable

 <div dir=3D"ltr"><span style=3D"color:rgb(80,0,80);font-size:12.8px">&gt; A=
 re you building from a single c source, or from libs?</span><br style=3D"co=
 lor:rgb(80,0,80);font-size:12.8px"><span style=3D"color:rgb(80,0,80);font-s=
 ize:12.8px">&gt; My bet is the swapping happens fine for c source or &quot;=
 normal&quot; objects,</span><br style=3D"color:rgb(80,0,80);font-size:12.8p=
 x"><span style=3D"color:rgb(80,0,80);font-size:12.8px">&gt; but you are usi=
 ng some lib that has been partially stripped, which kills</span><br style=
 =3D"color:rgb(80,0,80);font-size:12.8px"><span style=3D"color:rgb(80,0,80);=
 font-size:12.8px">&gt; the $t/$a markers. libgcc was one of those libraries=
  (untill fixed)</span><br style=3D"color:rgb(80,0,80);font-size:12.8px"><di=
 v><span style=3D"color:rgb(80,0,80);font-size:12.8px"><br></span></div><div=
 ><font color=3D"#500050"><span style=3D"font-size:12.8px">I have compiled 1=
  file.=C2=A0</span></font></div><div><font color=3D"#500050"><span style=3D=
 "font-size:12.8px">gcc -o api.o -DHAVE_CONFIG_H =C2=A0-I. -I.. -I../include=
  =C2=A0-c =C2=A0api.c</span><br></font></div><div><font color=3D"#500050"><=
 span style=3D"font-size:12.8px"><br></span></font></div><div><span style=3D=
 "color:rgb(80,0,80);font-size:12.8px">Now I have written a simple C functio=
 n which calls only one function from the objs.</span><font color=3D"#500050=
 "><span style=3D"font-size:12.8px"><br></span></font></div><div><span style=
 =3D"color:rgb(80,0,80);font-size:12.8px"><br></span></div><div><div><font c=
 olor=3D"#500050"><span style=3D"font-size:12.8px">gcc -o test2 -DHAVE_CONFI=
 G_H =C2=A0-I. -I.. -I../include test1.c api.o</span></font></div><div style=
 =3D"color:rgb(80,0,80);font-size:12.8px"><br></div></div><div style=3D""><d=
 iv style=3D"color:rgb(80,0,80);font-size:12.8px"># ./test2</div><div style=
 =3D"color:rgb(80,0,80);font-size:12.8px">pid 447 (test2), uid 0: exited on =
 signal 4 (core not dumped, err =3D 2)</div><div style=3D"color:rgb(80,0,80)=
 ;font-size:12.8px">[1] =C2=A0 Illegal instruction =C2=A0 =C2=A0 ./test2</di=
 v><div style=3D"color:rgb(80,0,80);font-size:12.8px"><br></div><div style=
 =3D""><div style=3D""><font color=3D"#500050"><span style=3D"font-size:12.8=
 px"># gcc -o api.o -DHAVE_CONFIG_H =C2=A0-I. -I.. -I../include =C2=A0-c =C2=
 =A0api.c</span></font></div><div style=3D""><font color=3D"#500050"><span s=
 tyle=3D"font-size:12.8px"># gcc -o test2 -DHAVE_CONFIG_H =C2=A0-I. -I.. -I.=
 ./include test1.c api.o</span></font></div><div style=3D""><font color=3D"#=
 500050"><span style=3D"font-size:12.8px"># ./test2</span></font></div><div =
 style=3D""><font color=3D"#500050"><span style=3D"font-size:12.8px"># =C2=
 =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
 =A0 =C2=A0 =C2=A0</span></font></div><div style=3D""><font color=3D"#500050=
 "><span style=3D"font-size:12.8px"><br></span></font></div><div style=3D"">=
 <font color=3D"#500050"><span style=3D"font-size:12.8px">The content of the=
  test1.c is always the same.</span></font></div><div style=3D""><font color=
 =3D"#500050"><span style=3D"font-size:12.8px"><br></span></font></div><div =
 style=3D""><font color=3D"#500050"><div style=3D""><span style=3D"font-size=
 :12.8px"># cat test1.c</span></div><div style=3D""><span style=3D"font-size=
 :12.8px">#include &lt;yaml.h&gt;</span></div><div style=3D""><span style=3D=
 "font-size:12.8px"><br></span></div><div style=3D""><span style=3D"font-siz=
 e:12.8px">int main ()</span></div><div style=3D""><span style=3D"font-size:=
 12.8px">{</span></div><div style=3D""><span style=3D"font-size:12.8px">=C2=
 =A0 yaml_parser_t parser;</span></div><div style=3D""><span style=3D"font-s=
 ize:12.8px">=C2=A0 yaml_parser_initialize (&amp;parser);</span></div><div s=
 tyle=3D""><span style=3D"font-size:12.8px">return 0;</span></div><div style=
 =3D""><span style=3D"font-size:12.8px">}</span></div><div style=3D"font-siz=
 e:12.8px"><br></div><div style=3D"font-size:12.8px">The obj is correctly en=
 dianness swapped in the latter case. Wonder why the same function crashes i=
 n one case and not the other.</div></font></div></div></div><div><font colo=
 r=3D"#500050"><span style=3D"font-size:12.8px"><br></span></font></div><div=
 ><span style=3D"color:rgb(80,0,80);font-size:12.8px"><br></span></div><div>=
 <span style=3D"color:rgb(80,0,80);font-size:12.8px"><br></span></div></div>=
 <div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Tue, Sep 8, 20=
 15 at 12:30 PM, Martin Husemann <span dir=3D"ltr">&lt;<a href=3D"mailto:mar=
 tin@duskware.de" target=3D"_blank">martin@duskware.de</a>&gt;</span> wrote:=
 <br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
 t:1px #ccc solid;padding-left:1ex"><span class=3D"">The following reply was=
  made to PR port-arm32/50218; it has been noted by GNATS.<br>
 <br>
 From: Martin Husemann &lt;<a href=3D"mailto:martin@duskware.de">martin@dusk=
 ware.de</a>&gt;<br>
 </span>To: Zaid Ibrahime &lt;<a href=3D"mailto:mzaidibrahime@gmail.com">mza=
 idibrahime@gmail.com</a>&gt;<br>
 Cc: <a href=3D"mailto:gnats-bugs@netbsd.org">gnats-bugs@netbsd.org</a><br>
 <span class=3D"">Subject: Re: port-arm32/50218: ARM executables linked with=
  native linker on cortex-a9 raises SIGILL<br>
 </span>Date: Tue, 8 Sep 2015 08:58:29 +0200<br>
 <div class=3D"HOEnZb"><div class=3D"h5"><br>
 =C2=A0On Tue, Sep 08, 2015 at 11:12:40AM +0530, Zaid Ibrahime wrote:<br>
 =C2=A0&gt;=C2=A0 &gt; Small programs(&lt;6K size) does not result in SIGILL=
  as all the<br>
 =C2=A0&gt; instruction are properly swapped for endianness by the linker.<b=
 r>
 =C2=A0&gt;<br>
 =C2=A0&gt;=C2=A0 &gt; Are you sure that it depends on size of the program?<=
 br>
 <br>
 =C2=A0Are you building from a single c source, or from libs?<br>
 =C2=A0My bet is the swapping happens fine for c source or &quot;normal&quot=
 ; objects,<br>
 =C2=A0but you are using some lib that has been partially stripped, which ki=
 lls<br>
 =C2=A0the $t/$a markers. libgcc was one of those libraries (untill fixed)<b=
 r>
 <br>
 =C2=A0Martin<br>
 <br>
 </div></div></blockquote></div><br></div>

 --94eb2c032e6048771a051f3aa196--

From: Zaid Ibrahime <mzaidibrahime@gmail.com>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: port-arm32/50218: ARM executables linked with native linker on
 cortex-a9 raises SIGILL
Date: Tue, 8 Sep 2015 17:12:42 +0530

 --001a114c8f042599ff051f3addb1
 Content-Type: text/plain; charset=UTF-8

 I have reduced the C file in api.c in the working case by commenting some
 part of the code. In the case of SIGILL its a full file

 On Tue, Sep 8, 2015 at 5:00 PM, Zaid Ibrahime <mzaidibrahime@gmail.com>
 wrote:

 > The following reply was made to PR port-arm32/50218; it has been noted by
 > GNATS.
 >
 > From: Zaid Ibrahime <mzaidibrahime@gmail.com>
 > To: gnats-bugs@netbsd.org
 > Cc: port-arm32-maintainer@netbsd.org, gnats-admin@netbsd.org,
 >         netbsd-bugs@netbsd.org
 > Subject: Re: port-arm32/50218: ARM executables linked with native linker on
 >  cortex-a9 raises SIGILL
 > Date: Tue, 8 Sep 2015 16:55:57 +0530
 >
 >  --94eb2c032e6048771a051f3aa196
 >  Content-Type: text/plain; charset=UTF-8
 >
 >  > Are you building from a single c source, or from libs?
 >  > My bet is the swapping happens fine for c source or "normal" objects,
 >  > but you are using some lib that has been partially stripped, which kills
 >  > the $t/$a markers. libgcc was one of those libraries (untill fixed)
 >
 >  I have compiled 1 file.
 >  gcc -o api.o -DHAVE_CONFIG_H  -I. -I.. -I../include  -c  api.c
 >
 >  Now I have written a simple C function which calls only one function from
 >  the objs.
 >
 >  gcc -o test2 -DHAVE_CONFIG_H  -I. -I.. -I../include test1.c api.o
 >
 >  # ./test2
 >  pid 447 (test2), uid 0: exited on signal 4 (core not dumped, err = 2)
 >  [1]   Illegal instruction     ./test2
 >
 >  # gcc -o api.o -DHAVE_CONFIG_H  -I. -I.. -I../include  -c  api.c
 >  # gcc -o test2 -DHAVE_CONFIG_H  -I. -I.. -I../include test1.c api.o
 >  # ./test2
 >  #
 >
 >  The content of the test1.c is always the same.
 >
 >  # cat test1.c
 >  #include <yaml.h>
 >
 >  int main ()
 >  {
 >    yaml_parser_t parser;
 >    yaml_parser_initialize (&parser);
 >  return 0;
 >  }
 >
 >  The obj is correctly endianness swapped in the latter case. Wonder why the
 >  same function crashes in one case and not the other.
 >
 >
 >
 >
 >  On Tue, Sep 8, 2015 at 12:30 PM, Martin Husemann <martin@duskware.de>
 > wrote:
 >
 >  > The following reply was made to PR port-arm32/50218; it has been noted
 > by
 >  > GNATS.
 >  >
 >  > From: Martin Husemann <martin@duskware.de>
 >  > To: Zaid Ibrahime <mzaidibrahime@gmail.com>
 >  > Cc: gnats-bugs@netbsd.org
 >  > Subject: Re: port-arm32/50218: ARM executables linked with native linker
 >  > on cortex-a9 raises SIGILL
 >  > Date: Tue, 8 Sep 2015 08:58:29 +0200
 >  >
 >  >  On Tue, Sep 08, 2015 at 11:12:40AM +0530, Zaid Ibrahime wrote:
 >  >  >  > Small programs(<6K size) does not result in SIGILL as all the
 >  >  > instruction are properly swapped for endianness by the linker.
 >  >  >
 >  >  >  > Are you sure that it depends on size of the program?
 >  >
 >  >  Are you building from a single c source, or from libs?
 >  >  My bet is the swapping happens fine for c source or "normal" objects,
 >  >  but you are using some lib that has been partially stripped, which
 > kills
 >  >  the $t/$a markers. libgcc was one of those libraries (untill fixed)
 >  >
 >  >  Martin
 >  >
 >  >
 >
 >  --94eb2c032e6048771a051f3aa196
 >  Content-Type: text/html; charset=UTF-8
 >  Content-Transfer-Encoding: quoted-printable
 >
 >  <div dir=3D"ltr"><span style=3D"color:rgb(80,0,80);font-size:12.8px">&gt;
 > A=
 >  re you building from a single c source, or from libs?</span><br
 > style=3D"co=
 >  lor:rgb(80,0,80);font-size:12.8px"><span
 > style=3D"color:rgb(80,0,80);font-s=
 >  ize:12.8px">&gt; My bet is the swapping happens fine for c source or
 > &quot;=
 >  normal&quot; objects,</span><br
 > style=3D"color:rgb(80,0,80);font-size:12.8p=
 >  x"><span style=3D"color:rgb(80,0,80);font-size:12.8px">&gt; but you are
 > usi=
 >  ng some lib that has been partially stripped, which kills</span><br style=
 >  =3D"color:rgb(80,0,80);font-size:12.8px"><span
 > style=3D"color:rgb(80,0,80);=
 >  font-size:12.8px">&gt; the $t/$a markers. libgcc was one of those
 > libraries=
 >   (untill fixed)</span><br
 > style=3D"color:rgb(80,0,80);font-size:12.8px"><di=
 >  v><span
 > style=3D"color:rgb(80,0,80);font-size:12.8px"><br></span></div><div=
 >  ><font color=3D"#500050"><span style=3D"font-size:12.8px">I have compiled
 > 1=
 >   file.=C2=A0</span></font></div><div><font color=3D"#500050"><span
 > style=3D=
 >  "font-size:12.8px">gcc -o api.o -DHAVE_CONFIG_H =C2=A0-I. -I..
 > -I../include=
 >   =C2=A0-c =C2=A0api.c</span><br></font></div><div><font
 > color=3D"#500050"><=
 >  span style=3D"font-size:12.8px"><br></span></font></div><div><span
 > style=3D=
 >  "color:rgb(80,0,80);font-size:12.8px">Now I have written a simple C
 > functio=
 >  n which calls only one function from the objs.</span><font
 > color=3D"#500050=
 >  "><span style=3D"font-size:12.8px"><br></span></font></div><div><span
 > style=
 >  =3D"color:rgb(80,0,80);font-size:12.8px"><br></span></div><div><div><font
 > c=
 >  olor=3D"#500050"><span style=3D"font-size:12.8px">gcc -o test2
 > -DHAVE_CONFI=
 >  G_H =C2=A0-I. -I.. -I../include test1.c api.o</span></font></div><div
 > style=
 >  =3D"color:rgb(80,0,80);font-size:12.8px"><br></div></div><div
 > style=3D""><d=
 >  iv style=3D"color:rgb(80,0,80);font-size:12.8px"># ./test2</div><div
 > style=
 >  =3D"color:rgb(80,0,80);font-size:12.8px">pid 447 (test2), uid 0: exited
 > on =
 >  signal 4 (core not dumped, err =3D 2)</div><div
 > style=3D"color:rgb(80,0,80)=
 >  ;font-size:12.8px">[1] =C2=A0 Illegal instruction =C2=A0 =C2=A0
 > ./test2</di=
 >  v><div style=3D"color:rgb(80,0,80);font-size:12.8px"><br></div><div style=
 >  =3D""><div style=3D""><font color=3D"#500050"><span
 > style=3D"font-size:12.8=
 >  px"># gcc -o api.o -DHAVE_CONFIG_H =C2=A0-I. -I.. -I../include =C2=A0-c
 > =C2=
 >  =A0api.c</span></font></div><div style=3D""><font color=3D"#500050"><span
 > s=
 >  tyle=3D"font-size:12.8px"># gcc -o test2 -DHAVE_CONFIG_H =C2=A0-I. -I..
 > -I.=
 >  ./include test1.c api.o</span></font></div><div style=3D""><font
 > color=3D"#=
 >  500050"><span style=3D"font-size:12.8px">#
 > ./test2</span></font></div><div =
 >  style=3D""><font color=3D"#500050"><span style=3D"font-size:12.8px"># =C2=
 >  =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
 > =
 >  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
 >  =A0 =C2=A0 =C2=A0</span></font></div><div style=3D""><font
 > color=3D"#500050=
 >  "><span style=3D"font-size:12.8px"><br></span></font></div><div
 > style=3D"">=
 >  <font color=3D"#500050"><span style=3D"font-size:12.8px">The content of
 > the=
 >   test1.c is always the same.</span></font></div><div style=3D""><font
 > color=
 >  =3D"#500050"><span
 > style=3D"font-size:12.8px"><br></span></font></div><div =
 >  style=3D""><font color=3D"#500050"><div style=3D""><span
 > style=3D"font-size=
 >  :12.8px"># cat test1.c</span></div><div style=3D""><span
 > style=3D"font-size=
 >  :12.8px">#include &lt;yaml.h&gt;</span></div><div style=3D""><span
 > style=3D=
 >  "font-size:12.8px"><br></span></div><div style=3D""><span
 > style=3D"font-siz=
 >  e:12.8px">int main ()</span></div><div style=3D""><span
 > style=3D"font-size:=
 >  12.8px">{</span></div><div style=3D""><span
 > style=3D"font-size:12.8px">=C2=
 >  =A0 yaml_parser_t parser;</span></div><div style=3D""><span
 > style=3D"font-s=
 >  ize:12.8px">=C2=A0 yaml_parser_initialize (&amp;parser);</span></div><div
 > s=
 >  tyle=3D""><span style=3D"font-size:12.8px">return 0;</span></div><div
 > style=
 >  =3D""><span style=3D"font-size:12.8px">}</span></div><div
 > style=3D"font-siz=
 >  e:12.8px"><br></div><div style=3D"font-size:12.8px">The obj is correctly
 > en=
 >  dianness swapped in the latter case. Wonder why the same function crashes
 > i=
 >  n one case and not the other.</div></font></div></div></div><div><font
 > colo=
 >  r=3D"#500050"><span
 > style=3D"font-size:12.8px"><br></span></font></div><div=
 >  ><span
 > style=3D"color:rgb(80,0,80);font-size:12.8px"><br></span></div><div>=
 >  <span
 > style=3D"color:rgb(80,0,80);font-size:12.8px"><br></span></div></div>=
 >  <div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Tue, Sep 8,
 > 20=
 >  15 at 12:30 PM, Martin Husemann <span dir=3D"ltr">&lt;<a href=3D"mailto:
 > mar=
 >  tin@duskware.de" target=3D"_blank">martin@duskware.de</a>&gt;</span>
 > wrote:=
 >  <br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0
 > .8ex;border-lef=
 >  t:1px #ccc solid;padding-left:1ex"><span class=3D"">The following reply
 > was=
 >   made to PR port-arm32/50218; it has been noted by GNATS.<br>
 >  <br>
 >  From: Martin Husemann &lt;<a href=3D"mailto:martin@duskware.de
 > ">martin@dusk=
 >  ware.de</a>&gt;<br>
 >  </span>To: Zaid Ibrahime &lt;<a href=3D"mailto:mzaidibrahime@gmail.com
 > ">mza=
 >  idibrahime@gmail.com</a>&gt;<br>
 >  Cc: <a href=3D"mailto:gnats-bugs@netbsd.org">gnats-bugs@netbsd.org
 > </a><br>
 >  <span class=3D"">Subject: Re: port-arm32/50218: ARM executables linked
 > with=
 >   native linker on cortex-a9 raises SIGILL<br>
 >  </span>Date: Tue, 8 Sep 2015 08:58:29 +0200<br>
 >  <div class=3D"HOEnZb"><div class=3D"h5"><br>
 >  =C2=A0On Tue, Sep 08, 2015 at 11:12:40AM +0530, Zaid Ibrahime wrote:<br>
 >  =C2=A0&gt;=C2=A0 &gt; Small programs(&lt;6K size) does not result in
 > SIGILL=
 >   as all the<br>
 >  =C2=A0&gt; instruction are properly swapped for endianness by the
 > linker.<b=
 >  r>
 >  =C2=A0&gt;<br>
 >  =C2=A0&gt;=C2=A0 &gt; Are you sure that it depends on size of the
 > program?<=
 >  br>
 >  <br>
 >  =C2=A0Are you building from a single c source, or from libs?<br>
 >  =C2=A0My bet is the swapping happens fine for c source or
 > &quot;normal&quot=
 >  ; objects,<br>
 >  =C2=A0but you are using some lib that has been partially stripped, which
 > ki=
 >  lls<br>
 >  =C2=A0the $t/$a markers. libgcc was one of those libraries (untill
 > fixed)<b=
 >  r>
 >  <br>
 >  =C2=A0Martin<br>
 >  <br>
 >  </div></div></blockquote></div><br></div>
 >
 >  --94eb2c032e6048771a051f3aa196--
 >
 >

 --001a114c8f042599ff051f3addb1
 Content-Type: text/html; charset=UTF-8
 Content-Transfer-Encoding: quoted-printable

 <div dir=3D"ltr">I have reduced the C file in api.c in the working case by =
 commenting some part of the code. In the case of SIGILL its a full file</di=
 v><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Tue, Sep 8, =
 2015 at 5:00 PM, Zaid Ibrahime <span dir=3D"ltr">&lt;<a href=3D"mailto:mzai=
 dibrahime@gmail.com" target=3D"_blank">mzaidibrahime@gmail.com</a>&gt;</spa=
 n> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;b=
 order-left:1px #ccc solid;padding-left:1ex"><span class=3D"">The following =
 reply was made to PR port-arm32/50218; it has been noted by GNATS.<br>
 <br>
 </span><span class=3D"">From: Zaid Ibrahime &lt;<a href=3D"mailto:mzaidibra=
 hime@gmail.com">mzaidibrahime@gmail.com</a>&gt;<br>
 To: <a href=3D"mailto:gnats-bugs@netbsd.org">gnats-bugs@netbsd.org</a><br>
 Cc: <a href=3D"mailto:port-arm32-maintainer@netbsd.org">port-arm32-maintain=
 er@netbsd.org</a>, <a href=3D"mailto:gnats-admin@netbsd.org">gnats-admin@ne=
 tbsd.org</a>,<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <a href=3D"mailto:netbsd-bugs@netbsd.org">netbs=
 d-bugs@netbsd.org</a><br>
 </span><span class=3D"">Subject: Re: port-arm32/50218: ARM executables link=
 ed with native linker on<br>
 =C2=A0cortex-a9 raises SIGILL<br>
 </span>Date: Tue, 8 Sep 2015 16:55:57 +0530<br>
 <br>
 =C2=A0--94eb2c032e6048771a051f3aa196<br>
 =C2=A0Content-Type: text/plain; charset=3DUTF-8<br>
 <div><div class=3D"h5"><br>
 =C2=A0&gt; Are you building from a single c source, or from libs?<br>
 =C2=A0&gt; My bet is the swapping happens fine for c source or &quot;normal=
 &quot; objects,<br>
 =C2=A0&gt; but you are using some lib that has been partially stripped, whi=
 ch kills<br>
 =C2=A0&gt; the $t/$a markers. libgcc was one of those libraries (untill fix=
 ed)<br>
 <br>
 =C2=A0I have compiled 1 file.<br>
 =C2=A0gcc -o api.o -DHAVE_CONFIG_H=C2=A0 -I. -I.. -I../include=C2=A0 -c=C2=
 =A0 api.c<br>
 <br>
 =C2=A0Now I have written a simple C function which calls only one function =
 from<br>
 =C2=A0the objs.<br>
 <br>
 =C2=A0gcc -o test2 -DHAVE_CONFIG_H=C2=A0 -I. -I.. -I../include test1.c api.=
 o<br>
 <br>
 =C2=A0# ./test2<br>
 =C2=A0pid 447 (test2), uid 0: exited on signal 4 (core not dumped, err =3D =
 2)<br>
 =C2=A0[1]=C2=A0 =C2=A0Illegal instruction=C2=A0 =C2=A0 =C2=A0./test2<br>
 <br>
 =C2=A0# gcc -o api.o -DHAVE_CONFIG_H=C2=A0 -I. -I.. -I../include=C2=A0 -c=
 =C2=A0 api.c<br>
 =C2=A0# gcc -o test2 -DHAVE_CONFIG_H=C2=A0 -I. -I.. -I../include test1.c ap=
 i.o<br>
 =C2=A0# ./test2<br>
 =C2=A0#<br>
 <br>
 =C2=A0The content of the test1.c is always the same.<br>
 <br>
 =C2=A0# cat test1.c<br>
 =C2=A0#include &lt;yaml.h&gt;<br>
 <br>
 =C2=A0int main ()<br>
 =C2=A0{<br>
 =C2=A0 =C2=A0yaml_parser_t parser;<br>
 =C2=A0 =C2=A0yaml_parser_initialize (&amp;parser);<br>
 =C2=A0return 0;<br>
 =C2=A0}<br>
 <br>
 =C2=A0The obj is correctly endianness swapped in the latter case. Wonder wh=
 y the<br>
 =C2=A0same function crashes in one case and not the other.<br>
 <br>
 <br>
 <br>
 <br>
 =C2=A0On Tue, Sep 8, 2015 at 12:30 PM, Martin Husemann &lt;<a href=3D"mailt=
 o:martin@duskware.de">martin@duskware.de</a>&gt; wrote:<br>
 <br>
 =C2=A0&gt; The following reply was made to PR port-arm32/50218; it has been=
  noted by<br>
 =C2=A0&gt; GNATS.<br>
 =C2=A0&gt;<br>
 =C2=A0&gt; From: Martin Husemann &lt;<a href=3D"mailto:martin@duskware.de">=
 martin@duskware.de</a>&gt;<br>
 =C2=A0&gt; To: Zaid Ibrahime &lt;<a href=3D"mailto:mzaidibrahime@gmail.com"=
 >mzaidibrahime@gmail.com</a>&gt;<br>
 =C2=A0&gt; Cc: <a href=3D"mailto:gnats-bugs@netbsd.org">gnats-bugs@netbsd.o=
 rg</a><br>
 =C2=A0&gt; Subject: Re: port-arm32/50218: ARM executables linked with nativ=
 e linker<br>
 =C2=A0&gt; on cortex-a9 raises SIGILL<br>
 =C2=A0&gt; Date: Tue, 8 Sep 2015 08:58:29 +0200<br>
 =C2=A0&gt;<br>
 =C2=A0&gt;=C2=A0 On Tue, Sep 08, 2015 at 11:12:40AM +0530, Zaid Ibrahime wr=
 ote:<br>
 =C2=A0&gt;=C2=A0 &gt;=C2=A0 &gt; Small programs(&lt;6K size) does not resul=
 t in SIGILL as all the<br>
 =C2=A0&gt;=C2=A0 &gt; instruction are properly swapped for endianness by th=
 e linker.<br>
 =C2=A0&gt;=C2=A0 &gt;<br>
 =C2=A0&gt;=C2=A0 &gt;=C2=A0 &gt; Are you sure that it depends on size of th=
 e program?<br>
 =C2=A0&gt;<br>
 =C2=A0&gt;=C2=A0 Are you building from a single c source, or from libs?<br>
 =C2=A0&gt;=C2=A0 My bet is the swapping happens fine for c source or &quot;=
 normal&quot; objects,<br>
 =C2=A0&gt;=C2=A0 but you are using some lib that has been partially strippe=
 d, which kills<br>
 =C2=A0&gt;=C2=A0 the $t/$a markers. libgcc was one of those libraries (unti=
 ll fixed)<br>
 =C2=A0&gt;<br>
 =C2=A0&gt;=C2=A0 Martin<br>
 =C2=A0&gt;<br>
 =C2=A0&gt;<br>
 <br>
 </div></div>=C2=A0--94eb2c032e6048771a051f3aa196<br>
 <span class=3D"">=C2=A0Content-Type: text/html; charset=3DUTF-8<br>
 =C2=A0Content-Transfer-Encoding: quoted-printable<br>
 <br>
 </span>=C2=A0&lt;div dir=3D3D&quot;ltr&quot;&gt;&lt;span style=3D3D&quot;co=
 lor:rgb(80,0,80);font-size:12.8px&quot;&gt;&amp;gt; A=3D<br>
 =C2=A0re you building from a single c source, or from libs?&lt;/span&gt;&lt=
 ;br style=3D3D&quot;co=3D<br>
 =C2=A0lor:rgb(80,0,80);font-size:12.8px&quot;&gt;&lt;span style=3D3D&quot;c=
 olor:rgb(80,0,80);font-s=3D<br>
 =C2=A0ize:12.8px&quot;&gt;&amp;gt; My bet is the swapping happens fine for =
 c source or &amp;quot;=3D<br>
 =C2=A0normal&amp;quot; objects,&lt;/span&gt;&lt;br style=3D3D&quot;color:rg=
 b(80,0,80);font-size:12.8p=3D<br>
 =C2=A0x&quot;&gt;&lt;span style=3D3D&quot;color:rgb(80,0,80);font-size:12.8=
 px&quot;&gt;&amp;gt; but you are usi=3D<br>
 =C2=A0ng some lib that has been partially stripped, which kills&lt;/span&gt=
 ;&lt;br style=3D<br>
 =C2=A0=3D3D&quot;color:rgb(80,0,80);font-size:12.8px&quot;&gt;&lt;span styl=
 e=3D3D&quot;color:rgb(80,0,80);=3D<br>
 =C2=A0font-size:12.8px&quot;&gt;&amp;gt; the $t/$a markers. libgcc was one =
 of those libraries=3D<br>
 =C2=A0 (untill fixed)&lt;/span&gt;&lt;br style=3D3D&quot;color:rgb(80,0,80)=
 ;font-size:12.8px&quot;&gt;&lt;di=3D<br>
 =C2=A0v&gt;&lt;span style=3D3D&quot;color:rgb(80,0,80);font-size:12.8px&quo=
 t;&gt;&lt;br&gt;&lt;/span&gt;&lt;/div&gt;&lt;div=3D<br>
 =C2=A0&gt;&lt;font color=3D3D&quot;#500050&quot;&gt;&lt;span style=3D3D&quo=
 t;font-size:12.8px&quot;&gt;I have compiled 1=3D<br>
 =C2=A0 file.=3DC2=3DA0&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;=
 font color=3D3D&quot;#500050&quot;&gt;&lt;span style=3D3D=3D<br>
 =C2=A0&quot;font-size:12.8px&quot;&gt;gcc -o api.o -DHAVE_CONFIG_H =3DC2=3D=
 A0-I. -I.. -I../include=3D<br>
 =C2=A0 =3DC2=3DA0-c =3DC2=3DA0api.c&lt;/span&gt;&lt;br&gt;&lt;/font&gt;&lt;=
 /div&gt;&lt;div&gt;&lt;font color=3D3D&quot;#500050&quot;&gt;&lt;=3D<br>
 =C2=A0span style=3D3D&quot;font-size:12.8px&quot;&gt;&lt;br&gt;&lt;/span&gt=
 ;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=3D3D=3D<br>
 =C2=A0&quot;color:rgb(80,0,80);font-size:12.8px&quot;&gt;Now I have written=
  a simple C functio=3D<br>
 =C2=A0n which calls only one function from the objs.&lt;/span&gt;&lt;font c=
 olor=3D3D&quot;#500050=3D<br>
 =C2=A0&quot;&gt;&lt;span style=3D3D&quot;font-size:12.8px&quot;&gt;&lt;br&g=
 t;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=3D<br>
 =C2=A0=3D3D&quot;color:rgb(80,0,80);font-size:12.8px&quot;&gt;&lt;br&gt;&lt=
 ;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;font c=3D<br>
 =C2=A0olor=3D3D&quot;#500050&quot;&gt;&lt;span style=3D3D&quot;font-size:12=
 .8px&quot;&gt;gcc -o test2 -DHAVE_CONFI=3D<br>
 =C2=A0G_H =3DC2=3DA0-I. -I.. -I../include test1.c api.o&lt;/span&gt;&lt;/fo=
 nt&gt;&lt;/div&gt;&lt;div style=3D<br>
 =C2=A0=3D3D&quot;color:rgb(80,0,80);font-size:12.8px&quot;&gt;&lt;br&gt;&lt=
 ;/div&gt;&lt;/div&gt;&lt;div style=3D3D&quot;&quot;&gt;&lt;d=3D<br>
 =C2=A0iv style=3D3D&quot;color:rgb(80,0,80);font-size:12.8px&quot;&gt;# ./t=
 est2&lt;/div&gt;&lt;div style=3D<br>
 =C2=A0=3D3D&quot;color:rgb(80,0,80);font-size:12.8px&quot;&gt;pid 447 (test=
 2), uid 0: exited on =3D<br>
 =C2=A0signal 4 (core not dumped, err =3D3D 2)&lt;/div&gt;&lt;div style=3D3D=
 &quot;color:rgb(80,0,80)=3D<br>
 =C2=A0;font-size:12.8px&quot;&gt;[1] =3DC2=3DA0 Illegal instruction =3DC2=
 =3DA0 =3DC2=3DA0 ./test2&lt;/di=3D<br>
 =C2=A0v&gt;&lt;div style=3D3D&quot;color:rgb(80,0,80);font-size:12.8px&quot=
 ;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=3D<br>
 =C2=A0=3D3D&quot;&quot;&gt;&lt;div style=3D3D&quot;&quot;&gt;&lt;font color=
 =3D3D&quot;#500050&quot;&gt;&lt;span style=3D3D&quot;font-size:12.8=3D<br>
 =C2=A0px&quot;&gt;# gcc -o api.o -DHAVE_CONFIG_H =3DC2=3DA0-I. -I.. -I../in=
 clude =3DC2=3DA0-c =3DC2=3D<br>
 =C2=A0=3DA0api.c&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=3D3D&qu=
 ot;&quot;&gt;&lt;font color=3D3D&quot;#500050&quot;&gt;&lt;span s=3D<br>
 =C2=A0tyle=3D3D&quot;font-size:12.8px&quot;&gt;# gcc -o test2 -DHAVE_CONFIG=
 _H =3DC2=3DA0-I. -I.. -I.=3D<br>
 =C2=A0./include test1.c api.o&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div =
 style=3D3D&quot;&quot;&gt;&lt;font color=3D3D&quot;#=3D<br>
 =C2=A0500050&quot;&gt;&lt;span style=3D3D&quot;font-size:12.8px&quot;&gt;# =
 ./test2&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div =3D<br>
 =C2=A0style=3D3D&quot;&quot;&gt;&lt;font color=3D3D&quot;#500050&quot;&gt;&=
 lt;span style=3D3D&quot;font-size:12.8px&quot;&gt;# =3DC2=3D<br>
 =C2=A0=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3D=
 A0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3D<br>
 =C2=A0=3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3D=
 C2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3DA0 =3DC2=3D<br>
 =C2=A0=3DA0 =3DC2=3DA0 =3DC2=3DA0&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;=
 div style=3D3D&quot;&quot;&gt;&lt;font color=3D3D&quot;#500050=3D<br>
 =C2=A0&quot;&gt;&lt;span style=3D3D&quot;font-size:12.8px&quot;&gt;&lt;br&g=
 t;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style=3D3D&quot;&quot;&gt;=
 =3D<br>
 =C2=A0&lt;font color=3D3D&quot;#500050&quot;&gt;&lt;span style=3D3D&quot;fo=
 nt-size:12.8px&quot;&gt;The content of the=3D<br>
 =C2=A0 test1.c is always the same.&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt=
 ;div style=3D3D&quot;&quot;&gt;&lt;font color=3D<br>
 =C2=A0=3D3D&quot;#500050&quot;&gt;&lt;span style=3D3D&quot;font-size:12.8px=
 &quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div =3D<br>
 =C2=A0style=3D3D&quot;&quot;&gt;&lt;font color=3D3D&quot;#500050&quot;&gt;&=
 lt;div style=3D3D&quot;&quot;&gt;&lt;span style=3D3D&quot;font-size=3D<br>
 =C2=A0:12.8px&quot;&gt;# cat test1.c&lt;/span&gt;&lt;/div&gt;&lt;div style=
 =3D3D&quot;&quot;&gt;&lt;span style=3D3D&quot;font-size=3D<br>
 =C2=A0:12.8px&quot;&gt;#include &amp;lt;yaml.h&amp;gt;&lt;/span&gt;&lt;/div=
 &gt;&lt;div style=3D3D&quot;&quot;&gt;&lt;span style=3D3D=3D<br>
 =C2=A0&quot;font-size:12.8px&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;/div&gt;&l=
 t;div style=3D3D&quot;&quot;&gt;&lt;span style=3D3D&quot;font-siz=3D<br>
 =C2=A0e:12.8px&quot;&gt;int main ()&lt;/span&gt;&lt;/div&gt;&lt;div style=
 =3D3D&quot;&quot;&gt;&lt;span style=3D3D&quot;font-size:=3D<br>
 =C2=A012.8px&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div style=3D3D&quot;&qu=
 ot;&gt;&lt;span style=3D3D&quot;font-size:12.8px&quot;&gt;=3DC2=3D<br>
 =C2=A0=3DA0 yaml_parser_t parser;&lt;/span&gt;&lt;/div&gt;&lt;div style=3D3=
 D&quot;&quot;&gt;&lt;span style=3D3D&quot;font-s=3D<br>
 =C2=A0ize:12.8px&quot;&gt;=3DC2=3DA0 yaml_parser_initialize (&amp;amp;parse=
 r);&lt;/span&gt;&lt;/div&gt;&lt;div s=3D<br>
 =C2=A0tyle=3D3D&quot;&quot;&gt;&lt;span style=3D3D&quot;font-size:12.8px&qu=
 ot;&gt;return 0;&lt;/span&gt;&lt;/div&gt;&lt;div style=3D<br>
 =C2=A0=3D3D&quot;&quot;&gt;&lt;span style=3D3D&quot;font-size:12.8px&quot;&=
 gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style=3D3D&quot;font-siz=3D<br>
 =C2=A0e:12.8px&quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=3D3D&quot;font-=
 size:12.8px&quot;&gt;The obj is correctly en=3D<br>
 =C2=A0dianness swapped in the latter case. Wonder why the same function cra=
 shes i=3D<br>
 =C2=A0n one case and not the other.&lt;/div&gt;&lt;/font&gt;&lt;/div&gt;&lt=
 ;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;font colo=3D<br>
 =C2=A0r=3D3D&quot;#500050&quot;&gt;&lt;span style=3D3D&quot;font-size:12.8p=
 x&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;&lt;div=3D<br>
 =C2=A0&gt;&lt;span style=3D3D&quot;color:rgb(80,0,80);font-size:12.8px&quot=
 ;&gt;&lt;br&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;=3D<br>
 =C2=A0&lt;span style=3D3D&quot;color:rgb(80,0,80);font-size:12.8px&quot;&gt=
 ;&lt;br&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;=3D<br>
 =C2=A0&lt;div class=3D3D&quot;gmail_extra&quot;&gt;&lt;br&gt;&lt;div class=
 =3D3D&quot;gmail_quote&quot;&gt;On Tue, Sep 8, 20=3D<br>
 =C2=A015 at 12:30 PM, Martin Husemann &lt;span dir=3D3D&quot;ltr&quot;&gt;&=
 amp;lt;&lt;a href=3D3D&quot;mailto:<a href=3D"mailto:mar">mar</a>=3D<br>
 =C2=A0<a href=3D"mailto:tin@duskware.de">tin@duskware.de</a>&quot; target=
 =3D3D&quot;_blank&quot;&gt;<a href=3D"mailto:martin@duskware.de">martin@dus=
 kware.de</a>&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:=3D<br>
 =C2=A0&lt;br&gt;&lt;blockquote class=3D3D&quot;gmail_quote&quot; style=3D3D=
 &quot;margin:0 0 0 .8ex;border-lef=3D<br>
 =C2=A0t:1px #ccc solid;padding-left:1ex&quot;&gt;&lt;span class=3D3D&quot;&=
 quot;&gt;The following reply was=3D<br>
 <span class=3D"">=C2=A0 made to PR port-arm32/50218; it has been noted by G=
 NATS.&lt;br&gt;<br>
 =C2=A0&lt;br&gt;<br>
 =C2=A0From: Martin Husemann &amp;lt;&lt;a href=3D3D&quot;mailto:<a href=3D"=
 mailto:martin@duskware.de">martin@duskware.de</a>&quot;&gt;martin@dusk=3D<b=
 r>
 =C2=A0<a href=3D"http://ware.de" rel=3D"noreferrer" target=3D"_blank">ware.=
 de</a>&lt;/a&gt;&amp;gt;&lt;br&gt;<br>
 </span>=C2=A0&lt;/span&gt;To: Zaid Ibrahime &amp;lt;&lt;a href=3D3D&quot;ma=
 ilto:<a href=3D"mailto:mzaidibrahime@gmail.com">mzaidibrahime@gmail.com</a>=
 &quot;&gt;mza=3D<br>
 =C2=A0<a href=3D"mailto:idibrahime@gmail.com">idibrahime@gmail.com</a>&lt;/=
 a&gt;&amp;gt;&lt;br&gt;<br>
 =C2=A0Cc: &lt;a href=3D3D&quot;mailto:<a href=3D"mailto:gnats-bugs@netbsd.o=
 rg">gnats-bugs@netbsd.org</a>&quot;&gt;<a href=3D"mailto:gnats-bugs@netbsd.=
 org">gnats-bugs@netbsd.org</a>&lt;/a&gt;&lt;br&gt;<br>
 =C2=A0&lt;span class=3D3D&quot;&quot;&gt;Subject: Re: port-arm32/50218: ARM=
  executables linked with=3D<br>
 =C2=A0 native linker on cortex-a9 raises SIGILL&lt;br&gt;<br>
 =C2=A0&lt;/span&gt;Date: Tue, 8 Sep 2015 08:58:29 +0200&lt;br&gt;<br>
 =C2=A0&lt;div class=3D3D&quot;HOEnZb&quot;&gt;&lt;div class=3D3D&quot;h5&qu=
 ot;&gt;&lt;br&gt;<br>
 =C2=A0=3DC2=3DA0On Tue, Sep 08, 2015 at 11:12:40AM +0530, Zaid Ibrahime wro=
 te:&lt;br&gt;<br>
 =C2=A0=3DC2=3DA0&amp;gt;=3DC2=3DA0 &amp;gt; Small programs(&amp;lt;6K size)=
  does not result in SIGILL=3D<br>
 =C2=A0 as all the&lt;br&gt;<br>
 =C2=A0=3DC2=3DA0&amp;gt; instruction are properly swapped for endianness by=
  the linker.&lt;b=3D<br>
 =C2=A0r&gt;<br>
 =C2=A0=3DC2=3DA0&amp;gt;&lt;br&gt;<br>
 =C2=A0=3DC2=3DA0&amp;gt;=3DC2=3DA0 &amp;gt; Are you sure that it depends on=
  size of the program?&lt;=3D<br>
 =C2=A0br&gt;<br>
 =C2=A0&lt;br&gt;<br>
 =C2=A0=3DC2=3DA0Are you building from a single c source, or from libs?&lt;b=
 r&gt;<br>
 =C2=A0=3DC2=3DA0My bet is the swapping happens fine for c source or &amp;qu=
 ot;normal&amp;quot=3D<br>
 =C2=A0; objects,&lt;br&gt;<br>
 =C2=A0=3DC2=3DA0but you are using some lib that has been partially stripped=
 , which ki=3D<br>
 =C2=A0lls&lt;br&gt;<br>
 =C2=A0=3DC2=3DA0the $t/$a markers. libgcc was one of those libraries (until=
 l fixed)&lt;b=3D<br>
 =C2=A0r&gt;<br>
 =C2=A0&lt;br&gt;<br>
 =C2=A0=3DC2=3DA0Martin&lt;br&gt;<br>
 =C2=A0&lt;br&gt;<br>
 =C2=A0&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;=
 /div&gt;<br>
 <br>
 =C2=A0--94eb2c032e6048771a051f3aa196--<br>
 <br>
 </blockquote></div><br></div>

 --001a114c8f042599ff051f3addb1--

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-arm32/50218: ARM executables linked with native linker on cortex-a9 raises SIGILL
Date: Tue, 8 Sep 2015 13:59:21 +0200

 So is the function where it crashes from libgcc?

 Martin

From: Zaid Ibrahime <mzaidibrahime@gmail.com>
To: gnats-bugs@netbsd.org
Cc: port-arm32-maintainer@netbsd.org, gnats-admin@netbsd.org, 
	netbsd-bugs@netbsd.org
Subject: Re: port-arm32/50218: ARM executables linked with native linker on
 cortex-a9 raises SIGILL
Date: Tue, 8 Sep 2015 18:14:36 +0530

 > So is the function where it crashes from libgcc?

 No the first instruction of the function itself crashes(due to wrong
 endianness). the function was compiled on the target.


 On Tue, Sep 8, 2015 at 5:30 PM, Martin Husemann <martin@duskware.de> wrote:
 > The following reply was made to PR port-arm32/50218; it has been noted by GNATS.
 >
 > From: Martin Husemann <martin@duskware.de>
 > To: gnats-bugs@NetBSD.org
 > Cc:
 > Subject: Re: port-arm32/50218: ARM executables linked with native linker on cortex-a9 raises SIGILL
 > Date: Tue, 8 Sep 2015 13:59:21 +0200
 >
 >  So is the function where it crashes from libgcc?
 >
 >  Martin
 >

From: Matt Thomas <matt@3am-software.com>
To: gnats-bugs@NetBSD.org
Cc: port-arm32-maintainer@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org,
 mzaidibrahime@gmail.com
Subject: Re: port-arm32/50218: ARM executables linked with native linker on cortex-a9 raises SIGILL 
Date: Tue, 8 Sep 2015 13:07:09 -0700

 > On Sep 8, 2015, at 5:45 AM, Zaid Ibrahime <mzaidibrahime@gmail.com> =
 wrote:
 >=20
 > The following reply was made to PR port-arm32/50218; it has been noted =
 by GNATS.
 >=20
 > From: Zaid Ibrahime <mzaidibrahime@gmail.com>
 > To: gnats-bugs@netbsd.org
 > Cc: port-arm32-maintainer@netbsd.org, gnats-admin@netbsd.org,=20
 > 	netbsd-bugs@netbsd.org
 > Subject: Re: port-arm32/50218: ARM executables linked with native =
 linker on
 > cortex-a9 raises SIGILL
 > Date: Tue, 8 Sep 2015 18:14:36 +0530
 >=20
 >> So is the function where it crashes from libgcc?
 >=20
 > No the first instruction of the function itself crashes(due to wrong
 > endianness). the function was compiled on the target.

 what command line are you using for linking?=

From: Zaid Ibrahime <mzaidibrahime@gmail.com>
To: gnats-bugs@netbsd.org
Cc: port-arm32-maintainer@netbsd.org, gnats-admin@netbsd.org, 
	netbsd-bugs@netbsd.org
Subject: Re: port-arm32/50218: ARM executables linked with native linker on
 cortex-a9 raises SIGILL
Date: Wed, 9 Sep 2015 12:28:10 +0530

  > what command line are you using for linking?

 Please find the compiler/linker options that I have tried out so far.
 (Note: All these options resulted in SIGILL)

 1.As in PR 49337, I have checked the following commands.(using
 "-static" itself results in SIGILL even for a small C program which
 just has return statement)
  > cc -Wall -O2 -static -c hello.c
  > cc -static -o first hello.o

 2. # gcc -o api.o -DHAVE_CONFIG_H  -I. -I.. -I../include  -c  api.c
     # ld -r -o libyaml.a  api.o
     #gcc =E2=80=93DHAVE_CONFIG_H  =E2=80=93o  test1  -I../include test1.c a=
 pi.o
 Also I have tried to pass explicitly"-be8" to the linker which
 resulted in the same SIGILL
 (As mentioned in the previous post, I am calling one of the function
 in api.c from test1.c
 also  in the second case when I reduced library size by commenting
 some part of the code in api.c. I was able to execute without any
 issue).


 3. #gcc -DHAVE_CONFIG_H -I. -I..  -I../include    -msoft-float
 -mtune=3Dcortex-a9 -c -o my.o my.c
     #gcc -shared  -fPIC -DPIC -o ./my.o   -L/lib -L/usr/lib
 -msoft-float -mtune=3Dcortex-a9 -Wl,-soname libmyx.so.2
     #gcc -I../include -msoft-float -dynamic -mtune=3Dcortex-a9 -g -o
 example-deconstructor example-deconstructor.o  ./libmyx.so.2



 On Wed, Sep 9, 2015 at 1:40 AM, Matt Thomas <matt@3am-software.com> wrote:
 > The following reply was made to PR port-arm32/50218; it has been noted by=
  GNATS.
 >
 > From: Matt Thomas <matt@3am-software.com>
 > To: gnats-bugs@NetBSD.org
 > Cc: port-arm32-maintainer@netbsd.org,
 >  gnats-admin@netbsd.org,
 >  netbsd-bugs@netbsd.org,
 >  mzaidibrahime@gmail.com
 > Subject: Re: port-arm32/50218: ARM executables linked with native linker =
 on cortex-a9 raises SIGILL
 > Date: Tue, 8 Sep 2015 13:07:09 -0700
 >
 >  > On Sep 8, 2015, at 5:45 AM, Zaid Ibrahime <mzaidibrahime@gmail.com> =
 =3D
 >  wrote:
 >  >=3D20
 >  > The following reply was made to PR port-arm32/50218; it has been noted=
  =3D
 >  by GNATS.
 >  >=3D20
 >  > From: Zaid Ibrahime <mzaidibrahime@gmail.com>
 >  > To: gnats-bugs@netbsd.org
 >  > Cc: port-arm32-maintainer@netbsd.org, gnats-admin@netbsd.org,=3D20
 >  >      netbsd-bugs@netbsd.org
 >  > Subject: Re: port-arm32/50218: ARM executables linked with native =3D
 >  linker on
 >  > cortex-a9 raises SIGILL
 >  > Date: Tue, 8 Sep 2015 18:14:36 +0530
 >  >=3D20
 >  >> So is the function where it crashes from libgcc?
 >  >=3D20
 >  > No the first instruction of the function itself crashes(due to wrong
 >  > endianness). the function was compiled on the target.
 >
 >  what command line are you using for linking?=3D
 >

From: Zaid Ibrahime <mzaidibrahime@gmail.com>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: port-arm32/50218: ARM executables linked with native linker on
 cortex-a9 raises SIGILL
Date: Sat, 19 Sep 2015 11:40:02 +0530

 Also when I use -static, it crashes all the time. Could the issue be
 with linker option or static library or the size?
 As far as my observation, if i could reduce the size of the static
 library less than 6000 bytes, I could compile and execute the program
 successfully.

 Please help on this as I am blocked with this completely

 On Wed, Sep 9, 2015 at 12:30 PM, Zaid Ibrahime <mzaidibrahime@gmail.com> wrote:
 > The following reply was made to PR port-arm32/50218; it has been noted by GNATS.
 >
 > From: Zaid Ibrahime <mzaidibrahime@gmail.com>
 > To: gnats-bugs@netbsd.org
 > Cc: port-arm32-maintainer@netbsd.org, gnats-admin@netbsd.org,
 >         netbsd-bugs@netbsd.org
 > Subject: Re: port-arm32/50218: ARM executables linked with native linker on
 >  cortex-a9 raises SIGILL
 > Date: Wed, 9 Sep 2015 12:28:10 +0530
 >
 >   > what command line are you using for linking?
 >
 >  Please find the compiler/linker options that I have tried out so far.
 >  (Note: All these options resulted in SIGILL)
 >
 >  1.As in PR 49337, I have checked the following commands.(using
 >  "-static" itself results in SIGILL even for a small C program which
 >  just has return statement)
 >   > cc -Wall -O2 -static -c hello.c
 >   > cc -static -o first hello.o
 >
 >  2. # gcc -o api.o -DHAVE_CONFIG_H  -I. -I.. -I../include  -c  api.c
 >      # ld -r -o libyaml.a  api.o
 >      #gcc =E2=80=93DHAVE_CONFIG_H  =E2=80=93o  test1  -I../include test1.c a=
 >  pi.o
 >  Also I have tried to pass explicitly"-be8" to the linker which
 >  resulted in the same SIGILL
 >  (As mentioned in the previous post, I am calling one of the function
 >  in api.c from test1.c
 >  also  in the second case when I reduced library size by commenting
 >  some part of the code in api.c. I was able to execute without any
 >  issue).
 >
 >
 >  3. #gcc -DHAVE_CONFIG_H -I. -I..  -I../include    -msoft-float
 >  -mtune=3Dcortex-a9 -c -o my.o my.c
 >      #gcc -shared  -fPIC -DPIC -o ./my.o   -L/lib -L/usr/lib
 >  -msoft-float -mtune=3Dcortex-a9 -Wl,-soname libmyx.so.2
 >      #gcc -I../include -msoft-float -dynamic -mtune=3Dcortex-a9 -g -o
 >  example-deconstructor example-deconstructor.o  ./libmyx.so.2
 >
 >
 >
 >  On Wed, Sep 9, 2015 at 1:40 AM, Matt Thomas <matt@3am-software.com> wrote:
 >  > The following reply was made to PR port-arm32/50218; it has been noted by=
 >   GNATS.
 >  >
 >  > From: Matt Thomas <matt@3am-software.com>
 >  > To: gnats-bugs@NetBSD.org
 >  > Cc: port-arm32-maintainer@netbsd.org,
 >  >  gnats-admin@netbsd.org,
 >  >  netbsd-bugs@netbsd.org,
 >  >  mzaidibrahime@gmail.com
 >  > Subject: Re: port-arm32/50218: ARM executables linked with native linker =
 >  on cortex-a9 raises SIGILL
 >  > Date: Tue, 8 Sep 2015 13:07:09 -0700
 >  >
 >  >  > On Sep 8, 2015, at 5:45 AM, Zaid Ibrahime <mzaidibrahime@gmail.com> =
 >  =3D
 >  >  wrote:
 >  >  >=3D20
 >  >  > The following reply was made to PR port-arm32/50218; it has been noted=
 >   =3D
 >  >  by GNATS.
 >  >  >=3D20
 >  >  > From: Zaid Ibrahime <mzaidibrahime@gmail.com>
 >  >  > To: gnats-bugs@netbsd.org
 >  >  > Cc: port-arm32-maintainer@netbsd.org, gnats-admin@netbsd.org,=3D20
 >  >  >      netbsd-bugs@netbsd.org
 >  >  > Subject: Re: port-arm32/50218: ARM executables linked with native =3D
 >  >  linker on
 >  >  > cortex-a9 raises SIGILL
 >  >  > Date: Tue, 8 Sep 2015 18:14:36 +0530
 >  >  >=3D20
 >  >  >> So is the function where it crashes from libgcc?
 >  >  >=3D20
 >  >  > No the first instruction of the function itself crashes(due to wrong
 >  >  > endianness). the function was compiled on the target.
 >  >
 >  >  what command line are you using for linking?=3D
 >  >
 >

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-arm32/50218: ARM executables linked with native linker on cortex-a9 raises SIGILL
Date: Sat, 19 Sep 2015 16:28:42 +0200

 On Sat, Sep 19, 2015 at 06:15:01AM +0000, Zaid Ibrahime wrote:
 >  Please help on this as I am blocked with this completely

 Is there a good enough reason to use 5.1 for this?
 The netbsd-7 branch (or -current) will give you a much better experience.

 Martin

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.