Re: [PATCH] testsuite fix: timezone: failing due to permissions in cross testing

2018-12-18 Thread Florian Weimer
* Joseph Myers:

> On Mon, 17 Dec 2018, Vineet Gupta wrote:
>
>> timezone test driver "zic" creates testdata directory wuth umask 755, so
>> only root owner/group has write permissions. However the buildroot
>
> root should not be involved in running tests at all; all tests should run 
> as a normal user, the same one that owns the build directory, and thus all 
> files and directories in the build directory should be owned by that user.
> (Some tests use user namespaces to test functionality that requires root, 
> but that's root inside a namespace, not the real user root.)

There are also some xtests that require root privileges, such as
nptl/tst-setuid1.  Building and testing as root is supported (but
obviously not recommended unless you use a throwaway machine).

Thanks,
Florian

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


Re: [PATCH] testsuite fix: timezone: failing due to permissions in cross testing

2018-12-18 Thread Vineet Gupta
On 12/17/18 3:25 PM, Joseph Myers wrote:
> root should not be involved in running tests at all; all tests should run 
> as a normal user, the same one that owns the build directory, and thus all 
> files and directories in the build directory should be owned by that user.  
> (Some tests use user namespaces to test functionality that requires root, 
> but that's root inside a namespace, not the real user root.)

I agree with this, but it is really hard /cumbersome to do this in a cross 
setup,
with a busybox based system. We need the real/full blown utilities and do this
natively.

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


Re: [PATCH] testsuite fix: timezone: failing due to permissions in cross testing

2018-12-18 Thread Joseph Myers
On Tue, 18 Dec 2018, Florian Weimer wrote:

> There are also some xtests that require root privileges, such as
> nptl/tst-setuid1.  Building and testing as root is supported (but

That looks like it ought to become a test using user namespaces (and so 
not an xtest).

> obviously not recommended unless you use a throwaway machine).

And the combination of some parts of the testsuite writing to the build 
directory as root and other parts as a normal user isn't supported, in 
particular.

-- 
Joseph S. Myers
jos...@codesourcery.com

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


[PATCH 1/2] ARC: show_regs: avoid page allocator

2018-12-18 Thread Vineet Gupta
Use on-stack smaller buffers instead of dynamic pages.

The motivation for this change was to address lockdep splat when
signal handling code calls show_regs (with preemption disabled) and
ARC show_regs calls into sleepable page allocator.

| potentially unexpected fatal signal 11.
| BUG: sleeping function called from invalid context at ../mm/page_alloc.c:4317
| in_atomic(): 1, irqs_disabled(): 0, pid: 57, name: segv
| no locks held by segv/57.
| Preemption disabled at:
| [<8182f17e>] get_signal+0x4a6/0x7c4
| CPU: 0 PID: 57 Comm: segv Not tainted 4.17.0+ #23
|
| Stack Trace:
|  arc_unwind_core.constprop.1+0xd0/0xf4
|  __might_sleep+0x1f6/0x234
|  __get_free_pages+0x174/0xca0
|  show_regs+0x22/0x330
|  get_signal+0x4ac/0x7c4 # print_fatal_signals() -> preempt_disable()
|  do_signal+0x30/0x224
|  resume_user_mode_begin+0x90/0xd8

Despite this, lockdep still barfs (see next change), but this patch
still has merit as in we use smaller/localized buffers now and there's
less instructoh trace to sift thru when debugging pesky issues.

Signed-off-by: Vineet Gupta 
---
 arch/arc/kernel/troubleshoot.c | 22 +-
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c
index e8d9fb452346..2885bec71fb8 100644
--- a/arch/arc/kernel/troubleshoot.c
+++ b/arch/arc/kernel/troubleshoot.c
@@ -58,11 +58,12 @@ static void show_callee_regs(struct callee_regs *cregs)
print_reg_file(&(cregs->r13), 13);
 }
 
-static void print_task_path_n_nm(struct task_struct *tsk, char *buf)
+static void print_task_path_n_nm(struct task_struct *tsk)
 {
char *path_nm = NULL;
struct mm_struct *mm;
struct file *exe_file;
+   char buf[256];
 
mm = get_task_mm(tsk);
if (!mm)
@@ -80,10 +81,9 @@ static void print_task_path_n_nm(struct task_struct *tsk, 
char *buf)
pr_info("Path: %s\n", !IS_ERR(path_nm) ? path_nm : "?");
 }
 
-static void show_faulting_vma(unsigned long address, char *buf)
+static void show_faulting_vma(unsigned long address)
 {
struct vm_area_struct *vma;
-   char *nm = buf;
struct mm_struct *active_mm = current->active_mm;
 
/* can't use print_vma_addr() yet as it doesn't check for
@@ -96,8 +96,11 @@ static void show_faulting_vma(unsigned long address, char 
*buf)
 * if the container VMA is not found
 */
if (vma && (vma->vm_start <= address)) {
+   char buf[256];
+   char *nm = "?";
+
if (vma->vm_file) {
-   nm = file_path(vma->vm_file, buf, PAGE_SIZE - 1);
+   nm = file_path(vma->vm_file, buf, 256-1);
if (IS_ERR(nm))
nm = "?";
}
@@ -173,13 +176,8 @@ void show_regs(struct pt_regs *regs)
 {
struct task_struct *tsk = current;
struct callee_regs *cregs;
-   char *buf;
-
-   buf = (char *)__get_free_page(GFP_KERNEL);
-   if (!buf)
-   return;
 
-   print_task_path_n_nm(tsk, buf);
+   print_task_path_n_nm(tsk);
show_regs_print_info(KERN_INFO);
 
show_ecr_verbose(regs);
@@ -189,7 +187,7 @@ void show_regs(struct pt_regs *regs)
(void *)regs->blink, (void *)regs->ret);
 
if (user_mode(regs))
-   show_faulting_vma(regs->ret, buf); /* faulting code, not data */
+   show_faulting_vma(regs->ret); /* faulting code, not data */
 
pr_info("[STAT32]: 0x%08lx", regs->status32);
 
@@ -221,8 +219,6 @@ void show_regs(struct pt_regs *regs)
cregs = (struct callee_regs *)current->thread.callee_reg;
if (cregs)
show_callee_regs(cregs);
-
-   free_page((unsigned long)buf);
 }
 
 void show_kernel_fault_diag(const char *str, struct pt_regs *regs,
-- 
2.7.4


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


[PATCH 0/2] ARC show_regs fixes

2018-12-18 Thread Vineet Gupta
Vineet Gupta (2):
  ARC: show_regs: avoid page allocator
  ARC: show_regs: fix lockdep splat for good

 arch/arc/kernel/troubleshoot.c | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

-- 
2.7.4


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


[PATCH 2/2] ARC: show_regs: fix lockdep splat for good

2018-12-18 Thread Vineet Gupta
signal handling core calls ARCH show_regs() with preemption disabled
which causes __might_sleep functions such as mmput leading to lockdep
splat.  Workaround by re-enabling preemption temporarily.

This may not be as bad as it sounds since the preemption disabling
itself was introduced for a supressing smp_processor_id() warning in x86
code by commit 3a9f84d354ce ("signals, debug: fix BUG: using
smp_processor_id() in preemptible code in print_fatal_signal()")

Signed-off-by: Vineet Gupta 
---
 arch/arc/kernel/troubleshoot.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c
index 2885bec71fb8..c650d3de13e1 100644
--- a/arch/arc/kernel/troubleshoot.c
+++ b/arch/arc/kernel/troubleshoot.c
@@ -177,6 +177,12 @@ void show_regs(struct pt_regs *regs)
struct task_struct *tsk = current;
struct callee_regs *cregs;
 
+   /*
+* generic code calls us with preemption disabled, but some calls
+* here could sleep, so re-enable to avoid lockdep splat
+*/
+   preempt_enable();
+
print_task_path_n_nm(tsk);
show_regs_print_info(KERN_INFO);
 
@@ -219,6 +225,8 @@ void show_regs(struct pt_regs *regs)
cregs = (struct callee_regs *)current->thread.callee_reg;
if (cregs)
show_callee_regs(cregs);
+
+   preempt_disable();
 }
 
 void show_kernel_fault_diag(const char *str, struct pt_regs *regs,
-- 
2.7.4


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


[PATCH 02/21] ARC: add definitions to elf/elf.h

2018-12-18 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 ChangeLog |  1 +
 elf/elf.h | 70 ++-
 2 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 456e4b670c23..3ec6eb82d2fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
* sysdeps/unix/make-syscalls.sh: Fix comment referencing
syscall-template file.
* stdlib/longlong.h: Fix asm constraints for ARC code.
+   * elf/elf.h: add defines for ARC.
 
 2018-12-17  Joseph Myers  
 
diff --git a/elf/elf.h b/elf/elf.h
index d57313e9bbc7..57d7c717784e 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -330,7 +330,7 @@ typedef struct
 #define EM_CLOUDSHIELD 192 /* CloudShield */
 #define EM_COREA_1ST   193 /* KIPO-KAIST Core-A 1st gen. */
 #define EM_COREA_2ND   194 /* KIPO-KAIST Core-A 2nd gen. */
-#define EM_ARC_COMPACT2195 /* Synopsys ARCompact V2 */
+#define EM_ARCV2   195 /* Synopsys ARCv2 ISA */
 #define EM_OPEN8   196 /* Open8 RISC */
 #define EM_RL78197 /* Renesas RL78 */
 #define EM_VIDEOCORE5  198 /* Broadcom VideoCore V */
@@ -3996,6 +3996,74 @@ enum
 #define R_NDS32_TLS_TPOFF  102
 #define R_NDS32_TLS_DESC   119
 
+/* ARCompact/ARCv2 specific relocs */
+#define R_ARC_NONE 0x0
+#define R_ARC_80x1
+#define R_ARC_16   0x2
+#define R_ARC_24   0x3
+#define R_ARC_32   0x4
+#define R_ARC_B26  0x5
+#define R_ARC_B22_PCREL0x6
+#define R_ARC_H30  0x7
+#define R_ARC_N8   0x8
+#define R_ARC_N16  0x9
+#define R_ARC_N24  0xA
+#define R_ARC_N32  0xB
+#define R_ARC_SDA  0xC
+#define R_ARC_SECTOFF  0xD
+#define R_ARC_S21H_PCREL   0xE
+#define R_ARC_S21W_PCREL   0xF
+#define R_ARC_S25H_PCREL   0x10
+#define R_ARC_S25W_PCREL   0x11
+#define R_ARC_SDA320x12
+#define R_ARC_SDA_LDST 0x13
+#define R_ARC_SDA_LDST10x14
+#define R_ARC_SDA_LDST20x15
+#define R_ARC_SDA16_LD 0x16
+#define R_ARC_SDA16_LD10x17
+#define R_ARC_SDA16_LD20x18
+#define R_ARC_S13_PCREL0x19
+#define R_ARC_W0x1A
+#define R_ARC_32_ME0x1B
+#define R_ARC_N32_ME   0x1C
+#define R_ARC_SECTOFF_ME   0x1D
+#define R_ARC_SDA32_ME 0x1E
+#define R_ARC_W_ME 0x1F
+#define R_ARC_H30_ME   0x20
+#define R_ARC_SECTOFF_U8   0x21
+#define R_ARC_SECTOFF_S9   0x22
+#define R_AC_SECTOFF_U80x23
+#define R_AC_SECTOFF_U8_1  0x24
+#define R_AC_SECTOFF_U8_2  0x25
+#define R_AC_SECTOFF_S90x26
+#define R_AC_SECTOFF_S9_1  0x27
+#define R_AC_SECTOFF_S9_2  0x28
+#define R_ARC_SECTOFF_ME_1 0x29
+#define R_ARC_SECTOFF_ME_2 0x2A
+#define R_ARC_SECTOFF_10x2B
+#define R_ARC_SECTOFF_20x2C
+#define R_ARC_PC32 0x32
+#define R_ARC_GOTPC32  0x33
+#define R_ARC_PLT320x34
+#define R_ARC_COPY 0x35
+#define R_ARC_GLOB_DAT 0x36
+#define R_ARC_JUMP_SLOT0x37
+#define R_ARC_RELATIVE 0x38
+#define R_ARC_GOTOFF   0x39
+#define R_ARC_GOTPC0x3A
+#define R_ARC_GOT320x3B
+
+#define R_ARC_TLS_DTPMOD   0x42
+#define R_ARC_TLS_DTPOFF   0x43
+#define R_ARC_TLS_TPOFF0x44
+#define R_ARC_TLS_GD_GOT   0x45
+#define R_ARC_TLS_GD_LD0x46
+#define R_ARC_TLS_GD_CALL  0x47
+#define R_ARC_TLS_IE_GOT   0x48
+#define R_ARC_TLS_DTPOFF_S90x4a
+#define R_ARC_TLS_LE_S90x4a
+#define R_ARC_TLS_LE_320x4b
+
 __END_DECLS
 
 #endif /* elf.h */
-- 
2.7.4


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


[PATCH 01/21] longlong.h: sync from gcc to fix ARC inline asm constraints

2018-12-18 Thread Vineet Gupta
This corresponds to the version

Author: law 
Date:   Tue Jun 27 16:10:15 2017 +

* longlong.h: Remove ns32k support.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249696 
138bc75d-0d04-0410-961f-82ee72b054a4

Signed-off-by: Vineet Gupta 
---
 ChangeLog |  1 +
 stdlib/longlong.h | 65 ++-
 2 files changed, 8 insertions(+), 58 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 027b23493ed8..456e4b670c23 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
* sysdeps/unix/make-syscalls.sh: Fix comment referencing
syscall-template file.
+   * stdlib/longlong.h: Fix asm constraints for ARC code.
 
 2018-12-17  Joseph Myers  
 
diff --git a/stdlib/longlong.h b/stdlib/longlong.h
index c7c6977c9fd6..fb982dd530c9 100644
--- a/stdlib/longlong.h
+++ b/stdlib/longlong.h
@@ -197,17 +197,17 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, 
UDItype);
   : "=r" ((USItype) (sh)), \
 "=&r" ((USItype) (sl)) \
   : "%r" ((USItype) (ah)), \
-"rIJ" ((USItype) (bh)),\
+"rICal" ((USItype) (bh)),  \
 "%r" ((USItype) (al)), \
-"rIJ" ((USItype) (bl)))
+"rICal" ((USItype) (bl)))
 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
   __asm__ ("sub.f  %1, %4, %5\n\tsbc   %0, %2, %3" \
   : "=r" ((USItype) (sh)), \
 "=&r" ((USItype) (sl)) \
   : "r" ((USItype) (ah)),  \
-"rIJ" ((USItype) (bh)),\
+"rICal" ((USItype) (bh)),  \
 "r" ((USItype) (al)),  \
-"rIJ" ((USItype) (bl)))
+"rICal" ((USItype) (bl)))
 
 #define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v)
 #ifdef __ARC_NORM__
