Re: ARC testsuite regressions (was Re: [PATCH v7.2 07/13] ARC: Linux Syscall Interface)

2020-07-10 Thread Florian Weimer
* Alistair Francis via Libc-alpha:

> On Thu, Jul 9, 2020 at 2:36 PM Vineet Gupta via Libc-alpha
>  wrote:
>>
>> On 7/9/20 2:13 PM, Vineet Gupta via Libc-alpha wrote:
>> >> Rebased ARC port on master and fired a build-many-glibcs  now 
>> >> (expect some
>> >> abilist updates). Will do a full testsuite run
>> >
>> > No regressions in sysvipc tests !
>>
>> But quite a few regressions. Baseline is ARC port off of upstream 
>> 81b1c8cbb5b4
>> "(hurd: Simplify usleep timeout computation)" and failures below seen in ARC 
>> port
>> off of today's master ffd178c651b8 "(sysv: linux: Add 64-bit time_t variant 
>> for
>> shmctl)"
>>
>> FAIL: dlfcn/tststatic
>> FAIL: dlfcn/tststatic2
>> FAIL: dlfcn/tststatic3
>> FAIL: dlfcn/tststatic4
>> FAIL: dlfcn/tststatic5
>> FAIL: elf/tst-libc_dlvsym
>> FAIL: elf/tst-libc_dlvsym-static
>> FAIL: elf/tst-single_threaded-static-dlopen
>> FAIL: elf/tst-tls9-static
>
> I see the same recent-ish regressions for RV32.

Did you rebuild from scratch?  After the libc.so/ld.so ABI changes that
went in recently, it could be the result of incomplete make
dependencies.

Thanks,
Florian


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: ARC testsuite regressions (was Re: [PATCH v7.2 07/13] ARC: Linux Syscall Interface)

2020-07-10 Thread Vineet Gupta
On 7/10/20 2:28 AM, Florian Weimer via Libc-alpha wrote:
> * Alistair Francis via Libc-alpha:
> 
>> On Thu, Jul 9, 2020 at 2:36 PM Vineet Gupta via Libc-alpha
>>  wrote:
>>>
>>> On 7/9/20 2:13 PM, Vineet Gupta via Libc-alpha wrote:
> Rebased ARC port on master and fired a build-many-glibcs  now 
> (expect some
> abilist updates). Will do a full testsuite run

 No regressions in sysvipc tests !
>>>
>>> But quite a few regressions. Baseline is ARC port off of upstream 
>>> 81b1c8cbb5b4
>>> "(hurd: Simplify usleep timeout computation)" and failures below seen in 
>>> ARC port
>>> off of today's master ffd178c651b8 "(sysv: linux: Add 64-bit time_t variant 
>>> for
>>> shmctl)"
>>>
>>> FAIL: dlfcn/tststatic
>>> FAIL: dlfcn/tststatic2
>>> FAIL: dlfcn/tststatic3
>>> FAIL: dlfcn/tststatic4
>>> FAIL: dlfcn/tststatic5
>>> FAIL: elf/tst-libc_dlvsym
>>> FAIL: elf/tst-libc_dlvsym-static
>>> FAIL: elf/tst-single_threaded-static-dlopen
>>> FAIL: elf/tst-tls9-static
>>
>> I see the same recent-ish regressions for RV32.
> 
> Did you rebuild from scratch?  After the libc.so/ld.so ABI changes that
> went in recently, it could be the result of incomplete make
> dependencies.

>From scratch meaning glibc alone or the whole toolchain. I used buildroot and
glibc-dirclean to nuke entire glibc but gcc was not rebuilt. I can try that too.

Some of the failed tests have prints about static TLS block ... so I'm wondering
if they could be related ?

| $ cat dlfcn/tststatic.out
| .../build/libc.so.6: cannot allocate memory in static TLS block

Also while we figure this out, does this prevent ARC port from being committed. 
It
is a functioning system otherwise: I'm doing doing cross run of testsuite with
sshd etc involved and these addition 10+ failures don't seem to be getting in 
the way.
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: ARC testsuite regressions (was Re: [PATCH v7.2 07/13] ARC: Linux Syscall Interface)

2020-07-10 Thread Florian Weimer
* Vineet Gupta via Libc-alpha:

> From scratch meaning glibc alone or the whole toolchain. I used
> buildroot and glibc-dirclean to nuke entire glibc but gcc was not
> rebuilt. I can try that too.

No, rebuilding glibc from scratch should be fine.

> Some of the failed tests have prints about static TLS block ... so I'm
> wondering if they could be related ?
>
> | $ cat dlfcn/tststatic.out
> | .../build/libc.so.6: cannot allocate memory in static TLS block

This suggests to me that the static initialization code does not produce
sufficient alignment for the TCB, given the 32-byte alignment required
by the rseq area.

You could try and see what happens if you change
sysdeps/arc/nptl/pthreaddef.h to this:

/* Alignment requirement for TCB.  */
#define TCB_ALIGNMENT   32

If that helps, we have more of a generic issue here. 8-/

The problem is that the TLS memory allocator does not add alignment
padding on its own.  This could meet additional alignment requirements
if there is just one thread yet when higher-aligned TLS is loaded.

> Also while we figure this out, does this prevent ARC port from being
> committed.

I don't think so.  We just have to make sure that it does not block the
release, i.e. resolve this during the next week or two.  Do you think
that would that be possible?

Thanks,
Florian


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: ARC testsuite regressions (was Re: [PATCH v7.2 07/13] ARC: Linux Syscall Interface)

2020-07-10 Thread Alistair Francis
On Fri, Jul 10, 2020 at 2:29 AM Florian Weimer  wrote:
>
> * Alistair Francis via Libc-alpha:
>
> > On Thu, Jul 9, 2020 at 2:36 PM Vineet Gupta via Libc-alpha
> >  wrote:
> >>
> >> On 7/9/20 2:13 PM, Vineet Gupta via Libc-alpha wrote:
> >> >> Rebased ARC port on master and fired a build-many-glibcs  now 
> >> >> (expect some
> >> >> abilist updates). Will do a full testsuite run
> >> >
> >> > No regressions in sysvipc tests !
> >>
> >> But quite a few regressions. Baseline is ARC port off of upstream 
> >> 81b1c8cbb5b4
> >> "(hurd: Simplify usleep timeout computation)" and failures below seen in 
> >> ARC port
> >> off of today's master ffd178c651b8 "(sysv: linux: Add 64-bit time_t 
> >> variant for
> >> shmctl)"
> >>
> >> FAIL: dlfcn/tststatic
> >> FAIL: dlfcn/tststatic2
> >> FAIL: dlfcn/tststatic3
> >> FAIL: dlfcn/tststatic4
> >> FAIL: dlfcn/tststatic5
> >> FAIL: elf/tst-libc_dlvsym
> >> FAIL: elf/tst-libc_dlvsym-static
> >> FAIL: elf/tst-single_threaded-static-dlopen
> >> FAIL: elf/tst-tls9-static
> >
> > I see the same recent-ish regressions for RV32.
>
> Did you rebuild from scratch?  After the libc.so/ld.so ABI changes that
> went in recently, it could be the result of incomplete make
> dependencies.

I re-built glibc from scratch on a RV32 setup.

I have now updated the RV32 host (GCC and host glibc) to be built from
the latest master and am rebuilding now.

Alistair

>
> Thanks,
> Florian
>

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: ARC testsuite regressions (was Re: [PATCH v7.2 07/13] ARC: Linux Syscall Interface)

2020-07-10 Thread Alistair Francis
On Fri, Jul 10, 2020 at 8:55 AM Vineet Gupta via Libc-alpha
 wrote:
>
> On 7/10/20 2:28 AM, Florian Weimer via Libc-alpha wrote:
> > * Alistair Francis via Libc-alpha:
> >
> >> On Thu, Jul 9, 2020 at 2:36 PM Vineet Gupta via Libc-alpha
> >>  wrote:
> >>>
> >>> On 7/9/20 2:13 PM, Vineet Gupta via Libc-alpha wrote:
> > Rebased ARC port on master and fired a build-many-glibcs  now 
> > (expect some
> > abilist updates). Will do a full testsuite run
> 
>  No regressions in sysvipc tests !
> >>>
> >>> But quite a few regressions. Baseline is ARC port off of upstream 
> >>> 81b1c8cbb5b4
> >>> "(hurd: Simplify usleep timeout computation)" and failures below seen in 
> >>> ARC port
> >>> off of today's master ffd178c651b8 "(sysv: linux: Add 64-bit time_t 
> >>> variant for
> >>> shmctl)"
> >>>
> >>> FAIL: dlfcn/tststatic
> >>> FAIL: dlfcn/tststatic2
> >>> FAIL: dlfcn/tststatic3
> >>> FAIL: dlfcn/tststatic4
> >>> FAIL: dlfcn/tststatic5
> >>> FAIL: elf/tst-libc_dlvsym
> >>> FAIL: elf/tst-libc_dlvsym-static
> >>> FAIL: elf/tst-single_threaded-static-dlopen
> >>> FAIL: elf/tst-tls9-static
> >>
> >> I see the same recent-ish regressions for RV32.
> >
> > Did you rebuild from scratch?  After the libc.so/ld.so ABI changes that
> > went in recently, it could be the result of incomplete make
> > dependencies.
>
> From scratch meaning glibc alone or the whole toolchain. I used buildroot and
> glibc-dirclean to nuke entire glibc but gcc was not rebuilt. I can try that 
> too.

