Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20180502134224.GW1392@brightrain.aerifal.cx>
Date: Wed, 2 May 2018 09:42:24 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Cc: Patrick Oppenlander <patrick.oppenlander@...il.com>
Subject: Re: Some questions

On Wed, May 02, 2018 at 12:14:41AM +0200, Szabolcs Nagy wrote:
> * Andre McCurdy <armccurdy@...il.com> [2018-05-01 14:49:00 -0700]:
> > On Tue, May 1, 2018 at 10:35 AM, Rich Felker <dalias@...c.org> wrote:
> > > I'm considering applying the attached patch, which would make it so
> > > VLAs don't break thumb syscalls and eliminate the need to force frame
> > > pointer off when building as thumb. This is all a workaround for gcc
> > > being wrong about not letting you use r7, but it seems reasonable and
> > > non-invasive. It just omits r7 from the constraints and uses a temp
> > > register to save/restore it.
> > 
> > This seems to fail when compiling src/thread/arm/__set_thread_area.c:
> > 
> >   {standard input}: Assembler messages:
> >   {standard input}:45: Error: invalid constant (f0005) after fixup
> >   make: *** [obj/src/thread/arm/__set_thread_area.o] Error 1
> > 
> > Without the patch, __set_thread_area() effectively compiles to:
> > 
> > __set_thread_area:
> >     push    {r7, lr}
> >     ldr    r7, .L2
> >     pop    {r7, pc}
> > .L2:
> >     .word    983045
> > 
> > With the patch:
> > 
> > __set_thread_area:
> >     push    {r7, lr}
> >     add    r7, sp, #0
> >     mov r3,r7 ; mov r7,#983045 ; svc 0 ; mov r7,r3
> >     pop    {r7, pc}
> > 
> > ie the immediate value 0xf0005 can't be loaded directly into r7 with a
> > single Thumb2 mov instruction.
> > 
> > I tried a quick test to replace the single mov instruction in
> > __asm_syscall() with a movw + movt pair:
> > 
> 
> i think the syscall can be just inline asm here,
> since __set_thread_area is arm specific code.
> 
> in generic code the mov r7,.. hack should work
> and fixes the vla issue.
> 
> (alternatively using just "r" operand instead
> of "rI" does not generate immediate, but will
> use more registers/instructions)

The above posted patch used "ri" not "rI". The "I" constraint, which I
switched to after posting the patch, only allows immediates that work
with mov, so the issue does not arise.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.