@@ -221,8 +221,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, 
UDItype);
 }  \
   while (0)
 #define COUNT_LEADING_ZEROS_0 32
-#endif
-#endif
+#endif /* __ARC_NORM__ */
+#endif /* __arc__ */
 
 #if defined (__arm__) && (defined (__thumb2__) || !defined (__thumb__)) \
  && W_TYPE_SIZE == 32
@@ -858,42 +858,6 @@ extern UDItype __umulsidi3 (USItype, USItype);
 #endif
 #endif /* __mips__ */
 
-#if defined (__ns32000__) && W_TYPE_SIZE == 32
-#define umul_ppmm(w1, w0, u, v) \
-  ({union {UDItype __ll;   \
-  struct {USItype __l, __h;} __i;  \
- } __xx;   \
-  __asm__ ("meid %2,%0"
\
-  : "=g" (__xx.__ll)   \
-  : "%0" ((USItype) (u)),  \
-"g" ((USItype) (v)));  \
-  (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
-#define __umulsidi3(u, v) \
-  ({UDItype __w;   \
-__asm__ ("meid %2,%0"  \
-: "=g" (__w)   \
-: "%0" ((USItype) (u)),\
-  "g" ((USItype) (v)));\
-__w; })
-#define udiv_qrnnd(q, r, n1, n0, d) \
-  ({union {UDItype __ll;   \
-  struct {USItype __l, __h;} __i;  \
- } __xx;   \
-  __xx.__i.__h = (n1); __xx.__i.__l = (n0);\
-  __asm__ ("deid %2,%0"
\
-  : "=g" (__xx.__ll)   \
-  : "0" (__xx.__ll),   \
-"g" ((USItype) (d)));  \
-  (r) = __xx.__i.__l; (q) = __xx.__i.__h; })
-#define count_trailing_zeros(count,x) \
-  do { \
-__asm__ ("ffsd %2,%0"  \
-   : "=r" ((USItype) (count))  \
-   : "0" ((USItype) 0),\
- "r" ((USItype) (x))); \
-  } while (0)
-#endif /* __ns32000__ */
-
 /* FIXME: We should test _IBMR2 here when we add assembly support for the
system vendor compilers.
  

[PATCH 00/21] glibc port to ARC processors

2018-12-18 Thread Vineet Gupta
Hi,

This is reposting of glibc port to ARC processors from synopsys.

The original posting was a while back [1]. The issues at the time were
  (1). Need for working upstream gcc/binutils (vs. the github forks)
  (2). Too many testsuite failures.

All the ducks seem to be in a row now, with last remaining gcc patch backported 
to
gcc-8-branch last week [2] and testsuite failures tended to/reduced 
significantly.

(a) build-many-glibcs.py check results are clean

| Summary of test results:
|   1173 PASS
|  15 XFAIL
|
| PASS: glibcs-arc-linux-gnu check

(b) Full testsuite ran in a cross compile setup using buildroot on HSDK 
development
platform.

Summary of test results:
 24 FAIL
   5124 PASS
 27 UNSUPPORTED
 19 XFAIL

| FAIL: localedata/sort-test# Needs more RAM:
| FAIL: stdio-common/bug22  # Needs more RAM: 2 GB memory
| FAIL: sunrpc/bug20790 # missing cpp on target
| FAIL: nptl/test-mutexattr-printers# need Python3 and target GDB on target
| FAIL: nptl/test-mutex-printers# need Python3 and target GDB on target
| FAIL: nptl/test-condattr-printers # need Python3 and target GDB on target
| FAIL: nptl/test-cond-printers # need Python3 and target GDB on target
| FAIL: nptl/test-rwlockattr-printers   # need Python3 and target GDB on target
| FAIL: nptl/test-rwlock-printers   # need Python3 and target GDB on target

| FAIL: iconv/test-iconvconfig  # Needs gconv installed
| FAIL: posix/bug-ga2   # DNS issue: google DNS vs. SNPS
| FAIL: posix/tst-getaddrinfo5  # DNS server not configured
| FAIL: posix/globtest  # require same user on target and host

| FAIL: elf/check-localplt  # passes for build-many-glibcs.py
# buildroot builds with slightly 
different toggles (-Os)
# such that gcc generates an extra 
memcpy PLT call
| FAIL: gmon/tst-gmon-pie-gprof
| FAIL: gmon/tst-sprofil
| FAIL: posix/tst-spawn
| FAIL: posix/tst-spawn-static
| FAIL: nptl/tst-cond16
| FAIL: nptl/tst-cond17
| FAIL: nptl/tst-umask1
| FAIL: nptl/tst-setuid2
| FAIL: nss/bug-erange
| FAIL: nss/tst-nss-test3

The full log for above can be found at [3]

Bulk of failures are due to cross test setup and/or RAM accessible on target.
We are analysing the other failures and will tend to them as we go along.

(c) Code was rebased off of master yesterday. Please review and comment.

(d) We currently only support soft float ABI, although I'm working on hard float
and hopefully will have it ready sometime during the review of this series

Thx,
-Vineet


[1] https://sourceware.org/ml/libc-alpha/2017-06/msg01355.html
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88001
[3] https://github.com/foss-for-synopsys-dwc-arc-processors/glibc/issues/1

Cupertino Miranda (2):
  ARC: testsuite fix: GD TLS issue
  ARC: fix several unwining and cancelation tests

Vineet Gupta (19):
  longlong.h: sync from gcc to fix ARC inline asm constraints
  ARC: add definitions to elf/elf.h
  ARC: ABI Implementation
  ARC: startup and dynamic linking code
  ARC: Thread Local Storage support
  ARC: Atomics and Locking primitives
  ARC: math soft float support
  ARC: Linux Syscall Interface
  ARC: Linux ABI
  ARC: Linux Startup and Dynamic Loading
  ARC: ABI lists
  ARC: Update syscall-names.list for ARC specific syscalls
  ARC: Build Infrastructure
  ARC: Enable __start as entry point vs. canonical _start
  ARC: testsuite fix: elf/check-initfini
  ARC: testsuite fix: sysvipc/*
  ARC: testsuite fix: stdlib/tst-makecontext
  build-many-glibcs.py: Enable ARC builds
  NEWS: mention ARC port

 ChangeLog  |  127 ++
 NEWS   |2 +
 elf/elf.h  |   70 +-
 scripts/build-many-glibcs.py   |4 +
 stdlib/longlong.h  |   65 +-
 sysdeps/arc/Implies|3 +
 sysdeps/arc/Makefile   |   25 +
 sysdeps/arc/Versions   |   14 +
 sysdeps/arc/__longjmp.S|   50 +
 sysdeps/arc/abort-instr.h  |2 +
 sysdeps/arc/atomic-machine.h   |   89 +
 sysdeps/arc/bits/endian.h  |   12 +
 sysdeps/arc/bits/fenv.h|   92 +
 sysdeps/arc/bits/link.h|   52 +
 sysdeps/arc/bits/setjmp.h  |   33 +
 sysdeps/arc/bsd-_setjmp.S  |1 +
 sysdeps/arc/bsd-setjmp.S   |1 +
 sysdeps/arc/configure  |   17 +
 sysdeps/arc/configure.ac   |   13 +
 sysdeps/arc/crti.S |   79 +
 sysdeps/arc/crtn.S |   56 +
 sysdeps/ar

[PATCH 14/21] ARC: Enable __start as entry point vs. canonical _start

2018-12-18 Thread Vineet Gupta
ARC linker scripts have defined __start as entry point so to not break
ABI for uClibc et al we allow __start for glibc as well

Signed-off-by: Vineet Gupta 
---
 ChangeLog|  3 +++
 sysdeps/arc/dl-machine.h | 14 ++
 sysdeps/arc/entry.h  |  5 +
 sysdeps/arc/start.S  | 14 +++---
 4 files changed, 29 insertions(+), 7 deletions(-)
 create mode 100644 sysdeps/arc/entry.h

diff --git a/ChangeLog b/ChangeLog
index 6628960c487e..86e4db890850 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -105,6 +105,9 @@
* sysdeps/unix/sysv/linux/arc/configure: New file.
* sysdeps/unix/sysv/linux/arc/configure.ac: New file.
* sysdeps/unix/sysv/linux/arc/shlib-versions: New file.
+   * sysdeps/arc/dl-machine.h: replace _start with __start.
+   * sysdeps/arc/start.S: likewise.
+   * sysdeps/arc/entry.h: Add ENTRY_POINT define check.
 
 2018-12-17  Joseph Myers  
 
diff --git a/sysdeps/arc/dl-machine.h b/sysdeps/arc/dl-machine.h
index da1aef79152d..02727a3a4d47 100644
--- a/sysdeps/arc/dl-machine.h
+++ b/sysdeps/arc/dl-machine.h
@@ -21,6 +21,12 @@
 
 #define ELF_MACHINE_NAME "arc"
 
+#include 
+
+#ifndef ENTRY_POINT
+#error ENTRY_POINT needs to be defined for ARC
+#endif
+
 #include 
 #include 
 #include 
@@ -150,9 +156,9 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, 
int profile)
 
 #define RTLD_START asm ("\
 .text  \n\
-.globl _start  \n\
-.type _start, @function\n\
-_start:\n\
+.globl __start \n\
+.type __start, @function   \n\
+__start:   \n\
; (1). bootstrap ld.so  \n\
bl.d_dl_start   \n\
mov_s   r0, sp  ; pass ptr to aux vector tbl\n\
@@ -182,7 +188,7 @@ _start: 
\n\
add r0, pcl, _dl_fini@pcl   \n\
j   [r13]   \n\
\n\
-   .size  _start,.-_start  \n\
+   .size  __start,.-__start\n\
.previous   \n\
 ");
 
diff --git a/sysdeps/arc/entry.h b/sysdeps/arc/entry.h
new file mode 100644
index ..adb01d981afd
--- /dev/null
+++ b/sysdeps/arc/entry.h
@@ -0,0 +1,5 @@
+#ifndef __ASSEMBLY__
+extern void __start (void) attribute_hidden;
+#endif
+
+#define ENTRY_POINT __start
diff --git a/sysdeps/arc/start.S b/sysdeps/arc/start.S
index 119d596db07f..79e73e27d00d 100644
--- a/sysdeps/arc/start.S
+++ b/sysdeps/arc/start.S
@@ -34,7 +34,14 @@
.  */
 
 
+#define __ASSEMBLY__ 1
+#include 
+#ifndef ENTRY_POINT
+#error ENTRY_POINT needs to be defined for ARC
+#endif
+
 /* When we enter this piece of code, the program stack looks like this:
+
 argcargument counter (integer)
 argv[0] program name (pointer)
 argv[1...N] program args (pointers)
@@ -45,9 +52,9 @@
 */
.text
.align 4
-   .global _start
-   .type _start,@function
-_start:
+   .global __start
+   .type __start,@function
+__start:
mov fp, 0
ld_sr1, [sp]; argc
 
@@ -71,6 +78,7 @@ _start:
 
/* Should never get here  */
flag1
+   .size  __start,.-__start
 
 /* Define a symbol for the first piece of initialized data.  */
.data
-- 
2.7.4


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


[PATCH 09/21] ARC: Linux ABI

2018-12-18 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 ChangeLog | 15 +
 sysdeps/arc/nptl/pthread-offsets.h|  5 ++
 sysdeps/arc/nptl/pthreaddef.h | 32 +
 sysdeps/unix/sysv/linux/arc/bits/procfs-id.h  | 25 +++
 sysdeps/unix/sysv/linux/arc/bits/procfs.h | 35 ++
 sysdeps/unix/sysv/linux/arc/bits/sigaction.h  | 85 
 sysdeps/unix/sysv/linux/arc/getcontext.S  | 65 +++
 sysdeps/unix/sysv/linux/arc/makecontext.c | 74 +
 sysdeps/unix/sysv/linux/arc/setcontext.S  | 93 +++
 sysdeps/unix/sysv/linux/arc/sigcontextinfo.h  | 23 +++
 sysdeps/unix/sysv/linux/arc/swapcontext.S | 92 ++
 sysdeps/unix/sysv/linux/arc/sys/cachectl.h| 36 +++
 sysdeps/unix/sysv/linux/arc/sys/ucontext.h| 71 
 sysdeps/unix/sysv/linux/arc/sys/user.h| 32 +
 sysdeps/unix/sysv/linux/arc/ucontext-macros.h | 29 +
 sysdeps/unix/sysv/linux/arc/ucontext_i.sym| 20 ++
 16 files changed, 732 insertions(+)
 create mode 100644 sysdeps/arc/nptl/pthread-offsets.h
 create mode 100644 sysdeps/arc/nptl/pthreaddef.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/procfs-id.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/procfs.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/bits/sigaction.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/ChangeLog b/ChangeLog
index 08a3ac7e8064..ca010c356597 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -56,6 +56,21 @@
* sysdeps/unix/sysv/linux/arc/sysdep.c: New file.
* sysdeps/unix/sysv/linux/arc/sysdep.h: New file.
* sysdeps/unix/sysv/linux/arc/vfork.S: New file.
+   * sysdeps/arc/nptl/pthread-offsets.h: New file.
+   * sysdeps/arc/nptl/pthreaddef.h: New file.
+   * sysdeps/unix/sysv/linux/arc/bits/procfs-id.h: New file.
+   * sysdeps/unix/sysv/linux/arc/bits/procfs.h: New file.
+   * sysdeps/unix/sysv/linux/arc/bits/sigaction.h: New file.
+   * sysdeps/unix/sysv/linux/arc/getcontext.S: New file.
+   * sysdeps/unix/sysv/linux/arc/makecontext.c: New file.
+   * sysdeps/unix/sysv/linux/arc/setcontext.S: New file.
+   * sysdeps/unix/sysv/linux/arc/sigcontextinfo.h: New file.
+   * sysdeps/unix/sysv/linux/arc/swapcontext.S: New file.
+   * sysdeps/unix/sysv/linux/arc/sys/cachectl.h: New file.
+   * sysdeps/unix/sysv/linux/arc/sys/ucontext.h: New file.
+   * sysdeps/unix/sysv/linux/arc/sys/user.h: New file.
+   * sysdeps/unix/sysv/linux/arc/ucontext-macros.h: New file.
+   * sysdeps/unix/sysv/linux/arc/ucontext_i.sym: New file.
 
 2018-12-17  Joseph Myers  
 
diff --git a/sysdeps/arc/nptl/pthread-offsets.h 
b/sysdeps/arc/nptl/pthread-offsets.h
new file mode 100644
index ..9617354dc7e3
--- /dev/null
+++ b/sysdeps/arc/nptl/pthread-offsets.h
@@ -0,0 +1,5 @@
+#define __PTHREAD_MUTEX_NUSERS_OFFSET   16
+#define __PTHREAD_MUTEX_KIND_OFFSET 12
+#define __PTHREAD_MUTEX_SPINS_OFFSET20
+#define __PTHREAD_MUTEX_ELISION_OFFSET  22
+#define __PTHREAD_MUTEX_LIST_OFFSET 20
diff --git a/sysdeps/arc/nptl/pthreaddef.h b/sysdeps/arc/nptl/pthreaddef.h
new file mode 100644
index ..41e13c53038c
--- /dev/null
+++ b/sysdeps/arc/nptl/pthreaddef.h
@@ -0,0 +1,32 @@
+/* pthread machine parameter definitions, ARC version.
+   Copyright (C) 2002-2018 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
+
+/* Minim

[PATCH 12/21] ARC: Update syscall-names.list for ARC specific syscalls

2018-12-18 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 ChangeLog  | 1 +
 sysdeps/unix/sysv/linux/syscall-names.list | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 4182e89ccbb3..3735df67a3b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -91,6 +91,7 @@
* sysdeps/unix/sysv/linux/arc/libthread_db.abilist: New file.
* sysdeps/unix/sysv/linux/arc/libutil.abilist: New file.
* sysdeps/unix/sysv/linux/arc/localplt.data: New file.
+   * sysdeps/unix/sysv/linux/syscall-names.list: Update for ARC.
 
 2018-12-17  Joseph Myers  
 
diff --git a/sysdeps/unix/sysv/linux/syscall-names.list 
b/sysdeps/unix/sysv/linux/syscall-names.list
index f88001c9c38d..62862010600f 100644
--- a/sysdeps/unix/sysv/linux/syscall-names.list
+++ b/sysdeps/unix/sysv/linux/syscall-names.list
@@ -42,6 +42,9 @@ adjtimex
 afs_syscall
 alarm
 alloc_hugepages
+arc_gettls
+arc_settls
+arc_usr_cmpxchg
 arch_prctl
 arm_fadvise64_64
 arm_sync_file_range
-- 
2.7.4


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


[PATCH 04/21] ARC: startup and dynamic linking code

2018-12-18 Thread Vineet Gupta
Code for C runtime startup and dynamic loading including PLT layout.

Signed-off-by: Vineet Gupta 
---
 ChangeLog |   6 +
 sysdeps/arc/bits/link.h   |  52 
 sysdeps/arc/dl-machine.h  | 333 ++
 sysdeps/arc/ldsodefs.h|  43 ++
 sysdeps/arc/sotruss-lib.c |  51 +++
 sysdeps/arc/start.S   |  81 +++
 sysdeps/arc/tst-audit.h   |  23 
 7 files changed, 589 insertions(+)
 create mode 100644 sysdeps/arc/bits/link.h
 create mode 100644 sysdeps/arc/dl-machine.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/ChangeLog b/ChangeLog
index c2efdafa9861..fd5602bde1a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -24,6 +24,12 @@
* sysdeps/arc/setjmp.S: New file.
* sysdeps/arc/sysdep.h: New file.
* sysdeps/arc/tls-macros.h: New file.
+   * sysdeps/arc/bits/link.h: New file.
+   * sysdeps/arc/dl-machine.h: New file.
+   * sysdeps/arc/ldsodefs.h: New file.
+   * sysdeps/arc/sotruss-lib.c: New file.
+   * sysdeps/arc/start.S: New file.
+   * sysdeps/arc/tst-audit.h: New file.
 
 2018-12-17  Joseph Myers  
 
diff --git a/sysdeps/arc/bits/link.h b/sysdeps/arc/bits/link.h
new file mode 100644
index ..1f4da2d9941c
--- /dev/null
+++ b/sysdeps/arc/bits/link.h
@@ -0,0 +1,52 @@
+/* Machine-specific declarations for dynamic linker interface, ARC version.
+   Copyright (C) 2009-2018 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 Elf32_Addr la_arc_gnu_pltenter (Elf32_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 (Elf32_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 ..da1aef79152d
--- /dev/null
+++ b/sysdeps/arc/dl-machine.h
@@ -0,0 +1,333 @@
+/* Machine-dependent ELF dynamic relocation inline functions.  ARC version.
+   Copyright (C) 1995-2018 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 
+#include 
+#include 
+
+/*
+ * Dynamic Linking ABI for ARCv2 ISA
+ *
+ *  PLT
+ * < DT_PLTGOT
+ *   

[PATCH 08/21] ARC: Linux Syscall Interface

2018-12-18 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 ChangeLog |  12 ++
 sysdeps/unix/sysv/linux/arc/cacheflush.c  |  29 +++
 sysdeps/unix/sysv/linux/arc/clone.S   | 100 ++
 sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h  |   6 +
 sysdeps/unix/sysv/linux/arc/kernel-features.h |  28 +++
 sysdeps/unix/sysv/linux/arc/mmap_internal.h   |  26 +++
 sysdeps/unix/sysv/linux/arc/profil-counter.h  |   2 +
 sysdeps/unix/sysv/linux/arc/pt-vfork.S|   1 +
 sysdeps/unix/sysv/linux/arc/sigaction.c   |  69 +++
 sysdeps/unix/sysv/linux/arc/syscall.S |  38 
 sysdeps/unix/sysv/linux/arc/sysdep.c  |  33 
 sysdeps/unix/sysv/linux/arc/sysdep.h  | 259 ++
 sysdeps/unix/sysv/linux/arc/vfork.S   |  42 +
 13 files changed, 645 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/arc/cacheflush.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/clone.S
 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/mmap_internal.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/profil-counter.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/pt-vfork.S
 create mode 100644 sysdeps/unix/sysv/linux/arc/sigaction.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/syscall.S
 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/ChangeLog b/ChangeLog
index b946f57204b6..08a3ac7e8064 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -44,6 +44,18 @@
* sysdeps/arc/nofpu/math-tests-exception.h: New file.
* sysdeps/arc/nofpu/math-tests-rounding.h: New file.
* sysdeps/arc/sfp-machine.h: New file.
+   * sysdeps/unix/sysv/linux/arc/cacheflush.c: New file.
+   * sysdeps/unix/sysv/linux/arc/clone.S: New file.
+   * sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h: New file.
+   * sysdeps/unix/sysv/linux/arc/kernel-features.h: New file.
+   * sysdeps/unix/sysv/linux/arc/mmap_internal.h: New file.
+   * sysdeps/unix/sysv/linux/arc/profil-counter.h: New file.
+   * sysdeps/unix/sysv/linux/arc/pt-vfork.S: New file.
+   * sysdeps/unix/sysv/linux/arc/sigaction.c: New file.
+   * sysdeps/unix/sysv/linux/arc/syscall.S: New file.
+   * sysdeps/unix/sysv/linux/arc/sysdep.c: New file.
+   * sysdeps/unix/sysv/linux/arc/sysdep.h: New file.
+   * sysdeps/unix/sysv/linux/arc/vfork.S: New file.
 
 2018-12-17  Joseph Myers  
 
diff --git a/sysdeps/unix/sysv/linux/arc/cacheflush.c 
b/sysdeps/unix/sysv/linux/arc/cacheflush.c
new file mode 100644
index ..7b14211eccf7
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/cacheflush.c
@@ -0,0 +1,29 @@
+/* cacheflush system call for ARC Linux.
+   Copyright (C) 2017-2018 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 
+#include 
+
+/* Flush cache(s).  */
+int
+_flush_cache (char *addr, const int nbytes, const int op)
+{
+  return INLINE_SYSCALL (cacheflush, 3, addr, nbytes, op);
+}
+weak_alias (_flush_cache, cacheflush)
diff --git a/sysdeps/unix/sysv/linux/arc/clone.S 
b/sysdeps/unix/sysv/linux/arc/clone.S
new file mode 100644
index ..04f2df5ef06d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/clone.S
@@ -0,0 +1,100 @@
+/* clone() implementation for ARC.
+   Copyright (C) 2008-2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andrew Jenner , 2008.
+
+   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
+   

[PATCH 07/21] ARC: math soft float support

2018-12-18 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 ChangeLog|  6 +++
 sysdeps/arc/bits/fenv.h  | 92 
 sysdeps/arc/math_private.h   |  6 +++
 sysdeps/arc/nofpu/Implies|  1 +
 sysdeps/arc/nofpu/math-tests-exception.h | 27 ++
 sysdeps/arc/nofpu/math-tests-rounding.h  | 27 ++
 sysdeps/arc/sfp-machine.h| 51 ++
 7 files changed, 210 insertions(+)
 create mode 100644 sysdeps/arc/bits/fenv.h
 create mode 100644 sysdeps/arc/math_private.h
 create mode 100644 sysdeps/arc/nofpu/Implies
 create mode 100644 sysdeps/arc/nofpu/math-tests-exception.h
 create mode 100644 sysdeps/arc/nofpu/math-tests-rounding.h
 create mode 100644 sysdeps/arc/sfp-machine.h

diff --git a/ChangeLog b/ChangeLog
index d2f6cd2d0d09..b946f57204b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -38,6 +38,12 @@
* sysdeps/arc/atomic-machine.h: New file.
* sysdeps/arc/nptl/bits/pthreadtypes-arch.h: New file.
* sysdeps/arc/nptl/bits/semaphore.h: New file.
+   * sysdeps/arc/bits/fenv.h: New file.
+   * sysdeps/arc/math_private.h: New file.
+   * sysdeps/arc/nofpu/Implies: New file.
+   * sysdeps/arc/nofpu/math-tests-exception.h: New file.
+   * sysdeps/arc/nofpu/math-tests-rounding.h: New file.
+   * sysdeps/arc/sfp-machine.h: New file.
 
 2018-12-17  Joseph Myers  
 
diff --git a/sysdeps/arc/bits/fenv.h b/sysdeps/arc/bits/fenv.h
new file mode 100644
index ..4053f57d1094
--- /dev/null
+++ b/sysdeps/arc/bits/fenv.h
@@ -0,0 +1,92 @@
+/* Copyright (C) 2012-2018 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
+
+#if defined(__ARC_FPU_SP__) || defined(__ARC_FPU_DP__)
+
+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)
+  FE_TONEAREST,
+FE_UPWARD =
+#define FE_UPWARD  (0x2)
+  FE_UPWARD,
+FE_DOWNWARD   =
+#define FE_DOWNWARD(0x3)
+  FE_DOWNWARD
+  };
+
+#else
+
+/* In the soft-float case, only rounding to nearest is supported, with
+   no exceptions.  */
+
+enum
+  {
+__FE_UNDEFINED = -1,
+
+FE_TONEAREST =
+# define FE_TONEAREST  0x0
+  FE_TONEAREST
+  };
+
+# define FE_ALL_EXCEPT 0
+
+#endif
+
+typedef unsigned int fexcept_t;
+typedef unsigned int 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/math_private.h b/sysdeps/arc/math_private.h
new file mode 100644
index ..35046d842533
--- /dev/null
+++ b/sysdeps/arc/math_private.h
@@ -0,0 +1,6 @@
+#ifndef ARC_MATH_PRIVATE_H
+#define ARC_MATH_PRIVATE_H
+
+#include_next 
+
+#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-exception.h 
b/sysdeps/arc/nofpu/math-tests-exception.h
new file mode 100644
index ..bb338388d8af
--- /dev/null
+++ b/sysdeps/arc/nofpu/math-tests-exception.h
@@ -0,0 +1,27 @@
+/* Configuration for math tests. exceptions support ARC version.
+   Copyright (C) 2017-2018 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

[PATCH 03/21] ARC: ABI Implementation

2018-12-18 Thread Vineet Gupta
This code deals with the ARC ABI.

Signed-off-by: Vineet Gupta 
---
 ChangeLog| 20 
 sysdeps/arc/__longjmp.S  | 50 
 sysdeps/arc/abort-instr.h|  2 ++
 sysdeps/arc/bits/endian.h| 12 +++
 sysdeps/arc/bits/setjmp.h| 33 +++
 sysdeps/arc/bsd-_setjmp.S|  1 +
 sysdeps/arc/bsd-setjmp.S |  1 +
 sysdeps/arc/crti.S   | 77 
 sysdeps/arc/crtn.S   | 56 
 sysdeps/arc/dl-runtime.c | 21 
 sysdeps/arc/dl-sysdep.h  | 25 ++
 sysdeps/arc/dl-trampoline.S  | 72 +
 sysdeps/arc/gccframe.h   | 21 
 sysdeps/arc/gmp-mparam.h | 23 +
 sysdeps/arc/jmpbuf-offsets.h | 46 ++
 sysdeps/arc/jmpbuf-unwind.h  | 47 +++
 sysdeps/arc/machine-gmon.h   | 33 +++
 sysdeps/arc/memusage.h   | 23 +
 sysdeps/arc/setjmp.S | 64 
 sysdeps/arc/sysdep.h | 49 
 sysdeps/arc/tls-macros.h | 29 +
 21 files changed, 705 insertions(+)
 create mode 100644 sysdeps/arc/__longjmp.S
 create mode 100644 sysdeps/arc/abort-instr.h
 create mode 100644 sysdeps/arc/bits/endian.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/crti.S
 create mode 100644 sysdeps/arc/crtn.S
 create mode 100644 sysdeps/arc/dl-runtime.c
 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/gmp-mparam.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/ChangeLog b/ChangeLog
index 3ec6eb82d2fe..c2efdafa9861 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,26 @@
syscall-template file.
* stdlib/longlong.h: Fix asm constraints for ARC code.
* elf/elf.h: add defines for ARC.
+   * sysdeps/arc/__longjmp.S: New file.
+   * sysdeps/arc/abort-instr.h: New file.
+   * sysdeps/arc/bits/endian.h: New file.
+   * sysdeps/arc/bits/setjmp.h: New file.
+   * sysdeps/arc/bsd-_setjmp.S: New file.
+   * sysdeps/arc/bsd-setjmp.S: New file.
+   * sysdeps/arc/crti.S: New file.
+   * sysdeps/arc/crtn.S: New file.
+   * sysdeps/arc/dl-runtime.c: New file.
+   * sysdeps/arc/dl-sysdep.h: New file.
+   * sysdeps/arc/dl-trampoline.S: New file.
+   * sysdeps/arc/gccframe.h: New file.
+   * sysdeps/arc/gmp-mparam.h: New file.
+   * sysdeps/arc/jmpbuf-offsets.h: New file.
+   * sysdeps/arc/jmpbuf-unwind.h: New file.
+   * sysdeps/arc/machine-gmon.h: New file.
+   * sysdeps/arc/memusage.h: New file.
+   * sysdeps/arc/setjmp.S: New file.
+   * sysdeps/arc/sysdep.h: New file.
+   * sysdeps/arc/tls-macros.h: New file.
 
 2018-12-17  Joseph Myers  
 
diff --git a/sysdeps/arc/__longjmp.S b/sysdeps/arc/__longjmp.S
new file mode 100644
index ..5ef271536bcc
--- /dev/null
+++ b/sysdeps/arc/__longjmp.S
@@ -0,0 +1,50 @@
+/* longjmp for ARC.
+   Copyright (C) 2017-2018 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)
+
+   ld_s r13,   [r0]
+   ld_s r14,   [r0,4]
+   ld   r15,   [r0,8]
+   ld   r16,   [r0,12]
+   ld   r17,   [r0,16]
+   ld   r18,   [r0,20]
+   ld   r19,   [r0,24]
+   ld   r20,   [r0,28]
+   ld   r21,   [r0,32]
+   ld   r22,   [r0,36]
+   ld   r23,   [r0,40]
+   ld   r24,   [r0,44]
+   ld   r25,   [r0,48]
+
+   ld   blink, [r0,60]
+   ld   fp,[r0,52]
+   ld   sp,[r0,56]
+
+   mov.f  r0, r1   ; 

[PATCH 05/21] ARC: Thread Local Storage support

2018-12-18 Thread Vineet Gupta
This includes all 4 TLS addressing models

Signed-off-by: Vineet Gupta 
---
 ChangeLog|   5 ++
 sysdeps/arc/dl-tls.h |  30 
 sysdeps/arc/libc-tls.c   |  27 +++
 sysdeps/arc/nptl/tcb-offsets.sym |  11 +++
 sysdeps/arc/nptl/tls.h   | 150 +++
 sysdeps/arc/stackinfo.h  |  33 +
 6 files changed, 256 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/ChangeLog b/ChangeLog
index fd5602bde1a7..6e53b171a72d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,6 +30,11 @@
* sysdeps/arc/sotruss-lib.c: New file.
* sysdeps/arc/start.S: New file.
* sysdeps/arc/tst-audit.h: New file.
+   * sysdeps/arc/dl-tls.h: New file.
+   * sysdeps/arc/libc-tls.c: New file.
+   * sysdeps/arc/nptl/tcb-offsets.sym: New file.
+   * sysdeps/arc/nptl/tls.h: New file.
+   * sysdeps/arc/stackinfo.h: New file.
 
 2018-12-17  Joseph Myers  
 
diff --git a/sysdeps/arc/dl-tls.h b/sysdeps/arc/dl-tls.h
new file mode 100644
index ..42b5df9ca4da
--- /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) 2012-2018 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 ..c6c865daac3e
--- /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) 2005-2018 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 ..56950e0676ed
--- /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 ..b6c2023ef3f6
--- /dev/null
+++ b/sysdeps/arc/nptl/tls.h
@@ -0,0 +1,150 @@
+/* Definition for thread-local data handling.  NPTL/ARC version.
+   Copyright (C) 2012-2018 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 (a

[PATCH 13/21] ARC: Build Infrastructure

2018-12-18 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 ChangeLog  | 13 +
 sysdeps/arc/Implies|  3 +++
 sysdeps/arc/Makefile   | 25 +
 sysdeps/arc/Versions   | 14 ++
 sysdeps/arc/configure  | 17 +
 sysdeps/arc/configure.ac   | 13 +
 sysdeps/arc/nptl/Makefile  | 22 ++
 sysdeps/arc/preconfigure   | 14 ++
 sysdeps/unix/sysv/linux/arc/Implies|  3 +++
 sysdeps/unix/sysv/linux/arc/Makefile   | 16 
 sysdeps/unix/sysv/linux/arc/Versions   | 12 
 sysdeps/unix/sysv/linux/arc/configure  |  4 
 sysdeps/unix/sysv/linux/arc/configure.ac   |  4 
 sysdeps/unix/sysv/linux/arc/shlib-versions |  2 ++
 14 files changed, 162 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/shlib-versions

diff --git a/ChangeLog b/ChangeLog
index 3735df67a3b2..6628960c487e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -92,6 +92,19 @@
* sysdeps/unix/sysv/linux/arc/libutil.abilist: New file.
* sysdeps/unix/sysv/linux/arc/localplt.data: New file.
* sysdeps/unix/sysv/linux/syscall-names.list: Update for ARC.
+   * sysdeps/arc/Implies: New file.
+   * sysdeps/arc/Makefile: New file.
+   * sysdeps/arc/Versions: New file.
+   * sysdeps/arc/configure: New file.
+   * sysdeps/arc/configure.ac: New file.
+   * sysdeps/arc/nptl/Makefile: New file.
+   * sysdeps/arc/preconfigure: New file.
+   * sysdeps/unix/sysv/linux/arc/Implies: New file.
+   * sysdeps/unix/sysv/linux/arc/Makefile: New file.
+   * sysdeps/unix/sysv/linux/arc/Versions: New file.
+   * sysdeps/unix/sysv/linux/arc/configure: New file.
+   * sysdeps/unix/sysv/linux/arc/configure.ac: New file.
+   * sysdeps/unix/sysv/linux/arc/shlib-versions: New file.
 
 2018-12-17  Joseph Myers  
 
diff --git a/sysdeps/arc/Implies b/sysdeps/arc/Implies
new file mode 100644
index ..387a0ca05204
--- /dev/null
+++ b/sysdeps/arc/Implies
@@ -0,0 +1,3 @@
+wordsize-32
+ieee754/dbl-64
+ieee754/flt-32
diff --git a/sysdeps/arc/Makefile b/sysdeps/arc/Makefile
new file mode 100644
index ..a88eda115b95
--- /dev/null
+++ b/sysdeps/arc/Makefile
@@ -0,0 +1,25 @@
+# ARC Makefile
+# Copyright (C) 1993-2018 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
+
+ifeq ($(subdir),debug)
+CFLAGS-backtrace.c += -funwind-tables
+endif
diff --git a/sysdeps/arc/Versions b/sysdeps/arc/Versions
new file mode 100644
index ..c088bb27a0e5
--- /dev/null
+++ b/sysdeps/arc/Versions
@@ -0,0 +1,14 @@
+libc {
+  GLIBC_2.29 {
+__adddf3; __addsf3; __divdf3; __divsf3; __eqdf2; __eqsf2; __extendsfdf2;
+__fixdfdi; __fixdfsi; __fixsfdi; __fixsfsi;
+__fixunsdfdi; __fixunsdfsi; __fixunssfdi; __fixunssfsi;
+__floatdidf; __floatdisf; __floatsidf; __floatsisf;
+__floatundidf; __floatundisf; __floatunsidf; __floatunsisf;
+__gedf2; __gesf2; __gtdf2; __gtsf2; __ledf2; __lesf2; __ltdf2; __ltsf2;
+__muldf3; __mulsf3; __nedf2; __nesf2; __negdf2; __negsf2;
+__subdf3; __subsf3; __truncdfsf2; __unorddf2; __unordsf2;
+__syscall_error;
+__mcount;
+  }
+}
diff --git a/sysdeps/arc/configure b/sysdeps/arc/configure
new file mode 100644
index ..2033957d0d9f
--- /dev/null
+++ b/sysdeps/arc/configure
@@ -0,0 +1,17 @@
+# This file is generated from configure.ac by Aut

[PATCH 17/21] ARC: testsuite fix: stdlib/tst-makecontext

2018-12-18 Thread Vineet Gupta
Terminate the unwinding by telling unwinder to fetch return address
(BLINK) from r15 which has been set apriori to 0.

Signed-off-by: Vineet Gupta 
---
 ChangeLog | 2 ++
 sysdeps/unix/sysv/linux/arc/makecontext.c | 1 +
 sysdeps/unix/sysv/linux/arc/setcontext.S  | 2 ++
 3 files changed, 5 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index d3a979a9236b..39ff298b0091 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -110,6 +110,8 @@
* sysdeps/arc/entry.h: Add ENTRY_POINT define check.
* sysdeps/arc/crti.S: add .hidden annotations.
* sysdeps/unix/sysv/linux/arc/ipc_priv.h: New file.
+   * sysdeps/unix/sysv/linux/arc/makecontext.c: clear r15.
+   * sysdeps/unix/sysv/linux/arc/setcontext.S: set blink from r15.
 
 2018-12-17  Joseph Myers  
 
diff --git a/sysdeps/unix/sysv/linux/arc/makecontext.c 
b/sysdeps/unix/sysv/linux/arc/makecontext.c
index 7018bed9d64a..8d233f83da7e 100644
--- a/sysdeps/unix/sysv/linux/arc/makecontext.c
+++ b/sysdeps/unix/sysv/linux/arc/makecontext.c
@@ -45,6 +45,7 @@ __makecontext (ucontext_t *ucp, void (*func) (void), int 
argc, ...)
*/
   ucp->uc_mcontext.callee.r13 = (unsigned long) func;
   ucp->uc_mcontext.callee.r14 = (unsigned long) ucp->uc_link;
+  ucp->uc_mcontext.callee.r15 = 0;
 
   r = &ucp->uc_mcontext.scratch.r0;
 
diff --git a/sysdeps/unix/sysv/linux/arc/setcontext.S 
b/sysdeps/unix/sysv/linux/arc/setcontext.S
index 3f503c661d95..6ec2ec0ddc79 100644
--- a/sysdeps/unix/sysv/linux/arc/setcontext.S
+++ b/sysdeps/unix/sysv/linux/arc/setcontext.S
@@ -79,6 +79,8 @@ weak_alias(__setcontext, setcontext)
 
 ENTRY(__startcontext)
 
+   cfi_register (blink, r15)
+
 /* call user @func, loaded in r13 by setcontext() */
 jl   [r13]
 
-- 
2.7.4


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


[PATCH 11/21] ARC: ABI lists

2018-12-18 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 ChangeLog  |   17 +
 sysdeps/arc/nofpu/libm-test-ulps   |  390 
 sysdeps/arc/nofpu/libm-test-ulps-name  |1 +
 sysdeps/unix/sysv/linux/arc/c++-types.data |   67 +
 sysdeps/unix/sysv/linux/arc/ld.abilist |9 +
 .../unix/sysv/linux/arc/libBrokenLocale.abilist|1 +
 sysdeps/unix/sysv/linux/arc/libanl.abilist |4 +
 sysdeps/unix/sysv/linux/arc/libc.abilist   | 2089 
 sysdeps/unix/sysv/linux/arc/libcrypt.abilist   |2 +
 sysdeps/unix/sysv/linux/arc/libdl.abilist  |9 +
 sysdeps/unix/sysv/linux/arc/libm.abilist   |  753 +++
 sysdeps/unix/sysv/linux/arc/libnsl.abilist |  120 ++
 sysdeps/unix/sysv/linux/arc/libpthread.abilist |  235 +++
 sysdeps/unix/sysv/linux/arc/libresolv.abilist  |   79 +
 sysdeps/unix/sysv/linux/arc/librt.abilist  |   35 +
 sysdeps/unix/sysv/linux/arc/libthread_db.abilist   |   40 +
 sysdeps/unix/sysv/linux/arc/libutil.abilist|6 +
 sysdeps/unix/sysv/linux/arc/localplt.data  |   15 +
 18 files changed, 3872 insertions(+)
 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/libnsl.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/ChangeLog b/ChangeLog
index f6ad5968d7de..4182e89ccbb3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -74,6 +74,23 @@
* sysdeps/unix/sysv/linux/arc/dl-static.c: New file.
* sysdeps/unix/sysv/linux/arc/ldconfig.h: New file.
* sysdeps/unix/sysv/linux/arc/ldsodefs.h: New file.
+   * sysdeps/arc/nofpu/libm-test-ulps: New file.
+   * sysdeps/arc/nofpu/libm-test-ulps-name: New file.
+   * sysdeps/unix/sysv/linux/arc/c++-types.data: New file.
+   * sysdeps/unix/sysv/linux/arc/ld.abilist: New file.
+   * sysdeps/unix/sysv/linux/arc/libBrokenLocale.abilist: New file.
+   * sysdeps/unix/sysv/linux/arc/libanl.abilist: New file.
+   * sysdeps/unix/sysv/linux/arc/libc.abilist: New file.
+   * sysdeps/unix/sysv/linux/arc/libcrypt.abilist: New file.
+   * sysdeps/unix/sysv/linux/arc/libdl.abilist: New file.
+   * sysdeps/unix/sysv/linux/arc/libm.abilist: New file.
+   * sysdeps/unix/sysv/linux/arc/libnsl.abilist: New file.
+   * sysdeps/unix/sysv/linux/arc/libpthread.abilist: New file.
+   * sysdeps/unix/sysv/linux/arc/libresolv.abilist: New file.
+   * sysdeps/unix/sysv/linux/arc/librt.abilist: New file.
+   * sysdeps/unix/sysv/linux/arc/libthread_db.abilist: New file.
+   * sysdeps/unix/sysv/linux/arc/libutil.abilist: New file.
+   * sysdeps/unix/sysv/linux/arc/localplt.data: New file.
 
 2018-12-17  Joseph Myers  
 
diff --git a/sysdeps/arc/nofpu/libm-test-ulps b/sysdeps/arc/nofpu/libm-test-ulps
new file mode 100644
index ..0e8ef313fa94
--- /dev/null
+++ b/sysdeps/arc/nofpu/libm-test-ulps
@@ -0,0 +1,390 @@
+# Begin of automatic generation
+
+# Maximal error of functions:
+Function: "acos":
+float: 1
+ifloat: 1
+
+Function: "acosh":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "asin":
+float: 1
+ifloat: 1
+
+Function: "asinh":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: "atan":
+float: 1
+ifloat: 1
+
+Function: "atan2":
+float: 1
+ifloat: 1
+
+Function: "atanh":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: "cabs":
+double: 1
+idouble: 1
+
+Function: Real part of "cacos":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: Imaginary part of "cacos":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Real part of "cacosh":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Imaginary part of "cacosh":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+
+Function: "carg":
+float: 1
+ifloat: 1
+
+Function: Real part of "casin":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+Function: Imaginary part of "casin":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Function: Real part of "casinh":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+
+Funct

[PATCH 15/21] ARC: testsuite fix: elf/check-initfini

2018-12-18 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 ChangeLog  | 1 +
 sysdeps/arc/crti.S | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 86e4db890850..909b1af09a31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -108,6 +108,7 @@
* sysdeps/arc/dl-machine.h: replace _start with __start.
* sysdeps/arc/start.S: likewise.
* sysdeps/arc/entry.h: Add ENTRY_POINT define check.
+   * sysdeps/arc/crti.S: add .hidden annotations.
 
 2018-12-17  Joseph Myers  
 
diff --git a/sysdeps/arc/crti.S b/sysdeps/arc/crti.S
index 8b823b54a29d..ea741b30e3cf 100644
--- a/sysdeps/arc/crti.S
+++ b/sysdeps/arc/crti.S
@@ -53,6 +53,7 @@
.section .init
.align 4
.global _init
+   .hidden _init
.type_init,@function
 _init:
st.ablink, [sp,-4]
@@ -69,6 +70,7 @@ _init:
.section .fini
.align 4
.global _fini
+   .hidden _fini
.type_fini,@function
 _fini:
st.a blink,[sp,-4]
-- 
2.7.4


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


[PATCH 21/21] NEWS: mention ARC port

2018-12-18 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 ChangeLog | 1 +
 NEWS  | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 46d288808153..92e19ac45df2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2018-12-17  Vineet Gupta 
 
* scripts/build-many-glibcs.py: Enable building for ARC.
+   * NEW: Mention ARC port.
 
 2018-12-17  Cupertino Miranda 
 
diff --git a/NEWS b/NEWS
index ae80818df4b3..56b21c3b9336 100644
--- a/NEWS
+++ b/NEWS
@@ -1078,6 +1078,8 @@ Version 2.26
 
 Major new features:
 
+* Port to ARC HS cores has been contributed by Synopsys.
+
 * A per-thread cache has been added to malloc. Access to the cache requires
   no locks and therefore significantly accelerates the fast path to allocate
   and free small amounts of memory. Refilling an empty cache requires locking
-- 
2.7.4


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


[PATCH 06/21] ARC: Atomics and Locking primitives

2018-12-18 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 ChangeLog |  3 ++
 sysdeps/arc/atomic-machine.h  | 89 +++
 sysdeps/arc/nptl/bits/pthreadtypes-arch.h | 72 +
 sysdeps/arc/nptl/bits/semaphore.h | 32 +++
 4 files changed, 196 insertions(+)
 create mode 100644 sysdeps/arc/atomic-machine.h
 create mode 100644 sysdeps/arc/nptl/bits/pthreadtypes-arch.h
 create mode 100644 sysdeps/arc/nptl/bits/semaphore.h

diff --git a/ChangeLog b/ChangeLog
index 6e53b171a72d..d2f6cd2d0d09 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,6 +35,9 @@
* sysdeps/arc/nptl/tcb-offsets.sym: New file.
* sysdeps/arc/nptl/tls.h: New file.
* sysdeps/arc/stackinfo.h: New file.
+   * sysdeps/arc/atomic-machine.h: New file.
+   * sysdeps/arc/nptl/bits/pthreadtypes-arch.h: New file.
+   * sysdeps/arc/nptl/bits/semaphore.h: New file.
 
 2018-12-17  Joseph Myers  
 
diff --git a/sysdeps/arc/atomic-machine.h b/sysdeps/arc/atomic-machine.h
new file mode 100644
index ..1a8d976794d0
--- /dev/null
+++ b/sysdeps/arc/atomic-machine.h
@@ -0,0 +1,89 @@
+/* Low-level functions for atomic operations. ARC version.
+   Copyright (C) 2012-2018 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 0
+#define ATOMIC_EXCHANGE_USES_CAS 1
+
+#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
+  (abort (), (__typeof (*mem)) 0)
+#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval)\
+  (abort (), (__typeof (*mem)) 0)
+#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval)\
+  (abort (), (__typeof (*mem)) 0)
+
+#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_32_acq(mem, newval, oldval)\
+  ({   \
+   __typeof(*(mem)) prev;  \
+   \
+   __asm__ __volatile__(   \
+   "1: llock   %0, [%1]\n" \
+   "   brne%0, %2, 2f  \n" \
+   "   scond   %3, [%1]\n" \
+   "   bnz 1b  \n" \
+   "2: \n" \
+   : "=&r"(prev)   \
+   : "r"(mem), "ir"(oldval),   \
+ "r"(newval) /* can't be "ir". scond can't take limm for "b" */\
+   : "cc", "memory");  \
+   \
+   prev;   \
+  })
+
+# define atomic_exchange_acq(mem, newvalue) \
+  ({   \
+   __typeof(*(mem)) __val = (newvalue);\
+   \
+   __asm__ __volatile__(   \
+   "1: ex   %0, [%1]   \n" \
+   : "+r"(__val)   \
+   : "r"(mem)  \
+   : "memory");\
+   \
+  

[PATCH 10/21] ARC: Linux Startup and Dynamic Loading

2018-12-18 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 ChangeLog   |  3 ++
 sysdeps/unix/sysv/linux/arc/dl-static.c | 84 +
 sysdeps/unix/sysv/linux/arc/ldconfig.h  | 25 ++
 sysdeps/unix/sysv/linux/arc/ldsodefs.h  | 32 +
 4 files changed, 144 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/arc/dl-static.c
 create mode 100644 sysdeps/unix/sysv/linux/arc/ldconfig.h
 create mode 100644 sysdeps/unix/sysv/linux/arc/ldsodefs.h

diff --git a/ChangeLog b/ChangeLog
index ca010c356597..f6ad5968d7de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -71,6 +71,9 @@
* sysdeps/unix/sysv/linux/arc/sys/user.h: New file.
* sysdeps/unix/sysv/linux/arc/ucontext-macros.h: New file.
* sysdeps/unix/sysv/linux/arc/ucontext_i.sym: New file.
+   * sysdeps/unix/sysv/linux/arc/dl-static.c: New file.
+   * sysdeps/unix/sysv/linux/arc/ldconfig.h: New file.
+   * sysdeps/unix/sysv/linux/arc/ldsodefs.h: New file.
 
 2018-12-17  Joseph Myers  
 
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 ..2683ee5e7e2a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/dl-static.c
@@ -0,0 +1,84 @@
+/* Variable initialization.  ARC version.
+   Copyright (C) 2001-2018 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/ldconfig.h 
b/sysdeps/unix/sysv/linux/arc/ldconfig.h
new file mode 100644
index ..c38ce20edaea
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/ldconfig.h
@@ -0,0 +1,25 @@
+/* dynamic linker names for ARC
+   Copyright (C) 2001-2018 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 
+
+#define SYSDEP_KNOWN_INTERPRETER_NAMES \
+  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 },
+#define SYSDEP_KNOWN_LIBRARY_NAMES \
+  { "libc.so.6", FLAG_ELF_LIBC6 }, \
+  { "libm.so.6", FLAG_ELF_LIBC6 },
diff --git a/sysdeps/unix/sysv/linux/arc/ldsodefs.h 
b/sysdeps/unix/sysv/linux/arc/ldsodefs.h
new file mode 100644
index ..005c49a7b7cd
--- /dev/null
+++ b/

[PATCH 20/21] build-many-glibcs.py: Enable ARC builds

2018-12-18 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 ChangeLog| 4 
 scripts/build-many-glibcs.py | 4 
 2 files changed, 8 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 376d0e401117..46d288808153 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2018-12-17  Vineet Gupta 
+
+   * scripts/build-many-glibcs.py: Enable building for ARC.
+
 2018-12-17  Cupertino Miranda 
 
* sysdeps/arc/dl-machine.h: Fix relocation.
diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
index 9051ff17b19d..97e9bedabe0c 100755
--- a/scripts/build-many-glibcs.py
+++ b/scripts/build-many-glibcs.py
@@ -155,6 +155,9 @@ 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=archs'])
 self.add_config(arch='alpha',
 os_name='linux-gnu')
 self.add_config(arch='arm',
@@ -1258,6 +1261,7 @@ class Config(object):
 def install_linux_headers(self, cmdlist):
 """Install Linux kernel headers."""
 arch_map = {'aarch64': 'arm64',
+'arc': 'arc',
 'alpha': 'alpha',
 'arm': 'arm',
 'hppa': 'parisc',
-- 
2.7.4


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


[PATCH 18/21] ARC: testsuite fix: GD TLS issue

2018-12-18 Thread Vineet Gupta
From: Cupertino Miranda 

Offset set by the linker in the GOT entries would be overwritten by the dynamic
loader instead of added to the symbol location.
Other target have the same approach on DTSOFF relocs.

Signed-off-by: Vineet Gupta 
---
 ChangeLog| 4 
 sysdeps/arc/dl-machine.h | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 39ff298b0091..ec068c7c5925 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2018-12-17  Cupertino Miranda 
+
+   * sysdeps/arc/dl-machine.h: Fix relocation.
+
 2018-12-17  Vineet Gupta 
 
* sysdeps/unix/make-syscalls.sh: Fix comment referencing
diff --git a/sysdeps/arc/dl-machine.h b/sysdeps/arc/dl-machine.h
index 02727a3a4d47..f4757904084a 100644
--- a/sysdeps/arc/dl-machine.h
+++ b/sysdeps/arc/dl-machine.h
@@ -290,7 +290,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) 
*reloc,
 case R_ARC_TLS_DTPOFF:
   if (sym != NULL)
 {
-  *reloc_addr = sym->st_value;
+  *reloc_addr += sym->st_value;
 }
   break;
 
-- 
2.7.4


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


[PATCH 16/21] ARC: testsuite fix: sysvipc/*

2018-12-18 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 ChangeLog  |  1 +
 sysdeps/unix/sysv/linux/arc/ipc_priv.h | 21 +
 2 files changed, 22 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/arc/ipc_priv.h

diff --git a/ChangeLog b/ChangeLog
index 909b1af09a31..d3a979a9236b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -109,6 +109,7 @@
* sysdeps/arc/start.S: likewise.
* sysdeps/arc/entry.h: Add ENTRY_POINT define check.
* sysdeps/arc/crti.S: add .hidden annotations.
+   * sysdeps/unix/sysv/linux/arc/ipc_priv.h: New file.
 
 2018-12-17  Joseph Myers  
 
diff --git a/sysdeps/unix/sysv/linux/arc/ipc_priv.h 
b/sysdeps/unix/sysv/linux/arc/ipc_priv.h
new file mode 100644
index ..5f6e9815d169
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/ipc_priv.h
@@ -0,0 +1,21 @@
+/* Old SysV permission definition for Linux.  ARC version.
+   Copyright (C) 2016-2018 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   /* For __key_t  */
+
+#define __IPC_64   0x0
-- 
2.7.4


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


[PATCH 19/21] ARC: fix several unwining and cancelation tests

2018-12-18 Thread Vineet Gupta
From: Cupertino Miranda 

1. Add dwarf CFI psuedo-ops to various syscall generators

2. Signature of sa_restorer was not what libgcc trampoline parser
   expects due to an intermediate mov instruction

Signed-off-by: Vineet Gupta 
Signed-off-by: Cupertino Miranda 
---
 ChangeLog |  8 
 sysdeps/arc/dl-trampoline.S   |  9 +
 sysdeps/arc/sysdep.h  |  2 ++
 sysdeps/unix/sysv/linux/arc/Makefile  |  4 
 sysdeps/unix/sysv/linux/arc/Versions  |  4 
 sysdeps/unix/sysv/linux/arc/sigaction.c   |  8 +---
 sysdeps/unix/sysv/linux/arc/sigrestorer.S | 28 
 7 files changed, 56 insertions(+), 7 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/arc/sigrestorer.S

diff --git a/ChangeLog b/ChangeLog
index ec068c7c5925..376d0e401117 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,14 @@
 2018-12-17  Cupertino Miranda 
 
* sysdeps/arc/dl-machine.h: Fix relocation.
+   * sysdeps/arc/dl-trampoline.S: Add cfi pseudo-ops.
+   * sysdeps/arc/sysdep.h: likewise.
+   * sysdeps/unix/sysv/linux/arc/sigrestorer.S: Add default sa_restorer
+   in asm.
+   * sysdeps/unix/sysv/linux/arc/sigaction.c: Delete "C" version of
+   restorer.
+   * sysdeps/unix/sysv/linux/arc/Makefile: Enable build.
+   * sysdeps/unix/sysv/linux/arc/Versions: expose default sa_restorer.
 
 2018-12-17  Vineet Gupta 
 
diff --git a/sysdeps/arc/dl-trampoline.S b/sysdeps/arc/dl-trampoline.S
index c704f0ff9a95..0fc9786ec1d3 100644
--- a/sysdeps/arc/dl-trampoline.S
+++ b/sysdeps/arc/dl-trampoline.S
@@ -37,11 +37,16 @@
st.ar7, [sp, -4]
st.ar8, [sp, -4]
st.ar9, [sp, -4]
+   cfi_adjust_cfa_offset (40)
push_s  blink
+   cfi_adjust_cfa_offset (4)
+   cfi_rel_offset (blink, 0)
 .endm
 
 .macro RESTORE_CALLER_SAVED_BUT_R0
ld.ab   blink,[sp, 4]
+   cfi_adjust_cfa_offset (-4)
+   cfi_restore (blink)
ld.ab   r9, [sp, 4]
ld.ab   r8, [sp, 4]
ld.ab   r7, [sp, 4]
@@ -51,6 +56,7 @@
pop_s   r3
pop_s   r2
pop_s   r1
+   cfi_adjust_cfa_offset (-36)
 .endm
 
 ; Upon entry, PLTn, which led us here, sets up the following regs
@@ -69,4 +75,7 @@ ENTRY(_dl_runtime_resolve)
RESTORE_CALLER_SAVED_BUT_R0
j_s.d   [r0]; r0 has resolved function addr
pop_s   r0  ; restore first arg to resolved call
+   cfi_adjust_cfa_offset (-4)
+   cfi_restore (r0)
+
 END(_dl_runtime_resolve)
diff --git a/sysdeps/arc/sysdep.h b/sysdeps/arc/sysdep.h
index 5c6e063d03fe..920611277089 100644
--- a/sysdeps/arc/sysdep.h
+++ b/sysdeps/arc/sysdep.h
@@ -32,10 +32,12 @@
 .globl C_SYMBOL_NAME(name) ASM_LINE_SEP\
 .type C_SYMBOL_NAME(name),%functionASM_LINE_SEP\
   C_LABEL(name)ASM_LINE_SEP\
+cfi_startproc  ASM_LINE_SEP\
 CALL_MCOUNT
 
 #undef  END
 #define END(name)  \
+  cfi_endproc  ASM_LINE_SEP\
   ASM_SIZE_DIRECTIVE(name)
 
 #ifdef SHARED
diff --git a/sysdeps/unix/sysv/linux/arc/Makefile 
b/sysdeps/unix/sysv/linux/arc/Makefile
index 76e5d24daea2..a6c6dfc6ec64 100644
--- a/sysdeps/unix/sysv/linux/arc/Makefile
+++ b/sysdeps/unix/sysv/linux/arc/Makefile
@@ -2,6 +2,10 @@ ifeq ($(subdir),stdlib)
 gen-as-const-headers += ucontext_i.sym
 endif
 
+ifeq ($(subdir),signal)
+sysdep_routines += sigrestorer
+endif
+
 ifeq ($(subdir),misc)
 # MIPS/Tile-style cacheflush routine
 sysdep_headers += sys/cachectl.h
diff --git a/sysdeps/unix/sysv/linux/arc/Versions 
b/sysdeps/unix/sysv/linux/arc/Versions
index ac3327426360..3d12161f7fe2 100644
--- a/sysdeps/unix/sysv/linux/arc/Versions
+++ b/sysdeps/unix/sysv/linux/arc/Versions
@@ -9,4 +9,8 @@ libc {
 _flush_cache;
 cacheflush;
   }
+  GLIBC_PRIVATE {
+# A copy of sigaction lives in libpthread, and needs these.
+__default_rt_sa_restorer;
+  }
 }
diff --git a/sysdeps/unix/sysv/linux/arc/sigaction.c 
b/sysdeps/unix/sysv/linux/arc/sigaction.c
index 0a58e78f8834..b437af677d58 100644
--- a/sysdeps/unix/sysv/linux/arc/sigaction.c
+++ b/sysdeps/unix/sysv/linux/arc/sigaction.c
@@ -22,13 +22,7 @@
 #include 
 #include 
 
-/*
- * Default sigretrun stub if user doesn't specify SA_RESTORER
- */
-static void __default_rt_sa_restorer(void)
-{
-   INTERNAL_SYSCALL_NCS(__NR_rt_sigreturn, , 0);
-}
+extern void __default_rt_sa_restorer(void);
 
 #define SA_RESTORER0x0400
 
diff --git a/sysdeps/unix/sysv/linux/arc/sigrestorer.S 
b/sysdeps/unix/sysv/linux/arc/sigrestorer.S
new file mode 100644
index ..d74cf0ec00e3
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/arc/sigrestorer.S
@@ -0,0 +1,28 @@
+/* Default sigreturn stub for ARC Linux.
+   Copyright (C) 2005-2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+

Re: [PATCH 12/21] ARC: Update syscall-names.list for ARC specific syscalls

2018-12-18 Thread Florian Weimer
* Vineet Gupta:

> diff --git a/sysdeps/unix/sysv/linux/syscall-names.list 
> b/sysdeps/unix/sysv/linux/syscall-names.list
> index f88001c9c38d..62862010600f 100644
> --- a/sysdeps/unix/sysv/linux/syscall-names.list
> +++ b/sysdeps/unix/sysv/linux/syscall-names.list
> @@ -42,6 +42,9 @@ adjtimex
>  afs_syscall
>  alarm
>  alloc_hugepages
> +arc_gettls
> +arc_settls
> +arc_usr_cmpxchg
>  arch_prctl
>  arm_fadvise64_64
>  arm_sync_file_range

This should come in with a sync with a released upstream kernel.  Will
the port be in Linux 4.20?

Thanks,
Florian

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


Re: [PATCH 14/21] ARC: Enable __start as entry point vs. canonical _start

2018-12-18 Thread Florian Weimer
* Vineet Gupta:

> ARC linker scripts have defined __start as entry point so to not break
> ABI for uClibc et al we allow __start for glibc as well

I think this change and the test suite fixes should be folded into the
initial addition of these files.  Or is there a reason for not doing
this?

Thanks,
Florian

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


Re: [PATCH 14/21] ARC: Enable __start as entry point vs. canonical _start

2018-12-18 Thread Vineet Gupta
On 12/18/18 1:28 PM, Florian Weimer wrote:
>> ARC linker scripts have defined __start as entry point so to not break
>> ABI for uClibc et al we allow __start for glibc as well
> I think this change and the test suite fixes should be folded into the
> initial addition of these files.  Or is there a reason for not doing
> this?

I deliberately kept them out to call out the fixes, sometimes these help new 
ports
which stumble into similar issues. And also ~2 years worth of work gets squashed
into a single blob is a shame :-)

-Vineet

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


[PATCH 12/25] clocksource/drivers/arc_timer: Utilize generic sched_clock

2018-12-18 Thread Daniel Lezcano
From: Alexey Brodkin 

It turned out we used to use default implementation of sched_clock()
from kernel/sched/clock.c which was as precise as 1/HZ, i.e.
by default we had 10 msec granularity of time measurement.

Now given ARC built-in timers are clocked with the same frequency as
CPU cores we may get much higher precision of time tracking.

Thus we switch to generic sched_clock which really reads ARC hardware
counters.

This is especially helpful for measuring short events.
That's what we used to have:
-->8
$ perf stat /bin/sh -c /root/lmbench-master/bin/arc/hello > /dev/null

 Performance counter stats for '/bin/sh -c /root/lmbench-master/bin/arc/hello':

 10.00  task-clock (msec) #2.832 CPUs utilized
 1  context-switches  #0.100 K/sec
 1  cpu-migrations#0.100 K/sec
63  page-faults   #0.006 M/sec
   3049480  cycles#0.305 GHz
   1091259  instructions  #0.36  insn per cycle
256828  branches  #   25.683 M/sec
 27026  branch-misses #   10.52% of all branches

   0.003530687 seconds time elapsed

   0.0 seconds user
   0.01000 seconds sys
-->8

And now we'll see:
-->8
$ perf stat /bin/sh -c /root/lmbench-master/bin/arc/hello > /dev/null

 Performance counter stats for '/bin/sh -c /root/lmbench-master/bin/arc/hello':

  3.004322  task-clock (msec) #0.865 CPUs utilized
 1  context-switches  #0.333 K/sec
 1  cpu-migrations#0.333 K/sec
63  page-faults   #0.021 M/sec
   2986734  cycles#0.994 GHz
   1087466  instructions  #0.36  insn per cycle
255209  branches  #   84.947 M/sec
 26002  branch-misses #   10.19% of all branches

   0.003474829 seconds time elapsed

   0.003519000 seconds user
   0.0 seconds sys
-->8

Note how much more meaningful is the second output - time spent for
execution pretty much matches number of cycles spent (we're runnign
@ 1GHz here).

Signed-off-by: Alexey Brodkin 
Cc: Daniel Lezcano 
Cc: Vineet Gupta 
Cc: Thomas Gleixner 
Cc: sta...@vger.kernel.org
Acked-by: Vineet Gupta 
Signed-off-by: Daniel Lezcano 

Signed-off-by: Daniel Lezcano 
---
 arch/arc/Kconfig|  1 +
 drivers/clocksource/Kconfig |  1 +
 drivers/clocksource/arc_timer.c | 22 ++
 3 files changed, 24 insertions(+)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index c9e2a1323536..74b5a654f664 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -26,6 +26,7 @@ config ARC
select GENERIC_IRQ_SHOW
select GENERIC_PCI_IOMAP
select GENERIC_PENDING_IRQ if SMP
+   select GENERIC_SCHED_CLOCK
select GENERIC_SMP_IDLE_THREAD
select HAVE_ARCH_KGDB
select HAVE_ARCH_TRACEHOOK
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 8761a1c21b6c..c57b156f49a2 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -277,6 +277,7 @@ config CLKSRC_MPS2
 
 config ARC_TIMERS
bool "Support for 32-bit TIMERn counters in ARC Cores" if COMPILE_TEST
+   depends on GENERIC_SCHED_CLOCK
select TIMER_OF
help
  These are legacy 32-bit TIMER0 and TIMER1 counters found on all ARC 
cores
diff --git a/drivers/clocksource/arc_timer.c b/drivers/clocksource/arc_timer.c
index 20da9b1d7f7d..b28970ca4a7a 100644
--- a/drivers/clocksource/arc_timer.c
+++ b/drivers/clocksource/arc_timer.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -88,6 +89,11 @@ static u64 arc_read_gfrc(struct clocksource *cs)
return (((u64)h) << 32) | l;
 }
 
+static notrace u64 arc_gfrc_clock_read(void)
+{
+   return arc_read_gfrc(NULL);
+}
+
 static struct clocksource arc_counter_gfrc = {
.name   = "ARConnect GFRC",
.rating = 400,
@@ -111,6 +117,8 @@ static int __init arc_cs_setup_gfrc(struct device_node 
*node)
if (ret)
return ret;
 
+   sched_clock_register(arc_gfrc_clock_read, 64, arc_timer_freq);
+
return clocksource_register_hz(&arc_counter_gfrc, arc_timer_freq);
 }
 TIMER_OF_DECLARE(arc_gfrc, "snps,archs-timer-gfrc", arc_cs_setup_gfrc);
@@ -139,6 +147,11 @@ static u64 arc_read_rtc(struct clocksource *cs)
return (((u64)h) << 32) | l;
 }
 
+static notrace u64 arc_rtc_clock_read(void)
+{
+   return arc_read_rtc(NULL);
+}
+
 static struct clocksource arc_counter_

Re: [PATCH 12/21] ARC: Update syscall-names.list for ARC specific syscalls

2018-12-18 Thread Vineet Gupta
On 12/18/18 1:26 PM, Florian Weimer wrote:
> This should come in with a sync with a released upstream kernel.  Will
> the port be in Linux 4.20?

linux port was upstreamed in 2013 in v3.9

-Vineet

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


Re: [PATCH 11/21] ARC: ABI lists

2018-12-18 Thread Andreas Schwab
On Dez 18 2018, Vineet Gupta  wrote:

>  sysdeps/unix/sysv/linux/arc/libnsl.abilist |  120 ++

You don't need that any more.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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


Re: [PATCH 11/21] ARC: ABI lists

2018-12-18 Thread Vineet Gupta
On 12/18/18 2:31 PM, Andreas Schwab wrote:
>>  sysdeps/unix/sysv/linux/arc/libnsl.abilist |  120 ++
> You don't need that any more.

Ok ! deleted now !

Thx,
-Vineet

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


Re: [PATCH 17/21] ARC: testsuite fix: stdlib/tst-makecontext

2018-12-18 Thread Andreas Schwab
On Dez 18 2018, Vineet Gupta  wrote:

> diff --git a/sysdeps/unix/sysv/linux/arc/setcontext.S 
> b/sysdeps/unix/sysv/linux/arc/setcontext.S
> index 3f503c661d95..6ec2ec0ddc79 100644
> --- a/sysdeps/unix/sysv/linux/arc/setcontext.S
> +++ b/sysdeps/unix/sysv/linux/arc/setcontext.S
> @@ -79,6 +79,8 @@ weak_alias(__setcontext, setcontext)
>  
>  ENTRY(__startcontext)
>  
> + cfi_register (blink, r15)
> +

You should precede that with a dummy .cfi_label (see
sysdeps/riscv/start.S) to force the CFI into the FDE instead of the
CIE.  Also, can you use cfi_undefined instead?

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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


Re: [PATCH 00/21] glibc port to ARC processors

2018-12-18 Thread Joseph Myers
On Tue, 18 Dec 2018, Vineet Gupta wrote:

> | FAIL: elf/check-localplt# passes for build-many-glibcs.py
>   # buildroot builds with slightly 
> different toggles (-Os)
>   # such that gcc generates an extra 
> memcpy PLT call

I fixed lots of such issues with -Os on various architectures; it should 
be possible to fix this one as well.  (I haven't run build-many-glibcs.py 
with -Os lately, so it's possible more problems have crept in or appear 
with current compilers.  When I was testing it, it failed for m68k - the 
m68k libm functions don't build with -Os because bits/mathinline.h doesn't 
get included then, which needs addressing anyway in some way to eliminate 
bits/mathinline.h from glibc - but worked for most or all other 
configurations.)

> (d) We currently only support soft float ABI, although I'm working on hard 
> float
> and hopefully will have it ready sometime during the review of this series

Could you confirm what the ABI entry or entries to go at 
 would look like?

Note that we generally expect new ports to use different dynamic linker 
names for each ABI.  This means separate names for hard float and soft 
float.  Since it appears you support both big and little endian, it also 
means separate dynamic linker names for each of those (and corresponding 
GCC changes will be needed to pass the right dynamic linker names to ld's 
-dynamic-linker option).  Then, each supported ABI should have a build in 
build-many-glibcs.py, and any unsupported ABI variants need to have a 
configure-time error (to avoid accidentally building a glibc incompatible 
with the correct ABI for such a port added in future).

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH 01/21] longlong.h: sync from gcc to fix ARC inline asm constraints

2018-12-18 Thread Joseph Myers
On Tue, 18 Dec 2018, Vineet Gupta wrote:

> diff --git a/ChangeLog b/ChangeLog
> index 027b23493ed8..456e4b670c23 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -2,6 +2,7 @@
>  
>   * sysdeps/unix/make-syscalls.sh: Fix comment referencing
>   syscall-template file.
> + * stdlib/longlong.h: Fix asm constraints for ARC code.

I don't see the above context in the current checked-in ChangeLog file.  
Patch 1 in a series should be creating a new ChangeLog entry in any case, 
not adding to an existing one (and it's best not to include the ChangeLog 
entry in the diffs, only adding it at the final commit time, to avoid 
problems for people applying your patches).

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH 14/21] ARC: Enable __start as entry point vs. canonical _start

2018-12-18 Thread Joseph Myers
On Tue, 18 Dec 2018, Vineet Gupta wrote:

> On 12/18/18 1:28 PM, Florian Weimer wrote:
> >> ARC linker scripts have defined __start as entry point so to not break
> >> ABI for uClibc et al we allow __start for glibc as well
> > I think this change and the test suite fixes should be folded into the
> > initial addition of these files.  Or is there a reason for not doing
> > this?
> 
> I deliberately kept them out to call out the fixes, sometimes these help 
> new ports which stumble into similar issues. And also ~2 years worth of 
> work gets squashed into a single blob is a shame :-)

Postings of a new port should generally post each new file in the form in 
which it is intended to be committed (and, thus, the form in which it 
should be reviewed); you should never post a known-buggy version and a 
subsequent fix to the bug; that wastes reviewers' time.  (The actual 
commit of the port should be a single commit with everything, modulo 
possible separate earlier commits for changes to architecture-independent 
files, as the port isn't useful with only a subset of the new files 
added.)

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH 00/21] glibc port to ARC processors

2018-12-18 Thread Vineet Gupta
On 12/18/18 2:52 PM, Joseph Myers wrote:
> On Tue, 18 Dec 2018, Vineet Gupta wrote:
> 
>> | FAIL: elf/check-localplt   # passes for build-many-glibcs.py
>>  # buildroot builds with slightly 
>> different toggles (-Os)
>>  # such that gcc generates an extra 
>> memcpy PLT call
> 
> I fixed lots of such issues with -Os on various architectures; it should 
> be possible to fix this one as well.  (I haven't run build-many-glibcs.py 
> with -Os lately, so it's possible more problems have crept in or appear 
> with current compilers.  When I was testing it, it failed for m68k - the 
> m68k libm functions don't build with -Os because bits/mathinline.h doesn't 
> get included then, which needs addressing anyway in some way to eliminate 
> bits/mathinline.h from glibc - but worked for most or all other 
> configurations.)

The actual xcheck runs posted later on have been with buildroot built toolchain
which defaults to -Os, so it works for ARC, except for this additional entry.

At any rate, the generated code will likely be different for -Os and otherwise,
does that mean entries get added conditionally to localplt.data etc ?

>> (d) We currently only support soft float ABI, although I'm working on hard 
>> float
>> and hopefully will have it ready sometime during the review of this 
>> series
> 
> Could you confirm what the ABI entry or entries to go at 
>  would look like?

soft-float LE: ld-linux-arc.so.2
hard-float LE: ld-linux-archf.so.2   (although this is just a preference)

> Note that we generally expect new ports to use different dynamic linker 
> names for each ABI.  This means separate names for hard float and soft 
> float.  Since it appears you support both big and little endian, it also 
> means separate dynamic linker names for each of those (and corresponding 
> GCC changes will be needed to pass the right dynamic linker names to ld's 
> -dynamic-linker option). 

ARC historically has supported both LE/BE, but we are kind of moving away from 
BE
and as far as I know, there's no-one actively working with BE (except 1 specific
customer with legact cores). It is safe to assume we won't support BE and this 
is
sort of easier said for ARC processors as they have many many hardware config
knobs and not all are supported for Linux usecase, so BE can be considered as 
such.

> Then, each supported ABI should have a build in 
> build-many-glibcs.py, and any unsupported ABI variants need to have a 
> configure-time error (to avoid accidentally building a glibc incompatible 
> with the correct ABI for such a port added in future).

Right, at this point I only have soft-float and work is ongoing for hard.

Thx for taking a look.
-Vineet

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


Re: [PATCH 14/21] ARC: Enable __start as entry point vs. canonical _start

2018-12-18 Thread Vineet Gupta
On 12/18/18 2:59 PM, Joseph Myers wrote:
>> I deliberately kept them out to call out the fixes, sometimes these help 
>> new ports which stumble into similar issues. And also ~2 years worth of 
>> work gets squashed into a single blob is a shame :-)
>
> Postings of a new port should generally post each new file in the form in 
> which it is intended to be committed (and, thus, the form in which it 
> should be reviewed); you should never post a known-buggy version and a 
> subsequent fix to the bug; that wastes reviewers' time.  (The actual 
> commit of the port should be a single commit with everything, modulo 
> possible separate earlier commits for changes to architecture-independent 
> files, as the port isn't useful with only a subset of the new files 
> added.

Ok I can certainly squash them in next version.

Thx,
-Vineet

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


Re: [PATCH 03/21] ARC: ABI Implementation

2018-12-18 Thread Joseph Myers
On Tue, 18 Dec 2018, Vineet Gupta wrote:

> +/* FLAG 1 is privilege mode only instruction, hence will crash any program */

Generally, throughout the port, make sure comments end ".  " (full stop, 
two spaces, end of comment).  I won't remark on other places with this 
formatting issue.

> diff --git a/sysdeps/arc/crti.S b/sysdeps/arc/crti.S

As a new port I think it would be best to use init_array in your Implies 
file so you don't need these crti / crtn files, and make GCC generate 
init_array / fini_array exclusively.  (See RISC-V and C-Sky discussions of 
this issue.)

> +#ifdef __A7__
> +#define ARC_PLT_SIZE 12
> +#else
> +#define ARC_PLT_SIZE 16
> +#endif

Except for the multiple-include guards round a whole header file, 
preprocessor directives inside #if should have indentation in glibc, so 
"# define" (and "#  define" inside two levels of #if, etc.).  (As usual, 
fix this throughout the port; I won't list other individual places with 
this issue.)

> +#define reloc_index  \
> +({   \
> +  unsigned long plt0 = D_PTR (l, l_info[DT_PLTGOT]); \
> +  unsigned long pltn = reloc_arg;\
> +  /* exclude PL0 and PLT1 */ \

Note the first letter of a comment should be capitalized (in addition to 
ending with ".  ").

> +  unsigned long idx = (pltn - plt0)/ARC_PLT_SIZE - 2;\

glibc style uses "unsigned long int", not just "unsigned long".

> diff --git a/sysdeps/arc/tls-macros.h b/sysdeps/arc/tls-macros.h
> new file mode 100644
> index ..51855edef6e7
> --- /dev/null
> +++ b/sysdeps/arc/tls-macros.h
> @@ -0,0 +1,29 @@
> +/* Macros to support TLS testing in times of missing compiler support.  */

Any file more than ten lines long should have copyright and license 
notices.

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH 01/21] longlong.h: sync from gcc to fix ARC inline asm constraints

2018-12-18 Thread Vineet Gupta
On 12/18/18 2:56 PM, Joseph Myers wrote:
>>  * sysdeps/unix/make-syscalls.sh: Fix comment referencing
>>  syscall-template file.
>> +* stdlib/longlong.h: Fix asm constraints for ARC code.
>
> I don't see the above context in the current checked-in ChangeLog file.  
> Patch 1 in a series should be creating a new ChangeLog entry in any case, 
> not adding to an existing one (and it's best not to include the ChangeLog 
> entry in the diffs, only adding it at the final commit time, to avoid 
> problems for people applying your patches).

Sorry my bad. I had one preceding patch in the pile which
  - created the Changlog entry
  - fixed a minor typo in make-syscalls.sh

I'll add that to v2.

Thx,
-Vineet

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


Re: [PATCH 00/21] glibc port to ARC processors

2018-12-18 Thread Joseph Myers
Another general point: when posting a new port, could you include pointers 
to architecture and ABI reference manuals in case those are of relevance 
to the review?  (URLs going directly to PDFs of those manuals are 
preferred.)

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH 06/21] ARC: Atomics and Locking primitives

2018-12-18 Thread Joseph Myers
On Tue, 18 Dec 2018, Vineet Gupta wrote:

> +#define USE_ATOMIC_COMPILER_BUILTINS 0

There is a strong preference for new ports to use 1 for this rather than 0 
(and not to have any asms in their atomic-machine.h unless there's some 
reason use of built-in functions is unsuitable) - see the recently posted 
C-Sky version, for example.  If you can't use 1, there should be a good 
reason, documented in a comment, for using asms instead of compiler 
built-in functions (e.g. if the compiler built-in functions would result 
in libatomic dependencies, which are unsuitable for glibc, rather than 
being expanded inline).

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH 07/21] ARC: math soft float support