That's the same with me. The toolchain wasn't rebuilt but glibc was
built from a clean directory. I am rebuilding now with a rebuilt
toolchain.

>
> Some of the failed tests have prints about static TLS block ... so I'm 
> wondering
> if they could be related ?

I see the same messages.

>
> | $ cat dlfcn/tststatic.out
> | .../build/libc.so.6: cannot allocate memory in static TLS block

That's what I see as well.

>
> Also while we figure this out, does this prevent ARC port from being 
> committed. It
> is a functioning system otherwise: I'm doing doing cross run of testsuite with
> sshd etc involved and these addition 10+ failures don't seem to be getting in 
> the way.

Good question!

Alistair

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: ARC testsuite regressions (was Re: [PATCH v7.2 07/13] ARC: Linux Syscall Interface)

2020-07-10 Thread Vineet Gupta
On 7/10/20 10:02 AM, Florian Weimer via Libc-alpha wrote:
> * Vineet Gupta via Libc-alpha:
> 
>> From scratch meaning glibc alone or the whole toolchain. I used
>> buildroot and glibc-dirclean to nuke entire glibc but gcc was not
>> rebuilt. I can try that too.
> 
> No, rebuilding glibc from scratch should be fine.

Right, I clean built the entire toolchain and that didn't help - but turned out 
to
be sane thing anyways as installed headers seems were not rebuilt/installed and 
I
needed the signum.h -> signum-arch.h fixup in vfork.S


>> Some of the failed tests have prints about static TLS block ... so I'm
>> wondering if they could be related ?
>>
>> | $ cat dlfcn/tststatic.out
>> | .../build/libc.so.6: cannot allocate memory in static TLS block
> 
> This suggests to me that the static initialization code does not produce
> sufficient alignment for the TCB, given the 32-byte alignment required
> by the rseq area.
> 
> You could try and see what happens if you change
> sysdeps/arc/nptl/pthreaddef.h to this:
> 
> /* Alignment requirement for TCB.  */
> #define TCB_ALIGNMENT   32
> 
> If that helps, we have more of a generic issue here. 8-/

Bingo, that fixes all the dlfcn/* failures (full testsuite still running)

PASS: dlfcn/tststatic
PASS: dlfcn/tststatic2
PASS: dlfcn/tststatic3
PASS: dlfcn/tststatic4
PASS: dlfcn/tststatic5

So is that the fix or more is needed ?

> The problem is that the TLS memory allocator does not add alignment
> padding on its own.  This could meet additional alignment requirements
> if there is just one thread yet when higher-aligned TLS is loaded.
> 
>> Also while we figure this out, does this prevent ARC port from being
>> committed.
> 
> I don't think so.  We just have to make sure that it does not block the
> release, i.e. resolve this during the next week or two.  Do you think
> that would that be possible?

So it makes sens to commit ARC port now and your fix along the lines can then 
say
what it fixed in-tree.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: ARC testsuite regressions (was Re: [PATCH v7.2 07/13] ARC: Linux Syscall Interface)

2020-07-10 Thread Florian Weimer
* Vineet Gupta:

> On 7/10/20 10:02 AM, Florian Weimer via Libc-alpha wrote:
>> * Vineet Gupta via Libc-alpha:
>> 
>>> From scratch meaning glibc alone or the whole toolchain. I used
>>> buildroot and glibc-dirclean to nuke entire glibc but gcc was not
>>> rebuilt. I can try that too.
>> 
>> No, rebuilding glibc from scratch should be fine.
>
> Right, I clean built the entire toolchain and that didn't help - but turned 
> out to
> be sane thing anyways as installed headers seems were not rebuilt/installed 
> and I
> needed the signum.h -> signum-arch.h fixup in vfork.S
>
>
>>> Some of the failed tests have prints about static TLS block ... so I'm
>>> wondering if they could be related ?
>>>
>>> | $ cat dlfcn/tststatic.out
>>> | .../build/libc.so.6: cannot allocate memory in static TLS block
>> 
>> This suggests to me that the static initialization code does not produce
>> sufficient alignment for the TCB, given the 32-byte alignment required
>> by the rseq area.
>> 
>> You could try and see what happens if you change
>> sysdeps/arc/nptl/pthreaddef.h to this:
>> 
>> /* Alignment requirement for TCB.  */
>> #define TCB_ALIGNMENT   32
>> 
>> If that helps, we have more of a generic issue here. 8-/
>
> Bingo, that fixes all the dlfcn/* failures (full testsuite still running)
>
> PASS: dlfcn/tststatic
> PASS: dlfcn/tststatic2
> PASS: dlfcn/tststatic3
> PASS: dlfcn/tststatic4
> PASS: dlfcn/tststatic5
>
> So is that the fix or more is needed ?

I have just posted an architecture-independent change here:

  

I had forgotten about the similar code for static dlopen when I made the
adjustment in elf/dl-tls.c.  I think we need to clean this up
eventually, it's fairly broken unfortunately.  But the patch I posted
should paper over this problem as far libc.so is concerned (like the
previous patch for dynamic TLS).

Would you mind reverting the TCB_ALIGNMENT change and test this patch?

Thanks,
Florian


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: ARC testsuite regressions (was Re: [PATCH v7.2 07/13] ARC: Linux Syscall Interface)

2020-07-10 Thread Florian Weimer
* Alistair Francis:

> On Fri, Jul 10, 2020 at 8:55 AM Vineet Gupta via Libc-alpha
>  wrote:
>>
>> On 7/10/20 2:28 AM, Florian Weimer via Libc-alpha wrote:
>> > * Alistair Francis via Libc-alpha:
>> >
>> >> On Thu, Jul 9, 2020 at 2:36 PM Vineet Gupta via Libc-alpha
>> >>  wrote:
>> >>>
>> >>> On 7/9/20 2:13 PM, Vineet Gupta via Libc-alpha wrote:
>> > Rebased ARC port on master and fired a build-many-glibcs  now 
>> > (expect some
>> > abilist updates). Will do a full testsuite run
>> 
>>  No regressions in sysvipc tests !
>> >>>
>> >>> But quite a few regressions. Baseline is ARC port off of upstream 
>> >>> 81b1c8cbb5b4
>> >>> "(hurd: Simplify usleep timeout computation)" and failures below seen in 
>> >>> ARC port
>> >>> off of today's master ffd178c651b8 "(sysv: linux: Add 64-bit time_t 
>> >>> variant for
>> >>> shmctl)"
>> >>>
>> >>> FAIL: dlfcn/tststatic
>> >>> FAIL: dlfcn/tststatic2
>> >>> FAIL: dlfcn/tststatic3
>> >>> FAIL: dlfcn/tststatic4
>> >>> FAIL: dlfcn/tststatic5
>> >>> FAIL: elf/tst-libc_dlvsym
>> >>> FAIL: elf/tst-libc_dlvsym-static
>> >>> FAIL: elf/tst-single_threaded-static-dlopen
>> >>> FAIL: elf/tst-tls9-static
>> >>
>> >> I see the same recent-ish regressions for RV32.
>> >
>> > Did you rebuild from scratch?  After the libc.so/ld.so ABI changes that
>> > went in recently, it could be the result of incomplete make
>> > dependencies.
>>
>> From scratch meaning glibc alone or the whole toolchain. I used buildroot and
>> glibc-dirclean to nuke entire glibc but gcc was not rebuilt. I can try that 
>> too.
>
> That's the same with me. The toolchain wasn't rebuilt but glibc was
> built from a clean directory. I am rebuilding now with a rebuilt
> toolchain.
>
>>
>> Some of the failed tests have prints about static TLS block ... so I'm 
>> wondering
>> if they could be related ?
>
> I see the same messages.
>
>>
>> | $ cat dlfcn/tststatic.out
>> | .../build/libc.so.6: cannot allocate memory in static TLS block
>
> That's what I see as well.

Sorry, my fault.  I posted a patch that should fix static dlopen:

  

Would you mind testing it?

Thanks,
Florian


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: ARC testsuite regressions (was Re: [PATCH v7.2 07/13] ARC: Linux Syscall Interface)

2020-07-10 Thread Alistair Francis
On Fri, Jul 10, 2020 at 1:33 PM Florian Weimer  wrote:
>
> * Alistair Francis:
>
> > On Fri, Jul 10, 2020 at 8:55 AM Vineet Gupta via Libc-alpha
> >  wrote:
> >>
> >> On 7/10/20 2:28 AM, Florian Weimer via Libc-alpha wrote:
> >> > * Alistair Francis via Libc-alpha:
> >> >
> >> >> On Thu, Jul 9, 2020 at 2:36 PM Vineet Gupta via Libc-alpha
> >> >>  wrote:
> >> >>>
> >> >>> On 7/9/20 2:13 PM, Vineet Gupta via Libc-alpha wrote:
> >> > Rebased ARC port on master and fired a build-many-glibcs  
> >> > now (expect some
> >> > abilist updates). Will do a full testsuite run
> >> 
> >>  No regressions in sysvipc tests !
> >> >>>
> >> >>> But quite a few regressions. Baseline is ARC port off of upstream 
> >> >>> 81b1c8cbb5b4
> >> >>> "(hurd: Simplify usleep timeout computation)" and failures below seen 
> >> >>> in ARC port
> >> >>> off of today's master ffd178c651b8 "(sysv: linux: Add 64-bit time_t 
> >> >>> variant for
> >> >>> shmctl)"
> >> >>>
> >> >>> FAIL: dlfcn/tststatic
> >> >>> FAIL: dlfcn/tststatic2
> >> >>> FAIL: dlfcn/tststatic3
> >> >>> FAIL: dlfcn/tststatic4
> >> >>> FAIL: dlfcn/tststatic5
> >> >>> FAIL: elf/tst-libc_dlvsym
> >> >>> FAIL: elf/tst-libc_dlvsym-static
> >> >>> FAIL: elf/tst-single_threaded-static-dlopen
> >> >>> FAIL: elf/tst-tls9-static
> >> >>
> >> >> I see the same recent-ish regressions for RV32.
> >> >
> >> > Did you rebuild from scratch?  After the libc.so/ld.so ABI changes that
> >> > went in recently, it could be the result of incomplete make
> >> > dependencies.
> >>
> >> From scratch meaning glibc alone or the whole toolchain. I used buildroot 
> >> and
> >> glibc-dirclean to nuke entire glibc but gcc was not rebuilt. I can try 
> >> that too.
> >
> > That's the same with me. The toolchain wasn't rebuilt but glibc was
> > built from a clean directory. I am rebuilding now with a rebuilt
> > toolchain.
> >
> >>
> >> Some of the failed tests have prints about static TLS block ... so I'm 
> >> wondering
> >> if they could be related ?
> >
> > I see the same messages.
> >
> >>
> >> | $ cat dlfcn/tststatic.out
> >> | .../build/libc.so.6: cannot allocate memory in static TLS block
> >
> > That's what I see as well.
>
> Sorry, my fault.  I posted a patch that should fix static dlopen:
>
>   
>
> Would you mind testing it?

Yep, I'm currently in the middle of a different test. When that
finishes I'll test again, that'll take around 48 hours though

Alistair

>
> Thanks,
> Florian
>

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[COMMITTED 09/13] ARC: Linux Startup and Dynamic Loading

2020-07-10 Thread Vineet Gupta
A big shoutout to Cupertino Miranda  for his
valuable contribution in initial bringup and debugging on Linux and
later in solving pesky unwinding/cancelation failures in testsuite.

Reviewed-by: Adhemerval Zanella  
---
 sysdeps/unix/sysv/linux/arc/dl-static.c | 84 +
 sysdeps/unix/sysv/linux/arc/ldsodefs.h  | 32 ++
 2 files changed, 116 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/arc/dl-static.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/ldsodefs.h

diff --git a/sysdeps/unix/sysv/linux/arc/dl-static.c 
b/sysdeps/unix/sysv/linux/arc/dl-static.c
new file mode 100644
index ..30bcd899d42d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/dl-static.c
@@ -0,0 +1,84 @@
+/* Variable initialization.  ARC version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#include 
+
+#ifdef SHARED
+
+void
+_dl_var_init (void *array[])
+{
+  /* It has to match "variables" below. */
+  enum
+{
+  DL_PAGESIZE = 0
+};
+
+  GLRO(dl_pagesize) = *((size_t *) array[DL_PAGESIZE]);
+}
+
+#else
+
+static void *variables[] =
+{
+  &GLRO(dl_pagesize)
+};
+
+static void
+_dl_unprotect_relro (struct link_map *l)
+{
+  ElfW(Addr) start = ((l->l_addr + l->l_relro_addr)
+ & ~(GLRO(dl_pagesize) - 1));
+  ElfW(Addr) end = ((l->l_addr + l->l_relro_addr + l->l_relro_size)
+   & ~(GLRO(dl_pagesize) - 1));
+
+  if (start != end)
+__mprotect ((void *) start, end - start, PROT_READ | PROT_WRITE);
+}
+
+void
+_dl_static_init (struct link_map *l)
+{
+  struct link_map *rtld_map = l;
+  struct r_scope_elem **scope;
+  const ElfW(Sym) *ref = NULL;
+  lookup_t loadbase;
+  void (*f) (void *[]);
+  size_t i;
+
+  loadbase = _dl_lookup_symbol_x ("_dl_var_init", l, &ref, l->l_local_scope,
+ NULL, 0, 1, NULL);
+
+  for (scope = l->l_local_scope; *scope != NULL; scope++)
+for (i = 0; i < (*scope)->r_nlist; i++)
+  if ((*scope)->r_list[i] == loadbase)
+   {
+ rtld_map = (*scope)->r_list[i];
+ break;
+   }
+
+  if (ref != NULL)
+{
+  f = (void (*) (void *[])) DL_SYMBOL_ADDRESS (loadbase, ref);
+  _dl_unprotect_relro (rtld_map);
+  f (variables);
+  _dl_protect_relro (rtld_map);
+}
+}
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/arc/ldsodefs.h 
b/sysdeps/unix/sysv/linux/arc/ldsodefs.h
new file mode 100644
index ..204a0ff8946c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/ldsodefs.h
@@ -0,0 +1,32 @@
+/* Run-time dynamic linker data structures for loaded ELF shared objects. ARC
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   .  */
+
+#ifndef_LDSODEFS_H
+
+/* Get the real definitions.  */
+#include_next 
+
+/* Now define our stuff.  */
+
+/* We need special support to initialize DSO loaded for statically linked
+   binaries.  */
+extern void _dl_static_init (struct link_map *map);
+#undef DL_STATIC_INIT
+#define DL_STATIC_INIT(map) _dl_static_init (map)
+
+#endif /* ldsodefs.h */
-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[COMMITTED 04/13] ARC: Atomics and Locking primitives

