diff options
Diffstat (limited to 'REORG.TODO/sysdeps/s390/s390-32')
46 files changed, 3208 insertions, 0 deletions
diff --git a/REORG.TODO/sysdeps/s390/s390-32/Implies b/REORG.TODO/sysdeps/s390/s390-32/Implies new file mode 100644 index 0000000000..39a34c5f57 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/Implies @@ -0,0 +1 @@ +wordsize-32 diff --git a/REORG.TODO/sysdeps/s390/s390-32/Makefile b/REORG.TODO/sysdeps/s390/s390-32/Makefile new file mode 100644 index 0000000000..a07f2986ae --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/Makefile @@ -0,0 +1,9 @@ +ifeq ($(subdir),gmon) +sysdep_routines += s390-mcount +endif + +ifeq ($(subdir),elf) +CFLAGS-rtld.c += -Wno-uninitialized -Wno-unused +CFLAGS-dl-load.c += -Wno-unused +CFLAGS-dl-reloc.c += -Wno-unused +endif diff --git a/REORG.TODO/sysdeps/s390/s390-32/Versions b/REORG.TODO/sysdeps/s390/s390-32/Versions new file mode 100644 index 0000000000..2b020f8f58 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/Versions @@ -0,0 +1,6 @@ +libc { + GLIBC_2.0 { + # Functions from libgcc. + __divdi3; __moddi3; __udivdi3; __umoddi3; + } +} diff --git a/REORG.TODO/sysdeps/s390/s390-32/__longjmp.c b/REORG.TODO/sysdeps/s390/s390-32/__longjmp.c new file mode 100644 index 0000000000..abdd9641e6 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/__longjmp.c @@ -0,0 +1,83 @@ +/* Copyright (C) 2000-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + + 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 + <http://www.gnu.org/licenses/>. */ + +#include <errno.h> +#include <sysdep.h> +#include <setjmp.h> +#include <bits/setjmp.h> +#include <stdlib.h> +#include <unistd.h> +#include <stap-probe.h> + +/* Jump to the position specified by ENV, causing the + setjmp call there to return VAL, or 1 if VAL is 0. */ +void +__longjmp (__jmp_buf env, int val) +{ +#ifdef PTR_DEMANGLE + uintptr_t guard = THREAD_GET_POINTER_GUARD (); +# ifdef CHECK_SP + CHECK_SP (env, guard); +# endif +#elif defined CHECK_SP + CHECK_SP (env, 0); +#endif + register int r2 __asm__ ("%r2") = val == 0 ? 1 : val; +#ifdef PTR_DEMANGLE + register uintptr_t r3 __asm__ ("%r3") = guard; + register void *r1 __asm__ ("%r1") = (void *) env; +#endif + /* Restore registers and jump back. */ + __asm__ __volatile__ ( + /* longjmp probe expects longjmp first argument, second + argument and target address. */ +#ifdef PTR_DEMANGLE + "lm %%r4,%%r5,32(%1)\n\t" + "xr %%r4,%2\n\t" + "xr %%r5,%2\n\t" + LIBC_PROBE_ASM (longjmp, 4@%1 -4@%0 4@%%r4) +#else + LIBC_PROBE_ASM (longjmp, 4@%1 -4@%0 4@%%r14) +#endif + + /* restore fpregs */ + "ld %%f6,48(%1)\n\t" + "ld %%f4,40(%1)\n\t" + + /* restore gregs and return to jmp_buf target */ +#ifdef PTR_DEMANGLE + "lm %%r6,%%r13,0(%1)\n\t" + "lr %%r15,%%r5\n\t" + LIBC_PROBE_ASM (longjmp_target, 4@%1 -4@%0 4@%%r4) + "br %%r4" +#else + "lm %%r6,%%r15,0(%1)\n\t" + LIBC_PROBE_ASM (longjmp_target, 4@%1 -4@%0 4@%%r14) + "br %%r14" +#endif + : : "r" (r2), +#ifdef PTR_DEMANGLE + "r" (r1), "r" (r3) +#else + "a" (env) +#endif + ); + + /* Avoid `volatile function does return' warnings. */ + for (;;); +} diff --git a/REORG.TODO/sysdeps/s390/s390-32/add_n.S b/REORG.TODO/sysdeps/s390/s390-32/add_n.S new file mode 100644 index 0000000000..ed9cc27693 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/add_n.S @@ -0,0 +1,63 @@ +/* Add two limb vectors of the same length > 0 and store sum in a third + limb vector. + Copyright (C) 2000-2017 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + This file is part of the GNU MP Library. + + The GNU MP 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 MP 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 MP Library; see the file COPYING.LIB. If not, + see <http://www.gnu.org/licenses/>. */ + +/* + INPUT PARAMETERS + res_ptr %r2 + s1_ptr %r3 + s2_ptr %r4 + size %r5 +*/ + +#include "sysdep.h" +#include "asm-syntax.h" + + .text +ENTRY(__mpn_add_n) + st %r6,24(%r15) # save register 6 + cfi_offset (%r6, -72) + sr %r1,%r1 + lhi %r0,1 # cannot use ahi to add carry, use alr +.L0: l %r6,0(%r1,%r3) # .L0 -> no carry from last add + al %r6,0(%r1,%r4) + st %r6,0(%r1,%r2) + la %r1,4(0,%r1) + brc 3,.L3 +.L1: brct %r5,.L0 + slr %r2,%r2 # no last carry to return + j .Lexit +.L2: l %r6,0(%r1,%r3) # .L2 -> carry from last add + al %r6,0(%r1,%r4) + brc 3,.L4 + alr %r6,%r0 # no carry yet, add carry from last add + st %r6,0(%r1,%r2) + la %r1,4(0,%r1) + brc 12,.L1 # new carry ? +.L3: brct %r5,.L2 + lr %r2,%r0 # return last carry + j .Lexit +.L4: alr %r6,%r0 # already a carry, add carry from last add + st %r6,0(%r1,%r2) + la %r1,4(0,%r1) + brct %r5,.L2 + lr %r2,%r0 # return last carry +.Lexit: l %r6,24(%r15) # restore register 6 + br %r14 +END(__mpn_add_n) diff --git a/REORG.TODO/sysdeps/s390/s390-32/addmul_1.S b/REORG.TODO/sysdeps/s390/s390-32/addmul_1.S new file mode 100644 index 0000000000..6a4318ce49 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/addmul_1.S @@ -0,0 +1,58 @@ +/* S390 __mpn_addmul_1 -- Multiply a limb vector with a limb and add + the result to a second limb vector. + Copyright (C) 2000-2017 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + This file is part of the GNU MP Library. + + The GNU MP 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 MP 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 MP Library; see the file COPYING.LIB. If not, + see <http://www.gnu.org/licenses/>. */ + +/* + INPUT PARAMETERS + res_ptr %r2 + s1_ptr %r3 + sizeP %r4 + s2_limb %r5 +*/ + +#include "sysdep.h" +#include "asm-syntax.h" + + .text +ENTRY(__mpn_addmul_1) + st %r6,24(%r15) + cfi_offset (%r6, -72) + slr %r6,%r6 # cy_limb = 0 +.L0: icm %r1,15,0(%r3) # get s1_ptr[i] + mr %r0,%r5 # umul_ppmm(prod_high,prod_low,s1_ptr[j],s2_limb) + jnm .L1 + alr %r0,%r5 +.L1: ltr %r5,%r5 + jnm .L2 + al %r0,0(%r3) +.L2: alr %r1,%r6 # prod_low += cy_limb + lr %r6,%r0 # cy_limb = prod_high + brc 12,.L3 + ahi %r6,1 # + (prod_low < cy_limb) +.L3: al %r1,0(%r2) # prod_low += res_ptr[i] + brc 12,.L4 + ahi %r6,1 # cy_limb++ +.L4: st %r1,0(%r2) + la %r2,4(0,%r2) + la %r3,4(0,%r3) + brct %r4,.L0 + lr %r2,%r6 # return cy_limb + l %r6,24(%r15) +.Lexit: br %r14 +END(__mpn_addmul_1) diff --git a/REORG.TODO/sysdeps/s390/s390-32/backtrace.c b/REORG.TODO/sysdeps/s390/s390-32/backtrace.c new file mode 100644 index 0000000000..705b05d139 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/backtrace.c @@ -0,0 +1,148 @@ +/* Return backtrace of current program state. + Copyright (C) 2000-2017 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>. + 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 + <http://www.gnu.org/licenses/>. */ + +#include <libc-lock.h> +#include <dlfcn.h> +#include <execinfo.h> +#include <stddef.h> +#include <stdlib.h> +#include <unwind.h> + +/* This is a global variable set at program start time. It marks the + highest used stack address. */ +extern void *__libc_stack_end; + + +/* This is the stack layout we see for every non-leaf function. + size offset + %r15 -> +------------------+ + 4 | back chain | 0 + 4 | end of stack | 4 + 8 | glue | 8 + 8 | scratch | 16 + 40 | save area r6-r15 | 24 + 16 | save area f4,f6 | 64 + 16 | empty | 80 + +------------------+ + r14 in the save area holds the return address. +*/ + +struct layout +{ + int back_chain; + int end_of_stack; + int glue[2]; + int scratch[2]; + int save_grps[10]; + int save_fp[4]; + int empty[2]; +}; + +struct trace_arg +{ + void **array; + int cnt, size; +}; + +#ifdef SHARED +static _Unwind_Reason_Code (*unwind_backtrace) (_Unwind_Trace_Fn, void *); +static _Unwind_Ptr (*unwind_getip) (struct _Unwind_Context *); + +static void +init (void) +{ + void *handle = __libc_dlopen ("libgcc_s.so.1"); + + if (handle == NULL) + return; + + unwind_backtrace = __libc_dlsym (handle, "_Unwind_Backtrace"); + unwind_getip = __libc_dlsym (handle, "_Unwind_GetIP"); + if (unwind_getip == NULL) + unwind_backtrace = NULL; +} + +static int +__backchain_backtrace (void **array, int size) +{ + /* We assume that all the code is generated with frame pointers set. */ + struct layout *stack; + int cnt = 0; + + __asm__ ("LR %0,%%r15" : "=d" (stack) ); + /* We skip the call to this function, it makes no sense to record it. */ + stack = (struct layout *) stack->back_chain; + while (cnt < size) + { + if (stack == NULL || (void *) stack > __libc_stack_end) + /* This means the address is out of range. Note that for the + toplevel we see a frame pointer with value NULL which clearly is + out of range. */ + break; + + array[cnt++] = (void *) (stack->save_grps[8] & 0x7fffffff); + + stack = (struct layout *) stack->back_chain; + } + + return cnt; +} +#else +# define unwind_backtrace _Unwind_Backtrace +# define unwind_getip _Unwind_GetIP +#endif + +static _Unwind_Reason_Code +backtrace_helper (struct _Unwind_Context *ctx, void *a) +{ + struct trace_arg *arg = a; + + /* We are first called with address in the __backtrace function. + Skip it. */ + if (arg->cnt != -1) + arg->array[arg->cnt] = (void *) unwind_getip (ctx); + if (++arg->cnt == arg->size) + return _URC_END_OF_STACK; + return _URC_NO_REASON; +} + +int +__backtrace (void **array, int size) +{ + struct trace_arg arg = { .array = array, .size = size, .cnt = -1 }; + + if (size <= 0) + return 0; + +#ifdef SHARED + __libc_once_define (static, once); + + __libc_once (once, init); + + if (unwind_backtrace == NULL) + return __backchain_backtrace (array, size); +#endif + + unwind_backtrace (backtrace_helper, &arg); + + return arg.cnt != -1 ? arg.cnt : 0; +} + +weak_alias (__backtrace, backtrace) +libc_hidden_def (__backtrace) diff --git a/REORG.TODO/sysdeps/s390/s390-32/bcopy.S b/REORG.TODO/sysdeps/s390/s390-32/bcopy.S new file mode 100644 index 0000000000..06f51f3aa7 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/bcopy.S @@ -0,0 +1,85 @@ +/* bcopy -- copy a block from source to destination. S/390 version. + This file is part of the GNU C Library. + Copyright (C) 2000-2017 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + + 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 + <http://www.gnu.org/licenses/>. */ + +/* INPUT PARAMETERS + %r2 = address of source + %r3 = address of destination + %r4 = number of bytes to copy. */ + +#include "sysdep.h" +#include "asm-syntax.h" + + .text +ENTRY(__bcopy) + ltr %r1,%r4 # zero bcopy ? + jz .L4 + clr %r2,%r3 # check against destructive overlap + jnl .L0 + alr %r1,%r2 + clr %r1,%r3 + jh .L7 +.L0: ahi %r4,-1 # length - 1 + lr %r1,%r4 + srl %r1,8 + ltr %r1,%r1 # < 256 bytes to move ? + jz .L2 + chi %r1,255 # > 1MB to move ? + jh .L5 +.L1: mvc 0(256,%r3),0(%r2) # move in 256 byte chunks + la %r2,256(%r2) + la %r3,256(%r3) + brct %r1,.L1 +.L2: bras %r1,.L3 # setup base pointer for execute + mvc 0(1,%r3),0(%r2) # instruction for execute +.L3: ex %r4,0(%r1) # execute mvc with length ((%r4)&255)+1 +.L4: br %r14 + + # data copies > 1MB are faster with mvcle. +.L5: ahi %r4,1 # length + 1 + lr %r5,%r4 # source length + lr %r4,%r2 # source address + lr %r2,%r3 # set destination + lr %r3,%r5 # destination length = source length +.L6: mvcle %r2,%r4,0 # thats it, MVCLE is your friend + jo .L6 + br %r14 +.L7: # destructive overlay, can not use mvcle + lr %r1,%r2 # bcopy is called with source,dest + lr %r2,%r3 # memmove with dest,source! Oh, well... + lr %r3,%r1 + basr %r1,0 +.L8: +#ifdef PIC + al %r1,.L9-.L8(%r1) # get address of global offset table + # load address of memmove + l %r1,memmove@GOT(%r1) + br %r1 +.L9: .long _GLOBAL_OFFSET_TABLE_-.L8 +#else + al %r1,.L9-.L8(%r1) # load address of memmove + br %r1 # jump to memmove +.L9: .long memmove-.L8 +#endif + +END(__bcopy) + +#ifndef NO_WEAK_ALIAS +weak_alias (__bcopy, bcopy) +#endif + diff --git a/REORG.TODO/sysdeps/s390/s390-32/bits/wordsize.h b/REORG.TODO/sysdeps/s390/s390-32/bits/wordsize.h new file mode 100644 index 0000000000..129e47182b --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/bits/wordsize.h @@ -0,0 +1,11 @@ +/* Determine the wordsize from the preprocessor defines. */ + +#if defined __s390x__ +# define __WORDSIZE 64 +#else +# define __WORDSIZE 32 +# define __WORDSIZE32_SIZE_ULONG 1 +# define __WORDSIZE32_PTRDIFF_LONG 0 +#endif + +#define __WORDSIZE_TIME64_COMPAT32 0 diff --git a/REORG.TODO/sysdeps/s390/s390-32/bsd-_setjmp.S b/REORG.TODO/sysdeps/s390/s390-32/bsd-_setjmp.S new file mode 100644 index 0000000000..1417270201 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/bsd-_setjmp.S @@ -0,0 +1 @@ +/* We don't need any code here since the setjmp.S file contains it. */ diff --git a/REORG.TODO/sysdeps/s390/s390-32/bsd-setjmp.S b/REORG.TODO/sysdeps/s390/s390-32/bsd-setjmp.S new file mode 100644 index 0000000000..1417270201 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/bsd-setjmp.S @@ -0,0 +1 @@ +/* We don't need any code here since the setjmp.S file contains it. */ diff --git a/REORG.TODO/sysdeps/s390/s390-32/bzero.S b/REORG.TODO/sysdeps/s390/s390-32/bzero.S new file mode 100644 index 0000000000..b6f85e681f --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/bzero.S @@ -0,0 +1,42 @@ +/* bzero -- set a block of memory to zero. IBM S390 version + This file is part of the GNU C Library. + Copyright (C) 2000-2017 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + + 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 + <http://www.gnu.org/licenses/>. */ + +/* + * R2 = address to memory area + * R3 = number of bytes to fill + */ + +#include "sysdep.h" +#include "asm-syntax.h" + + .text +ENTRY(__bzero) + ltr %r3,%r3 + jz .L1 + sr %r1,%r1 # set pad byte to zero + sr %r4,%r4 # no source for MVCLE, only a pad byte + sr %r5,%r5 +.L0: mvcle %r2,%r4,0(%r1) # thats it, MVCLE is your friend + jo .L0 +.L1: br %r14 +END(__bzero) + +#ifndef NO_WEAK_ALIAS +weak_alias (__bzero, bzero) +#endif diff --git a/REORG.TODO/sysdeps/s390/s390-32/crti.S b/REORG.TODO/sysdeps/s390/s390-32/crti.S new file mode 100644 index 0000000000..54bd4590c0 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/crti.S @@ -0,0 +1,102 @@ +/* Special .init and .fini section support for S/390. + Copyright (C) 2000-2017 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. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file with other + programs, and to distribute those programs without any restriction + coming from the use of this file. (The GNU Lesser General Public + License restrictions do apply in other respects; for example, they + cover modification of the file, and distribution when not linked + into another program.) + + Note that people who make modified versions of this file are not + obligated to grant this special exception for their modified + versions; it is their choice whether to do so. The GNU Lesser + General Public License gives permission to release a modified + version without this exception; this exception also makes it + possible to release a modified version which carries forward this + exception. + + 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 + <http://www.gnu.org/licenses/>. */ + +/* crti.S puts a function prologue at the beginning of the .init and + .fini sections and defines global symbols for those addresses, so + they can be called as functions. The symbols _init and _fini are + magic and cause the linker to emit DT_INIT and DT_FINI. */ + +#include <libc-symbols.h> +#include <sysdep.h> + +#ifndef PREINIT_FUNCTION +# define PREINIT_FUNCTION __gmon_start__ +#endif + +#ifndef PREINIT_FUNCTION_WEAK +# define PREINIT_FUNCTION_WEAK 1 +#endif + +#if PREINIT_FUNCTION_WEAK + weak_extern (PREINIT_FUNCTION) +#else + .hidden PREINIT_FUNCTION +#endif + + .section .init,"ax",@progbits + .globl _init + .type _init,@function + .align 4 +_init: + stm %r6,%r15,24(%r15) + bras %r13,1f +0: +#if PREINIT_FUNCTION_WEAK + .long PREINIT_FUNCTION@GOT +#else + .long PREINIT_FUNCTION-0b +#endif + .long _GLOBAL_OFFSET_TABLE_-0b +1: lr %r1,%r15 + ahi %r15,-96 + st %r1,0(%r15) + l %r12,4(%r13) + ar %r12,%r13 + l %r1,0(%r13) +#if PREINIT_FUNCTION_WEAK + l %r1,0(%r1,%r12) + ltr %r1,%r1 + je 2f +#else + la %r1,0(%r1,%r13) +#endif + basr %r14,%r1 + .align 4,0x07 +2: + + .section .fini,"ax",@progbits + .globl _fini + .type _fini,@function + .align 4 +_fini: + stm %r6,%r15,24(%r15) + bras %r13,1f +0: .long _GLOBAL_OFFSET_TABLE_-0b +1: lr %r1,%r15 + ahi %r15,-96 + st %r1,0(%r15) + l %r12,0(%r13) + ar %r12,%r13 + .align 4,0x07 diff --git a/REORG.TODO/sysdeps/s390/s390-32/crtn.S b/REORG.TODO/sysdeps/s390/s390-32/crtn.S new file mode 100644 index 0000000000..3f5d85e2b2 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/crtn.S @@ -0,0 +1,47 @@ +/* Special .init and .fini section support for S/390. + Copyright (C) 2000-2017 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. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file with other + programs, and to distribute those programs without any restriction + coming from the use of this file. (The GNU Lesser General Public + License restrictions do apply in other respects; for example, they + cover modification of the file, and distribution when not linked + into another program.) + + Note that people who make modified versions of this file are not + obligated to grant this special exception for their modified + versions; it is their choice whether to do so. The GNU Lesser + General Public License gives permission to release a modified + version without this exception; this exception also makes it + possible to release a modified version which carries forward this + exception. + + 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 + <http://www.gnu.org/licenses/>. */ + +/* crtn.S puts function epilogues in the .init and .fini sections + corresponding to the prologues in crti.S. */ + + .section .init,"ax",@progbits + l %r4,152(%r15) + lm %r6,%r15,120(%r15) + br %r4 + + .section .fini,"ax",@progbits + l %r4,152(%r15) + lm %r6,%r15,120(%r15) + br %r4 diff --git a/REORG.TODO/sysdeps/s390/s390-32/dl-machine.h b/REORG.TODO/sysdeps/s390/s390-32/dl-machine.h new file mode 100644 index 0000000000..2e3c77c58e --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/dl-machine.h @@ -0,0 +1,522 @@ +/* Machine-dependent ELF dynamic relocation inline functions. S390 Version. + Copyright (C) 2000-2017 Free Software Foundation, Inc. + Contributed by Carl Pederson & Martin Schwidefsky. + 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 + <http://www.gnu.org/licenses/>. */ + +#ifndef dl_machine_h +#define dl_machine_h + +#define ELF_MACHINE_NAME "s390" + +#include <sys/param.h> +#include <string.h> +#include <link.h> +#include <sysdeps/s390/dl-procinfo.h> +#include <dl-irel.h> + +/* This is an older, now obsolete value. */ +#define EM_S390_OLD 0xA390 + +/* Return nonzero iff ELF header is compatible with the running host. */ +static inline int +elf_machine_matches_host (const Elf32_Ehdr *ehdr) +{ + /* Check if the kernel provides the high gpr facility if needed by + the binary. */ + if ((ehdr->e_flags & EF_S390_HIGH_GPRS) + && !(GLRO (dl_hwcap) & HWCAP_S390_HIGH_GPRS)) + return 0; + + return (ehdr->e_machine == EM_S390 || ehdr->e_machine == EM_S390_OLD) + && ehdr->e_ident[EI_CLASS] == ELFCLASS32; +} + + +/* Return the link-time address of _DYNAMIC. Conveniently, this is the + first element of the GOT. This must be inlined in a function which + uses global data. */ + +static inline Elf32_Addr +elf_machine_dynamic (void) +{ + register Elf32_Addr *got; + + __asm__( " bras %0,2f\n" + "1: .long _GLOBAL_OFFSET_TABLE_-1b\n" + "2: al %0,0(%0)" + : "=&a" (got) : : "0" ); + + return *got; +} + + +/* Return the run-time load address of the shared object. */ +static inline Elf32_Addr +elf_machine_load_address (void) +{ + Elf32_Addr addr; + + __asm__( " bras 1,2f\n" + "1: .long _GLOBAL_OFFSET_TABLE_ - 1b\n" + " .long (_dl_start - 1b - 0x80000000) & 0x00000000ffffffff\n" + "2: l %0,4(1)\n" + " ar %0,1\n" + " al 1,0(1)\n" + " sl %0,_dl_start@GOT(1)" + : "=&d" (addr) : : "1" ); + return addr; +} + +/* Set up the loaded object described by L so its unrelocated PLT + entries will jump to the on-demand fixup code in dl-runtime.c. */ + +static inline int __attribute__ ((unused)) +elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) +{ + extern void _dl_runtime_resolve (Elf32_Word); + extern void _dl_runtime_profile (Elf32_Word); +#if defined HAVE_S390_VX_ASM_SUPPORT + extern void _dl_runtime_resolve_vx (Elf32_Word); + extern void _dl_runtime_profile_vx (Elf32_Word); +#endif + + + if (l->l_info[DT_JMPREL] && lazy) + { + /* The GOT entries for functions in the PLT have not yet been filled + in. Their initial contents will arrange when called to push an + offset into the .rel.plt section, push _GLOBAL_OFFSET_TABLE_[1], + and then jump to _GLOBAL_OFFSET_TABLE[2]. */ + Elf32_Addr *got; + got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]); + /* If a library is prelinked but we have to relocate anyway, + we have to be able to undo the prelinking of .got.plt. + The prelinker saved us here address of .plt + 0x2c. */ + if (got[1]) + { + l->l_mach.plt = got[1] + l->l_addr; + l->l_mach.jmprel = (const Elf32_Rela *) D_PTR (l, l_info[DT_JMPREL]); + } + got[1] = (Elf32_Addr) l; /* Identify this shared object. */ + + /* The got[2] entry contains the address of a function which gets + called to get the address of a so far unresolved function and + jump to it. The profiling extension of the dynamic linker allows + to intercept the calls to collect information. In this case we + don't store the address in the GOT so that all future calls also + end in this function. */ + if (__glibc_unlikely (profile)) + { +#if defined HAVE_S390_VX_ASM_SUPPORT + if (GLRO(dl_hwcap) & HWCAP_S390_VX) + got[2] = (Elf32_Addr) &_dl_runtime_profile_vx; + else + got[2] = (Elf32_Addr) &_dl_runtime_profile; +#else + got[2] = (Elf32_Addr) &_dl_runtime_profile; +#endif + + if (GLRO(dl_profile) != NULL + && _dl_name_match_p (GLRO(dl_profile), l)) + /* This is the object we are looking for. Say that we really + want profiling and the timers are started. */ + GL(dl_profile_map) = l; + } + else + { + /* This function will get called to fix up the GOT entry indicated by + the offset on the stack, and then jump to the resolved address. */ +#if defined HAVE_S390_VX_ASM_SUPPORT + if (GLRO(dl_hwcap) & HWCAP_S390_VX) + got[2] = (Elf32_Addr) &_dl_runtime_resolve_vx; + else + got[2] = (Elf32_Addr) &_dl_runtime_resolve; +#else + got[2] = (Elf32_Addr) &_dl_runtime_resolve; +#endif + } + } + + return lazy; +} + +/* Mask identifying addresses reserved for the user program, + where the dynamic linker should not map anything. */ +#define ELF_MACHINE_USER_ADDRESS_MASK 0xf8000000UL + +/* Initial entry point code for the dynamic linker. + The C function `_dl_start' is the real entry point; + its return value is the user program's entry point. */ + +#define RTLD_START __asm__ ("\n\ +.text\n\ +.align 4\n\ +.globl _start\n\ +.globl _dl_start_user\n\ +_start:\n\ + basr %r13,0\n\ +0: ahi %r13,.Llit-0b\n\ + lr %r2,%r15\n\ + # Alloc stack frame\n\ + ahi %r15,-96\n\ + # Set the back chain to zero\n\ + xc 0(4,%r15),0(%r15)\n\ + # Call _dl_start with %r2 pointing to arg on stack\n\ + l %r14,.Ladr1-.Llit(%r13)\n\ + bas %r14,0(%r14,%r13) # call _dl_start\n\ +_dl_start_user:\n\ + # Save the user entry point address in %r8.\n\ + lr %r8,%r2\n\ + # Point %r12 at the GOT.\n\ + l %r12,.Ladr0-.Llit(%r13)\n\ + ar %r12,%r13\n\ + # See if we were run as a command with the executable file\n\ + # name as an extra leading argument.\n\ + l %r1,_dl_skip_args@GOT(%r12)\n\ + l %r1,0(%r1) # load _dl_skip_args\n\ + ltr %r1,%r1\n\ + je 4f # Skip the arg adjustment if there were none.\n\ + # Get the original argument count.\n\ + l %r0,96(%r15)\n\ + # Subtract _dl_skip_args from it.\n\ + sr %r0,%r1\n\ + # Store back the modified argument count.\n\ + st %r0,96(%r15)\n\ + # Copy argv and envp forward to account for skipped argv entries.\n\ + # We skipped at least one argument or we would not get here.\n\ + la %r6,100(%r15) # Destination pointer i.e. &argv[0]\n\ + lr %r5,%r6\n\ + lr %r0,%r1\n\ + sll %r0,2\n # Number of skipped bytes.\n\ + ar %r5,%r0 # Source pointer = Dest + Skipped args.\n\ + # argv copy loop:\n\ +1: l %r7,0(%r5) # Load a word from the source.\n\ + st %r7,0(%r6) # Store the word in the destination.\n\ + ahi %r5,4\n\ + ahi %r6,4\n\ + ltr %r7,%r7\n\ + jne 1b # Stop after copying the NULL.\n\ + # envp copy loop:\n\ +2: l %r7,0(%r5) # Load a word from the source.\n\ + st %r7,0(%r6) # Store the word in the destination.\n\ + ahi %r5,4\n\ + ahi %r6,4\n\ + ltr %r7,%r7\n\ + jne 2b # Stop after copying the NULL.\n\ + # Now we have to zero out the envp entries after NULL to allow\n\ + # start.S to properly find auxv by skipping zeroes.\n\ + # zero out loop:\n\ + lhi %r7,0\n\ +3: st %r7,0(%r6) # Store zero.\n\ + ahi %r6,4 # Advance dest pointer.\n\ + ahi %r1,-1 # Subtract one from the word count.\n\ + ltr %r1,%r1\n\ + jne 3b # Keep copying if the word count is non-zero.\n\ + # Adjust _dl_argv\n\ + la %r6,100(%r15)\n\ + l %r1,_dl_argv@GOT(%r12)\n\ + st %r6,0(%r1)\n\ + # The special initializer gets called with the stack just\n\ + # as the application's entry point will see it; it can\n\ + # switch stacks if it moves these contents over.\n\ +" RTLD_START_SPECIAL_INIT "\n\ + # Call the function to run the initializers.\n\ + # Load the parameters:\n\ + # (%r2, %r3, %r4, %r5) = (_dl_loaded, argc, argv, envp)\n\ +4: l %r2,_rtld_local@GOT(%r12)\n\ + l %r2,0(%r2)\n\ + l %r3,96(%r15)\n\ + la %r4,100(%r15)\n\ + lr %r5,%r3\n\ + sll %r5,2\n\ + la %r5,104(%r5,%r15)\n\ + l %r1,.Ladr4-.Llit(%r13)\n\ + bas %r14,0(%r1,%r13)\n\ + # Pass our finalizer function to the user in %r14, as per ELF ABI.\n\ + l %r14,_dl_fini@GOT(%r12)\n\ + # Free stack frame\n\ + ahi %r15,96\n\ + # Jump to the user's entry point (saved in %r8).\n\ + br %r8\n\ +.Llit:\n\ +.Ladr0: .long _GLOBAL_OFFSET_TABLE_-.Llit\n\ +.Ladr1: .long _dl_start-.Llit\n\ +.Ladr4: .long _dl_init@PLT-.Llit\n\ +"); + +#ifndef RTLD_START_SPECIAL_INIT +#define RTLD_START_SPECIAL_INIT /* nothing */ +#endif + +/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or + TLS variable, so undefined references should not be allowed to + define the value. + ELF_RTYPE_CLASS_COPY iff TYPE should not be allowed to resolve to one + of the main executable's symbols, as for a COPY reloc. */ +#define elf_machine_type_class(type) \ + ((((type) == R_390_JMP_SLOT || (type) == R_390_TLS_DTPMOD \ + || (type) == R_390_TLS_DTPOFF || (type) == R_390_TLS_TPOFF) \ + * ELF_RTYPE_CLASS_PLT) \ + | (((type) == R_390_COPY) * ELF_RTYPE_CLASS_COPY)) + +/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */ +#define ELF_MACHINE_JMP_SLOT R_390_JMP_SLOT + +/* The S390 never uses Elf32_Rel relocations. */ +#define ELF_MACHINE_NO_REL 1 +#define ELF_MACHINE_NO_RELA 0 + +/* We define an initialization functions. This is called very early in + _dl_sysdep_start. */ +#define DL_PLATFORM_INIT dl_platform_init () + +static inline void __attribute__ ((unused)) +dl_platform_init (void) +{ + if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0') + /* Avoid an empty string which would disturb us. */ + GLRO(dl_platform) = NULL; +} + +static inline Elf32_Addr +elf_machine_fixup_plt (struct link_map *map, lookup_t t, + const Elf32_Rela *reloc, + Elf32_Addr *reloc_addr, Elf32_Addr value) +{ + return *reloc_addr = value; +} + +/* Return the final value of a plt relocation. */ +static inline Elf32_Addr +elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc, + Elf32_Addr value) +{ + return value; +} + +/* Names of the architecture-specific auditing callback functions. */ +#define ARCH_LA_PLTENTER s390_32_gnu_pltenter +#define ARCH_LA_PLTEXIT s390_32_gnu_pltexit + +#endif /* !dl_machine_h */ + + +#ifdef RESOLVE_MAP + +/* Perform the relocation specified by RELOC and SYM (which is fully resolved). + MAP is the object containing the reloc. */ + +auto inline void +__attribute__ ((always_inline)) +elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, + const Elf32_Sym *sym, const struct r_found_version *version, + void *const reloc_addr_arg, int skip_ifunc) +{ + Elf32_Addr *const reloc_addr = reloc_addr_arg; + const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); + +#if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC + if (__glibc_unlikely (r_type == R_390_RELATIVE)) + { +# if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC + /* This is defined in rtld.c, but nowhere in the static libc.a; + make the reference weak so static programs can still link. + This declaration cannot be done when compiling rtld.c + (i.e. #ifdef RTLD_BOOTSTRAP) because rtld.c contains the + common defn for _dl_rtld_map, which is incompatible with a + weak decl in the same file. */ +# ifndef SHARED + weak_extern (GL(dl_rtld_map)); +# endif + if (map != &GL(dl_rtld_map)) /* Already done in rtld itself. */ +# endif + *reloc_addr = map->l_addr + reloc->r_addend; + } + else +#endif + if (__glibc_unlikely (r_type == R_390_NONE)) + return; + else + { +#if !defined RTLD_BOOTSTRAP && !defined RESOLVE_CONFLICT_FIND_MAP + /* Only needed for R_390_COPY below. */ + const Elf32_Sym *const refsym = sym; +#endif + struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type); + Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value; + + if (sym != NULL + && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0) + && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1) + && __builtin_expect (!skip_ifunc, 1)) + value = elf_ifunc_invoke (value); + + switch (r_type) + { + case R_390_IRELATIVE: + value = map->l_addr + reloc->r_addend; + if (__glibc_likely (!skip_ifunc)) + value = elf_ifunc_invoke (value); + *reloc_addr = value; + break; + + case R_390_GLOB_DAT: + case R_390_JMP_SLOT: + *reloc_addr = value + reloc->r_addend; + break; + +#ifndef RESOLVE_CONFLICT_FIND_MAP + case R_390_TLS_DTPMOD: +# ifdef RTLD_BOOTSTRAP + /* During startup the dynamic linker is always the module + with index 1. + XXX If this relocation is necessary move before RESOLVE + call. */ + *reloc_addr = 1; +# else + /* Get the information from the link map returned by the + resolv function. */ + if (sym_map != NULL) + *reloc_addr = sym_map->l_tls_modid; +# endif + break; + case R_390_TLS_DTPOFF: +# ifndef RTLD_BOOTSTRAP + /* During relocation all TLS symbols are defined and used. + Therefore the offset is already correct. */ + if (sym != NULL) + *reloc_addr = sym->st_value + reloc->r_addend; +# endif + break; + case R_390_TLS_TPOFF: + /* The offset is negative, forward from the thread pointer. */ +# ifdef RTLD_BOOTSTRAP + *reloc_addr = sym->st_value + reloc->r_addend - map->l_tls_offset; +# else + /* We know the offset of the object the symbol is contained in. + It is a negative value which will be added to the + thread pointer. */ + if (sym != NULL) + { + CHECK_STATIC_TLS (map, sym_map); + *reloc_addr = (sym->st_value + reloc->r_addend + - sym_map->l_tls_offset); + } +#endif + break; +#endif /* use TLS */ + +#ifndef RTLD_BOOTSTRAP +# ifndef RESOLVE_CONFLICT_FIND_MAP + /* Not needed in dl-conflict.c. */ + case R_390_COPY: + if (sym == NULL) + /* This can happen in trace mode if an object could not be + found. */ + break; + if (__builtin_expect (sym->st_size > refsym->st_size, 0) + || (__builtin_expect (sym->st_size < refsym->st_size, 0) + && __builtin_expect (GLRO(dl_verbose), 0))) + { + const char *strtab; + + strtab = (const char *) D_PTR(map,l_info[DT_STRTAB]); + _dl_error_printf ("\ +%s: Symbol `%s' has different size in shared object, consider re-linking\n", + RTLD_PROGNAME, strtab + refsym->st_name); + } + memcpy (reloc_addr_arg, (void *) value, + MIN (sym->st_size, refsym->st_size)); + break; +# endif + case R_390_32: + *reloc_addr = value + reloc->r_addend; + break; + case R_390_16: + *(unsigned short *) reloc_addr = value + reloc->r_addend; + break; + case R_390_8: + *(char *) reloc_addr = value + reloc->r_addend; + break; +# ifndef RESOLVE_CONFLICT_FIND_MAP + case R_390_PC32: + *reloc_addr = value + reloc->r_addend - (Elf32_Addr) reloc_addr; + break; + case R_390_PC16DBL: + *(unsigned short *) reloc_addr = (unsigned short) + ((short) (value + reloc->r_addend - (Elf32_Addr) reloc_addr) >> 1); + break; + case R_390_PC32DBL: + *(unsigned int *) reloc_addr = (unsigned int) + ((int) (value + reloc->r_addend - (Elf32_Addr) reloc_addr) >> 1); + break; + case R_390_PC16: + *(unsigned short *) reloc_addr = + value + reloc->r_addend - (Elf32_Addr) reloc_addr; + break; + case R_390_NONE: + break; +# endif +#endif +#if !defined(RTLD_BOOTSTRAP) || defined(_NDEBUG) + default: + /* We add these checks in the version to relocate ld.so only + if we are still debugging. */ + _dl_reloc_bad_type (map, r_type, 0); + break; +#endif + } + } +} + +auto inline void +__attribute__ ((always_inline)) +elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc, + void *const reloc_addr_arg) +{ + Elf32_Addr *const reloc_addr = reloc_addr_arg; + *reloc_addr = l_addr + reloc->r_addend; +} + +auto inline void +__attribute__ ((always_inline)) +elf_machine_lazy_rel (struct link_map *map, + Elf32_Addr l_addr, const Elf32_Rela *reloc, + int skip_ifunc) +{ + Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset); + const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); + /* Check for unexpected PLT reloc type. */ + if (__glibc_likely (r_type == R_390_JMP_SLOT)) + { + if (__builtin_expect (map->l_mach.plt, 0) == 0) + *reloc_addr += l_addr; + else + *reloc_addr = map->l_mach.plt + (reloc - map->l_mach.jmprel) * 32; + } + else if (__glibc_likely (r_type == R_390_IRELATIVE)) + { + Elf32_Addr value = map->l_addr + reloc->r_addend; + if (__glibc_likely (!skip_ifunc)) + value = elf_ifunc_invoke (value); + *reloc_addr = value; + } + else + _dl_reloc_bad_type (map, r_type, 1); +} + +#endif /* RESOLVE_MAP */ diff --git a/REORG.TODO/sysdeps/s390/s390-32/dl-sysdep.h b/REORG.TODO/sysdeps/s390/s390-32/dl-sysdep.h new file mode 100644 index 0000000000..f32114bf56 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/dl-sysdep.h @@ -0,0 +1,23 @@ +/* System-specific settings for dynamic linker code. S/390 version. + Copyright (C) 2014-2017 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 + <http://www.gnu.org/licenses/>. */ + +#include_next <dl-sysdep.h> + +/* _dl_argv cannot be attribute_relro, because _dl_start_user + might write into it after _dl_start returns. */ +#define DL_ARGV_NOT_RELRO 1 diff --git a/REORG.TODO/sysdeps/s390/s390-32/dl-trampoline.S b/REORG.TODO/sysdeps/s390/s390-32/dl-trampoline.S new file mode 100644 index 0000000000..34377e7c51 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/dl-trampoline.S @@ -0,0 +1,33 @@ +/* PLT trampolines. s390 version. + Copyright (C) 2005-2017 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 + <http://www.gnu.org/licenses/>. */ + +#include <sysdep.h> + + .text +/* Create variant of _dl_runtime_resolve/profile for machines before z13. + No vector registers are saved/restored. */ +#include <dl-trampoline.h> + +#if defined HAVE_S390_VX_ASM_SUPPORT +/* Create variant of _dl_runtime_resolve/profile for z13 and newer. + The vector registers are saved/restored, too.*/ +# define _dl_runtime_resolve _dl_runtime_resolve_vx +# define _dl_runtime_profile _dl_runtime_profile_vx +# define RESTORE_VRS +# include <dl-trampoline.h> +#endif diff --git a/REORG.TODO/sysdeps/s390/s390-32/dl-trampoline.h b/REORG.TODO/sysdeps/s390/s390-32/dl-trampoline.h new file mode 100644 index 0000000000..19776eec8a --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/dl-trampoline.h @@ -0,0 +1,231 @@ +/* PLT trampolines. s390 version. + Copyright (C) 2016-2017 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 + <http://www.gnu.org/licenses/>. */ + +/* This code is used in dl-runtime.c to call the `fixup' function + and then redirect to the address it returns. */ + +/* The PLT stubs will call _dl_runtime_resolve/_dl_runtime_profile + * with the following linkage: + * r2 - r6 : parameter registers + * f0, f2 : floating point parameter registers + * v24, v26, v28, v30, v25, v27, v29, v31 : vector parameter registers + * 24(r15), 28(r15) : PLT arguments PLT1, PLT2 + * 96(r15) : additional stack parameters + * The normal clobber rules for function calls apply: + * r0 - r5 : call clobbered + * r6 - r13 : call saved + * r14 : return address (call clobbered) + * r15 : stack pointer (call saved) + * f4, f6 : call saved + * f0 - f3, f5, f7 - f15 : call clobbered + * v0 - v3, v5, v7 - v15 : bytes 0-7 overlap with fprs: call clobbered + bytes 8-15: call clobbered + * v4, v6 : bytes 0-7 overlap with f4, f6: call saved + bytes 8-15: call clobbered + * v16 - v31 : call clobbered + */ + + + .globl _dl_runtime_resolve + .type _dl_runtime_resolve, @function + cfi_startproc + .align 16 +_dl_runtime_resolve: + stm %r2,%r5,32(%r15) # save registers + cfi_offset (r2, -64) + cfi_offset (r3, -60) + cfi_offset (r4, -56) + cfi_offset (r5, -52) + std %f0,56(%r15) + cfi_offset (f0, -40) + std %f2,64(%r15) + cfi_offset (f2, -32) + st %r14,8(%r15) + cfi_offset (r14, -88) + lr %r0,%r15 + lm %r2,%r3,24(%r15) # load args saved by PLT +#ifdef RESTORE_VRS + ahi %r15,-224 # create stack frame + cfi_adjust_cfa_offset (224) + .machine push + .machine "z13" + .machinemode "zarch_nohighgprs" + vstm %v24,%v31,96(%r15) # store call-clobbered vr arguments + cfi_offset (v24, -224) + cfi_offset (v25, -208) + cfi_offset (v26, -192) + cfi_offset (v27, -176) + cfi_offset (v28, -160) + cfi_offset (v29, -144) + cfi_offset (v30, -128) + cfi_offset (v31, -112) + .machine pop +#else + ahi %r15,-96 # create stack frame + cfi_adjust_cfa_offset (96) +#endif + st %r0,0(%r15) # write backchain + basr %r1,0 +0: l %r14,1f-0b(%r1) + bas %r14,0(%r14,%r1) # call _dl_fixup + lr %r1,%r2 # function addr returned in r2 +#ifdef RESTORE_VRS + .machine push + .machine "z13" + .machinemode "zarch_nohighgprs" + vlm %v24,%v31,96(%r15) # restore vector registers + .machine pop + ahi %r15,224 # remove stack frame + cfi_adjust_cfa_offset (-224) +#else + ahi %r15,96 # remove stack frame + cfi_adjust_cfa_offset (-96) +#endif + l %r14,8(15) # restore registers + ld %f0,56(%r15) + ld %f2,64(%r15) + lm %r2,%r5,32(%r15) + br %r1 +1: .long _dl_fixup - 0b + cfi_endproc + .size _dl_runtime_resolve, .-_dl_runtime_resolve + + +#ifndef PROF + .globl _dl_runtime_profile + .type _dl_runtime_profile, @function + cfi_startproc + .align 16 +_dl_runtime_profile: + st %r12,12(%r15) # r12 is used as backup of r15 + cfi_offset (r12, -84) + st %r14,16(%r15) + cfi_offset (r14, -80) + lr %r12,%r15 # backup stack pointer + cfi_def_cfa_register (12) + ahi %r15,-264 # create stack frame: + # 96 + sizeof(La_s390_32_regs) + st %r12,0(%r15) # save backchain + + stm %r2,%r6,96(%r15) # save registers + cfi_offset (r2, -264) # + r6 needed as arg for + cfi_offset (r3, -260) # _dl_profile_fixup + cfi_offset (r4, -256) + cfi_offset (r5, -252) + cfi_offset (r6, -248) + std %f0,120(%r15) + cfi_offset (f0, -240) + std %f2,128(%r15) + cfi_offset (f2, -232) +#ifdef RESTORE_VRS + .machine push + .machine "z13" + .machinemode "zarch_nohighgprs" + vstm %v24,%v31,136(%r15) # store call-clobbered vr arguments + cfi_offset (v24, -224) + cfi_offset (v25, -208) + cfi_offset (v26, -192) + cfi_offset (v27, -176) + cfi_offset (v28, -160) + cfi_offset (v29, -144) + cfi_offset (v30, -128) + cfi_offset (v31, -112) + .machine pop +#endif + + lm %r2,%r3,24(%r12) # load arguments saved by PLT + lr %r4,%r14 # return address as third parameter + basr %r1,0 +0: l %r14,6f-0b(%r1) + la %r5,96(%r15) # pointer to struct La_s390_32_regs + la %r6,20(%r12) # long int * framesize + bas %r14,0(%r14,%r1) # call resolver + lr %r1,%r2 # function addr returned in r2 + ld %f0,120(%r15) # restore call-clobbered arg fprs + ld %f2,128(%r15) +#ifdef RESTORE_VRS + .machine push + .machine "z13" + .machinemode "zarch_nohighgprs" + vlm %v24,%v31,136(%r15) # restore call-clobbered arg vrs + .machine pop +#endif + icm %r0,15,20(%r12) # load & test framesize + jnm 2f + + lm %r2,%r6,96(%r15) # framesize < 0 means no pltexit call + # so we can do a tail call without + # copying the arg overflow area + lr %r15,%r12 # remove stack frame + cfi_def_cfa_register (15) + l %r14,16(%r15) # restore registers + l %r12,12(%r15) + br %r1 # tail-call to the resolved function + + cfi_def_cfa_register (12) +2: la %r4,96(%r15) # pointer to struct La_s390_32_regs + st %r4,32(%r12) + jz 4f # framesize == 0 ? + ahi %r0,7 # align framesize to 8 + lhi %r2,-8 + nr %r0,%r2 + slr %r15,%r0 # make room for framesize bytes + st %r12,0(%r15) # save backchain + la %r2,96(%r15) + la %r3,96(%r12) + srl %r0,3 +3: mvc 0(8,%r2),0(%r3) # copy additional parameters + la %r2,8(%r2) + la %r3,8(%r3) + brct %r0,3b +4: lm %r2,%r6,0(%r4) # load register parameters + basr %r14,%r1 # call resolved function + stm %r2,%r3,40(%r12) # store return values r2, r3, f0 + std %f0,48(%r12) # to struct La_s390_32_retval +#ifdef RESTORE_VRS + .machine push + .machine "z13" + vst %v24,56(%r12) # store return value v24 + .machine pop +#endif + lm %r2,%r4,24(%r12) # r2, r3: load arguments saved by PLT + # r4: pointer to struct La_s390_32_regs + basr %r1,0 +5: l %r14,7f-5b(%r1) + la %r5,40(%r12) # pointer to struct La_s390_32_retval + bas %r14,0(%r14,%r1) # call _dl_call_pltexit + + lr %r15,%r12 # remove stack frame + cfi_def_cfa_register (15) + l %r14,16(%r15) # restore registers + l %r12,12(%r15) + lm %r2,%r3,40(%r15) # restore return values + ld %f0,48(%r15) +#ifdef RESTORE_VRS + .machine push + .machine "z13" + vl %v24,56(%r15) # restore return value v24 + .machine pop +#endif + br %r14 + +6: .long _dl_profile_fixup - 0b +7: .long _dl_call_pltexit - 5b + cfi_endproc + .size _dl_runtime_profile, .-_dl_runtime_profile +#endif diff --git a/REORG.TODO/sysdeps/s390/s390-32/memchr.S b/REORG.TODO/sysdeps/s390/s390-32/memchr.S new file mode 100644 index 0000000000..4ffac6061c --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/memchr.S @@ -0,0 +1,41 @@ +/* Search a character in a block of memory. For IBM S390 + Copyright (C) 2000-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + + 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 + <http://www.gnu.org/licenses/>. */ + +/* + * R2 = address to memory area + * R3 = character to find + * R4 = number of bytes to search + */ + +#include "sysdep.h" +#include "asm-syntax.h" + + .text +ENTRY(memchr) + lhi %r0,0xff + nr %r0,%r3 + lr %r1,%r2 + la %r2,0(%r4,%r1) +0: srst %r2,%r1 + jo 0b + brc 13,1f + slr %r2,%r2 +1: br %r14 +END(memchr) +libc_hidden_builtin_def (memchr) diff --git a/REORG.TODO/sysdeps/s390/s390-32/memcmp.S b/REORG.TODO/sysdeps/s390/s390-32/memcmp.S new file mode 100644 index 0000000000..ca02144a4a --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/memcmp.S @@ -0,0 +1,66 @@ +/* memcmp - compare two memory blocks. 32 bit S/390 version. + Copyright (C) 2012-2017 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 + <http://www.gnu.org/licenses/>. */ + + +#include "sysdep.h" +#include "asm-syntax.h" + +/* INPUT PARAMETERS + %r2 = address of first memory area + %r3 = address of second memory area + %r4 = number of bytes to compare. */ + + .text +#ifdef USE_MULTIARCH +ENTRY(__memcmp_default) +#else +ENTRY(memcmp) +#endif + .machine "g5" + basr %r5,0 +.L_G5_16: + ltr %r4,%r4 + je .L_G5_4 + ahi %r4,-1 + lr %r1,%r4 + srl %r1,8 + ltr %r1,%r1 + jne .L_G5_12 + ex %r4,.L_G5_17-.L_G5_16(%r5) +.L_G5_4: + ipm %r2 + sll %r2,2 + sra %r2,30 + br %r14 +.L_G5_12: + clc 0(256,%r3),0(%r2) + jne .L_G5_4 + la %r3,256(%r3) + la %r2,256(%r2) + brct %r1,.L_G5_12 + ex %r4,.L_G5_17-.L_G5_16(%r5) + j .L_G5_4 +.L_G5_17: + clc 0(1,%r3),0(%r2) +#ifdef USE_MULTIARCH +END(__memcmp_default) +#else +END(memcmp) +libc_hidden_builtin_def (memcmp) +weak_alias(memcmp, bcmp) +#endif diff --git a/REORG.TODO/sysdeps/s390/s390-32/memcpy.S b/REORG.TODO/sysdeps/s390/s390-32/memcpy.S new file mode 100644 index 0000000000..0177f19431 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/memcpy.S @@ -0,0 +1,89 @@ +/* memcpy - copy a block from source to destination. S/390 version. + Copyright (C) 2012-2017 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 + <http://www.gnu.org/licenses/>. */ + + +#include "sysdep.h" +#include "asm-syntax.h" + +/* INPUT PARAMETERS + %r2 = address of destination memory area + %r3 = address of source memory area + %r4 = number of bytes to copy. */ + + .text +ENTRY(__mempcpy) + .machine "g5" + lr %r1,%r2 # Use as dest + la %r2,0(%r4,%r2) # Return dest + n + j .L_G5_start +END(__mempcpy) +#ifndef USE_MULTIARCH +libc_hidden_def (__mempcpy) +weak_alias (__mempcpy, mempcpy) +libc_hidden_builtin_def (mempcpy) +#endif + +ENTRY(memcpy) + .machine "g5" + lr %r1,%r2 # r1: Use as dest ; r2: Return dest +.L_G5_start: + ltr %r4,%r4 + je .L_G5_99 + ahi %r4,-1 + lr %r5,%r4 + srl %r5,8 + ltr %r5,%r5 + jne .L_G5_13 +.L_G5_4: + basr %r5,0 +.L_G5_16: + ex %r4,.L_G5_17-.L_G5_16(%r5) +.L_G5_99: + br %r14 +.L_G5_13: + chi %r5,4096 # Switch to mvcle for copies >1MB + jh __memcpy_mvcle +.L_G5_12: + mvc 0(256,%r1),0(%r3) + la %r1,256(%r1) + la %r3,256(%r3) + brct %r5,.L_G5_12 + j .L_G5_4 +.L_G5_17: + mvc 0(1,%r1),0(%r3) +END(memcpy) +#ifndef USE_MULTIARCH +libc_hidden_builtin_def (memcpy) +#endif + +ENTRY(__memcpy_mvcle) + # Using as standalone function will result in unexpected + # results since the length field is incremented by 1 in order to + # compensate the changes already done in the functions above. + lr %r0,%r2 # backup return dest [ + n ] + ahi %r4,1 # length + 1 + lr %r5,%r4 # source length + lr %r4,%r3 # source address + lr %r2,%r1 # destination address + lr %r3,%r5 # destination length = source length +.L_MVCLE_1: + mvcle %r2,%r4,0 # thats it, MVCLE is your friend + jo .L_MVCLE_1 + lr %r2,%r0 # return destination address + br %r14 +END(__memcpy_mvcle) diff --git a/REORG.TODO/sysdeps/s390/s390-32/memset.S b/REORG.TODO/sysdeps/s390/s390-32/memset.S new file mode 100644 index 0000000000..720f393c30 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/memset.S @@ -0,0 +1,65 @@ +/* Set a block of memory to some byte value. For IBM S390 + Copyright (C) 2012-2017 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 + <http://www.gnu.org/licenses/>. */ + + +#include "sysdep.h" +#include "asm-syntax.h" + +/* INPUT PARAMETERS + %r2 = address to memory area + %r3 = byte to fill memory with + %r4 = number of bytes to fill. */ + + .text + +#ifdef USE_MULTIARCH +ENTRY(__memset_default) +#else +ENTRY(memset) +#endif + .machine "g5" + basr %r5,0 +.L_G5_19: + ltr %r4,%r4 + je .L_G5_4 + stc %r3,0(%r2) + chi %r4,1 + lr %r1,%r2 + je .L_G5_4 + ahi %r4,-2 + lr %r3,%r4 + srl %r3,8 + ltr %r3,%r3 + jne .L_G5_14 + ex %r4,.L_G5_20-.L_G5_19(%r5) +.L_G5_4: + br %r14 +.L_G5_14: + mvc 1(256,%r1),0(%r1) + la %r1,256(%r1) + brct %r3,.L_G5_14 + ex %r4,.L_G5_20-.L_G5_19(%r5) + j .L_G5_4 +.L_G5_20: + mvc 1(1,%r1),0(%r1) +#ifdef USE_MULTIARCH +END(__memset_default) +#else +END(memset) +libc_hidden_builtin_def (memset) +#endif diff --git a/REORG.TODO/sysdeps/s390/s390-32/mul_1.S b/REORG.TODO/sysdeps/s390/s390-32/mul_1.S new file mode 100644 index 0000000000..4f08fa2c80 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/mul_1.S @@ -0,0 +1,55 @@ +/* __mpn_mul_1 -- Multiply a limb vector with a limb and store + the result in a second limb vector. + Copyright (C) 2000-2017 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + This file is part of the GNU MP Library. + + The GNU MP 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 MP 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 MP Library; see the file COPYING.LIB. If not, + see <http://www.gnu.org/licenses/>. */ + +/* + INPUT PARAMETERS + res_ptr %r2 + s1_ptr %r3 + size %r4 + s2_limb %r5 +*/ + +#include <sysdep.h> +#include "asm-syntax.h" + + .text +ENTRY(__mpn_mul_1) + st %r6,24(%r15) + cfi_offset (%r6, -72) + slr %r6,%r6 # cy_limb = 0 +.L0: icm %r1,15,0(%r3) # get s1_ptr[i] + mr %r0,%r5 # umul_ppmm(prod_high,prod_low,s1_ptr[j],s2_limb) + jnm .L1 + alr %r0,%r5 +.L1: ltr %r5,%r5 + jnm .L2 + al %r0,0(%r3) +.L2: alr %r1,%r6 # prod_low += cy_limb + lr %r6,%r0 # cy_limb = prod_high + brc 12,.L3 + ahi %r6,1 # + (prod_low < cy_limb) +.L3: st %r1,0(%r2) + la %r2,4(0,%r2) + la %r3,4(0,%r3) + brct %r4,.L0 + lr %r2,%r6 # return cy_limb + l %r6,24(%r15) +.Lexit: br %r14 +END(__mpn_mul_1) diff --git a/REORG.TODO/sysdeps/s390/s390-32/multiarch/Makefile b/REORG.TODO/sysdeps/s390/s390-32/multiarch/Makefile new file mode 100644 index 0000000000..f8aee14bbd --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/multiarch/Makefile @@ -0,0 +1,4 @@ +ifeq ($(subdir),string) +sysdep_routines += memset memset-s390 memcpy memcpy-s390 \ + memcmp memcmp-s390 +endif diff --git a/REORG.TODO/sysdeps/s390/s390-32/multiarch/memchr.c b/REORG.TODO/sysdeps/s390/s390-32/multiarch/memchr.c new file mode 100644 index 0000000000..808c3b837a --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/multiarch/memchr.c @@ -0,0 +1,21 @@ +/* Multiple versions of memchr. + Copyright (C) 2015-2017 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 + <http://www.gnu.org/licenses/>. */ + +/* This wrapper-file is needed, because otherwise file + sysdeps/s390/s390-[32|64]/memchr.S will be used. */ +#include <sysdeps/s390/multiarch/memchr.c> diff --git a/REORG.TODO/sysdeps/s390/s390-32/multiarch/memcmp-s390.S b/REORG.TODO/sysdeps/s390/s390-32/multiarch/memcmp-s390.S new file mode 100644 index 0000000000..86a76b4c98 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/multiarch/memcmp-s390.S @@ -0,0 +1,107 @@ +/* CPU specific memcmp implementations. 32 bit S/390 version. + Copyright (C) 2012-2017 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 + <http://www.gnu.org/licenses/>. */ + + +#include "sysdep.h" +#include "asm-syntax.h" + +/* INPUT PARAMETERS + %r2 = address of first memory area + %r3 = address of second memory area + %r4 = number of bytes to compare. */ + + .text + +#if IS_IN (libc) + +ENTRY(__memcmp_z196) + .machine "z196" + .machinemode "zarch_nohighgprs" + ltr %r4,%r4 + je .L_Z196_4 + ahi %r4,-1 + srlk %r1,%r4,8 + ltr %r1,%r1 + jne .L_Z196_2 +.L_Z196_3: + exrl %r4,.L_Z196_14 +.L_Z196_4: + ipm %r2 + sll %r2,2 + sra %r2,30 + br %r14 +.L_Z196_17: + la %r3,256(%r3) + la %r2,256(%r2) + ahi %r1,-1 + je .L_Z196_3 +.L_Z196_2: + pfd 1,512(%r3) + pfd 1,512(%r2) + clc 0(256,%r3),0(%r2) + je .L_Z196_17 + ipm %r2 + sll %r2,2 + sra %r2,30 + br %r14 +.L_Z196_14: + clc 0(1,%r3),0(%r2) +END(__memcmp_z196) + +ENTRY(__memcmp_z10) + .machine "z10" + .machinemode "zarch_nohighgprs" + ltr %r4,%r4 + je .L_Z10_4 + ahi %r4,-1 + lr %r1,%r4 + srl %r1,8 + cijlh %r1,0,.L_Z10_12 +.L_Z10_3: + exrl %r4,.L_Z10_15 +.L_Z10_4: + ipm %r2 + sll %r2,2 + sra %r2,30 + br %r14 +.L_Z10_12: + pfd 1,512(%r3) + pfd 1,512(%r2) + clc 0(256,%r3),0(%r2) + jne .L_Z10_4 + la %r3,256(%r3) + la %r2,256(%r2) + brct %r1,.L_Z10_12 + j .L_Z10_3 +.L_Z10_15: + clc 0(1,%r3),0(%r2) +END(__memcmp_z10) + +#endif /* IS_IN (libc) */ + +#include "../memcmp.S" + +#if !IS_IN (libc) +.globl memcmp +.set memcmp,__memcmp_default +.weak bcmp +.set bcmp,__memcmp_default +#elif defined SHARED && IS_IN (libc) +.globl __GI_memcmp +.set __GI_memcmp,__memcmp_default +#endif diff --git a/REORG.TODO/sysdeps/s390/s390-32/multiarch/memcmp.c b/REORG.TODO/sysdeps/s390/s390-32/multiarch/memcmp.c new file mode 100644 index 0000000000..2d8d8f4d50 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/multiarch/memcmp.c @@ -0,0 +1,27 @@ +/* Multiple versions of memcmp. + Copyright (C) 2015-2017 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 + <http://www.gnu.org/licenses/>. */ + +#if IS_IN (libc) +# define memcmp __redirect_memcmp +# include <string.h> +# undef memcmp +# include <ifunc-resolve.h> + +s390_libc_ifunc (__redirect_memcmp, __memcmp, memcmp) +weak_alias (memcmp, bcmp); +#endif diff --git a/REORG.TODO/sysdeps/s390/s390-32/multiarch/memcpy-s390.S b/REORG.TODO/sysdeps/s390/s390-32/multiarch/memcpy-s390.S new file mode 100644 index 0000000000..bec51af110 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/multiarch/memcpy-s390.S @@ -0,0 +1,128 @@ +/* CPU specific memcpy implementations. 32 bit S/390 version. + Copyright (C) 2012-2017 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 + <http://www.gnu.org/licenses/>. */ + + +#include "sysdep.h" +#include "asm-syntax.h" + +/* INPUT PARAMETERS + %r2 = target operands address + %r3 = source operands address + %r4 = number of bytes to copy. */ + + .text + +#if defined SHARED && IS_IN (libc) + +ENTRY(____mempcpy_z196) + .machine "z196" + .machinemode "zarch_nohighgprs" + lr %r1,%r2 # Use as dest + la %r2,0(%r4,%r2) # Return dest + n + j .L_Z196_start +END(____mempcpy_z196) + +ENTRY(__memcpy_z196) + .machine "z196" + .machinemode "zarch_nohighgprs" + lr %r1,%r2 # r1: Use as dest ; r2: Return dest +.L_Z196_start: + llgfr %r4,%r4 + ltgr %r4,%r4 + je .L_Z196_4 + aghi %r4,-1 + srlg %r5,%r4,8 + ltgr %r5,%r5 + jne .L_Z196_5 +.L_Z196_3: + exrl %r4,.L_Z196_14 +.L_Z196_4: + br %r14 +.L_Z196_5: + cgfi %r5,262144 # Switch to mvcle for copies >64MB + jh __memcpy_mvcle +.L_Z196_2: + pfd 1,768(%r3) + pfd 2,768(%r1) + mvc 0(256,%r1),0(%r3) + aghi %r5,-1 + la %r1,256(%r1) + la %r3,256(%r3) + jne .L_Z196_2 + j .L_Z196_3 +.L_Z196_14: + mvc 0(1,%r1),0(%r3) +END(__memcpy_z196) + +ENTRY(____mempcpy_z10) + .machine "z10" + .machinemode "zarch_nohighgprs" + lr %r1,%r2 # Use as dest + la %r2,0(%r4,%r2) # Return dest + n + j .L_Z10_start +END(____mempcpy_z10) + +ENTRY(__memcpy_z10) + .machine "z10" + .machinemode "zarch_nohighgprs" + lr %r1,%r2 # r1: Use as dest ; r2: Return dest +.L_Z10_start: + llgfr %r4,%r4 + cgije %r4,0,.L_Z10_4 + aghi %r4,-1 + srlg %r5,%r4,8 + cgijlh %r5,0,.L_Z10_13 +.L_Z10_3: + exrl %r4,.L_Z10_15 +.L_Z10_4: + br %r14 +.L_Z10_13: + cgfi %r5,65535 # Switch to mvcle for copies >16MB + jh __memcpy_mvcle +.L_Z10_12: + pfd 1,768(%r3) + pfd 2,768(%r1) + mvc 0(256,%r1),0(%r3) + la %r1,256(%r1) + la %r3,256(%r3) + brctg %r5,.L_Z10_12 + j .L_Z10_3 +.L_Z10_15: + mvc 0(1,%r1),0(%r3) +END(__memcpy_z10) + +# define __mempcpy ____mempcpy_default +#endif /* SHARED && IS_IN (libc) */ + +#define memcpy __memcpy_default +#include "../memcpy.S" +#undef memcpy + +#if defined SHARED && IS_IN (libc) +.globl __GI_memcpy +.set __GI_memcpy,__memcpy_default +.globl __GI_mempcpy +.set __GI_mempcpy,____mempcpy_default +.globl __GI___mempcpy +.set __GI___mempcpy,____mempcpy_default +#else +.globl memcpy +.set memcpy,__memcpy_default +.weak mempcpy +.set mempcpy,__mempcpy +#endif diff --git a/REORG.TODO/sysdeps/s390/s390-32/multiarch/memcpy.c b/REORG.TODO/sysdeps/s390/s390-32/multiarch/memcpy.c new file mode 100644 index 0000000000..4b8e546fb0 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/multiarch/memcpy.c @@ -0,0 +1,27 @@ +/* Multiple versions of memcpy. + Copyright (C) 2015-2017 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 + <http://www.gnu.org/licenses/>. */ + +/* In the static lib memcpy is needed before the reloc is resolved. */ +#if defined SHARED && IS_IN (libc) +# define memcpy __redirect_memcpy +# include <string.h> +# undef memcpy +# include <ifunc-resolve.h> + +s390_libc_ifunc (__redirect_memcpy, __memcpy, memcpy) +#endif diff --git a/REORG.TODO/sysdeps/s390/s390-32/multiarch/memset-s390.S b/REORG.TODO/sysdeps/s390/s390-32/multiarch/memset-s390.S new file mode 100644 index 0000000000..59660b2499 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/multiarch/memset-s390.S @@ -0,0 +1,116 @@ +/* Set a block of memory to some byte value. 32 bit S/390 version. + Copyright (C) 2012-2017 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 + <http://www.gnu.org/licenses/>. */ + + +#include "sysdep.h" +#include "asm-syntax.h" + +/* INPUT PARAMETERS + %r2 = address of memory area + %r3 = byte to fill memory with + %r4 = number of bytes to fill. */ + + .text + +#if IS_IN (libc) + +ENTRY(__memset_z196) + .machine "z196" + .machinemode "zarch_nohighgprs" + llgfr %r4,%r4 + ltgr %r4,%r4 + je .L_Z196_4 + stc %r3,0(%r2) + lr %r1,%r2 + cghi %r4,1 + je .L_Z196_4 + aghi %r4,-2 + srlg %r5,%r4,8 + ltgr %r5,%r5 + jne .L_Z196_1 +.L_Z196_3: + exrl %r4,.L_Z196_17 +.L_Z196_4: + br %r14 +.L_Z196_1: + cgfi %r5,1048576 + jh __memset_mvcle # Switch to mvcle for >256MB +.L_Z196_2: + pfd 2,1024(%r1) + mvc 1(256,%r1),0(%r1) + aghi %r5,-1 + la %r1,256(%r1) + jne .L_Z196_2 + j .L_Z196_3 +.L_Z196_17: + mvc 1(1,%r1),0(%r1) +END(__memset_z196) + +ENTRY(__memset_z10) + .machine "z10" + .machinemode "zarch_nohighgprs" + llgfr %r4,%r4 + cgije %r4,0,.L_Z10_4 + stc %r3,0(%r2) + lr %r1,%r2 + cgije %r4,1,.L_Z10_4 + aghi %r4,-2 + srlg %r5,%r4,8 + cgijlh %r5,0,.L_Z10_15 +.L_Z10_3: + exrl %r4,.L_Z10_18 +.L_Z10_4: + br %r14 +.L_Z10_15: + cgfi %r5,163840 # Switch to mvcle for >40MB + jh __memset_mvcle +.L_Z10_14: + pfd 2,1024(%r1) + mvc 1(256,%r1),0(%r1) + la %r1,256(%r1) + brctg %r5,.L_Z10_14 + j .L_Z10_3 +.L_Z10_18: + mvc 1(1,%r1),0(%r1) +END(__memset_z10) + +ENTRY(__memset_mvcle) + ahi %r4,2 # take back the change done by the caller + lr %r0,%r2 # save source address + lr %r1,%r3 # move pad byte to R1 + lr %r3,%r4 + sr %r4,%r4 # no source for MVCLE, only a pad byte + sr %r5,%r5 +.L0: mvcle %r2,%r4,0(%r1) # thats it, MVCLE is your friend + jo .L0 + lr %r2,%r0 # return value is source address +.L1: + br %r14 +END(__memset_mvcle) + +#endif /* IS_IN (libc) */ + +#include "../memset.S" + +#if !IS_IN (libc) +.globl memset +.set memset,__memset_default +#elif defined SHARED && IS_IN (libc) +.globl __GI_memset +.set __GI_memset,__memset_default +#endif diff --git a/REORG.TODO/sysdeps/s390/s390-32/multiarch/memset.c b/REORG.TODO/sysdeps/s390/s390-32/multiarch/memset.c new file mode 100644 index 0000000000..421c0854a0 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/multiarch/memset.c @@ -0,0 +1,26 @@ +/* Multiple versions of memset. + Copyright (C) 2015-2017 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 + <http://www.gnu.org/licenses/>. */ + +#if IS_IN (libc) +# define memset __redirect_memset +# include <string.h> +# undef memset +# include <ifunc-resolve.h> + +s390_libc_ifunc (__redirect_memset, __memset, memset) +#endif diff --git a/REORG.TODO/sysdeps/s390/s390-32/multiarch/strcmp.c b/REORG.TODO/sysdeps/s390/s390-32/multiarch/strcmp.c new file mode 100644 index 0000000000..6a20a304cc --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/multiarch/strcmp.c @@ -0,0 +1,21 @@ +/* Multiple versions of strcmp. + Copyright (C) 2015-2017 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 + <http://www.gnu.org/licenses/>. */ + +/* This wrapper-file is needed, because otherwise file + sysdeps/s390/s390-[32|64]/strcmp.S will be used. */ +#include <sysdeps/s390/multiarch/strcmp.c> diff --git a/REORG.TODO/sysdeps/s390/s390-32/multiarch/strcpy.c b/REORG.TODO/sysdeps/s390/s390-32/multiarch/strcpy.c new file mode 100644 index 0000000000..7f380a471d --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/multiarch/strcpy.c @@ -0,0 +1,21 @@ +/* Multiple versions of strcpy. + Copyright (C) 2015-2017 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 + <http://www.gnu.org/licenses/>. */ + +/* This wrapper-file is needed, because otherwise file + sysdeps/s390/s390-[32|64]/strcpy.S will be used. */ +#include <sysdeps/s390/multiarch/strcpy.c> diff --git a/REORG.TODO/sysdeps/s390/s390-32/multiarch/strncpy.c b/REORG.TODO/sysdeps/s390/s390-32/multiarch/strncpy.c new file mode 100644 index 0000000000..15dacec974 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/multiarch/strncpy.c @@ -0,0 +1,21 @@ +/* Multiple versions of strncpy. + Copyright (C) 2015-2017 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 + <http://www.gnu.org/licenses/>. */ + +/* This wrapper-file is needed, because otherwise file + sysdeps/s390/s390-[32|64]/strncpy.S will be used. */ +#include <sysdeps/s390/multiarch/strncpy.c> diff --git a/REORG.TODO/sysdeps/s390/s390-32/s390-mcount.S b/REORG.TODO/sysdeps/s390/s390-32/s390-mcount.S new file mode 100644 index 0000000000..fe25c5506d --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/s390-mcount.S @@ -0,0 +1,89 @@ +/* S/390-specific implementation of profiling support. + Copyright (C) 2000-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com) + + 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 + <http://www.gnu.org/licenses/>. */ + +#include <sysdep.h> + +/* + * How profiling works on S/390: + * On the start of each function _mcount is called with the address of a + * data word in %r1 (initialized to 0, used for counting). The compiler + * with the option -p generates code of the form: + * + * STM 6,15,24(15) + * BRAS 13,.LTN0_0 + * .LT0_0: + * .LC12: .long _mcount + * .LC13: .long .LP0 + * .data + * .align 4 + * .LP0: .long 0 + * .text + * # function profiler + * st 14,4(15) + * l 14,.LC12-.LT0_0(13) + * l 1,.LC13-.LT0_0(13) + * basr 14,14 + * l 14,4(15) + * + * The _mcount implementation now has to call __mcount_internal with the + * address of .LP0 as first parameter and the return address as second + * parameter. &.LP0 was loaded to %r1 and the return address is in %r14. + * _mcount may not modify any register. + */ + + .globl C_SYMBOL_NAME(_mcount) + .type C_SYMBOL_NAME(_mcount), @function + cfi_startproc + .align ALIGNARG(4) +C_LABEL(_mcount) + /* Save the caller-clobbered registers. */ + ahi %r15,-128 + cfi_adjust_cfa_offset (128) + stm %r14,%r5,96(%r15) + cfi_offset (r14, 0) + cfi_offset (r15, 4) + l %r2,132(%r15) # callers address = first parameter + la %r2,0(%r2) # clear bit 0 + la %r3,0(%r14) # callees address = second parameter + +#ifdef PIC + bras %r14,0f + .long _GLOBAL_OFFSET_TABLE_-. +0: al %r14,0(%r14) + l %r14,__mcount_internal@GOT(%r14) +#else + bras %r14,0f + .long __mcount_internal +0: l %r14,0(%r14) +#endif + basr %r14,%r14 + + /* + * Pop the saved registers. Please note that `mcount' has no + * return value. + */ + lm %r14,%r5,96(%r15) + ahi %r15,128 + cfi_adjust_cfa_offset (-128) + br %r14 + cfi_endproc + ASM_SIZE_DIRECTIVE(C_SYMBOL_NAME(_mcount)) + +#undef mcount +weak_alias (_mcount, mcount) diff --git a/REORG.TODO/sysdeps/s390/s390-32/setjmp.S b/REORG.TODO/sysdeps/s390/s390-32/setjmp.S new file mode 100644 index 0000000000..1e240dbc83 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/setjmp.S @@ -0,0 +1,123 @@ +/* setjmp for s390, ELF version. + Copyright (C) 2000-2017 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + 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 + <http://www.gnu.org/licenses/>. */ + +#include <sysdep.h> +#define _ASM +#define _SETJMP_H +#include <bits/setjmp.h> +#include <shlib-compat.h> +#include <stap-probe.h> + +#if !IS_IN (rtld) && defined SHARED \ + && SHLIB_COMPAT (libc, GLIBC_2_19, GLIBC_2_20) +# define NEED_COMPAT_SYMBOLS 1 +/* We need a unique name in case of symbol versioning. */ +# define setjmp __v1setjmp +# define _setjmp __v1_setjmp +# define __sigsetjmp __v1__sigsetjmp +#else +# define NEED_COMPAT_SYMBOLS 0 +#endif + + /* We include the BSD entry points here as well. */ +ENTRY (setjmp) + lhi %r3,1 /* second argument of one */ + j .Linternal_sigsetjmp /* branch relativ to __sigsetjmp */ +END (setjmp) + + /* Binary compatibility entry point. */ +ENTRY(_setjmp) + lhi %r3,0 /* second argument of zero */ + j .Linternal_sigsetjmp /* branch relativ to __sigsetjmp */ +END (_setjmp) +#if NEED_COMPAT_SYMBOLS +strong_alias (_setjmp, __GI__setjmp) +#else +libc_hidden_def (_setjmp) +#endif + +ENTRY(__setjmp) + lhi %r3,0 /* second argument of zero */ + j .Linternal_sigsetjmp /* branch relativ to __sigsetjmp */ +END (__setjmp) + +ENTRY(__sigsetjmp) +.Linternal_sigsetjmp: + /* setjmp probe expects sig/setjmp first argument (4@%r2), second + argument (-4@%r3) and target address (4@%r14). */ + LIBC_PROBE (setjmp, 3, 4@%r2, -4@%r3, 4@%r14) +#ifdef PTR_MANGLE + stm %r6,%r13,0(%r2) /* store registers in jmp_buf */ + lr %r4,%r14 + lr %r5,%r15 + PTR_MANGLE (%r4, %r1) + PTR_MANGLE2 (%r5, %r1) + stm %r4,%r5,32(%r2) +#else + stm %r6,%r15,0(%r2) /* store registers in jmp_buf */ +#endif + std %f4,40(%r2) + std %f6,48(%r2) +#if IS_IN (rtld) + /* In ld.so we never save the signal mask. */ + lhi %r2,0 + br %r14 +#elif defined PIC + /* We cannot use the PLT, because it requires that %r12 be set, but + we can't save and restore our caller's value. Instead, we do an + indirect jump through the GOT. */ + basr %r1,0 +.L0: al %r1,.L1 - .L0(0,%r1) /* get address of global offset table */ + /* get address of __sigjmp_save from got */ + l %r1,__sigjmp_save@GOT(%r1) + br %r1 +.L1: .long _GLOBAL_OFFSET_TABLE_ - .L0 +#else + basr %r1,0 +.L0: l %r1,.L1-.L0(0,%r1) /* load address of __sigjmp_save */ + br %r1 /* tail-call __sigjmp_save */ +.L1: .long __sigjmp_save +#endif +END (__sigsetjmp) +#if NEED_COMPAT_SYMBOLS +strong_alias (__sigsetjmp, __GI___sigsetjmp) +#else +libc_hidden_def (__sigsetjmp) +#endif + +#if NEED_COMPAT_SYMBOLS +/* In glibc release 2.19 new versions of setjmp-functions were introduced, + but were reverted before 2.20. Thus both versions are the same function. */ + +# undef setjmp +# undef _setjmp +# undef __sigsetjmp + +strong_alias (__v1setjmp, __v2setjmp); +versioned_symbol (libc, __v1setjmp, setjmp, GLIBC_2_0); +compat_symbol (libc, __v2setjmp, setjmp, GLIBC_2_19); + +strong_alias (__v1_setjmp, __v2_setjmp); +versioned_symbol (libc, __v1_setjmp, _setjmp, GLIBC_2_0); +compat_symbol (libc, __v2_setjmp, _setjmp, GLIBC_2_19); + +strong_alias (__v1__sigsetjmp, __v2__sigsetjmp); +versioned_symbol (libc, __v1__sigsetjmp, __sigsetjmp, GLIBC_2_0); +compat_symbol (libc, __v2__sigsetjmp, __sigsetjmp, GLIBC_2_19); +#endif /* NEED_COMPAT_SYMBOLS */ diff --git a/REORG.TODO/sysdeps/s390/s390-32/stackguard-macros.h b/REORG.TODO/sysdeps/s390/s390-32/stackguard-macros.h new file mode 100644 index 0000000000..46109744ed --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/stackguard-macros.h @@ -0,0 +1,15 @@ +#include <stdint.h> + +#define STACK_CHK_GUARD \ + ({ uintptr_t x; __asm__ ("ear %0,%%a0; l %0,0x14(%0)" : "=a" (x)); x; }) + +/* On s390/s390x there is no unique pointer guard, instead we use the + same value as the stack guard. */ +#define POINTER_CHK_GUARD \ + ({ \ + uintptr_t x; \ + __asm__ ("ear %0,%%a0; l %0,%1(%0)" \ + : "=a" (x) \ + : "i" (offsetof (tcbhead_t, stack_guard))); \ + x; \ + }) diff --git a/REORG.TODO/sysdeps/s390/s390-32/start.S b/REORG.TODO/sysdeps/s390/s390-32/start.S new file mode 100644 index 0000000000..07400f1752 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/start.S @@ -0,0 +1,211 @@ +/* Startup code compliant to the ELF s390 ABI. + Copyright (C) 2000-2017 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + 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. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file with other + programs, and to distribute those programs without any restriction + coming from the use of this file. (The GNU Lesser General Public + License restrictions do apply in other respects; for example, they + cover modification of the file, and distribution when not linked + into another program.) + + Note that people who make modified versions of this file are not + obligated to grant this special exception for their modified + versions; it is their choice whether to do so. The GNU Lesser + General Public License gives permission to release a modified + version without this exception; this exception also makes it + possible to release a modified version which carries forward this + exception. + + 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 + <http://www.gnu.org/licenses/>. */ + +/* + This is the canonical entry point, usually the first thing in the text + segment. Most registers' values are unspecified, except for: + + %r14 Contains a function pointer to be registered with `atexit'. + This is how the dynamic linker arranges to have DT_FINI + functions called for shared libraries that have been loaded + before this code runs. + + %r15 The stack contains the arguments and environment: + 0(%r15) argc + 4(%r15) argv[0] + ... + (4*argc)(%r15) NULL + (4*(argc+1))(%r15) envp[0] + ... + NULL +*/ + + .text + .globl _start + .type _start,@function +_start: + /* Check if the kernel provides highgprs facility if needed by + the binary. */ + + lr %r6,%r15 + la %r6,4(%r6) /* Skip the argument counter. */ + +.L11: l %r5,0(%r6) /* Skip the argument vector. */ + la %r6,4(%r6) + ltr %r5,%r5 + jne .L11 + +.L12: l %r5,0(%r6) /* Skip the environment vector. */ + la %r6,4(%r6) + ltr %r5,%r5 + jne .L12 + + /* Usually the auxiliary vector can be expected directly after + the environment variables. But we have to skip extra zeros + because the loader might have removed unsecure variables for + setuid programs. */ + +.L26: l %r5,0(%r6) + la %r6,4(%r6) + ltr %r5,%r5 + jz .L26 + + ahi %r6,-4 + + /* Obtain the needed values from the auxiliary vector. */ + + lhi %r7,16 /* AT_HWCAP */ + lhi %r8,3 /* AT_PHDR */ + lhi %r9,5 /* AT_PHNUM */ + lhi %r2,4 /* AT_PHENT */ +.L13: l %r5,0(%r6) + clr %r5,%r7 + jne .L15 + l %r10,4(%r6) /* r10 = AT_HWCAP value. */ +.L15: clr %r5,%r8 + jne .L16 + l %r11,4(%r6) /* r11 = AT_PHDR value. */ +.L16: clr %r5,%r9 + jne .L17 + l %r12,4(%r6) /* r12 = AT_PHNUM value. */ +.L17: clr %r5,%r2 + jne .L18 + l %r0,4(%r6) /* r0 = AT_PHENT value. */ +.L18: ltr %r5,%r5 + la %r6,8(%r6) + jnz .L13 + + /* Locate the ELF header by looking for the first PT_LOAD + segment with a p_offset of zero. */ + + lr %r4,%r11 /* Backup AT_PHDR. */ + lhi %r7,1 /* PT_LOAD id */ + lhi %r8,0 +.L19: cl %r7,0(%r4) /* p_type == PT_LOAD? */ + jne .L20 + cl %r8,4(%r4) /* p_offset == 0? */ + jne .L20 + l %r9,8(%r4) /* r9 = PT_LOAD.p_vaddr <- ELF header address */ + j .L24 +.L20: alr %r4,%r0 /* r4 += AT_PHENT value */ + brct %r12,.L19 + + j .+2 /* Trap, there must be such a phdr. */ + +.L24: lr %r4,%r11 /* Backup AT_PHDR. */ + lhi %r2,6 /* PT_PHDR id */ +.L23: cl %r2,0(%r4) + jne .L22 + l %r3,8(%r4) /* r3 = PT_PHDR p_vaddr */ + j .L25 +.L22: alr %r4,%r0 /* r4 += AT_PHENT value */ + brct %r12,.L23 + + j .L14 /* No PT_PHDR found - skip checking. */ + +.L25: slr %r11,%r3 /* AT_PHDR - PT_PHDR.p_vaddr (relocation offset)*/ + alr %r9,%r11 /* PT_LOAD.p_vaddr += relocation offset */ + + l %r5,36(%r9) /* Load the e_flags field. */ + tml %r5,1 + jz .L14 /* Binary does not require highgprs facility. */ + + tml %r10,512 /* Check the AT_HWCAP value. */ + jz 2 /* Trap if no highgprs facility available. */ +.L14: + + /* Setup pointer to literal pool of _start */ + basr %r13,0 +.L0: ahi %r13,.Llit-.L0 + + /* load argc and argv from stack */ + la %r4,4(%r15) # get argv + l %r3,0(%r15) # get argc + + /* align the stack to a double word boundary */ + lhi %r0,-8 + nr %r15,%r0 + + /* Setup a stack frame and a parameter area */ + ahi %r15,-104 # make room on stack + xc 0(4,%r15),0(%r15) # clear back-chain + + /* set up arguments for __libc_start_main: + main, argc, argv, envp, _init, _fini, rtld_fini, stack_end + Note that envp will be determined later in __libc_start_main + */ + stm %r14,%r15,96(%r15) # store rtld_fini/stack_end to parameter area + la %r7,96(%r15) + l %r6,.L2-.Llit(%r13) # load pointer to __libc_csu_fini + l %r5,.L1-.Llit(%r13) # load pointer to __libc_csu_init + l %r2,.L3-.Llit(%r13) # load pointer to main + l %r1,.L4-.Llit(%r13) # load pointer to __libc_start_main +#ifdef PIC + l %r12,.L5-.Llit(%r13) # load .got pointer + la %r6,0(%r13,%r6) + la %r5,0(%r13,%r5) + la %r12,0(%r13,%r12) + l %r2,0(%r12,%r2) + la %r1,0(%r13,%r1) +#endif + + /* ok, now branch to the libc main routine */ + basr %r14,%r1 + + /* crash if __libc_start_main returns */ + .word 0 + +.Llit: +#ifndef PIC +.L1: .long __libc_csu_init +.L2: .long __libc_csu_fini +.L3: .long main +.L4: .long __libc_start_main +#else +.L1: .long __libc_csu_init-.Llit +.L2: .long __libc_csu_fini-.Llit +.L3: .long main@GOT +.L4: .long __libc_start_main@plt-.Llit +.L5: .long _GLOBAL_OFFSET_TABLE_-.Llit +#endif + +/* Define a symbol for the first piece of initialized data. */ + .data + .globl __data_start +__data_start: + .long 0 + .weak data_start + data_start = __data_start diff --git a/REORG.TODO/sysdeps/s390/s390-32/strcmp.S b/REORG.TODO/sysdeps/s390/s390-32/strcmp.S new file mode 100644 index 0000000000..69754c5f5a --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/strcmp.S @@ -0,0 +1,41 @@ +/* strcmp - compare two string. S/390 version. + This file is part of the GNU C Library. + Copyright (C) 2001-2017 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + + 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 + <http://www.gnu.org/licenses/>. */ + +/* INPUT PARAMETERS + %r2 = address of string 1 + %r3 = address of string 2. */ + +#include "sysdep.h" +#include "asm-syntax.h" + + .text +ENTRY(strcmp) + slr %r0,%r0 +0: clst %r2,%r3 + jo 0b + jp 1f + jm 2f + slr %r2,%r2 + br %r14 +1: lhi %r2,1 + br %r14 +2: lhi %r2,-1 + br %r14 +END(strcmp) +libc_hidden_builtin_def (strcmp) diff --git a/REORG.TODO/sysdeps/s390/s390-32/strcpy.S b/REORG.TODO/sysdeps/s390/s390-32/strcpy.S new file mode 100644 index 0000000000..ab06ff8d72 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/strcpy.S @@ -0,0 +1,36 @@ +/* strcpy - copy a string from source to destination. For IBM S390 + This file is part of the GNU C Library. + Copyright (C) 2000-2017 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + + 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 + <http://www.gnu.org/licenses/>. */ + +/* + * R2 = address of destination + * R3 = address of source + */ + +#include "sysdep.h" +#include "asm-syntax.h" + + .text +ENTRY(strcpy) + slr %r0,%r0 + lr %r1,%r2 +0: mvst %r1,%r3 + jo 0b + br %r14 +END(strcpy) +libc_hidden_builtin_def (strcpy) diff --git a/REORG.TODO/sysdeps/s390/s390-32/strncpy.S b/REORG.TODO/sysdeps/s390/s390-32/strncpy.S new file mode 100644 index 0000000000..c642bce90d --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/strncpy.S @@ -0,0 +1,79 @@ +/* strncpy - copy at most n characters from a string from source to + destination. For IBM S390 + This file is part of the GNU C Library. + Copyright (C) 2000-2017 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + + 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 + <http://www.gnu.org/licenses/>. */ + +/* + * R2 = address of destination (dst) + * R3 = address of source (src) + * R4 = max of bytes to copy + */ + +#include "sysdep.h" +#include "asm-syntax.h" + +ENTRY(strncpy) + .text + st %r2,24(%r15) # save dst pointer + slr %r2,%r3 # %r3 points to src, %r2+%r3 to dst + lhi %r1,3 + nr %r1,%r4 # last 2 bits of # bytes + srl %r4,2 + ltr %r4,%r4 # less than 4 bytes to copy ? + jz .L1 + bras %r5,.L0 # enter loop & load address of a 0 + .long 0 +.L0: icm %r0,8,0(%r3) # first byte + jz .L3 + icm %r0,4,1(%r3) # second byte + jz .L4 + icm %r0,2,2(%r3) # third byte + jz .L5 + icm %r0,1,3(%r3) # fourth byte + jz .L6 + st %r0,0(%r2,%r3) # store all four to dest. + la %r3,4(%r3) + brct %r4,.L0 +.L1: ltr %r1,%r1 + jz .Lexit +.L2: icm %r0,1,0(%r3) + stc %r0,0(%r2,%r3) + la %r3,1(%r3) + jz .L7 + brct %r1,.L2 + j .Lexit +.L3: icm %r0,4,0(%r5) +.L4: icm %r0,2,0(%r5) +.L5: icm %r0,1,0(%r5) +.L6: st %r0,0(%r2,%r3) + la %r3,4(%r3) + ahi %r4,-1 + j .L8 +.L7: ahi %r1,-1 +.L8: sll %r4,2 + alr %r4,%r1 + alr %r2,%r3 # start of dst area to be zeroed + lr %r3,%r4 + slr %r4,%r4 + slr %r5,%r5 +.L9: mvcle %r2,%r4,0 # pad dst with zeroes + jo .L9 +.Lexit: l %r2,24(%r15) # return dst pointer + br %r14 +END(strncpy) +libc_hidden_builtin_def (strncpy) diff --git a/REORG.TODO/sysdeps/s390/s390-32/sub_n.S b/REORG.TODO/sysdeps/s390/s390-32/sub_n.S new file mode 100644 index 0000000000..358c8deddb --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/sub_n.S @@ -0,0 +1,62 @@ +/* __mpn_sub_n -- Add two limb vectors of the same length > 0 and store + sum in a third limb vector. + Copyright (C) 2000-2017 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + This file is part of the GNU MP Library. + + The GNU MP 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 MP 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 MP Library; see the file COPYING.LIB. If not, + see <http://www.gnu.org/licenses/>. */ + +/* + INPUT PARAMETERS + res_ptr %r2 + s1_ptr %r3 + s2_ptr %r4 + size %r5 +*/ + +#include "sysdep.h" +#include "asm-syntax.h" + +ENTRY(__mpn_sub_n) + st %r6,24(%r15) # save register 6 + cfi_offset (%r6, -72) + sr %r1,%r1 + lhi %r0,1 # cannot use ahi to add carry, use slr +.L0: l %r6,0(%r1,%r3) # .L0 -> no carry from last sub + sl %r6,0(%r1,%r4) + st %r6,0(%r1,%r2) + la %r1,4(0,%r1) + brc 4,.L3 +.L1: brct %r5,.L0 + slr %r2,%r2 # no last carry to return + j .Lexit +.L2: l %r6,0(%r1,%r3) # .L2 -> carry from last sub + sl %r6,0(%r1,%r4) + brc 4,.L4 + slr %r6,%r0 # no carry yet, add carry from last sub + st %r6,0(%r1,%r2) + la %r1,4(0,%r1) + brc 11,.L1 # new carry ? +.L3: brct %r5,.L2 + lr %r2,%r0 # return last carry + j .Lexit +.L4: slr %r6,%r0 # already a carry, add carry from last sub + st %r6,0(%r1,%r2) + la %r1,4(0,%r1) + brct %r5,.L2 + lr %r2,%r0 # return last carry +.Lexit: l %r6,24(%r15) # restore register 6 + br %r14 +END(__mpn_sub_n) diff --git a/REORG.TODO/sysdeps/s390/s390-32/symbol-hacks.h b/REORG.TODO/sysdeps/s390/s390-32/symbol-hacks.h new file mode 100644 index 0000000000..585c42365a --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/symbol-hacks.h @@ -0,0 +1,21 @@ +/* Hacks needed for symbol manipulation. s390 version. + Copyright (C) 2017 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 + <http://www.gnu.org/licenses/>. */ + +#include <sysdeps/wordsize-32/divdi3-symbol-hacks.h> + +#include_next "symbol-hacks.h" diff --git a/REORG.TODO/sysdeps/s390/s390-32/sysdep.h b/REORG.TODO/sysdeps/s390/s390-32/sysdep.h new file mode 100644 index 0000000000..15a4e3e687 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/sysdep.h @@ -0,0 +1,101 @@ +/* Assembler macros for s390. + Copyright (C) 2000-2017 Free Software Foundation, Inc. + Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). + 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 + <http://www.gnu.org/licenses/>. */ + +#include <sysdeps/generic/sysdep.h> + +#ifdef __ASSEMBLER__ + +/* Syntactic details of assembler. */ + +/* ELF uses byte-counts for .align, most others use log2 of count of bytes. */ +#define ALIGNARG(log2) 1<<log2 +#define ASM_SIZE_DIRECTIVE(name) .size name,.-name; + + +/* Define an entry point visible from C. */ +#define ENTRY(name) \ + .globl C_SYMBOL_NAME(name); \ + .type C_SYMBOL_NAME(name),@function; \ + .align ALIGNARG(2); \ + C_LABEL(name) \ + cfi_startproc; \ + CALL_MCOUNT + +#undef END +#define END(name) \ + cfi_endproc; \ + ASM_SIZE_DIRECTIVE(name) \ + +/* If compiled for profiling, call `mcount' at the start of each function. */ +#ifdef PROF +#ifdef PIC +#define CALL_MCOUNT \ + lr 0,14 ; bras 14,.+12 ; .long _GLOBAL_OFFSET_TABLE_ - . ; .long 0f-. ; \ + lr 1,14 ; al 1,4(14) ; al 14,0(14) ; l 14,_mcount@GOT(14) ; \ + basr 14,14 ; lr 14,0 ; .data ; .align 4 ; 0: .long 0 ; .text ; +#else +#define CALL_MCOUNT \ + lr 0,14 ; bras 14,.+12 ; .long _mcount ; .long 0f ; \ + l 1,4(14) ; l 14,0(14) ; basr 14,14 ; lr 14,0 ; \ + .data ; .align 4 ; 0: .long 0 ; .text ; +#endif +#else +#define CALL_MCOUNT /* Do nothing. */ +#endif + +/* Since C identifiers are not normally prefixed with an underscore + on this system, the asm identifier `syscall_error' intrudes on the + C name space. Make sure we use an innocuous name. */ +#define syscall_error __syscall_error +#define mcount _mcount + +#undef PSEUDO +#define PSEUDO(name, syscall_name, args) \ +lose: SYSCALL_PIC_SETUP \ + basr %r1,0; \ +0: al %r1,1f-0b(%r1); \ + br %r1; \ +1: .long JUMPTARGET(syscall_error) - 0b; \ + .globl syscall_error; \ + ENTRY (name) \ + DO_CALL (syscall_name, args); \ + jm lose + +#undef PSEUDO_END +#define PSEUDO_END(name) \ + END (name) + +#undef JUMPTARGET +#ifdef PIC +#define JUMPTARGET(name) name##@PLT +#define SYSCALL_PIC_SETUP \ + bras %r12,1f \ +0: .long _GLOBAL_OFFSET_TABLE_-0b \ +1: al %r12,0(%r12) +#else +#define JUMPTARGET(name) name +#define SYSCALL_PIC_SETUP /* Nothing. */ +#endif + +/* Local label name for asm code. */ +#ifndef L +#define L(name) .L##name +#endif + +#endif /* __ASSEMBLER__ */ diff --git a/REORG.TODO/sysdeps/s390/s390-32/tls-macros.h b/REORG.TODO/sysdeps/s390/s390-32/tls-macros.h new file mode 100644 index 0000000000..a4c5fffa33 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/tls-macros.h @@ -0,0 +1,104 @@ +#define TLS_LE(x) \ + ({ unsigned long __offset; \ + __asm__ ("bras %0,1f\n" \ + "0:\t.long " #x "@ntpoff\n" \ + "1:\tl %0,0(%0)" \ + : "=a" (__offset) : : "cc" ); \ + (int *) (__builtin_thread_pointer() + __offset); }) + +#ifdef PIC +# define TLS_IE(x) \ + ({ unsigned long __offset, __got; \ + __asm__ ("bras %0,1f\n" \ + "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t" \ + ".long " #x "@gotntpoff\n" \ + "1:\tl %1,0(%0)\n\t" \ + "la %1,0(%1,%0)\n\t" \ + "l %0,4(%0)\n\t" \ + "l %0,0(%0,%1):tls_load:" #x "\n" \ + : "=&a" (__offset), "=&a" (__got) : : "cc" ); \ + (int *) (__builtin_thread_pointer() + __offset); }) +#else +# define TLS_IE(x) \ + ({ unsigned long __offset; \ + __asm__ ("bras %0,1f\n" \ + "0:\t.long " #x "@indntpoff\n" \ + "1:\t l %0,0(%0)\n\t" \ + "l %0,0(%0):tls_load:" #x \ + : "=&a" (__offset) : : "cc" ); \ + (int *) (__builtin_thread_pointer() + __offset); }) +#endif + +#ifdef PIC +# define TLS_LD(x) \ + ({ unsigned long __offset, __save12; \ + __asm__ ("bras %0,1f\n" \ + "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t" \ + ".long __tls_get_offset@plt-0b\n\t" \ + ".long " #x "@tlsldm\n\t" \ + ".long " #x "@dtpoff\n" \ + "1:\tlr %1,%%r12\n\t" \ + "l %%r12,0(%0)\n\t" \ + "la %%r12,0(%%r12,%0)\n\t" \ + "l %%r1,4(%0)\n\t" \ + "l %%r2,8(%0)\n\t" \ + "bas %%r14,0(%%r1,%0):tls_ldcall:" #x "\n\t" \ + "l %0,12(%0)\n\t" \ + "alr %0,%%r2\n\t" \ + "lr %%r12,%1" \ + : "=&a" (__offset), "=&a" (__save12) \ + : : "cc", "0", "1", "2", "3", "4", "5", "14"); \ + (int *) (__builtin_thread_pointer() + __offset); }) +#else +# define TLS_LD(x) \ + ({ unsigned long __offset; \ + __asm__ ("bras %0,1f\n" \ + "0:\t.long _GLOBAL_OFFSET_TABLE_\n\t" \ + ".long __tls_get_offset@plt\n\t" \ + ".long " #x "@tlsldm\n\t" \ + ".long " #x "@dtpoff\n" \ + "1:\tl %%r12,0(%0)\n\t" \ + "l %%r1,4(%0)\n\t" \ + "l %%r2,8(%0)\n\t" \ + "bas %%r14,0(%%r1):tls_ldcall:" #x "\n\t" \ + "l %0,12(%0)\n\t" \ + "alr %0,%%r2" \ + : "=&a" (__offset) \ + : : "cc", "0", "1", "2", "3", "4", "5", "12", "14"); \ + (int *) (__builtin_thread_pointer() + __offset); }) +#endif + +#ifdef PIC +# define TLS_GD(x) \ + ({ unsigned long __offset, __save12; \ + __asm__ ("bras %0,1f\n" \ + "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t" \ + ".long __tls_get_offset@plt-0b\n\t" \ + ".long " #x "@tlsgd\n" \ + "1:\tlr %1,%%r12\n\t" \ + "l %%r12,0(%0)\n\t" \ + "la %%r12,0(%%r12,%0)\n\t" \ + "l %%r1,4(%0)\n\t" \ + "l %%r2,8(%0)\n\t" \ + "bas %%r14,0(%%r1,%0):tls_gdcall:" #x "\n\t" \ + "lr %0,%%r2\n\t" \ + "lr %%r12,%1" \ + : "=&a" (__offset), "=&a" (__save12) \ + : : "cc", "0", "1", "2", "3", "4", "5", "14"); \ + (int *) (__builtin_thread_pointer() + __offset); }) +#else +# define TLS_GD(x) \ + ({ unsigned long __offset; \ + __asm__ ("bras %0,1f\n" \ + "0:\t.long _GLOBAL_OFFSET_TABLE_\n\t" \ + ".long __tls_get_offset@plt\n\t" \ + ".long " #x "@tlsgd\n" \ + "1:\tl %%r12,0(%0)\n\t" \ + "l %%r1,4(%0)\n\t" \ + "l %%r2,8(%0)\n\t" \ + "bas %%r14,0(%%r1):tls_gdcall:" #x "\n\t" \ + "lr %0,%%r2" \ + : "=&a" (__offset) \ + : : "cc", "0", "1", "2", "3", "4", "5", "12", "14"); \ + (int *) (__builtin_thread_pointer() + __offset); }) +#endif diff --git a/REORG.TODO/sysdeps/s390/s390-32/tst-audit.h b/REORG.TODO/sysdeps/s390/s390-32/tst-audit.h new file mode 100644 index 0000000000..daabc70aa9 --- /dev/null +++ b/REORG.TODO/sysdeps/s390/s390-32/tst-audit.h @@ -0,0 +1,25 @@ +/* Definitions for testing PLT entry/exit auditing. S/390 32-bit version. + + Copyright (C) 2012-2017 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 + <http://www.gnu.org/licenses/>. */ + +#define pltenter la_s390_32_gnu_pltenter +#define pltexit la_s390_32_gnu_pltexit +#define La_regs La_s390_32_regs +#define La_retval La_s390_32_retval +#define int_retval lrv_r2 |