2018-12-18 Thread Joseph Myers
On Tue, 18 Dec 2018, Vineet Gupta wrote:

> +#if defined(__ARC_FPU_SP__) || defined(__ARC_FPU_DP__)

Missing spaces before '(' (should have such spaces in most cases between 
an identifier or keyword and '(' - calls to "defined", calls to functions, 
calls to macros, __attribute__, etc. - except for a few cases of calls to 
macros such as ElfW where the result is logically used like an 
identifier).

> +/* In the soft-float case, only rounding to nearest is supported, with
> +   no exceptions.  */

To confirm: hard-float and soft-float are always different ABIs; you don't 
support hard-float compilation using the soft-float function calling ABI 
(like is supported for ARM and RISC-V, for example)?  (If you support 
hard-float compilation with the soft-float ABI, it would be problematic to 
have different FE_TONEAREST values in the two cases - ARM and RISC-V both 
define all the FE_* macros independently of whether hard or soft float is 
used, because they support that case.)

> diff --git a/sysdeps/arc/math_private.h b/sysdeps/arc/math_private.h

This file should not be needed now.

> diff --git a/sysdeps/arc/nofpu/math-tests-exception.h 
> b/sysdeps/arc/nofpu/math-tests-exception.h

This file does nothing (the name is wrong, the name actually used is 
math-tests-exceptions.h).  And it should not be needed unless you support 
hard-float compilation with the soft-float ABI (and thus define all the 
FE_* names in bits/fenv.h even for soft-float).