2020-07-10 Thread Vineet Gupta
Reviewed-by: Adhemerval Zanella  
---
 sysdeps/arc/atomic-machine.h | 69 
 1 file changed, 69 insertions(+)
 create mode 100644 sysdeps/arc/atomic-machine.h

diff --git a/sysdeps/arc/atomic-machine.h b/sysdeps/arc/atomic-machine.h
new file mode 100644
index ..1c8638bb44ef
--- /dev/null
+++ b/sysdeps/arc/atomic-machine.h
@@ -0,0 +1,69 @@
+/* Low-level functions for atomic operations. ARC version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#ifndef _ARC_BITS_ATOMIC_H
+#define _ARC_BITS_ATOMIC_H 1
+
+#include 
+
+typedef int32_t atomic32_t;
+typedef uint32_t uatomic32_t;
+typedef int_fast32_t atomic_fast32_t;
+typedef uint_fast32_t uatomic_fast32_t;
+
+typedef intptr_t atomicptr_t;
+typedef uintptr_t uatomicptr_t;
+typedef intmax_t atomic_max_t;
+typedef uintmax_t uatomic_max_t;
+
+#define __HAVE_64B_ATOMICS 0
+#define USE_ATOMIC_COMPILER_BUILTINS 1
+
+/* ARC does have legacy atomic EX reg, [mem] instruction but the micro-arch
+   is not as optimal as LLOCK/SCOND specially for SMP.  */
+#define ATOMIC_EXCHANGE_USES_CAS 1
+
+#define __arch_compare_and_exchange_bool_8_acq(mem, newval, oldval)\
+  (abort (), 0)
+#define __arch_compare_and_exchange_bool_16_acq(mem, newval, oldval)   \
+  (abort (), 0)
+#define __arch_compare_and_exchange_bool_64_acq(mem, newval, oldval)   \
+  (abort (), 0)
+
+#define __arch_compare_and_exchange_val_8_int(mem, newval, oldval, model)  
\
+  (abort (), (__typeof (*mem)) 0)
+#define __arch_compare_and_exchange_val_16_int(mem, newval, oldval, model) 
\
+  (abort (), (__typeof (*mem)) 0)
+#define __arch_compare_and_exchange_val_64_int(mem, newval, oldval, model) 
\
+  (abort (), (__typeof (*mem)) 0)
+
+#define __arch_compare_and_exchange_val_32_int(mem, newval, oldval, model) 
\
+  ({   
\
+typeof (*mem) __oldval = (oldval); 
\
+__atomic_compare_exchange_n (mem, (void *) &__oldval, newval, 0,   
\
+ model, __ATOMIC_RELAXED); 
\
+__oldval;  
\
+  })
+
+#define atomic_compare_and_exchange_val_acq(mem, new, old) \
+  __atomic_val_bysize (__arch_compare_and_exchange_val, int,   \
+  mem, new, old, __ATOMIC_ACQUIRE)
+
+#define atomic_full_barrier()  ({ asm volatile ("dmb 3":::"memory"); })
+
+#endif /* _ARC_BITS_ATOMIC_H */
-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[COMMITTED 02/13] ARC: startup and dynamic linking code

2020-07-10 Thread Vineet Gupta
Code for C runtime startup and dynamic loading including PLT layout.

Reviewed-by: Adhemerval Zanella  
---
 sysdeps/arc/bits/link.h   |  52 ++
 sysdeps/arc/dl-machine.h  | 344 ++
 sysdeps/arc/entry.h   |   5 +
 sysdeps/arc/ldsodefs.h|  43 +
 sysdeps/arc/sotruss-lib.c |  50 ++
 sysdeps/arc/start.S   |  74 
 sysdeps/arc/tst-audit.h   |  23 +++
 7 files changed, 591 insertions(+)
 create mode 100644 sysdeps/arc/bits/link.h
 create mode 100644 sysdeps/arc/dl-machine.h
 create mode 100644 sysdeps/arc/entry.h
 create mode 100644 sysdeps/arc/ldsodefs.h
 create mode 100644 sysdeps/arc/sotruss-lib.c
 create mode 100644 sysdeps/arc/start.S
 create mode 100644 sysdeps/arc/tst-audit.h

diff --git a/sysdeps/arc/bits/link.h b/sysdeps/arc/bits/link.h
new file mode 100644
index ..b687250a7a07
--- /dev/null
+++ b/sysdeps/arc/bits/link.h
@@ -0,0 +1,52 @@
+/* Machine-specific declarations for dynamic linker interface, ARC version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#ifndef_LINK_H
+# error "Never include  directly; use  instead."
+#endif
+
+/* Registers for entry into PLT on ARC.  */
+typedef struct La_arc_regs
+{
+  uint32_t lr_reg[8]; /* r0 through r7 (upto 8 args).  */
+} La_arc_regs;
+
+/* Return values for calls from PLT on ARC.  */
+typedef struct La_arc_retval
+{
+  /* For ARCv2, a 64-bit integer return value can use 2 regs.  */
+  uint32_t lrv_reg[2];
+} La_arc_retval;
+
+__BEGIN_DECLS
+
+extern ElfW(Addr) la_arc_gnu_pltenter (ElfW(Sym) *__sym, unsigned int __ndx,
+uintptr_t *__refcook,
+uintptr_t *__defcook,
+La_arc_regs *__regs,
+unsigned int *__flags,
+const char *__symname,
+long int *__framesizep);
+extern unsigned int la_arc_gnu_pltexit (ElfW(Sym) *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ const La_arc_regs *__inregs,
+ La_arc_retval *__outregs,
+ const char *symname);
+
+__END_DECLS
diff --git a/sysdeps/arc/dl-machine.h b/sysdeps/arc/dl-machine.h
new file mode 100644
index ..e47f19905f1f
--- /dev/null
+++ b/sysdeps/arc/dl-machine.h
@@ -0,0 +1,344 @@
+/* Machine-dependent ELF dynamic relocation inline functions.  ARC version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#ifndef dl_machine_h
+#define dl_machine_h
+
+#define ELF_MACHINE_NAME "arc"
+
+#include 
+
+#ifndef ENTRY_POINT
+# error ENTRY_POINT needs to be defined for ARC
+#endif
+
+#include 
+#include 
+#include 
+
+/* Dynamic Linking ABI for ARCv2 ISA.
+
+PLT
+   < DT_PLTGOT
+  |  ld r11, [pcl, off-to-GOT[1] |  0
+  |  |  4
+   plt0   |  ld r10, [pcl, off-to-GOT[2] |  8
+  |  | 12
+  |  j [r10] | 16
+  
+  |Base address of GOT   | 20
+  
+  |  ld r12, [pcl, off-to-GOT[3] | 24
+   plt1   |

[COMMITTED 13/13] Documentation for ARC port

2020-07-10 Thread Vineet Gupta
(a) ABI doc:

https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/wiki/files/ARCv2_ABI.pdf

(b) Programmer's Reference Manual (PRM) : needs a download request to be filled
https://www.synopsys.com/dw/ipdir.php?ds=arc-hs44-hs46-hs48

https://www.synopsys.com/dw/doc.php/ds/cc/programmers-reference-manual-ARC-HS.pdf

As of port merge (and Florian's patch to fix static TLS), glibc testsuite
(cross-test setup) has following failures:

FAIL: elf/tst-audit14
FAIL: elf/tst-audit15
FAIL: elf/tst-audit16
FAIL: elf/tst-ldconfig-ld_so_conf-update
FAIL: elf/tst-libc_dlvsym
FAIL: elf/tst-libc_dlvsym-static
FAIL: iconv/test-iconvconfig# Needs gconv installed
FAIL: io/ftwtest# Requires execution by non-root
FAIL: io/tst-lockf
FAIL: libio/tst-wfile-sync
FAIL: locale/tst-localedef-path-norm
FAIL: nptl/test-cond-printers   # needs Python3 and target GDB on target
FAIL: nptl/test-condattr-printers   #ditto
FAIL: nptl/test-mutex-printers  #ditto
FAIL: nptl/test-mutexattr-printers  #ditto
FAIL: nptl/test-rwlock-printers #ditto
FAIL: nptl/test-rwlockattr-printers #ditto
FAIL: nptl/tst-umask1   # passes if run natively on target (NFS 
ACLv3 support needed)
FAIL: nss/bug-erange
FAIL: nss/tst-nss-files-hosts-getent
FAIL: nss/tst-nss-files-hosts-multi
FAIL: posix/bug-ga2
FAIL: posix/globtest# require same user on target and host
FAIL: posix/tst-getaddrinfo5
FAIL: stdio-common/tst-vfprintf-width-prec
FAIL: stdio-common/tst-vfprintf-width-prec-alloc
FAIL: stdio-common/tst-vfprintf-width-prec-mem
FAIL: string/tst-strerror
FAIL: string/tst-strsignal
FAIL: sunrpc/bug20790   # missing cpp on target
FAIL: timezone/tst-tzset

Reviewed-by: Adhemerval Zanella  
---
 NEWS| 11 +++
 README  |  1 +
 manual/install.texi |  4 
 3 files changed, 16 insertions(+)

diff --git a/NEWS b/NEWS
index 0b25b4fde99a..92dcb77fef07 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,17 @@ Major new features:
 
 * New locale added: ckb_IQ (Kurdish/Sorani spoken in Iraq)
 
+* Support for Synopsys ARC HS cores (ARCv2 ISA) running Linux has been
+  added. This port requires at least binutils-2.32, gcc-8.3 and Linux-5.1.
+  Three ABIs are supported:
+
+ - arc-linux-gnu
+ - arc-linux-gnuhf
+ - arceb-linux-gnu
+
+  The arc* ABI is little-endian while arceb is big-endian. All ABIs use
+  64-bit time (y2038 safe) and 64-bit file offsets (LFS default).
+
 * The GNU C Library now loads audit modules listed in the DT_AUDIT and
   DT_DEPAUDIT dynamic section entries of the main executable.
 
diff --git a/README b/README
index 31c5da0405bd..903f07e4840a 100644
--- a/README
+++ b/README
@@ -24,6 +24,7 @@ The GNU C Library supports these configurations for using 
Linux kernels:
 
aarch64*-*-linux-gnu
alpha*-*-linux-gnu
+   arc*-*-linux-gnu
arm-*-linux-gnueabi
csky-*-linux-gnuabiv2
hppa-*-linux-gnu
diff --git a/manual/install.texi b/manual/install.texi
index ea0059a4ec98..735e99bb0356 100644
--- a/manual/install.texi
+++ b/manual/install.texi
@@ -512,6 +512,8 @@ Library with support for IEEE long double.
 @c powerpc64le performs an autoconf test to verify the compiler compiles with
 @c commands like "$CC -c foo.c -mabi=ibmlongdouble -mlong-double-128".
 
+For ARC architecture builds, GCC 8.3 or higher is needed.
+
 For multi-arch support it is recommended to use a GCC which has been built with
 support for GNU indirect functions.  This ensures that correct debugging
 information is generated for functions selected by IFUNC resolvers.  This
@@ -537,6 +539,8 @@ For PowerPC 64-bits little-endian (powerpc64le), 
@command{objcopy} is required
 to support @option{--update-section}.  This option requires binutils 2.26 or
 newer.
 
+ARC architecture needs @code{binutils} 2.32 or higher for TLS related fixes.
+
 @item
 GNU @code{texinfo} 4.7 or later
 
-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[COMMITTED 07/13] ARC: Linux Syscall Interface

2020-07-10 Thread Vineet Gupta
Reviewed-by: Adhemerval Zanella  
---
 sysdeps/unix/sysv/linux/arc/arch-syscall.h| 298 ++
 sysdeps/unix/sysv/linux/arc/bits/timesize.h   |  21 ++
 sysdeps/unix/sysv/linux/arc/clone.S   |  93 ++
 .../unix/sysv/linux/arc/fixup-asm-unistd.h|  46 +++
 sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h  |   6 +
 sysdeps/unix/sysv/linux/arc/kernel-features.h |  27 ++
 sysdeps/unix/sysv/linux/arc/kernel_stat.h |  26 ++
 sysdeps/unix/sysv/linux/arc/mmap_internal.h   |  27 ++
 sysdeps/unix/sysv/linux/arc/sigaction.c   |  31 ++
 sysdeps/unix/sysv/linux/arc/sigrestorer.S |  29 ++
 sysdeps/unix/sysv/linux/arc/syscall.S |  33 ++
 sysdeps/unix/sysv/linux/arc/syscalls.list |   3 +
 sysdeps/unix/sysv/linux/arc/sysdep.c  |  33 ++
 sysdeps/unix/sysv/linux/arc/sysdep.h  | 226 +
 sysdeps/unix/sysv/linux/arc/vfork.S   |  42 +++
 15 files changed, 941 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/arc/arch-syscall.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/timesize.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/clone.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/fixup-asm-unistd.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/kernel-features.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/kernel_stat.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/mmap_internal.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/sigaction.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/sigrestorer.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/syscall.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/syscalls.list
 create mode 100644 sysdeps/unix/sysv/linux/arc/sysdep.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/sysdep.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/vfork.S

diff --git a/sysdeps/unix/sysv/linux/arc/arch-syscall.h 
b/sysdeps/unix/sysv/linux/arc/arch-syscall.h
new file mode 100644
index ..58cd927da81b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/arch-syscall.h
@@ -0,0 +1,298 @@
+/* AUTOGENERATED by update-syscall-lists.py.  */
+#define __NR_accept 202
+#define __NR_accept4 242
+#define __NR_acct 89
+#define __NR_add_key 217
+#define __NR_adjtimex 171
+#define __NR_arc_gettls 246
+#define __NR_arc_settls 245
+#define __NR_arc_usr_cmpxchg 248
+#define __NR_bind 200
+#define __NR_bpf 280
+#define __NR_brk 214
+#define __NR_cacheflush 244
+#define __NR_capget 90
+#define __NR_capset 91
+#define __NR_chdir 49
+#define __NR_chroot 51
+#define __NR_clock_adjtime64 405
+#define __NR_clock_getres_time64 406
+#define __NR_clock_gettime64 403
+#define __NR_clock_nanosleep_time64 407
+#define __NR_clock_settime64 404
+#define __NR_clone 220
+#define __NR_clone3 435
+#define __NR_close 57
+#define __NR_connect 203
+#define __NR_copy_file_range 285
+#define __NR_delete_module 106
+#define __NR_dup 23
+#define __NR_dup3 24
+#define __NR_epoll_create1 20
+#define __NR_epoll_ctl 21
+#define __NR_epoll_pwait 22
+#define __NR_eventfd2 19
+#define __NR_execve 221
+#define __NR_execveat 281
+#define __NR_exit 93
+#define __NR_exit_group 94
+#define __NR_faccessat 48
+#define __NR_fadvise64_64 223
+#define __NR_fallocate 47
+#define __NR_fanotify_init 262
+#define __NR_fanotify_mark 263
+#define __NR_fchdir 50
+#define __NR_fchmod 52
+#define __NR_fchmodat 53
+#define __NR_fchown 55
+#define __NR_fchownat 54
+#define __NR_fcntl64 25
+#define __NR_fdatasync 83
+#define __NR_fgetxattr 10
+#define __NR_finit_module 273
+#define __NR_flistxattr 13
+#define __NR_flock 32
+#define __NR_fremovexattr 16
+#define __NR_fsconfig 431
+#define __NR_fsetxattr 7
+#define __NR_fsmount 432
+#define __NR_fsopen 430
+#define __NR_fspick 433
+#define __NR_fstatfs64 44
+#define __NR_fsync 82
+#define __NR_ftruncate64 46
+#define __NR_futex_time64 422
+#define __NR_get_mempolicy 236
+#define __NR_get_robust_list 100
+#define __NR_getcpu 168
+#define __NR_getcwd 17
+#define __NR_getdents64 61
+#define __NR_getegid 177
+#define __NR_geteuid 175
+#define __NR_getgid 176
+#define __NR_getgroups 158
+#define __NR_getitimer 102
+#define __NR_getpeername 205
+#define __NR_getpgid 155
+#define __NR_getpid 172
+#define __NR_getppid 173
+#define __NR_getpriority 141
+#define __NR_getrandom 278
+#define __NR_getresgid 150
+#define __NR_getresuid 148
+#define __NR_getrlimit 163
+#define __NR_getrusage 165
+#define __NR_getsid 156
+#define __NR_getsockname 204
+#define __NR_getsockopt 209
+#define __NR_gettid 178
+#define __NR_gettimeofday 169
+#define __NR_getuid 174
+#define __NR_getxattr 8
+#define __NR_init_module 105
+#define __NR_inotify_add_watch 27
+#define __NR_inotify_init1 26
+#define __NR_inotify_rm_watch 28
+#define __NR_io_cancel 3
+#define __NR_io_destroy 1
+#define __NR_io_getevents 4
+#define __NR_io_pgetevents 292
+#define __NR_io_pgetevents_time64 416
+#define __NR_io_setup 0
+#define __NR_io_submit 2
+#define __NR_io_uring_enter 426
+#define __NR_io_urin