> diff --git a/sysdeps/arc/nofpu/math-tests-rounding.h 
> b/sysdeps/arc/nofpu/math-tests-rounding.h

Again, not needed unless hard-float compilation with the soft-float ABI is 
supported and bits/fenv.h has corresponding contents.

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH 04/21] ARC: startup and dynamic linking code

2018-12-18 Thread Joseph Myers
On Tue, 18 Dec 2018, Vineet Gupta wrote:

> +/*
> + * Dynamic Linking ABI for ARCv2 ISA
> + *

glibc does not use leading '*' on each line of a comment (needs fixing 
throughout this file).

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH 08/21] ARC: Linux Syscall Interface

2018-12-18 Thread Joseph Myers
On Tue, 18 Dec 2018, Vineet Gupta wrote:

> +/* Flush cache(s).  */
> +int
> +_flush_cache (char *addr, const int nbytes, const int op)
> +{
> +  return INLINE_SYSCALL (cacheflush, 3, addr, nbytes, op);
> +}
> +weak_alias (_flush_cache, cacheflush)

Can't this use a syscalls.list entry instead of needing its own .c file?

> diff --git a/sysdeps/unix/sysv/linux/arc/pt-vfork.S 
> b/sysdeps/unix/sysv/linux/arc/pt-vfork.S
> new file mode 100644
> index ..65cc3823ac87
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/arc/pt-vfork.S
> @@ -0,0 +1 @@
> +#include 