[COMMITTED 03/13] ARC: Thread Local Storage support

2020-07-10 Thread Vineet Gupta
This includes all 4 TLS addressing models

Reviewed-by: Adhemerval Zanella  
---
 sysdeps/arc/dl-tls.h |  30 +++
 sysdeps/arc/libc-tls.c   |  27 ++
 sysdeps/arc/nptl/tcb-offsets.sym |  11 +++
 sysdeps/arc/nptl/tls.h   | 139 +++
 sysdeps/arc/stackinfo.h  |  33 
 5 files changed, 240 insertions(+)
 create mode 100644 sysdeps/arc/dl-tls.h
 create mode 100644 sysdeps/arc/libc-tls.c
 create mode 100644 sysdeps/arc/nptl/tcb-offsets.sym
 create mode 100644 sysdeps/arc/nptl/tls.h
 create mode 100644 sysdeps/arc/stackinfo.h

diff --git a/sysdeps/arc/dl-tls.h b/sysdeps/arc/dl-tls.h
new file mode 100644
index ..0f3626d197c9
--- /dev/null
+++ b/sysdeps/arc/dl-tls.h
@@ -0,0 +1,30 @@
+/* Thread-local storage handling in the ELF dynamic linker.  ARC version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+
+/* Type used for the representation of TLS information in the GOT.  */
+typedef struct
+{
+  unsigned long int ti_module;
+  unsigned long int ti_offset;
+} tls_index;
+
+extern void *__tls_get_addr (tls_index *ti);
+
+/* Value used for dtv entries for which the allocation is delayed.  */
+#define TLS_DTV_UNALLOCATED((void *) -1l)
diff --git a/sysdeps/arc/libc-tls.c b/sysdeps/arc/libc-tls.c
new file mode 100644
index ..234932c29512
--- /dev/null
+++ b/sysdeps/arc/libc-tls.c
@@ -0,0 +1,27 @@
+/* Thread-local storage handling in the ELF dynamic linker.  ARC version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#include 
+#include 
+
+void *
+__tls_get_addr (tls_index *ti)
+{
+  dtv_t *dtv = THREAD_DTV ();
+  return (char *) dtv[1].pointer.val + ti->ti_offset;
+}
diff --git a/sysdeps/arc/nptl/tcb-offsets.sym b/sysdeps/arc/nptl/tcb-offsets.sym
new file mode 100644
index ..64c432c22e76
--- /dev/null
+++ b/sysdeps/arc/nptl/tcb-offsets.sym
@@ -0,0 +1,11 @@
+#include 
+#include 
+
+-- Derive offsets relative to the thread register.
+#define thread_offsetof(mem)   (long)(offsetof (struct pthread, mem) - sizeof 
(struct pthread))
+
+MULTIPLE_THREADS_OFFSEToffsetof (struct pthread, 
header.multiple_threads)
+TLS_PRE_TCB_SIZE   sizeof (struct pthread)
+TLS_TCB_SIZE   sizeof (tcbhead_t)
+
+PTHREAD_TIDoffsetof (struct pthread, tid)
diff --git a/sysdeps/arc/nptl/tls.h b/sysdeps/arc/nptl/tls.h
new file mode 100644
index ..184b550ab5c9
--- /dev/null
+++ b/sysdeps/arc/nptl/tls.h
@@ -0,0 +1,139 @@
+/* Definition for thread-local data handling.  NPTL/ARC version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#ifndef _ARC_NPTL_TLS_H
+#define _ARC_NPTL_TLS_H1
+
+#include 
+
+#ifndef __ASSEMBLER__
+
+# include 

[COMMITTED 01/13] ARC: ABI Implementation

2020-07-10 Thread Vineet Gupta
This code deals with the ARC ABI.

Reviewed-by: Adhemerval Zanella  
---
 sysdeps/arc/__longjmp.S   | 49 
 sysdeps/arc/abort-instr.h |  2 +
 sysdeps/arc/bits/endianness.h | 15 
 sysdeps/arc/bits/setjmp.h | 26 +
 sysdeps/arc/bsd-_setjmp.S |  1 +
 sysdeps/arc/bsd-setjmp.S  |  1 +
 sysdeps/arc/dl-runtime.h  | 42 
 sysdeps/arc/dl-sysdep.h   | 25 
 sysdeps/arc/dl-trampoline.S   | 72 +++
 sysdeps/arc/gccframe.h| 21 ++
 sysdeps/arc/jmpbuf-offsets.h  | 22 +++
 sysdeps/arc/jmpbuf-unwind.h   | 47 +++
 sysdeps/arc/machine-gmon.h| 35 +
 sysdeps/arc/memusage.h| 23 +++
 sysdeps/arc/setjmp.S  | 66 
 sysdeps/arc/sysdep.h  | 53 ++
 sysdeps/arc/tls-macros.h  | 47 +++
 17 files changed, 547 insertions(+)
 create mode 100644 sysdeps/arc/__longjmp.S
 create mode 100644 sysdeps/arc/abort-instr.h
 create mode 100644 sysdeps/arc/bits/endianness.h
 create mode 100644 sysdeps/arc/bits/setjmp.h
 create mode 100644 sysdeps/arc/bsd-_setjmp.S
 create mode 100644 sysdeps/arc/bsd-setjmp.S
 create mode 100644 sysdeps/arc/dl-runtime.h
 create mode 100644 sysdeps/arc/dl-sysdep.h
 create mode 100644 sysdeps/arc/dl-trampoline.S
 create mode 100644 sysdeps/arc/gccframe.h
 create mode 100644 sysdeps/arc/jmpbuf-offsets.h
 create mode 100644 sysdeps/arc/jmpbuf-unwind.h
 create mode 100644 sysdeps/arc/machine-gmon.h
 create mode 100644 sysdeps/arc/memusage.h
 create mode 100644 sysdeps/arc/setjmp.S
 create mode 100644 sysdeps/arc/sysdep.h
 create mode 100644 sysdeps/arc/tls-macros.h

diff --git a/sysdeps/arc/__longjmp.S b/sysdeps/arc/__longjmp.S
new file mode 100644
index ..fcbf1bb6c0e2
--- /dev/null
+++ b/sysdeps/arc/__longjmp.S
@@ -0,0 +1,49 @@
+/* longjmp for ARC.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#include 
+#include 
+
+/* @ r0 = jump buffer from which regs will be restored
+   @ r1 = value that setjmp( ) will return due to this longjmp.  */
+
+ENTRY (__longjmp)
+
+   LDR (blink, r0,  0)
+   LDR (sp,r0,  1)
+   LDR (fp,r0,  2)
+   LDR (gp,r0,  3)
+
+   LDR (r13,   r0,  4)
+   LDR (r14,   r0,  5)
+   LDR (r15,   r0,  6)
+   LDR (r16,   r0,  7)
+   LDR (r17,   r0,  8)
+   LDR (r18,   r0,  9)
+   LDR (r19,   r0, 10)
+   LDR (r20,   r0, 11)
+   LDR (r21,   r0, 12)
+   LDR (r22,   r0, 13)
+   LDR (r23,   r0, 14)
+   LDR (r24,   r0, 15)
+
+   mov.f  r0, r1
+   j.d[blink]
+   mov.z  r0, 1/* don't return 0 to setjmp callsite from longjmp.  */
+
+END (__longjmp)
diff --git a/sysdeps/arc/abort-instr.h b/sysdeps/arc/abort-instr.h
new file mode 100644
index ..49f33613c404
--- /dev/null
+++ b/sysdeps/arc/abort-instr.h
@@ -0,0 +1,2 @@
+/* FLAG 1 is privilege mode only instruction, hence will crash any program.  */
+#define ABORT_INSTRUCTION asm ("flag 1")
diff --git a/sysdeps/arc/bits/endianness.h b/sysdeps/arc/bits/endianness.h
new file mode 100644
index ..8f17ca84b485
--- /dev/null
+++ b/sysdeps/arc/bits/endianness.h
@@ -0,0 +1,15 @@
+#ifndef _BITS_ENDIANNESS_H
+#define _BITS_ENDIANNESS_H 1
+
+#ifndef _BITS_ENDIAN_H
+# error "Never use  directly; include  instead."
+#endif
+
+/* ARC has selectable endianness.  */
+#ifdef __BIG_ENDIAN__
+# define __BYTE_ORDER __BIG_ENDIAN
+#else
+# define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
+
+#endif /* bits/endianness.h */
diff --git a/sysdeps/arc/bits/setjmp.h b/sysdeps/arc/bits/setjmp.h
new file mode 100644
index ..9136bdba34ea
--- /dev/null
+++ b/sysdeps/arc/bits/setjmp.h
@@ -0,0 +1,26 @@
+/* Define the machine-dependent type 'jmp_buf'.  ARC version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+

[COMMITTED 08/13] ARC: Linux ABI

2020-07-10 Thread Vineet Gupta
Reviewed-by: Adhemerval Zanella  
---
 sysdeps/arc/nptl/pthreaddef.h | 32 +++
 sysdeps/unix/sysv/linux/arc/bits/procfs.h | 35 +++
 .../sysv/linux/arc/bits/types/__sigset_t.h| 12 +++
 sysdeps/unix/sysv/linux/arc/getcontext.S  | 64 +
 sysdeps/unix/sysv/linux/arc/makecontext.c | 73 ++
 sysdeps/unix/sysv/linux/arc/setcontext.S  | 93 ++
 sysdeps/unix/sysv/linux/arc/sigcontextinfo.h  | 28 ++
 sysdeps/unix/sysv/linux/arc/swapcontext.S | 94 +++
 sysdeps/unix/sysv/linux/arc/sys/cachectl.h| 35 +++
 sysdeps/unix/sysv/linux/arc/sys/ucontext.h| 57 +++
 sysdeps/unix/sysv/linux/arc/sys/user.h| 32 +++
 sysdeps/unix/sysv/linux/arc/ucontext-macros.h | 25 +
 sysdeps/unix/sysv/linux/arc/ucontext_i.sym| 20 
 13 files changed, 600 insertions(+)
 create mode 100644 sysdeps/arc/nptl/pthreaddef.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/procfs.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/types/__sigset_t.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/getcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/makecontext.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/setcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/sigcontextinfo.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/swapcontext.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/sys/cachectl.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/sys/ucontext.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/sys/user.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/ucontext-macros.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/ucontext_i.sym

diff --git a/sysdeps/arc/nptl/pthreaddef.h b/sysdeps/arc/nptl/pthreaddef.h
new file mode 100644
index ..5c2b752becad
--- /dev/null
+++ b/sysdeps/arc/nptl/pthreaddef.h
@@ -0,0 +1,32 @@
+/* pthread machine parameter definitions, ARC version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+/* Default stack size.  */
+#define ARCH_STACK_DEFAULT_SIZE(2 * 1024 * 1024)
+
+/* Required stack pointer alignment at beginning.  */
+#define STACK_ALIGN4
+
+/* Minimal stack size after allocating thread descriptor and guard size.  */
+#define MINIMAL_REST_STACK 2048
+
+/* Alignment requirement for TCB.  */
+#define TCB_ALIGNMENT  4
+
+/* Location of current stack frame.  */
+#define CURRENT_STACK_FRAME__builtin_frame_address (0)
diff --git a/sysdeps/unix/sysv/linux/arc/bits/procfs.h 
b/sysdeps/unix/sysv/linux/arc/bits/procfs.h
new file mode 100644
index ..9fabca2c4747
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/bits/procfs.h
@@ -0,0 +1,35 @@
+/* Types for registers for sys/procfs.h.  ARC version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#ifndef _SYS_PROCFS_H
+# error "Never include  directly; use  instead."
+#endif
+
+#include 
+
+/* And the whole bunch of them.  We could have used `struct
+   user_regs' directly in the typedef, but tradition says that
+   the register set is an array, which does have some peculiar
+   semantics, so leave it that way.  */
+#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof (elf_greg_t))
+
+typedef unsigned long int elf_greg_t;
+typedef unsigned long int elf_gregset_t[ELF_NGREG];
+
+/* There's no seperate floating point reg file in ARCv2.  */
+typedef struct { } elf_fpregset_t;
diff --git a/sysdeps/unix/sysv/linux/arc/bits/types/__sigset_t.h 
b/sysdeps/unix/sysv/lin