This does nothing for a new port (it's just defining compat symbols).  I'd 
expect

/* Not needed.  */

instead, as for RISC-V.

> diff --git a/sysdeps/unix/sysv/linux/arc/sigaction.c 
> b/sysdeps/unix/sysv/linux/arc/sigaction.c

Why do you need this, rather than using the unified version (possibly with 
a few macros defined first)?

> +/* All syscall handler come here to avoid generated code bloat due to
> + * GOT reference  to errno_location or it's equivalent
> + */
> +int __syscall_error(int err_no)

Return type goes on a separate line to the function name in a function 
definition.  (This is in addition to the formatting issues that have been 
noted elsewhere in the patch series, of which this code has at least three 
- '*' at start of comment lines, missing '.' at end of comment and missing 
space before '('.)

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH 09/21] ARC: Linux ABI

2018-12-18 Thread Joseph Myers
On Tue, 18 Dec 2018, Vineet Gupta wrote:

> +typedef unsigned short int __pr_uid_t;
> +typedef unsigned short int __pr_gid_t;

Are you sure?  I don't see an ARC-specific definition of __kernel_uid_t or 
__kernel_gid_t in the Linux kernel at all (which would mean unsigned int 
is actually used and you don't need this header at all).

> diff --git a/sysdeps/unix/sysv/linux/arc/bits/sigaction.h 
> b/sysdeps/unix/sysv/linux/arc/bits/sigaction.h

I wouldn't expect new architectures to have their own bits/sigaction.h.  
Rather, I'd expect them to use the generic bits/sigaction.h and the 
generic code to convert from the userspace struct sigaction to the kernel 
version.

> +#ifdef __USE_MISC
> +# define __ctx(fld) fld
> +#else
> +# define __ctx(fld) __ ## fld
> +#endif

New ports should just use namespace-clean field names here 
unconditionally.  The __ctx macros with __USE_MISC conditionals are purely 
for maximum API-compatibility for existing ports that needed to be fixed 
to make them namespace-clean.

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH 13/21] ARC: Build Infrastructure

2018-12-18 Thread Joseph Myers
On Tue, 18 Dec 2018, Vineet Gupta wrote:

> +libc {
> +  GLIBC_2.29 {
> +__adddf3; __addsf3; __divdf3; __divsf3; __eqdf2; __eqsf2; __extendsfdf2;
> +__fixdfdi; __fixdfsi; __fixsfdi; __fixsfsi;
> +__fixunsdfdi; __fixunsdfsi; __fixunssfdi; __fixunssfsi;
> +__floatdidf; __floatdisf; __floatsidf; __floatsisf;
> +__floatundidf; __floatundisf; __floatunsidf; __floatunsisf;
> +__gedf2; __gesf2; __gtdf2; __gtsf2; __ledf2; __lesf2; __ltdf2; __ltsf2;
> +__muldf3; __mulsf3; __nedf2; __nesf2; __negdf2; __negsf2;
> +__subdf3; __subsf3; __truncdfsf2; __unorddf2; __unordsf2;

Exporting soft-fp symbols from glibc is only appropriate if you are also 
building soft-fp in glibc (as opposed to building it in libgcc) - which 
might be done with a view to possibly enabling support for exceptions and 
rounding modes for soft-float, as on powerpc soft-float, for example.  I 
don't see a Subdirs files containing "soft-fp" in this patch series.  If 
you're just linking with libgcc, you should not be re-exporting these 
functions from libc.so (and indeed I don't see them in your ABI baselines 
- libgcc.a has them as hidden symbols to prevent such re-exporting).

> +libc_cv_fpie=no

Why?  I'd expect -fpie to be working for all glibc architectures with any 
modern GCC version (I wouldn't expect it to need extra GCC back-end 
support beyond -fpic).

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH 21/21] NEWS: mention ARC port

2018-12-18 Thread Joseph Myers
On Tue, 18 Dec 2018, Vineet Gupta wrote:

> @@ -1078,6 +1078,8 @@ Version 2.26
>  
>  Major new features:
>  
> +* Port to ARC HS cores has been contributed by Synopsys.
> +

Obviously this belongs under 2.29, or whatever version gets the port, not 
2.26.

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH 10/21] ARC: Linux Startup and Dynamic Loading