[COMMITTED 05/13] ARC: math soft float support

2020-07-10 Thread Vineet Gupta
Reviewed-by: Adhemerval Zanella  
---
 sysdeps/arc/bits/fenv.h   | 78 +++
 sysdeps/arc/nofpu/Implies |  1 +
 sysdeps/arc/nofpu/math-tests-exceptions.h | 27 
 sysdeps/arc/nofpu/math-tests-rounding.h   | 27 
 sysdeps/arc/sfp-machine.h | 70 
 5 files changed, 203 insertions(+)
 create mode 100644 sysdeps/arc/bits/fenv.h
 create mode 100644 sysdeps/arc/nofpu/Implies
 create mode 100644 sysdeps/arc/nofpu/math-tests-exceptions.h
 create mode 100644 sysdeps/arc/nofpu/math-tests-rounding.h
 create mode 100644 sysdeps/arc/sfp-machine.h

diff --git a/sysdeps/arc/bits/fenv.h b/sysdeps/arc/bits/fenv.h
new file mode 100644
index ..b375641e6248
--- /dev/null
+++ b/sysdeps/arc/bits/fenv.h
@@ -0,0 +1,78 @@
+/* Floating point environment.  ARC version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#ifndef _FENV_H
+# error "Never use  directly; include  instead."
+#endif
+
+enum
+  {
+FE_INVALID   =
+# define FE_INVALID(0x01)
+  FE_INVALID,
+FE_DIVBYZERO =
+# define FE_DIVBYZERO  (0x02)
+  FE_DIVBYZERO,
+FE_OVERFLOW  =
+# define FE_OVERFLOW   (0x04)
+  FE_OVERFLOW,
+FE_UNDERFLOW =
+# define FE_UNDERFLOW  (0x08)
+  FE_UNDERFLOW,
+FE_INEXACT   =
+# define FE_INEXACT(0x10)
+  FE_INEXACT
+  };
+
+# define FE_ALL_EXCEPT \
+   (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
+
+enum
+  {
+FE_TOWARDZERO =
+# define FE_TOWARDZERO (0x0)
+  FE_TOWARDZERO,
+FE_TONEAREST  =
+# define FE_TONEAREST  (0x1)   /* default */
+  FE_TONEAREST,
+FE_UPWARD =
+# define FE_UPWARD (0x2)
+  FE_UPWARD,
+FE_DOWNWARD   =
+# define FE_DOWNWARD   (0x3)
+  FE_DOWNWARD
+  };
+
+typedef unsigned int fexcept_t;
+
+typedef struct
+{
+  unsigned int __fpcr;
+  unsigned int __fpsr;
+} fenv_t;
+
+/* If the default argument is used we use this value.  */
+#define FE_DFL_ENV ((const fenv_t *) -1)
+
+#if __GLIBC_USE (IEC_60559_BFP_EXT)
+/* Type representing floating-point control modes.  */
+typedef unsigned int femode_t;
+
+/* Default floating-point control modes.  */
+# define FE_DFL_MODE   ((const femode_t *) -1L)
+#endif
diff --git a/sysdeps/arc/nofpu/Implies b/sysdeps/arc/nofpu/Implies
new file mode 100644
index ..abcbadb25f22
--- /dev/null
+++ b/sysdeps/arc/nofpu/Implies
@@ -0,0 +1 @@
+ieee754/soft-fp
diff --git a/sysdeps/arc/nofpu/math-tests-exceptions.h 
b/sysdeps/arc/nofpu/math-tests-exceptions.h
new file mode 100644
index ..b2a712c8c254
--- /dev/null
+++ b/sysdeps/arc/nofpu/math-tests-exceptions.h
@@ -0,0 +1,27 @@
+/* Configuration for math tests.  Exceptions support ARC version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   .  */
+
+#ifndef ARC_NOFPU_MATH_TESTS_EXCEPTIONS_H
+#define ARC_NOFPU_MATH_TESTS_EXCEPTIONS_H 1
+
+/* Soft-float does not support exceptions.  */
+#define EXCEPTION_TESTS_float  0
+#define EXCEPTION_TESTS_double 0
+#define EXCEPTION_TESTS_long_double0
+
+#endif
diff --git a/sysdeps/arc/nofpu/math-tests-rounding.h 
b/sysdeps/arc/nofpu/math-tests-rounding.h
new file mode 100644
index ..2f67483db20d
--- /dev/null
+++ b/sysdeps/arc/nofpu/math-tests-rounding.h
@@ -0,0 +1,27 @@
+/* Configuration for math tests: rounding mode support.  ARC version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free softw

[COMMITTED 12/13] build-many-glibcs.py: Enable ARC builds

2020-07-10 Thread Vineet Gupta
Reviewed-by: Adhemerval Zanella  
---
 scripts/build-many-glibcs.py | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index dfaaf50a192c..00ba6f6b1193 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -162,6 +162,15 @@ class Context(object):
'cfg': ['--disable-multi-arch']}])
 self.add_config(arch='aarch64_be',
 os_name='linux-gnu')
+self.add_config(arch='arc',
+os_name='linux-gnu',
+gcc_cfg=['--disable-multilib', '--with-cpu=hs38'])
+self.add_config(arch='arc',
+os_name='linux-gnuhf',
+gcc_cfg=['--disable-multilib', 
'--with-cpu=hs38_linux'])
+self.add_config(arch='arceb',
+os_name='linux-gnu',
+gcc_cfg=['--disable-multilib', '--with-cpu=hs38'])
 self.add_config(arch='alpha',
 os_name='linux-gnu')
 self.add_config(arch='arm',
@@ -1221,6 +1230,7 @@ def install_linux_headers(policy, cmdlist):
 """Install Linux kernel headers."""
 arch_map = {'aarch64': 'arm64',
 'alpha': 'alpha',
+'arc': 'arc',
 'arm': 'arm',
 'csky': 'csky',
 'hppa': 'parisc',
-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[COMMITTED 06/13] ARC: hardware floating point support

2020-07-10 Thread Vineet Gupta
Reviewed-by: Adhemerval Zanella 
---
 sysdeps/arc/fpu/fclrexcpt.c  |  36 
 sysdeps/arc/fpu/fegetenv.c   |  37 
 sysdeps/arc/fpu/fegetmode.c  |  31 +++
 sysdeps/arc/fpu/fegetround.c |  32 +++
 sysdeps/arc/fpu/feholdexcpt.c|  43 +
 sysdeps/arc/fpu/fesetenv.c   |  48 ++
 sysdeps/arc/fpu/fesetexcept.c|  32 +++
 sysdeps/arc/fpu/fesetmode.c  |  40 +
 sysdeps/arc/fpu/fesetround.c |  40 +
 sysdeps/arc/fpu/feupdateenv.c|  51 +++
 sysdeps/arc/fpu/fgetexcptflg.c   |  31 +++
 sysdeps/arc/fpu/fraiseexcpt.c|  39 +
 sysdeps/arc/fpu/fsetexcptflg.c   |  38 
 sysdeps/arc/fpu/ftestexcept.c|  33 +++
 sysdeps/arc/fpu/math-use-builtins-fma.h  |   4 +
 sysdeps/arc/fpu/math-use-builtins-sqrt.h |   4 +
 sysdeps/arc/fpu_control.h| 106 +++
 sysdeps/arc/get-rounding-mode.h  |  38 
 sysdeps/arc/math-tests-trap.h|  27 ++
 sysdeps/arc/tininess.h   |   1 +
 20 files changed, 711 insertions(+)
 create mode 100644 sysdeps/arc/fpu/fclrexcpt.c
 create mode 100644 sysdeps/arc/fpu/fegetenv.c
 create mode 100644 sysdeps/arc/fpu/fegetmode.c
 create mode 100644 sysdeps/arc/fpu/fegetround.c
 create mode 100644 sysdeps/arc/fpu/feholdexcpt.c
 create mode 100644 sysdeps/arc/fpu/fesetenv.c
 create mode 100644 sysdeps/arc/fpu/fesetexcept.c
 create mode 100644 sysdeps/arc/fpu/fesetmode.c
 create mode 100644 sysdeps/arc/fpu/fesetround.c
 create mode 100644 sysdeps/arc/fpu/feupdateenv.c
 create mode 100644 sysdeps/arc/fpu/fgetexcptflg.c
 create mode 100644 sysdeps/arc/fpu/fraiseexcpt.c
 create mode 100644 sysdeps/arc/fpu/fsetexcptflg.c
 create mode 100644 sysdeps/arc/fpu/ftestexcept.c
 create mode 100644 sysdeps/arc/fpu/math-use-builtins-fma.h
 create mode 100644 sysdeps/arc/fpu/math-use-builtins-sqrt.h
 create mode 100644 sysdeps/arc/fpu_control.h
 create mode 100644 sysdeps/arc/get-rounding-mode.h
 create mode 100644 sysdeps/arc/math-tests-trap.h
 create mode 100644 sysdeps/arc/tininess.h

diff --git a/sysdeps/arc/fpu/fclrexcpt.c b/sysdeps/arc/fpu/fclrexcpt.c
new file mode 100644
index ..7653d99a008c
--- /dev/null
+++ b/sysdeps/arc/fpu/fclrexcpt.c
@@ -0,0 +1,36 @@
+/* Clear given exceptions in current floating-point environment.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#include 
+#include 
+
+int
+feclearexcept (int excepts)
+{
+  unsigned int fpsr;
+
+  _FPU_GETS (fpsr);
+
+  /* Clear the relevant bits, FWE is preserved.  */
+  fpsr &= ~excepts;
+
+  _FPU_SETS (fpsr);
+
+  return 0;
+}
+libm_hidden_def (feclearexcept)
diff --git a/sysdeps/arc/fpu/fegetenv.c b/sysdeps/arc/fpu/fegetenv.c
new file mode 100644
index ..bbb3b477b423
--- /dev/null
+++ b/sysdeps/arc/fpu/fegetenv.c
@@ -0,0 +1,37 @@
+/* Store current floating-point environment.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+#include 
+#include 
+
+int
+__fegetenv (fenv_t *envp)
+{
+  unsigned int fpcr;
+  unsigned int fpsr;
+
+  _FPU_GETCW (fpcr);
+  _FPU_GETS (fpsr);
+  envp->__fpcr = fpcr;
+  envp->__fpsr = fpsr;
+
+  return 0;
+}
+libm_hidden_def (__fegetenv)
+weak_alias (__fegetenv, fegetenv)
+libm_hidden_weak (fegetenv)
diff --git a/sysdeps/arc/fpu/fegetmode.c b/sysdeps/arc/fpu/fegetmode.c
new file mode 100644
index ..f02c9119f222
--- 

[COMMITTED 11/13] ARC: Build Infrastructure

2020-07-10 Thread Vineet Gupta
Reviewed-by: Adhemerval Zanella  
---
 config.h.in|   3 +
 sysdeps/arc/Implies|   3 +
 sysdeps/arc/Makefile   |  21 +++
 sysdeps/arc/Versions   |   8 +
 sysdeps/arc/configure  | 182 +
 sysdeps/arc/configure.ac   |  26 +++
 sysdeps/arc/nptl/Makefile  |  22 +++
 sysdeps/arc/preconfigure   |  14 ++
 sysdeps/unix/sysv/linux/arc/Implies|   3 +
 sysdeps/unix/sysv/linux/arc/Makefile   |  29 
 sysdeps/unix/sysv/linux/arc/Versions   |  16 ++
 sysdeps/unix/sysv/linux/arc/configure  |   4 +
 sysdeps/unix/sysv/linux/arc/configure.ac   |   4 +
 sysdeps/unix/sysv/linux/arc/ldconfig.h |  27 +++
 sysdeps/unix/sysv/linux/arc/shlib-versions |   7 +
 15 files changed, 369 insertions(+)
 create mode 100644 sysdeps/arc/Implies
 create mode 100644 sysdeps/arc/Makefile
 create mode 100644 sysdeps/arc/Versions
 create mode 100644 sysdeps/arc/configure
 create mode 100644 sysdeps/arc/configure.ac
 create mode 100644 sysdeps/arc/nptl/Makefile
 create mode 100644 sysdeps/arc/preconfigure
 create mode 100644 sysdeps/unix/sysv/linux/arc/Implies
 create mode 100644 sysdeps/unix/sysv/linux/arc/Makefile
 create mode 100644 sysdeps/unix/sysv/linux/arc/Versions
 create mode 100644 sysdeps/unix/sysv/linux/arc/configure
 create mode 100644 sysdeps/unix/sysv/linux/arc/configure.ac
 create mode 100644 sysdeps/unix/sysv/linux/arc/ldconfig.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/shlib-versions

diff --git a/config.h.in b/config.h.in
index 8dea97f625cc..4693234552d9 100644
--- a/config.h.in
+++ b/config.h.in
@@ -118,6 +118,9 @@
 /* AArch64 PAC-RET code generation is enabled.  */
 #define HAVE_AARCH64_PAC_RET 0
 