2018-12-18 Thread Joseph Myers
On Tue, 18 Dec 2018, Vineet Gupta wrote:

> diff --git a/sysdeps/unix/sysv/linux/arc/ldconfig.h 
> b/sysdeps/unix/sysv/linux/arc/ldconfig.h

This header should only be needed if you support multiple ABIs 
simultaneously on the same system; note most architectures don't have it.  
Maybe it will be relevant when you add support for the hard-float ABI, but 
not yet.

> +#define SYSDEP_KNOWN_INTERPRETER_NAMES \
> +  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 },

That's not the dynamic linker name you're using elsewhere.

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH 00/21] glibc port to ARC processors

2018-12-18 Thread Joseph Myers
On Tue, 18 Dec 2018, Vineet Gupta wrote:

> At any rate, the generated code will likely be different for -Os and 
> otherwise,
> does that mean entries get added conditionally to localplt.data etc ?

Entries *can* have a "?" to indicate they are optional (although avoiding 
the PLT reference is better - see how include/string.h does asm 
redirection of mempcpy and stpcpy, or likewise in 
sysdeps/wordsize-32/divdi3-symbol-hacks.h, for example).

> ARC historically has supported both LE/BE, but we are kind of moving 
> away from BE and as far as I know, there's no-one actively working with 
> BE (except 1 specific customer with legact cores). It is safe to assume 
> we won't support BE and this is sort of easier said for ARC processors 
> as they have many many hardware config knobs and not all are supported 
> for Linux usecase, so BE can be considered as such.