+/* ARC big endian ABI */
+#undef HAVE_ARC_BE
+
 /* C-SKY ABI version.  */
 #undef CSKYABI
 
diff --git a/sysdeps/arc/Implies b/sysdeps/arc/Implies
new file mode 100644
index ..780c4e246769
--- /dev/null
+++ b/sysdeps/arc/Implies
@@ -0,0 +1,3 @@
+wordsize-32
+ieee754/flt-32
+ieee754/dbl-64
diff --git a/sysdeps/arc/Makefile b/sysdeps/arc/Makefile
new file mode 100644
index ..d5a702e29e58
--- /dev/null
+++ b/sysdeps/arc/Makefile
@@ -0,0 +1,21 @@
+# ARC Makefile
+# Copyright (C) 2020 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library.  If not, see
+# .
+
+# We don't support long doubles as a distinct type.  We don't need to set
+# this variable; it's here mostly for documentational purposes.
+long-double-fcts = no
diff --git a/sysdeps/arc/Versions b/sysdeps/arc/Versions
new file mode 100644
index ..6ac7b8e49505
--- /dev/null
+++ b/sysdeps/arc/Versions
@@ -0,0 +1,8 @@
+libc {
+  GLIBC_2.32 {
+__mcount;
+  }
+  GLIBC_PRIVATE {
+__syscall_error;
+  }
+}
diff --git a/sysdeps/arc/configure b/sysdeps/arc/configure
new file mode 100644
index ..bce7d3c3773d
--- /dev/null
+++ b/sysdeps/arc/configure
@@ -0,0 +1,182 @@
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
+ # Local configure fragment for sysdeps/arc.
+
+$as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h
+
+libc_cv_have_sdata_section=no
+
+# For ARC, historically ; was used for comments and not newline
+# Later # also got added to comment list, but ; couldn't be switched to
+# canonical newline as there's lots of code out there which will break
+libc_cv_asm_line_sep='`'
+cat >>confdefs.h <<_ACEOF
+#define ASM_LINE_SEP $libc_cv_asm_line_sep
+_ACEOF
+
+
+# For big endian ABI, generate a symbol for selecting right dynamic linker
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long 
lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+for ac_prog in grep ggrep; do
+for ac_exec_ext in '' $ac_executable_extensions; do
+  ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+  as_fn_executable_p "$ac_path_G

[COMMITTED 10/13] ARC: ABI lists

2020-07-10 Thread Vineet Gupta
Reviewed-by: Adhemerval Zanella  
---
 sysdeps/arc/fpu/libm-test-ulps| 1142 +
 sysdeps/arc/fpu/libm-test-ulps-name   |1 +
 sysdeps/arc/nofpu/libm-test-ulps  |  270 +++
 sysdeps/arc/nofpu/libm-test-ulps-name |1 +
 sysdeps/unix/sysv/linux/arc/c++-types.data|   67 +
 sysdeps/unix/sysv/linux/arc/ld.abilist|5 +
 .../sysv/linux/arc/libBrokenLocale.abilist|1 +
 sysdeps/unix/sysv/linux/arc/libanl.abilist|4 +
 sysdeps/unix/sysv/linux/arc/libc.abilist  | 2085 +
 sysdeps/unix/sysv/linux/arc/libcrypt.abilist  |2 +
 sysdeps/unix/sysv/linux/arc/libdl.abilist |9 +
 sysdeps/unix/sysv/linux/arc/libm.abilist  |  699 ++
 .../unix/sysv/linux/arc/libpthread.abilist|  213 ++
 sysdeps/unix/sysv/linux/arc/libresolv.abilist |   79 +
 sysdeps/unix/sysv/linux/arc/librt.abilist |   35 +
 .../unix/sysv/linux/arc/libthread_db.abilist  |   40 +
 sysdeps/unix/sysv/linux/arc/libutil.abilist   |6 +
 sysdeps/unix/sysv/linux/arc/localplt.data |   12 +
 18 files changed, 4671 insertions(+)
 create mode 100644 sysdeps/arc/fpu/libm-test-ulps
 create mode 100644 sysdeps/arc/fpu/libm-test-ulps-name
 create mode 100644 sysdeps/arc/nofpu/libm-test-ulps
 create mode 100644 sysdeps/arc/nofpu/libm-test-ulps-name
 create mode 100644 sysdeps/unix/sysv/linux/arc/c++-types.data
 create mode 100644 sysdeps/unix/sysv/linux/arc/ld.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libBrokenLocale.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libanl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libc.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libcrypt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libdl.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libm.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libpthread.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libresolv.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/librt.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libthread_db.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/libutil.abilist
 create mode 100644 sysdeps/unix/sysv/linux/arc/localplt.data

diff --git a/sysdeps/arc/fpu/libm-test-ulps b/sysdeps/arc/fpu/libm-test-ulps
new file mode 100644
index ..f7f98caa0d5e
--- /dev/null
+++ b/sysdeps/arc/fpu/libm-test-ulps
@@ -0,0 +1,1142 @@
+# Begin of automatic generation
+
+# Maximal error of functions:
+Function: "acos":
+double: 1
+float: 1
+
+Function: "acos_downward":
+double: 1
+float: 1
+
+Function: "acos_towardzero":
+double: 1
+float: 1
+
+Function: "acos_upward":
+double: 1
+float: 1
+
+Function: "acosh":
+double: 3
+float: 2
+
+Function: "acosh_downward":
+double: 2
+float: 2
+
+Function: "acosh_towardzero":
+double: 2
+float: 2
+
+Function: "acosh_upward":
+double: 3
+float: 3
+
+Function: "asin":
+double: 1
+float: 1
+
+Function: "asin_downward":
+double: 1
+float: 1
+
+Function: "asin_towardzero":
+double: 1
+float: 1
+
+Function: "asin_upward":
+double: 1
+float: 1
+
+Function: "asinh":
+double: 3
+float: 2
+
+Function: "asinh_downward":
+double: 3
+float: 3
+
+Function: "asinh_towardzero":
+double: 2
+float: 2
+
+Function: "asinh_upward":
+double: 3
+float: 3
+
+Function: "atan":
+double: 1
+float: 1
+
+Function: "atan2":
+double: 7
+float: 2
+
+Function: "atan2_downward":
+double: 5
+float: 2
+
+Function: "atan2_towardzero":
+double: 5
+float: 2
+
+Function: "atan2_upward":
+double: 8
+float: 2
+
+Function: "atan_downward":
+double: 1
+float: 2
+
+Function: "atan_towardzero":
+double: 1
+float: 1
+
+Function: "atan_upward":
+double: 2
+float: 2
+
+Function: "atanh":
+double: 2
+float: 2
+
+Function: "atanh_downward":
+double: 3
+float: 3
+
+Function: "atanh_towardzero":
+double: 2
+float: 2
+
+Function: "atanh_upward":
+double: 3
+float: 3
+
+Function: "cabs":
+double: 1
+float: 1
+
+Function: "cabs_downward":
+double: 1
+
+Function: "cabs_towardzero":
+double: 1
+
+Function: "cabs_upward":
+double: 2
+float: 1
+
+Function: Real part of "cacos":
+double: 2
+float: 2
+
+Function: Imaginary part of "cacos":
+double: 5
+float: 3
+
+Function: Real part of "cacos_downward":
+double: 3
+float: 2
+
+Function: Imaginary part of "cacos_downward":
+double: 5
+float: 3
+
+Function: Real part of "cacos_towardzero":
+double: 3
+float: 2
+
+Function: Imaginary part of "cacos_towardzero":
+double: 4
+float: 2
+
+Function: Real part of "cacos_upward":
+double: 2
+float: 3
+
+Function: Imaginary part of "cacos_upward":
+double: 5
+float: 5
+
+Function: Real part of "cacosh":
+double: 5
+float: 4
+
+Function: Imaginary part of "cacosh":
+double: 2
+float: 2
+
+Function: Real part of "cacosh_downward":
+double: 4
+float: 2
+
+Function: Imaginary part of "cacosh_downward":
+double: 3
+float: 3
+
+Function: Real part of "cacosh_towardzero":
+double: 4
+float: 2
+
+Function: Imaginary part of "cacosh_towardzero":
+double: 3
+float: 2
+
+Function: Real part of "c