In that case, there should be a #error in bits/endian.h, or a 
configure-time error, or something like that, to make clear the glibc port 
does not support BE.

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH 07/21] ARC: math soft float support

2018-12-18 Thread Joseph Myers
On Tue, 18 Dec 2018, Joseph Myers wrote:

> On Tue, 18 Dec 2018, Vineet Gupta wrote:
> 
> > +#if defined(__ARC_FPU_SP__) || defined(__ARC_FPU_DP__)
> 
> Missing spaces before '(' (should have such spaces in most cases between 
> an identifier or keyword and '(' - calls to "defined", calls to functions, 
> calls to macros, __attribute__, etc. - except for a few cases of calls to 
> macros such as ElfW where the result is logically used like an 
> identifier).

Or, of course, just omit the parentheses in the "defined" case, which is 
very common for calls to "defined" in glibc.

(Function-like macro definitions are a case where you *can't* have the 
space because the syntax of C requires no space between the name of the 
macro being defined and the '(' before the list of argument names.)

-- 
Joseph S. Myers
jos...@codesourcery.com

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


Re: [PATCH 04/21] ARC: startup and dynamic linking code

2018-12-18 Thread Vineet Gupta
On 12/18/18 3:24 PM, Joseph Myers wrote:
> On Tue, 18 Dec 2018, Vineet Gupta wrote:
> 
>> +/*
>> + * Dynamic Linking ABI for ARCv2 ISA
>> + *
> glibc does not use leading '*' on each line of a comment (needs fixing 
> throughout this file).

OK !

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


Re: [PATCH 03/21] ARC: ABI Implementation

2018-12-18 Thread Vineet Gupta
On 12/18/18 3:09 PM, Joseph Myers wrote:
> On Tue, 18 Dec 2018, Vineet Gupta wrote:
> 
>> +/* FLAG 1 is privilege mode only instruction, hence will crash any program 
>> */
> 
> Generally, throughout the port, make sure comments end ".  " (full stop, 
> two spaces, end of comment).  I won't remark on other places with this 
> formatting issue.

OK. Fixed series wide.

>> diff --git a/sysdeps/arc/crti.S b/sysdeps/arc/crti.S
> 
> As a new port I think it would be best to use init_array in your Implies 
> file so you don't need these crti / crtn files, and make GCC generate 
> init_array / fini_array exclusively.  (See RISC-V and C-Sky discussions of 
> this issue.)

OK I can try enabling this !

>> +#ifdef __A7__
>> +#define ARC_PLT_SIZE12
>> +#else
>> +#define ARC_PLT_SIZE16
>> +#endif
> 
> Except for the multiple-include guards round a whole header file, 
> preprocessor directives inside #if should have indentation in glibc, so 
> "# define" (and "#  define" inside two levels of #if, etc.).  (As usual, 
> fix this throughout the port; I won't list other individual places with 
> this issue.)

Done series wide.

> 
>> +#define reloc_index \
>> +({  \
>> +  unsigned long plt0 = D_PTR (l, l_info[DT_PLTGOT]);\
>> +  unsigned long pltn = reloc_arg;   \
>> +  /* exclude PL0 and PLT1 */\
> 
> Note the first letter of a comment should be capitalized (in addition to 
> ending with ".  ").
> 
>> +  unsigned long idx = (pltn - plt0)/ARC_PLT_SIZE - 2;   \
> 
> glibc style uses "unsigned long int", not just "unsigned long".

Done series wide.

>> diff --git a/sysdeps/arc/tls-macros.h b/sysdeps/arc/tls-macros.h
>> new file mode 100644
>> index ..51855edef6e7
>> --- /dev/null
>> +++ b/sysdeps/arc/tls-macros.h
>> @@ -0,0 +1,29 @@
>> +/* Macros to support TLS testing in times of missing compiler support.  */
> 
> Any file more than ten lines long should have copyright and license 
> notices.

Done.

P.S. Is there a lint file or are these style guidelines in wiki somewhere. If 
not
I can volunteer to capture them in a wiki/readme for future port submissions.

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


Re: [PATCH 08/21] ARC: Linux Syscall Interface

2018-12-18 Thread Vineet Gupta
On 12/18/18 3:30 PM, Joseph Myers wrote:
> On Tue, 18 Dec 2018, Vineet Gupta wrote:
> 
>> +/* Flush cache(s).  */
>> +int
>> +_flush_cache (char *addr, const int nbytes, const int op)
>> +{
>> +  return INLINE_SYSCALL (cacheflush, 3, addr, nbytes, op);
>> +}
>> +weak_alias (_flush_cache, cacheflush)
> 
> Can't this use a syscalls.list entry instead of needing its own .c file?

Sure it can ! Done now.

>> diff --git a/sysdeps/unix/sysv/linux/arc/pt-vfork.S 
>> b/sysdeps/unix/sysv/linux/arc/pt-vfork.S
>> new file mode 100644
>> index ..65cc3823ac87
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/arc/pt-vfork.S
>> @@ -0,0 +1 @@
>> +#include 
> 
> This does nothing for a new port (it's just defining compat symbols).  I'd 
> expect
> 
> /* Not needed.  */
> 
> instead, as for RISC-V.

Done !

>> diff --git a/sysdeps/unix/sysv/linux/arc/sigaction.c 
>> b/sysdeps/unix/sysv/linux/arc/sigaction.c
> 
> Why do you need this, rather than using the unified version (possibly with 
> a few macros defined first)?

The only syscall ABI requirement is that we pass our our own SA_RESTORER stub
(rather than inject one in kernel, and deal with cache sync etc etc). Indeed the
common code can be used - likely was not the case when I started with ARC port, 
or
more likely the port that I started ARC port from ;-)

I'll update this.


>> +/* All syscall handler come here to avoid generated code bloat due to
>> + * GOT reference  to errno_location or it's equivalent
>> + */
>> +int __syscall_error(int err_no)
> 
> Return type goes on a separate line to the function name in a function 
> definition.

Oops sorry fixed.

> (This is in addition to the formatting issues that have been 
> noted elsewhere in the patch series, of which this code has at least three 
> - '*' at start of comment lines, missing '.' at end of comment and missing 
> space before '('.)

Sorry again. I can sense your valid frustration, but then a lint file or 
kernel's
checkpatch style tools ill go a long way. Anyhow for now I've fixed annoyances
(hopefully all of them).

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